LP1806087 Org setting to enable experimental staff catalog
authorBill Erickson <berickxx@gmail.com>
Thu, 10 Jan 2019 17:11:41 +0000 (12:11 -0500)
committerDan Wells <dbw2@calvin.edu>
Wed, 20 Feb 2019 21:59:31 +0000 (16:59 -0500)
Adds a new org unit setting "GUI: Enable Experimental Angular Staff
Catalog" (ui.staff.angular_catalog.enabled).  When set to true, a new
navbar menu item will appear in both the Angular and AngJS client menus
for "Staff Catalog (Experimental)".  This action directs the user to the
Angular staff catalog.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/eg2/src/app/core/org.service.ts
Open-ILS/src/eg2/src/app/staff/nav.component.html
Open-ILS/src/eg2/src/app/staff/nav.component.ts
Open-ILS/src/eg2/src/app/staff/resolver.service.ts
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.ang-catalog-preview-setting.sql [new file with mode: 0644]
Open-ILS/src/templates/staff/navbar.tt2
Open-ILS/web/js/ui/default/staff/services/navbar.js
Open-ILS/web/js/ui/default/staff/services/startup.js

index 71dba93..0acb227 100644 (file)
@@ -253,8 +253,9 @@ export class OrgService {
             }
 
         } else if (!anonymous) {
-            return Promise.reject(
-                'Use "anonymous" To retrieve org settings without an authtoken');
+            console.warn('Attempt to fetch org setting(s)', 
+                name, 'in non-anonymous mode without an authtoken');
+            return Promise.resolve({});
         }
 
         if (useCache) {
index 0642f49..d5ce844 100644 (file)
             <span class="material-icons">search</span>
             <span i18n>Search the Catalog</span>
           </a>
-          <!--
-            Link to experimental Angular staff catalog.
-            Leaving disabled until more functionality can be fleshed out.
-          -->
-          <a class="dropdown-item"
-              routerLink="/staff/catalog/search">
+          <a *ngIf="showAngularCatalog"
+            class="dropdown-item"
+            routerLink="/staff/catalog/search">
             <span class="material-icons">search</span>
             <span i18n>Staff Catalog (Experimental)</span>
           </a>
index c477c11..54bbcbe 100644 (file)
@@ -1,6 +1,7 @@
 import {Component, OnInit, ViewChild} from '@angular/core';
 import {ActivatedRoute, Router} from '@angular/router';
 import {Location} from '@angular/common';
+import {OrgService} from '@eg/core/org.service';
 import {AuthService} from '@eg/core/auth.service';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {LocaleService} from '@eg/core/locale.service';
@@ -18,8 +19,12 @@ export class StaffNavComponent implements OnInit {
     locales: any[];
     currentLocale: any;
 
+    // When active, show a link to the experimental Angular staff catalog
+    showAngularCatalog: boolean;
+
     constructor(
         private router: Router,
+        private org: OrgService,
         private auth: AuthService,
         private pcrud: PcrudService,
         private locale: LocaleService,
@@ -38,6 +43,15 @@ export class StaffNavComponent implements OnInit {
                     l => l.code() === this.locale.currentLocaleCode())[0];
             }
         );
+
+        // NOTE: this can eventually go away.
+        // Avoid attempts to fetch org settings if the user has not yet 
+        // logged in (e.g. this is the login page).
+        if (this.user()) {
+            this.org.settings('ui.staff.angular_catalog.enabled')
+            .then(settings => this.showAngularCatalog = 
+                Boolean(settings['ui.staff.angular_catalog.enabled']));
+        }
     }
 
     user() {
index 748b701..2c94ec7 100644 (file)
@@ -130,7 +130,8 @@ export class StaffResolver implements Resolve<Observable<any>> {
             'lib.timezone',
             'webstaff.format.dates',
             'webstaff.format.date_and_time',
-            'ui.staff.max_recent_patrons'
+            'ui.staff.max_recent_patrons',
+            'ui.staff.angular_catalog.enabled' // navbar
         ]).then(settings => {
             this.format.wsOrgTimezone = settings['lib.timezone'];
             this.format.dateFormat = settings['webstaff.format.dates'];
index ab3568e..5047e77 100644 (file)
@@ -19840,7 +19840,24 @@ VALUES (
     )
 );
 
-
+-- NOTE: This setting should be removed once the Angular catalog
+-- becomes the default.
+INSERT into config.org_unit_setting_type 
+    (name, datatype, grp, label, description)
+VALUES ( 
+    'ui.staff.angular_catalog.enabled', 'bool', 'gui',
+    oils_i18n_gettext(
+        'ui.staff.angular_catalog.enabled',
+        'GUI: Enable Experimental Angular Staff Catalog',
+        'coust', 'label'
+    ),
+    oils_i18n_gettext(
+        'ui.staff.angular_catalog.enabled',
+        'Display an entry point in the browser client for the ' ||
+        'experimental Angular staff catalog.',
+        'coust', 'description'
+    )
+);
 
 INSERT INTO config.org_unit_setting_type
     (name, label, description, grp, datatype)
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.ang-catalog-preview-setting.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.ang-catalog-preview-setting.sql
new file mode 100644 (file)
index 0000000..1bc4888
--- /dev/null
@@ -0,0 +1,23 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT into config.org_unit_setting_type 
+    (name, datatype, grp, label, description)
+VALUES ( 
+    'ui.staff.angular_catalog.enabled', 'bool', 'gui',
+    oils_i18n_gettext(
+        'ui.staff.angular_catalog.enabled',
+        'GUI: Enable Experimental Angular Staff Catalog',
+        'coust', 'label'
+    ),
+    oils_i18n_gettext(
+        'ui.staff.angular_catalog.enabled',
+        'Display an entry point in the browser client for the ' ||
+        'experimental Angular staff catalog.',
+        'coust', 'description'
+    )
+);
+
+COMMIT;
+
index eb1d471..2b42347 100644 (file)
           </li>
           <!--
             Link to experimental Angular staff catalog.
-            Leaving disabled until more functionality can be fleshed out.
           -->
-          <!--
-          <li>
-            <a href="/eg2/staff/catalog/search" target="_self">
+          <li ng-if="showAngularCatalog">
+            <a href="/eg2/staff/catalog/search">
               <span class="glyphicon glyphicon-search"></span>
               <span>[% l('Staff Catalog (Experimental)') %]</span>
             </a>
           </li>
-          -->
           <li>
             <a href="./cat/bucket/record/view" target="_self">
               <span class="glyphicon glyphicon-list-alt"></span>
index dcc72de..2702fc0 100644 (file)
@@ -113,11 +113,16 @@ angular.module('egCoreMod')
                             $scope.username = egCore.auth.user().usrname();
                             $scope.workstation = egCore.auth.workstation();
 
-                            egCore.org.settings('ui.staff.max_recent_patrons')
-                            .then(function(s) {
+                            egCore.org.settings([
+                                'ui.staff.max_recent_patrons',
+                                'ui.staff.angular_catalog.enabled'
+                            ]).then(function(s) {
                                 var val = s['ui.staff.max_recent_patrons'];
                                 $scope.showRecentPatron = val > 0;
                                 $scope.showRecentPatrons = val > 1;
+
+                                $scope.showAngularCatalog = 
+                                    s['ui.staff.angular_catalog.enabled'];
                             });
                         }
                         // need to defer initialization of hotkeys to this point
index 41c6977..706bd6f 100644 (file)
@@ -36,6 +36,7 @@ function($q,  $rootScope,  $location,  $window,  egIDL,  egAuth,  egEnv , egOrg
                 'webstaff.format.dates',
                 'webstaff.format.date_and_time',
                 'ui.staff.max_recent_patrons', // affects navbar
+                'ui.staff.angular_catalog.enabled', // affects navbar
                 'lib.timezone'
             ]).then(
                 function(set) {