From: Bill Erickson Date: Tue, 3 Apr 2018 22:08:08 +0000 (-0400) Subject: LP#1750894 Sample settings ; hatch wip X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7e21813b368ebce087cd0a25afebf538e68aba0a;p=working%2FEvergreen.git LP#1750894 Sample settings ; hatch wip Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.workstation-settings.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.workstation-settings.sql index 2824e4b0d7..d71360ea96 100644 --- a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.workstation-settings.sql +++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.workstation-settings.sql @@ -1,18 +1,85 @@ BEGIN; --- TODO: entries for all existing workstation settings we want to track. --- TEST DATA +INSERT INTO config.workstation_setting_type (name, grp, datatype, label) +VALUES ( + 'eg.circ.checkin.no_precat_alert', 'circ', 'bool', + oils_i18n_gettext( + 'eg.circ.checkin.no_precat_alert', + 'Checkin: Ignore Precataloged Items', + 'cwst', 'label' + ) +), ( + 'eg.circ.checkin.noop', 'circ', 'bool', + oils_i18n_gettext( + 'eg.circ.checkin.noop', + 'Checkin: Suppress Holds and Transits', + 'cwst', 'label' + ) +), ( + 'eg.circ.checkin.void_overdues', 'circ', 'bool', + oils_i18n_gettext( + 'eg.circ.checkin.void_overdues', + 'Checkin: Amnesty Mode', + 'cwst', 'label' + ) +), ( + 'eg.circ.checkin.auto_print_holds_transits', 'circ', 'bool', + oils_i18n_gettext( + 'eg.circ.checkin.auto_print_holds_transits', + 'Checkin: Auto-Print Holds and Transits', + 'cwst', 'label' + ) +), ( + 'eg.circ.checkin.clear_expired', 'circ', 'bool', + oils_i18n_gettext( + 'eg.circ.checkin.clear_expired', + 'Checkin: Clear Holds Shelf', + 'cwst', 'label' + ) +), ( + 'eg.circ.checkin.retarget_holds', 'circ', 'bool', + oils_i18n_gettext( + 'eg.circ.checkin.retarget_holds', + 'Checkin: Retarget Local Holds', + 'cwst', 'label' + ) +), ( + 'eg.circ.checkin.retarget_holds_all', 'circ', 'bool', + oils_i18n_gettext( + 'eg.circ.checkin.retarget_holds_all', + 'Checkin: Retarget All Statuses', + 'cwst', 'label' + ) +), ( + 'eg.circ.checkin.hold_as_transit', 'circ', 'bool', + oils_i18n_gettext( + 'eg.circ.checkin.hold_as_transit', + 'Checkin: Capture Local Holds as Transits', + 'cwst', 'label' + ) +), ( + 'eg.circ.checkin.manual_float', 'circ', 'bool', + oils_i18n_gettext( + 'eg.circ.checkin.manual_float', + 'Checkin: Manual Floating Active', + 'cwst', 'label' + ) +), ( + 'circ.checkin.strict_barcode', 'circ', 'bool', + oils_i18n_gettext( + 'circ.checkin.strict_barcode', + 'Checkin: Strict Barcode', + 'cwst', 'label' + ) +); + /* -INSERT INTO config.workstation_setting_type (name, label, grp, datatype) -VALUES ('eg.circ.checkin.no_precat_alert', - 'Checkin Suppress Precat Alert' /*TODO: i18n*/, 'circ', 'bool'); - */ INSERT INTO permission.perm_list (id, code, description) VALUES (594, 'APPLY_WORKSTATION_SETTING', oils_i18n_gettext(594, 'APPLY_WORKSTATION_SETTING', 'ppl', 'description')); - +*/ COMMIT; diff --git a/Open-ILS/web/js/ui/default/staff/services/hatch.js b/Open-ILS/web/js/ui/default/staff/services/hatch.js index f7083a7b67..216b462663 100644 --- a/Open-ILS/web/js/ui/default/staff/services/hatch.js +++ b/Open-ILS/web/js/ui/default/staff/services/hatch.js @@ -25,13 +25,14 @@ angular.module('egCoreMod') .factory('egHatch', - ['$q','$window','$timeout','$interpolate','$cookies', - function($q , $window , $timeout , $interpolate , $cookies) { + ['$q','$window','$timeout','$interpolate','$cookies','egNet','$injector', + function($q , $window , $timeout , $interpolate , $cookies , egNet , $injector ) { var service = {}; service.msgId = 1; service.messages = {}; service.hatchAvailable = false; + service.auth = null; // ref to egAuth loaded on-demand to avoid circular ref. // key/value cache -- avoid unnecessary Hatch extension requests. // Only affects *RemoteItem calls. @@ -50,7 +51,7 @@ angular.module('egCoreMod') * at a time and each maintains its own data separately. */ service.onCallPrefixes = ['eg.workstation']; - + // Returns true if the key can be set/get in localStorage even when // Hatch is not available. service.keyIsOnCall = function(key) { @@ -62,6 +63,39 @@ angular.module('egCoreMod') return oncall; } + /** + * Settings with these prefixes will always live in the browser. + */ + service.browserOnlyPrefixes = ['eg.workstation', 'eg.hatch']; + + // For testing (and possibly migration) purposes, hard-code the + // list of settings that are available to be applied on the server, + // either via workstation or user settings. + service.serverSettings = [ + 'eg.circ.checkin.no_precat_alert', + 'eg.circ.checkin.noop', + 'eg.circ.checkin.void_overdues', + 'eg.circ.checkin.auto_print_holds_transits', + 'eg.circ.checkin.clear_expired', + 'eg.circ.checkin.retarget_holds', + 'eg.circ.checkin.retarget_holds_all', + 'eg.circ.checkin.hold_as_transit', + 'eg.circ.checkin.manual_float', + 'circ.checkin.strict_barcode' + ]; + + service.keyStoredOnServer = function(key) { + var browserOnly = false; + angular.forEach(service.browserOnlyPrefixes, function(pfx) { + if (key.match(new RegExp('^' + pfx))) + browserOnly = true; + }); + + if (browserOnly) return false; + + return service.serverSettings.indexOf(key) > -1 + } + // write a message to the Hatch port service.sendToHatch = function(msg) { var msg2 = {}; @@ -273,6 +307,10 @@ angular.module('egCoreMod') * tmp values are removed during logout or browser close. */ service.setItem = function(key, value) { + + if (service.keyStoredOnServer(key)) + return service.setServerItem(key, value); + if (!service.useSettings()) return $q.when(service.setLocalItem(key, value)); @@ -290,6 +328,18 @@ angular.module('egCoreMod') return $q.reject(); } + + service.setServerItem = function(key, value) { + if (!service.auth) service.auth = $injector.get('egAuth'); + var settings = {}; + settings[key] = value; + return egNet.request( + 'open-ils.actor', + 'open-ils.actor.settings.apply.user_or_ws', + service.auth.token(), settings + ); + } + // set the value for a stored or new item service.setRemoteItem = function(key, value) { service.keyCache[key] = value;