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;
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.
* 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) {
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 = {};
* 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));
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;