LP#1779158 Angular vandelay more import form
authorBill Erickson <berickxx@gmail.com>
Sun, 1 Jul 2018 19:36:12 +0000 (15:36 -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/import.component.html
Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.ts
Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.service.ts

index e380b6a..f7bbaac 100644 (file)
       <eg-typeahead [entries]="formatEntries('matchSets')" 
         placeholder="Match Set..." i18n-placeholder></eg-typeahead>
     </div>
+    <div class="col-lg-3">
+      <label i18n>Limit Matches to Bucket</label>
+    </div>
+    <div class="col-lg-3">
+      <eg-typeahead [entries]="formatEntries('bibBuckets')" 
+        placeholder="Buckets..." i18n-placeholder></eg-typeahead>
+    </div>
   </div>
   <div class="row">
     <div class="col-lg-3">
index 725c0fd..ed640b1 100644 (file)
@@ -13,18 +13,8 @@ export class ImportComponent implements OnInit, AfterViewInit {
 
     recordType: string;
     newQueueName: string;
-    allQueues: {[qtype: string]: IdlObject[]};
-    activeQueues: {[qtype: string]: IdlObject[]}; 
     attrDefs: {[atype: string]: IdlObject[]};
-    bibSources: IdlObject[];
-    bibBuckets: IdlObject[];
-    itemImportAttrDefs: IdlObject[];
-    matchSets: {[stype: string]: IdlObject[]};
     defaultMatchSet: string;
-    mergeProfiles: IdlObject[];
-
-    matchSetEntries: TypeaheadEntry[];
-    importItemDefEntries: TypeaheadEntry[];
 
     importNonMatching: boolean;
     mergeOnExact: boolean;
@@ -41,8 +31,6 @@ export class ImportComponent implements OnInit, AfterViewInit {
     ) {
         this.recordType = 'bib';
         this.attrDefs = {};
-        this.matchSets = {};
-        this.activeQueues = {};
         this.minQualityRatio = 0;
     }
 
@@ -65,22 +53,14 @@ export class ImportComponent implements OnInit, AfterViewInit {
                 .then(defs => this.attrDefs.bib = defs),
             this.vandelay.getAttrDefs('auth')
                 .then(defs => this.attrDefs.auth = defs),
-            this.vandelay.getMergeProfiles()
-                .then(profiles => this.mergeProfiles = profiles),
-            this.vandelay.getActiveQueues('bib')
-                .then(queues => this.activeQueues.bib = queues),
-            this.vandelay.getActiveQueues('auth')
-                .then(queues => this.activeQueues.auth = queues),
-            this.vandelay.getMatchSets('bib')
-                .then(sets => this.matchSets.bib = sets),
-            this.vandelay.getMatchSets('auth')
-                .then(sets => this.matchSets.auth= sets),
-            this.vandelay.getBibBuckets()
-                .then(bkts => this.bibBuckets = bkts),
-            this.vandelay.getBibSources()
-                .then(srcs => this.bibSources = srcs),
-            this.vandelay.getItemImportDefs()
-                .then(defs => this.itemImportAttrDefs = defs),
+            this.vandelay.getMergeProfiles(),
+            this.vandelay.getActiveQueues('bib'),
+            this.vandelay.getActiveQueues('auth'),
+            this.vandelay.getMatchSets('bib'),
+            this.vandelay.getMatchSets('auth'),
+            this.vandelay.getBibBuckets(),
+            this.vandelay.getBibSources(),
+            this.vandelay.getItemImportDefs(),
             this.org.settings(['vandelay.default_match_set']).then(
                 s => this.defaultMatchSet = s['vandelay.default_match_set'])
         ];
@@ -91,33 +71,37 @@ export class ImportComponent implements OnInit, AfterViewInit {
     // Format typeahead data sets
     formatEntries(etype: string): TypeaheadEntry[] {
         const rtype = this.recordType;
+        let list;
 
         switch (etype) {
             case 'bibSources':
-                return (this.bibSources || []).map(s => {
-                    return {id: s.id(), label: s.source()};
-                });
+                return (this.vandelay.bibSources || []).map(
+                    s => { return {id: s.id(), label: s.source()}; });
+
+            case 'bibBuckets':
+                list = this.vandelay.bibBuckets;
+                break;
 
             case 'activeQueues':
-                return (this.activeQueues[rtype] || []).map(q => {
-                    return {id: q.id(), label: q.name()};
-                });
+                list = this.vandelay.activeQueues[rtype];
+                break;
 
             case 'matchSets':
-                return (this.matchSets[rtype] || []).map(s => { 
-                    return {id: s.id(), label: s.name()}; 
-                });
+                list = this.vandelay.matchSets[rtype];
+                break;
 
             case 'importItemDefs':
-                return (this.itemImportAttrDefs || []).map(d => {
-                    return {id: d.id(), label: d.name()};
-                 });
+                list = this.vandelay.importItemAttrDefs;
+                break;
 
             case 'mergeProfiles':
-                return (this.mergeProfiles || []).map(d => {
-                    return {id: d.id(), label: d.name()};
-                 });
+                list = this.vandelay.mergeProfiles;
+                break;
         }
+
+        return (list || []).map(item => {
+            return {id: item.id(), label: item.name()};
+        });
     }
 }
 
index 46bfd09..caa7ca3 100644 (file)
@@ -145,7 +145,11 @@ export class VandelayService {
             'open-ils.actor', 
             'open-ils.actor.container.retrieve_by_class',
             this.auth.token(), this.auth.user().id(), 'biblio', 'staff_client'
-        ).pipe(tap(bkt => bkts.push(bkt))).toPromise().then(() => bkts);
+        //).pipe(tap(bkt => bkts.push(bkt))).toPromise().then(() => bkts);
+        ).toPromise().then(bkts => {
+            this.bibBuckets = bkts;
+            return bkts;
+        });
     }
 
     getCopyStatuses(): Promise<any> {