LP1894131 Sticky catalog holdings org select
authorBill Erickson <berickxx@gmail.com>
Fri, 16 Oct 2020 14:41:46 +0000 (10:41 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 28 Jan 2021 19:13:22 +0000 (14:13 -0500)
Adds a workstation setting to make the org selector in the catalog
holdings tab sticky.

Also repairs some logic errors in the org select persistKey loading.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Elaine Hardy <ehardy@georgialibraries.org>

Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html
Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.holdings-org-select.sql [new file with mode: 0644]

index 1a11435..3436045 100644 (file)
@@ -152,15 +152,6 @@ export class OrgSelectComponent implements OnInit {
         this.org.absorbTree();
         this.sortedOrgs = this.org.list();
 
-        if (this.initialOrg || this.initialOrgId) {
-            this.selected = this.formatForDisplay(
-                this.initialOrg || this.org.get(this.initialOrgId)
-            );
-
-            this.markAsLoaded();
-            return;
-        }
-
         const promise = this.persistKey ?
             this.getFromSetting() : Promise.resolve(null);
 
@@ -168,7 +159,18 @@ export class OrgSelectComponent implements OnInit {
 
             if (!startupOrgId) {
 
-                if (this.fallbackOrgId) {
+                if (this.selected) {
+                    // A value may have been applied while we were
+                    // talking to the network.
+                    startupOrgId = this.selected.id;
+
+                } else if (this.initialOrg) {
+                    startupOrgId = this.initialOrg.id();
+
+                } else if (this.initialOrgId) {
+                    startupOrgId = this.initialOrgId;
+
+                } else if (this.fallbackOrgId) {
                     startupOrgId = this.fallbackOrgId;
 
                 } else if (this.fallbackOrg) {
index 8ba41a8..5f3ec56 100644 (file)
@@ -8,7 +8,7 @@
         <div class="input-group-text" i18n>Holdings Maintenance</div>
       </div>
       <eg-org-select [initialOrg]="contextOrg" 
-        (onChange)="contextOrgChanged($event)">
+        persistKey="catalog.holdings" (onChange)="contextOrgChanged($event)">
       </eg-org-select>
     </div>
   </div>
index 3bde851..2a58ef6 100644 (file)
@@ -1,7 +1,7 @@
 import {Component, OnInit, Input, ViewChild, ViewEncapsulation
     } from '@angular/core';
 import {Router} from '@angular/router';
-import {Observable, Observer, of} from 'rxjs';
+import {Observable, Observer, of, empty} from 'rxjs';
 import {map} from 'rxjs/operators';
 import {Pager} from '@eg/share/util/pager';
 import {IdlObject, IdlService} from '@eg/core/idl.service';
@@ -161,6 +161,11 @@ export class HoldingsMaintenanceComponent implements OnInit {
 
     contextOrg: IdlObject;
 
+    // The context org may come from a workstation setting.
+    // Wait for confirmation from the org-select (via onchange in this
+    // case) that the desired context org unit has been found.
+    contextOrgLoaded = false;
+
     constructor(
         private router: Router,
         private org: OrgService,
@@ -256,13 +261,15 @@ export class HoldingsMaintenanceComponent implements OnInit {
         this.emptyCallNumsCheckbox.checked(settings['cat.holdings_show_empty']);
         this.emptyLibsCheckbox.checked(settings['cat.holdings_show_empty_org']);
 
-        this.initHoldingsTree();
         this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
+            if (!this.contextOrgLoaded) { return empty(); }
             return this.fetchHoldings(pager);
         };
     }
 
+    // No data is loaded until the first occurrence of the org change handler
     contextOrgChanged(org: IdlObject) {
+        this.contextOrgLoaded = true;
         this.contextOrg = org;
         this.hardRefresh();
     }
index bf9b329..bf3e7ab 100644 (file)
@@ -21238,3 +21238,14 @@ VALUES (
         'cwst', 'label'
     )
 );
+
+INSERT INTO config.workstation_setting_type (name, grp, datatype, fm_class, label)
+VALUES (
+    'eg.orgselect.catalog.holdings', 'gui', 'link', 'aou',
+    oils_i18n_gettext(
+        'eg.orgselect.catalog.holdings',
+        'Default org unit for catalog holdings tab',
+        'cwst', 'label'
+    )
+);
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.holdings-org-select.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.holdings-org-select.sql
new file mode 100644 (file)
index 0000000..cd61302
--- /dev/null
@@ -0,0 +1,17 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.workstation_setting_type (name, grp, datatype, fm_class, label)
+VALUES (
+    'eg.orgselect.catalog.holdings', 'gui', 'link', 'aou',
+    oils_i18n_gettext(
+        'eg.orgselect.catalog.holdings',
+        'Default org unit for catalog holdings tab',
+        'cwst', 'label'
+    )
+);
+
+COMMIT;
+
+