From 1a9f22f5d7098bc6e3d792e5af6adb400edcd2b1 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 16 Oct 2020 10:41:46 -0400 Subject: [PATCH] LP1894131 Sticky catalog holdings org select 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 Signed-off-by: Elaine Hardy --- .../share/org-select/org-select.component.ts | 22 ++++++++++--------- .../catalog/record/holdings.component.html | 2 +- .../catalog/record/holdings.component.ts | 11 ++++++++-- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 11 ++++++++++ .../upgrade/XXXX.data.holdings-org-select.sql | 17 ++++++++++++++ 5 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.holdings-org-select.sql diff --git a/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts b/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts index 1a11435558..3436045d10 100644 --- a/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts @@ -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) { diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html index 8ba41a8489..5f3ec56743 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.html @@ -8,7 +8,7 @@
Holdings Maintenance
+ persistKey="catalog.holdings" (onChange)="contextOrgChanged($event)"> diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts index 3bde851412..2a58ef605c 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/holdings.component.ts @@ -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(); } diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index bf9b3293ec..bf3e7ab61b 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -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 index 0000000000..cd61302743 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.holdings-org-select.sql @@ -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; + + -- 2.43.2