LP1861701 Staff catalog copy location groups WIP user/berick/lp1861701-staffcat-copy-loc-groups
authorBill Erickson <berickxx@gmail.com>
Mon, 3 Feb 2020 19:22:59 +0000 (14:22 -0500)
committerBill Erickson <berickxx@gmail.com>
Mon, 3 Feb 2020 19:22:59 +0000 (14:22 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/catalog/eg-org-copy-loc-select.html [deleted file]
Open-ILS/src/eg2/src/app/share/catalog/org-copy-loc-select.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/share/catalog/org-copy-loc-select.component.ts
Open-ILS/src/eg2/src/app/share/catalog/search-context.ts
Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts

diff --git a/Open-ILS/src/eg2/src/app/share/catalog/eg-org-copy-loc-select.html b/Open-ILS/src/eg2/src/app/share/catalog/eg-org-copy-loc-select.html
deleted file mode 100644 (file)
index 6a0d087..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-
-<eg-combobox #cbox></eg-combobox>
diff --git a/Open-ILS/src/eg2/src/app/share/catalog/org-copy-loc-select.component.html b/Open-ILS/src/eg2/src/app/share/catalog/org-copy-loc-select.component.html
new file mode 100644 (file)
index 0000000..6a0d087
--- /dev/null
@@ -0,0 +1,2 @@
+
+<eg-combobox #cbox></eg-combobox>
index 0f8db65..ff1587e 100644 (file)
@@ -11,9 +11,14 @@ import {ComboboxComponent, ComboboxEntry} from '@eg/share/combobox/combobox.comp
 
 const PAD_SPACE = ' '; // U+2007
 
+export interface OrgCopyLocEntry {
+    org?: number; // org unit ID
+    grp?: number; // copy location group ID
+}
+
 @Component({
   selector: 'eg-org-copy-loc-select',
-  templateUrl: 'eg-org-copy-loc-select.html',
+  templateUrl: 'org-copy-loc-select.component.html',
   providers: [
     {
       provide: NG_VALUE_ACCESSOR,
@@ -95,13 +100,30 @@ export class OrgCopyLocSelectComponent implements AfterViewInit {
     }
 
     cboxChange(entry: ComboboxEntry) {
+        let value: OrgCopyLocEntry = null;
+        if (entry) {
+            value = {};
+            const org = entry.id.match(/org_(\d+)/);
+            const grp = entry.id.match(/grp_(\d+)/);
+            value.org = org ? org[1] : null;
+            value.grp = grp ? grp[1] : null;
+        }
         this.propagateChange(entry);
     }
 
-    writeValue(entry: ComboboxEntry) {
-        if (this.cbox) {
-            this.cbox.selectedId = entry ? entry.id : null;
+    writeValue(entry: OrgCopyLocEntry) {
+        if (!this.cbox) { return; }
+        let id: string = null;
+
+        if (entry) {
+            if (entry.org) {
+                id = 'org_' + entry.org;
+            } else if (entry.grp) {
+                id = 'grp_' + entry.grp;
+            }
         }
+
+        this.cbox.selectedId = id;
     }
 
     registerOnChange(fn) {
index 041d710..54876b3 100644 (file)
@@ -2,6 +2,7 @@ import {OrgService} from '@eg/core/org.service';
 import {IdlObject} from '@eg/core/idl.service';
 import {Pager} from '@eg/share/util/pager';
 import {ArrayUtil} from '@eg/share/util/array';
+import {OrgCopyLocEntry} from '@eg/share/catalog/org-copy-loc-select.component';
 
 // CCVM's we care about in a catalog context
 // Don't fetch them all because there are a lot.
index 3287e1d..b55bf3c 100644 (file)
@@ -6,7 +6,7 @@ import {CatalogService} from '@eg/share/catalog/catalog.service';
 import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context';
 import {StaffCatalogService} from './catalog.service';
 import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap';
-import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
+import {OrgCopyLocEntry} from '@eg/share/catalog/org-copy-loc-select.component';
 
 @Component({
   selector: 'eg-catalog-search-form',
@@ -21,7 +21,7 @@ export class SearchFormComponent implements OnInit, AfterViewInit {
     showSearchFilters = false;
     copyLocations: IdlObject[];
     searchTab: string;
-    orgCopyLoc: ComboboxEntry;
+    orgCopyLoc: OrgCopyLocEntry;
 
     constructor(
         private renderer: Renderer2,