From 7ecae917bdd3a6ddc829e8a67bb0d4bc48c9d9e4 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 3 Jan 2022 12:54:43 -0500 Subject: [PATCH] LP1771636 Org Select Combined Org Names Option Adds an option to the staff client workstation settings page for "Include Full Library Names in Library Selector?". When enabled, Angular org unit selectors display the full branch in addition to the branch short code. Signed-off-by: Bill Erickson Signed-off-by: John Amundson Signed-off-by: Michele Morgan --- .../app/share/org-select/org-select.component.ts | 42 ++++++++++++++++------ Open-ILS/src/sql/Pg/950.data.seed-values.sql | 9 +++++ .../upgrade/XXXX.data.org-select-combo-names.sql | 15 ++++++++ .../templates/staff/admin/workstation/t_splash.tt2 | 12 +++++++ .../js/ui/default/staff/admin/workstation/app.js | 12 +++++++ 5 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-select-combo-names.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 005c07625c..93dee2944d 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 @@ -41,6 +41,8 @@ interface OrgDisplay { export class OrgSelectComponent implements OnInit { static domId = 0; + showCombinedNames = false; // Managed via user/workstation setting + selected: OrgDisplay; click$ = new Subject(); valueFromSetting: number = null; @@ -156,17 +158,29 @@ export class OrgSelectComponent implements OnInit { ngOnInit() { - // Sort the tree and reabsorb to propagate the sorted nodes to - // the org.list() used by this component. Maintain our own - // copy of the org list in case the org service is sorted in a - // different manner by other parts of the code. - this.org.sortTree(this.displayField); - this.org.absorbTree(); - this.sortedOrgs = this.org.list(); - const promise = this.persistKey ? + let promise = this.persistKey ? this.getFromSetting() : Promise.resolve(null); + promise = promise.then(startupOrg => { + return this.serverStore.getItem('eg.orgselect.show_combined_names') + .then(show => { + const sortField = show ? 'name' : this.displayField; + + // Sort the tree and reabsorb to propagate the sorted + // nodes to the org.list() used by this component. + // Maintain our own copy of the org list in case the + // org service is sorted in a different manner by other + // parts of the code. + this.org.sortTree(sortField); + this.org.absorbTree(); + this.sortedOrgs = this.org.list(); + + this.showCombinedNames = show; + }) + .then(_ => startupOrg); + }); + promise.then((startupOrgId: number) => { if (!startupOrgId) { @@ -203,6 +217,14 @@ export class OrgSelectComponent implements OnInit { }); } + getDisplayLabel(org: IdlObject): string { + if (this.showCombinedNames) { + return `${org.name()} (${org.shortname()})`; + } else { + return org[this.displayField](); + } + } + getFromSetting(): Promise { const key = `eg.orgselect.${this.persistKey}`; @@ -246,7 +268,7 @@ export class OrgSelectComponent implements OnInit { // Format for display in the selector drop-down and input. formatForDisplay(org: IdlObject): OrgDisplay { - let label = org[this.displayField](); + let label = this.getDisplayLabel(org); if (!this.readOnly) { label = PAD_SPACE.repeat(org.ou_type().depth()) + label; } @@ -322,7 +344,7 @@ export class OrgSelectComponent implements OnInit { // org units. orgs = orgs.filter(org => { return term === '' || // show all - org[this.displayField]() + this.getDisplayLabel(org) .toLowerCase().indexOf(term.toLowerCase()) > -1; }); 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 efcf20a9c2..c99fa509c2 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -22183,3 +22183,12 @@ VALUES ( ) ); +INSERT into config.workstation_setting_type (name, grp, datatype, label) +VALUES ( + 'eg.orgselect.show_combined_names', 'gui', 'bool', + oils_i18n_gettext( + 'eg.orgselect.show_combined_names', + 'Library Selector Show Combined Names', + 'cwst', 'label' + ) +); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-select-combo-names.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-select-combo-names.sql new file mode 100644 index 0000000000..054330bf24 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-select-combo-names.sql @@ -0,0 +1,15 @@ +BEGIN; + +-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version); + +INSERT into config.workstation_setting_type (name, grp, datatype, label) +VALUES ( + 'eg.orgselect.show_combined_names', 'gui', 'bool', + oils_i18n_gettext( + 'eg.orgselect.show_combined_names', + 'Library Selector Show Combined Names', + 'cwst', 'label' + ) +); + +COMMIT; diff --git a/Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2 b/Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2 index 61a8d08fe8..4e4563399b 100644 --- a/Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2 +++ b/Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2 @@ -82,6 +82,18 @@ +
+
+
+ +
+
+
+
diff --git a/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js b/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js index 527e6b03ba..29d880d4a2 100644 --- a/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js +++ b/Open-ILS/web/js/ui/default/staff/admin/workstation/app.js @@ -182,6 +182,10 @@ function($scope , $window , $location , egCore , egConfirmDialog) { $scope.disable_sound = val; }); + egCore.hatch.getItem('eg.orgselect.show_combined_names').then(function(val) { + $scope.orgselect_combo_names = val; + }); + egCore.hatch.getItem('eg.search.search_lib').then(function(val) { $scope.search_lib = egCore.org.get(val); }); @@ -214,6 +218,14 @@ function($scope , $window , $location , egCore , egConfirmDialog) { } } + $scope.apply_orgselect_combob_names = function() { + if ($scope.orgselect_combo_names) { + egCore.hatch.setItem('eg.orgselect.show_combined_names', true); + } else { + egCore.hatch.removeItem('eg.orgselect.show_combined_names'); + } + } + $scope.test_audio = function(sound) { egCore.audio.play(sound); } -- 2.11.0