From 38feacd1a79ab733e3ae8cfb356fba18383795f8 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 10 Jan 2019 12:11:41 -0500 Subject: [PATCH] LP1806087 Org setting to enable experimental staff catalog 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 Signed-off-by: Dan Wells --- Open-ILS/src/eg2/src/app/core/org.service.ts | 5 ++-- .../src/eg2/src/app/staff/nav.component.html | 9 +++----- .../src/eg2/src/app/staff/nav.component.ts | 14 +++++++++++ .../src/eg2/src/app/staff/resolver.service.ts | 3 ++- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 19 ++++++++++++++- .../XXXX.data.ang-catalog-preview-setting.sql | 23 +++++++++++++++++++ Open-ILS/src/templates/staff/navbar.tt2 | 7 ++---- .../js/ui/default/staff/services/navbar.js | 9 ++++++-- .../js/ui/default/staff/services/startup.js | 1 + 9 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.ang-catalog-preview-setting.sql diff --git a/Open-ILS/src/eg2/src/app/core/org.service.ts b/Open-ILS/src/eg2/src/app/core/org.service.ts index 71dba933ed..0acb2279e9 100644 --- a/Open-ILS/src/eg2/src/app/core/org.service.ts +++ b/Open-ILS/src/eg2/src/app/core/org.service.ts @@ -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) { diff --git a/Open-ILS/src/eg2/src/app/staff/nav.component.html b/Open-ILS/src/eg2/src/app/staff/nav.component.html index 0642f493e1..d5ce844f53 100644 --- a/Open-ILS/src/eg2/src/app/staff/nav.component.html +++ b/Open-ILS/src/eg2/src/app/staff/nav.component.html @@ -136,12 +136,9 @@ search Search the Catalog - - + search Staff Catalog (Experimental) diff --git a/Open-ILS/src/eg2/src/app/staff/nav.component.ts b/Open-ILS/src/eg2/src/app/staff/nav.component.ts index c477c116b9..54bbcbe511 100644 --- a/Open-ILS/src/eg2/src/app/staff/nav.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/nav.component.ts @@ -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() { diff --git a/Open-ILS/src/eg2/src/app/staff/resolver.service.ts b/Open-ILS/src/eg2/src/app/staff/resolver.service.ts index 748b701e5c..2c94ec76d3 100644 --- a/Open-ILS/src/eg2/src/app/staff/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/resolver.service.ts @@ -130,7 +130,8 @@ export class StaffResolver implements Resolve> { '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']; 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 ab3568eaee..5047e77f5e 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -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 index 0000000000..1bc4888045 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.ang-catalog-preview-setting.sql @@ -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; + diff --git a/Open-ILS/src/templates/staff/navbar.tt2 b/Open-ILS/src/templates/staff/navbar.tt2 index eb1d4719c6..2b423470ae 100644 --- a/Open-ILS/src/templates/staff/navbar.tt2 +++ b/Open-ILS/src/templates/staff/navbar.tt2 @@ -253,16 +253,13 @@ -
  • diff --git a/Open-ILS/web/js/ui/default/staff/services/navbar.js b/Open-ILS/web/js/ui/default/staff/services/navbar.js index dcc72deaa4..2702fc05f0 100644 --- a/Open-ILS/web/js/ui/default/staff/services/navbar.js +++ b/Open-ILS/web/js/ui/default/staff/services/navbar.js @@ -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 diff --git a/Open-ILS/web/js/ui/default/staff/services/startup.js b/Open-ILS/web/js/ui/default/staff/services/startup.js index 41c69775d0..706bd6ffdf 100644 --- a/Open-ILS/web/js/ui/default/staff/services/startup.js +++ b/Open-ILS/web/js/ui/default/staff/services/startup.js @@ -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) { -- 2.43.2