LP#1779158 Initial match set UI
authorBill Erickson <berickxx@gmail.com>
Tue, 17 Jul 2018 17:06:13 +0000 (13:06 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 11 Oct 2018 18:56:30 +0000 (14:56 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set-list.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/cat/vandelay/match-set.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/cat/vandelay/routing.module.ts
Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.component.html
Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.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 (file)
index 0000000..7674be2
--- /dev/null
@@ -0,0 +1,37 @@
+
+<div class="d-flex mb-3">
+  <div>
+    <div class="input-group">
+      <div class="input-group-prepend">
+        <span class="input-group-text">Owner</span>
+      </div>
+      <eg-org-select
+        [initialOrg]="contextOrg"
+        (onChange)="orgOnChange($event)">
+      </eg-org-select>
+    </div>
+  </div>
+</div>
+
+<ng-template #nameTmpl let-row="row">
+  <a routerLink="/staff/cat/vandelay/match_sets/{{row.id()}}/editor">
+    {{row.name()}}
+  </a> 
+</ng-template>
+
+<eg-grid #grid [dataSource]="gridSource"
+  persistKey="cat.vandelay.match_set.list"
+  idlClass="vms" [dataSource]="queueSource">
+  <eg-grid-toolbar-button label="New Match Set" i18n-label [action]="createNew">
+  </eg-grid-toolbar-button>
+  <eg-grid-toolbar-action label="Delete Selected" i18n-label 
+    [action]="deleteSelected"></eg-grid-toolbar-action>
+  <eg-grid-column name="name" [cellTemplate]="nameTmpl">
+  </eg-grid-column>
+</eg-grid>
+
+<eg-fm-record-editor #editDialog idlClass="vms">
+</eg-fm-record-editor>
+
+
+
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 (file)
index 0000000..6a67531
--- /dev/null
@@ -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 (file)
index 0000000..ce6287e
--- /dev/null
@@ -0,0 +1,11 @@
+
+<ngb-tabset [activeId]="matchSetTab" (tabChange)="onTabChange($event)">
+       <ngb-tab title="Match Set Editor" i18n-title id="editor">
+               <ng-template ngbTabContent>
+               </ng-template>
+       </ngb-tab>
+       <ngb-tab title="Match Set Quality Metrics" i18n-title id="quality">
+               <ng-template ngbTabContent>
+               </ng-template>
+       </ngb-tab>
+</ngb-tabset>
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 (file)
index 0000000..3527d41
--- /dev/null
@@ -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]);
+    }
+}
+
index 3378f86..a7776d5 100644 (file)
@@ -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
   }]
 }];
 
index 4104491..1fc1a52 100644 (file)
@@ -23,7 +23,7 @@
         i18n>Merge / Overlay Profiles</a>
   </li>
   <li class="nav-item">
-    <a class="nav-link disabled" [ngClass]="{active: tab=='match_sets'}" 
+    <a class="nav-link" [ngClass]="{active: tab=='match_sets'}" 
       routerLink="/staff/cat/vandelay/match_sets" 
         i18n>Record Match Sets</a>
   </li>
index 9f0e8db..5726b4e 100644 (file)
@@ -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,