From 512bcbce6c3a894746429b15055287233626b998 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 17 Jul 2018 13:06:13 -0400 Subject: [PATCH] LP#1779158 Initial match set UI Signed-off-by: Bill Erickson --- .../cat/vandelay/match-set-list.component.html | 37 ++++++++++ .../staff/cat/vandelay/match-set-list.component.ts | 78 ++++++++++++++++++++++ .../staff/cat/vandelay/match-set.component.html | 11 +++ .../app/staff/cat/vandelay/match-set.component.ts | 36 ++++++++++ .../src/app/staff/cat/vandelay/routing.module.ts | 8 +++ .../app/staff/cat/vandelay/vandelay.component.html | 2 +- .../src/app/staff/cat/vandelay/vandelay.module.ts | 6 +- 7 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.html new file mode 100644 index 0000000000..7674be239d --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.html @@ -0,0 +1,37 @@ + +
+
+
+
+ Owner +
+ + +
+
+
+ + + + {{row.name()}} + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.ts new file mode 100644 index 0000000000..6a67531a72 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.ts @@ -0,0 +1,78 @@ +import {Component, AfterViewInit, ViewChild} from '@angular/core'; +import {Router} from '@angular/router'; +import {Pager} from '@eg/share/util/pager'; +import {IdlObject} from '@eg/core/idl.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {OrgService} from '@eg/core/org.service'; +import {AuthService} from '@eg/core/auth.service'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {GridDataSource, GridColumn} from '@eg/share/grid/grid'; +import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; + +@Component({ + templateUrl: 'match-set-list.component.html' +}) +export class MatchSetListComponent implements AfterViewInit { + + contextOrg: IdlObject; + gridSource: GridDataSource; + deleteSelected: (rows: IdlObject[]) => void; + createNew: () => void; + @ViewChild('grid') grid: GridComponent; + @ViewChild('editDialog') editDialog: FmRecordEditorComponent; + + constructor( + private router: Router, + private pcrud: PcrudService, + private auth: AuthService, + private org: OrgService) { + + this.gridSource = new GridDataSource(); + this.contextOrg = this.org.get(this.auth.user().ws_ou()); + + this.gridSource.getRows = (pager: Pager) => { + const orgs = this.org.descendants(this.contextOrg, true); + return this.pcrud.search('vms', {owner: orgs}, { + order_by: {vms: ['name']}, + limit: pager.limit, + offset: pager.offset + }); + } + + this.createNew = () => { + this.editDialog.mode = 'create'; + this.editDialog.open({size: 'lg'}).then( + ok => this.grid.reload(), + err => {} + ); + }; + + this.deleteSelected = (matchSets: IdlObject[]) => { + matchSets.forEach(matchSet => matchSet.isdeleted(true)); + this.pcrud.autoApply(matchSets).subscribe( + val => console.debug('deleted: ' + val), + err => {}, + () => this.grid.reload() + ); + }; + } + + ngAfterViewInit() { + this.grid.onRowActivate.subscribe( + (matchSet: IdlObject) => { + this.editDialog.mode = 'update'; + this.editDialog.recId = matchSet.id(); + this.editDialog.open({size: 'lg'}).then( + ok => this.grid.reload(), + err => {} + ); + } + ); + } + + orgOnChange(org: IdlObject) { + this.contextOrg = org; + this.grid.reload(); + } +} + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.html new file mode 100644 index 0000000000..ce6287e391 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.html @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.ts new file mode 100644 index 0000000000..3527d41ef5 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.ts @@ -0,0 +1,36 @@ +import {Component, OnInit, ViewChild} from '@angular/core'; +import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap'; + +@Component({ + templateUrl: 'match-set.component.html' +}) +export class MatchSetComponent { + + matchSetId: number; + matchSetTab: string; + + constructor( + private router: Router, + private route: ActivatedRoute) { + this.route.paramMap.subscribe((params: ParamMap) => { + this.matchSetId = +params.get('id'); + this.matchSetTab = params.get('matchSetTab'); + }); + } + + // Changing a tab in the UI means changing the route. + // Changing the route ultimately results in changing the tab. + onTabChange(evt: NgbTabChangeEvent) { + this.matchSetTab = evt.nextId; + + // prevent tab changing until after route navigation + evt.preventDefault(); + + const url = + `/staff/cat/vandelay/match_sets/${this.matchSetId}/${this.matchSetTab}`; + + this.router.navigate([url]); + } +} + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/routing.module.ts index 3378f86809..a7776d5bda 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/routing.module.ts @@ -10,6 +10,8 @@ import {DisplayAttrsComponent} from './display-attrs.component'; import {MergeProfilesComponent} from './merge-profiles.component'; import {HoldingsProfilesComponent} from './holdings-profiles.component'; import {QueueItemsComponent} from './queue-items.component'; +import {MatchSetListComponent} from './match-set-list.component'; +import {MatchSetComponent} from './match-set.component'; const routes: Routes = [{ path: '', @@ -51,6 +53,12 @@ const routes: Routes = [{ }, { path: 'holdings_profiles', component: HoldingsProfilesComponent + }, { + path: 'match_sets', + component: MatchSetListComponent + }, { + path: 'match_sets/:id/:matchSetTab', + component: MatchSetComponent }] }]; diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.component.html index 410449136c..1fc1a52b40 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.component.html @@ -23,7 +23,7 @@ i18n>Merge / Overlay Profiles diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts index 9f0e8db666..5726b4e87c 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts @@ -16,6 +16,8 @@ import {MergeProfilesComponent} from './merge-profiles.component'; import {HoldingsProfilesComponent} from './holdings-profiles.component'; import {QueueItemsComponent} from './queue-items.component'; import {RecordItemsComponent} from './record-items.component'; +import {MatchSetListComponent} from './match-set-list.component'; +import {MatchSetComponent} from './match-set.component'; @NgModule({ declarations: [ @@ -30,7 +32,9 @@ import {RecordItemsComponent} from './record-items.component'; MergeProfilesComponent, HoldingsProfilesComponent, QueueItemsComponent, - RecordItemsComponent + RecordItemsComponent, + MatchSetListComponent, + MatchSetComponent ], imports: [ StaffCommonModule, -- 2.11.0