LP1771636 Org Select Combined Org Names Option
authorBill Erickson <berickxx@gmail.com>
Mon, 3 Jan 2022 17:54:43 +0000 (12:54 -0500)
committerMichele Morgan <mmorgan@noblenet.org>
Fri, 29 Jul 2022 19:41:21 +0000 (15:41 -0400)
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 <berickxx@gmail.com>
Signed-off-by: John Amundson <jamundson@cwmars.org>
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>
Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.org-select-combo-names.sql [new file with mode: 0644]
Open-ILS/src/templates/staff/admin/workstation/t_splash.tt2
Open-ILS/web/js/ui/default/staff/admin/workstation/app.js

index 005c076..93dee29 100644 (file)
@@ -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<string>();
     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<number> {
 
         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;
 
                     });
index efcf20a..c99fa50 100644 (file)
@@ -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 (file)
index 0000000..054330b
--- /dev/null
@@ -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;
index 61a8d08..4e45633 100644 (file)
         </div>
       </div>
 
+      <div class="row new-entry">
+        <div class="col-md-12">
+          <div class="checkbox">
+            <label>
+              <input type="checkbox" ng-model="orgselect_combo_names"
+                  ng-change="apply_orgselect_combob_names()">
+                [% l('Include Full Library Names in Library Selector?') %]
+            </label>
+          </div>
+        </div>
+      </div>
+
     </div><!-- left column -->
     <div class="col-md-6"><!-- right column -->
 
index 527e6b0..29d880d 100644 (file)
@@ -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);
     }