From f76deff4a41e75acbffc51355f9d25c6c2f6ee60 Mon Sep 17 00:00:00 2001 From: Thomas Berezansky Date: Wed, 18 Apr 2012 22:03:16 -0400 Subject: [PATCH] Floating Groups Convert the floating bool to a link to floating groups. Each group contains zero or more members that define how copies can float. See the included documentation file for an overview. Signed-off-by: Thomas Berezansky Conflicts: Open-ILS/src/sql/Pg/950.data.seed-values.sql --- Open-ILS/examples/fm_IDL.xml | 51 +++++- .../src/perlmods/lib/OpenILS/Application/Circ.pm | 2 +- .../lib/OpenILS/Application/Circ/Circulate.pm | 19 +- Open-ILS/src/sql/Pg/040.schema.asset.sql | 4 +- Open-ILS/src/sql/Pg/120.floating_groups.sql | 51 ++++++ Open-ILS/src/sql/Pg/800.fkeys.sql | 3 + Open-ILS/src/sql/Pg/950.data.seed-values.sql | 7 +- Open-ILS/src/sql/Pg/sql_file_manifest | 1 + .../src/sql/Pg/upgrade/XXXX.floating_groups.sql | 82 +++++++++ .../conify/global/config/floating_groups.tt2 | 59 ++++++ .../conify/global/config/floating_groups.js | 197 +++++++++++++++++++++ Open-ILS/web/opac/locale/en-US/lang.dtd | 3 + .../staff_client/chrome/content/OpenILS/data.js | 21 +++ .../staff_client/chrome/content/main/constants.js | 1 + .../xul/staff_client/chrome/content/main/menu.js | 4 + .../chrome/content/main/menu_frame_menus.xul | 4 + .../chrome/locale/en-US/offline.properties | 1 + .../xul/staff_client/server/cat/copy_editor.js | 4 +- .../server/circ/alternate_copy_summary.js | 2 +- Open-ILS/xul/staff_client/server/circ/checkin.js | 15 ++ .../staff_client/server/circ/checkin_overlay.xul | 4 + Open-ILS/xul/staff_client/server/circ/util.js | 10 +- .../server/locale/en-US/cat.properties | 3 +- Open-ILS/xul/staff_client/server/skin/circ.css | 1 + docs/floating_groups.txt | 122 +++++++++++++ 25 files changed, 651 insertions(+), 20 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/120.floating_groups.sql create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.floating_groups.sql create mode 100644 Open-ILS/src/templates/conify/global/config/floating_groups.tt2 create mode 100644 Open-ILS/web/js/ui/default/conify/global/config/floating_groups.js create mode 100644 docs/floating_groups.txt diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 935e8f5661..cbb7c18689 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -4519,7 +4519,7 @@ SELECT usr, - + @@ -4546,6 +4546,7 @@ SELECT usr, + @@ -5908,7 +5909,7 @@ SELECT usr, - + @@ -5942,6 +5943,7 @@ SELECT usr, + @@ -5984,7 +5986,7 @@ SELECT usr, - + @@ -5995,6 +5997,7 @@ SELECT usr, + @@ -10202,7 +10205,47 @@ SELECT usr, - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm index 5c2a754a9b..6386ac0618 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm @@ -975,7 +975,7 @@ sub copy_details { { flesh => 2, flesh_fields => { - acp => ['call_number','parts','peer_record_maps'], + acp => ['call_number','parts','peer_record_maps','floating'], acn => ['record','prefix','suffix','label_class'] } } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index 273978eb96..059da69822 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -32,7 +32,7 @@ sub determine_booking_status { my $MK_ENV_FLESH = { flesh => 2, - flesh_fields => {acp => ['call_number','parts'], acn => ['record']} + flesh_fields => {acp => ['call_number','parts','floating'], acn => ['record']} }; sub initialize { @@ -543,6 +543,7 @@ my @AUTOLOAD_FIELDS = qw/ limit_groups override_args checkout_is_for_hold + manual_float /; @@ -2702,8 +2703,20 @@ sub do_checkin { } else { # copy needs to transit "home", or stick here if it's a floating copy - - if ($U->is_true( $self->copy->floating ) && !$self->remote_hold) { # copy is floating, stick here + my $can_float = 0; + if ($self->copy->floating && ($self->manual_float || !$U->is_true($self->copy->floating->manual)) && !$self->remote_hold) { # copy is potentially floating? + my $res = $self->editor->json_query( + { from => [ + 'evergreen.can_float', + $self->copy->floating->id, + $self->copy->circ_lib, + $self->circ_lib + ] + } + ); + $can_float = $U->is_true($res->[0]->{'evergreen.can_float'}) if $res; + } + if ($can_float) { # Yep, floating, stick here $self->checkin_changed(1); $self->copy->circ_lib( $self->circ_lib ); $self->update_copy; diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index ddeaaf9de3..7b1ac4e71d 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -96,7 +96,7 @@ CREATE TABLE asset.copy ( alert_message TEXT, opac_visible BOOL NOT NULL DEFAULT TRUE, deleted BOOL NOT NULL DEFAULT FALSE, - floating BOOL NOT NULL DEFAULT FALSE, + floating INT, dummy_isbn TEXT, status_changed_time TIMESTAMP WITH TIME ZONE, active_date TIMESTAMP WITH TIME ZONE, @@ -522,7 +522,7 @@ CREATE TABLE asset.copy_template ( circ_as_type TEXT, alert_message TEXT, opac_visible BOOL, - floating BOOL, + floating INT, mint_condition BOOL ); diff --git a/Open-ILS/src/sql/Pg/120.floating_groups.sql b/Open-ILS/src/sql/Pg/120.floating_groups.sql new file mode 100644 index 0000000000..cd04d91740 --- /dev/null +++ b/Open-ILS/src/sql/Pg/120.floating_groups.sql @@ -0,0 +1,51 @@ +-- Floating Groups +BEGIN; + +CREATE TABLE config.floating_group ( + id SERIAL PRIMARY KEY, + name TEXT UNIQUE NOT NULL, + manual BOOL NOT NULL DEFAULT FALSE + ); + +CREATE TABLE config.floating_group_member ( + id SERIAL PRIMARY KEY, + floating_group INT NOT NULL REFERENCES config.floating_group (id), + org_unit INT NOT NULL REFERENCES actor.org_unit (id), + stop_depth INT NOT NULL DEFAULT 0, + max_depth INT, + exclude BOOL NOT NULL DEFAULT FALSE + ); + +CREATE OR REPLACE FUNCTION evergreen.can_float( copy_floating_group integer, from_ou integer, to_ou integer ) RETURNS BOOL AS $f$ +DECLARE + float_member config.floating_group_member%ROWTYPE; + shared_ou_depth INT; + to_ou_depth INT; +BEGIN + -- Grab the shared OU depth. If this is less than the stop depth later we ignore the entry. + SELECT INTO shared_ou_depth max(depth) FROM actor.org_unit_common_ancestors( from_ou, to_ou ) aou JOIN actor.org_unit_type aout ON aou.ou_type = aout.id; + -- Grab the to ou depth. If this is greater than max depth we ignore the entry. + SELECT INTO to_ou_depth depth FROM actor.org_unit aou JOIN actor.org_unit_type aout ON aou.ou_type = aout.id WHERE aou.id = to_ou; + -- Grab float members that apply. We don't care what we get beyond wanting excluded ones first. + SELECT INTO float_member * + FROM + config.floating_group_member cfgm + JOIN actor.org_unit aou ON cfgm.org_unit = aou.id + JOIN actor.org_unit_type aout ON aou.ou_type = aout.id + WHERE + cfgm.floating_group = copy_floating_group + AND to_ou IN (SELECT id FROM actor.org_unit_descendants(aou.id)) + AND cfgm.stop_depth <= shared_ou_depth + AND (cfgm.max_depth IS NULL OR to_ou_depth <= max_depth) + ORDER BY + exclude DESC; + -- If we found something then we want to return the opposite of the exclude flag + IF FOUND THEN + RETURN NOT float_member.exclude; + END IF; + -- Otherwise no floating. + RETURN false; +END; +$f$ LANGUAGE PLPGSQL; + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/800.fkeys.sql b/Open-ILS/src/sql/Pg/800.fkeys.sql index 53be2e1a9e..a3a89b951a 100644 --- a/Open-ILS/src/sql/Pg/800.fkeys.sql +++ b/Open-ILS/src/sql/Pg/800.fkeys.sql @@ -126,4 +126,7 @@ ALTER TABLE config.z3950_source ADD CONSTRAINT use_perm_fkey FOREIGN KEY (use_pe ALTER TABLE config.org_unit_setting_type_log ADD CONSTRAINT config_org_unit_setting_type_log_fkey FOREIGN KEY (org) REFERENCES actor.org_unit (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE asset.copy ADD CONSTRAINT asset_copy_floating_fkey FOREIGN KEY (floating) REFERENCES config.floating_group (id) DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE asset.copy_template ADD CONSTRAINT asset_copy_template_floating_fkey FOREIGN KEY (floating) REFERENCES config.floating_group (id) DEFERRABLE INITIALLY DEFERRED; + COMMIT; 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 90a577441c..875421b34e 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -1573,10 +1573,11 @@ INSERT INTO permission.perm_list ( id, code, description ) VALUES ( 541, 'ADMIN_TOOLBAR_FOR_WORKSTATION', oils_i18n_gettext( 541, 'Allows a user to create, edit, and delete custom toolbars for workstations', 'ppl', 'description')), ( 542, 'ADMIN_TOOLBAR_FOR_USER', oils_i18n_gettext( 542, - 'Allows a user to create, edit, and delete custom toolbars for users', 'ppl', 'description')) + 'Allows a user to create, edit, and delete custom toolbars for users', 'ppl', 'description')), + ( 543, 'ADMIN_FLOAT_GROUPS', oils_i18n_gettext( 543, + 'Allows administration of floating groups', 'ppl', 'description' )) ; - SELECT SETVAL('permission.perm_list_id_seq'::TEXT, 1000); INSERT INTO permission.grp_tree (id, name, parent, description, perm_interval, usergroup, application_perm) VALUES @@ -12263,3 +12264,5 @@ VALUES ( ); +INSERT INTO config.floating_group(name) VALUES ('Everywhere'); +INSERT INTO config.floating_group_member(floating_group, org_unit) VALUES (1, 1); diff --git a/Open-ILS/src/sql/Pg/sql_file_manifest b/Open-ILS/src/sql/Pg/sql_file_manifest index 70d7dcda96..c3d6abc1b4 100644 --- a/Open-ILS/src/sql/Pg/sql_file_manifest +++ b/Open-ILS/src/sql/Pg/sql_file_manifest @@ -31,6 +31,7 @@ FTS_CONFIG_FILE 099.matrix_weights.sql 100.circ_matrix.sql 110.hold_matrix.sql +120.floating_groups.sql 210.schema.serials.sql 200.schema.acq.sql diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.floating_groups.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.floating_groups.sql new file mode 100644 index 0000000000..4842580477 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.floating_groups.sql @@ -0,0 +1,82 @@ +CREATE TABLE config.floating_group ( + id SERIAL PRIMARY KEY, + name TEXT UNIQUE NOT NULL, + manual BOOL NOT NULL DEFAULT FALSE + ); + +CREATE TABLE config.floating_group_member ( + id SERIAL PRIMARY KEY, + floating_group INT NOT NULL REFERENCES config.floating_group (id), + org_unit INT NOT NULL REFERENCES actor.org_unit (id), + stop_depth INT NOT NULL DEFAULT 0, + max_depth INT, + exclude BOOL NOT NULL DEFAULT FALSE + ); + +CREATE OR REPLACE FUNCTION evergreen.can_float( copy_floating_group integer, from_ou integer, to_ou integer ) RETURNS BOOL AS $f$ +DECLARE + float_member config.floating_group_member%ROWTYPE; + shared_ou_depth INT; + to_ou_depth INT; +BEGIN + -- Grab the shared OU depth. If this is less than the stop depth later we ignore the entry. + SELECT INTO shared_ou_depth max(depth) FROM actor.org_unit_common_ancestors( from_ou, to_ou ) aou JOIN actor.org_unit_type aout ON aou.ou_type = aout.id; + -- Grab the to ou depth. If this is greater than max depth we ignore the entry. + SELECT INTO to_ou_depth depth FROM actor.org_unit aou JOIN actor.org_unit_type aout ON aou.ou_type = aout.id WHERE aou.id = to_ou; + -- Grab float members that apply. We don't care what we get beyond wanting excluded ones first. + SELECT INTO float_member * + FROM + config.floating_group_member cfgm + JOIN actor.org_unit aou ON cfgm.org_unit = aou.id + JOIN actor.org_unit_type aout ON aou.ou_type = aout.id + WHERE + cfgm.floating_group = copy_floating_group + AND to_ou IN (SELECT id FROM actor.org_unit_descendants(aou.id)) + AND cfgm.stop_depth <= shared_ou_depth + AND (cfgm.max_depth IS NULL OR to_ou_depth <= max_depth) + ORDER BY + exclude DESC; + -- If we found something then we want to return the opposite of the exclude flag + IF FOUND THEN + RETURN NOT float_member.exclude; + END IF; + -- Otherwise no floating. + RETURN false; +END; +$f$ LANGUAGE PLPGSQL; + +INSERT INTO config.floating_group(name) VALUES ('Everywhere'); +INSERT INTO config.floating_group_member(floating_group, org_unit) VALUES (1, 1); + +-- We need to drop these before we can update asset.copy +DROP VIEW auditor.asset_copy_lifecycle; +DROP VIEW auditor.serial_unit_lifecycle; + +-- Update the appropriate auditor tables +ALTER TABLE auditor.asset_copy_history + ALTER COLUMN floating DROP DEFAULT, + ALTER COLUMN floating DROP NOT NULL, + ALTER COLUMN floating TYPE int USING CASE WHEN floating THEN 1 ELSE NULL END; +ALTER TABLE auditor.serial_unit_history + ALTER COLUMN floating DROP DEFAULT, + ALTER COLUMN floating DROP NOT NULL, + ALTER COLUMN floating TYPE int USING CASE WHEN floating THEN 1 ELSE NULL END; + +-- Update asset.copy itself (does not appear to trigger update triggers!) +ALTER TABLE asset.copy + ALTER COLUMN floating DROP DEFAULT, + ALTER COLUMN floating DROP NOT NULL, + ALTER COLUMN floating TYPE int USING CASE WHEN floating THEN 1 ELSE NULL END; + +ALTER TABLE asset.copy ADD CONSTRAINT asset_copy_floating_fkey FOREIGN KEY (floating) REFERENCES config.floating_group (id) DEFERRABLE INITIALLY DEFERRED; + +-- Update asset.copy_template too +ALTER TABLE asset.copy_template + ALTER COLUMN floating TYPE int USING CASE WHEN floating THEN 1 ELSE NULL END; +ALTER TABLE asset.copy_template ADD CONSTRAINT asset_copy_template_floating_fkey FOREIGN KEY (floating) REFERENCES config.floating_group (id) DEFERRABLE INITIALLY DEFERRED; + +INSERT INTO permission.perm_list( code, description) VALUES +('ADMIN_FLOAT_GROUPS', 'Allows administration of floating groups'); + +-- And lets just update all auditors to re-create those lifecycle views +SELECT auditor.update_auditors(); diff --git a/Open-ILS/src/templates/conify/global/config/floating_groups.tt2 b/Open-ILS/src/templates/conify/global/config/floating_groups.tt2 new file mode 100644 index 0000000000..035f647cc6 --- /dev/null +++ b/Open-ILS/src/templates/conify/global/config/floating_groups.tt2 @@ -0,0 +1,59 @@ +[% ctx.page_title = 'Floating Groups Configuration' %] +[% WRAPPER base.tt2 %] + +
+
Floating Groups Configuration
+
+
+
+ +
+
+ + + + + + +[% END %] + diff --git a/Open-ILS/web/js/ui/default/conify/global/config/floating_groups.js b/Open-ILS/web/js/ui/default/conify/global/config/floating_groups.js new file mode 100644 index 0000000000..666670ea91 --- /dev/null +++ b/Open-ILS/web/js/ui/default/conify/global/config/floating_groups.js @@ -0,0 +1,197 @@ +dojo.require('dijit.layout.ContentPane'); +dojo.require('dijit.form.Button'); +dojo.require('openils.widget.AutoGrid'); +dojo.require('openils.widget.AutoFieldWidget'); +dojo.require('openils.PermaCrud'); +dojo.require('openils.widget.ProgressDialog'); + +var groupMemberEditor = null; +var groupMemberEntryCache = []; +var orgUnitCache = {}; + +function load(){ + cfgGrid.loadAll({order_by:{cfg:'name'}}); + cfgGrid.onEditPane = buildEditPaneAdditions; + cfgGrid.onPostUpdate = updateLinked; + cfgGrid.onPostCreate = updateLinked; + groupMemberEditor = dojo.byId('group-member-editor').parentNode.removeChild(dojo.byId('group-member-editor')); + + // Cache org unit info for later display + var pcrud = new openils.PermaCrud(); + var temp = pcrud.retrieveAll('aou'); + dojo.forEach(temp, function(g) { orgUnitCache[g.id()] = g; } ); +} + +function byName(name, ctxt) { + return dojo.query('[name=' + name + ']', ctxt)[0]; +} + +function buildEditPaneAdditions(editPane) { + groupMemberEntryCache = []; + var tr = document.createElement('tr'); + var td = document.createElement('td'); + td.setAttribute('colspan','2'); + // Explanation.... + // editPane.domNode.lastChild = Table + // .lastChild = Table Body + // .lastChild = Table Row containing Action Buttons + editPane.domNode.lastChild.lastChild.insertBefore(tr, editPane.domNode.lastChild.lastChild.lastChild); + tr.appendChild(td); + curGroupMemberEditor = groupMemberEditor.cloneNode(true); + td.appendChild(curGroupMemberEditor); + var groupMemberTmpl = byName('group-member-entry-tbody', curGroupMemberEditor).removeChild(byName('group-member-entry-row', curGroupMemberEditor)); + + var selector = new openils.widget.AutoFieldWidget({ + fmClass : 'cfgm', + fmField : 'org_unit', + parentNode : byName('org-unit-selector', curGroupMemberEditor) + }); + selector.build(); + + function addMember(ounit) { + var row = groupMemberTmpl.cloneNode(true); + row.setAttribute('org_unit', ounit); + byName('org-unit', row).innerHTML = orgUnitCache[ounit].shortname(); + byName('remove-group-member', row).onclick = function() { + byName('group-member-entry-tbody', cfgGrid.editPane.domNode).removeChild(row); + } + byName('group-member-entry-tbody', editPane.domNode).appendChild(row); + } + + byName('add-group-member', editPane.domNode).onclick = function() { + addMember(selector.widget.attr('value')); + } + + // On edit we need to load existing entries. + // On create, not so much. + if(!editPane.fmObject) return; + + if(editPane.mode == 'update') { + var pcrud = new openils.PermaCrud(); + groupMemberEntryCache = pcrud.search('cfgm', {floating_group: editPane.fmObject.id()}); + dojo.forEach(groupMemberEntryCache, function(g) { addGroupMember(groupMemberTmpl, g); } ); + } +} + +function addGroupMember(tmpl, group_member_entry) { + var row = tmpl.cloneNode(true); + row.setAttribute('group_member', group_member_entry.id()); + byName('org-unit', row).innerHTML = orgUnitCache[group_member_entry.org_unit()].shortname(); + byName('group-member-stop-depth', row).value = group_member_entry.stop_depth(); + if(group_member_entry.max_depth() != null) { + byName('group-member-max-depth', row).value = group_member_entry.max_depth(); + } + if(group_member_entry.exclude() == 't') { + byName('group-member-exclude', row).setAttribute('checked', 'true'); + } + byName('remove-group-member', row).onclick = function() { + byName('group-member-entry-tbody', cfgGrid.editPane.domNode).removeChild(row); + } + byName('group-member-entry-tbody', cfgGrid.editPane.domNode).appendChild(row); +} + +function updateLinked(fmObject, rowindex) { + var id = null; + if(rowindex != undefined && this.editPane && this.editPane.fmObject) { + // Edit, grab existing ID + id = this.editPane.fmObject.id(); + } else if(fmObject.id) { + // Create, grab new ID + id = fmObject.id(); + } + // If we don't have an ID, drop out. + if(id == null) return; + var pcrud = new openils.PermaCrud(); + progressDialog.show(true); + + var add = []; + var remove = []; + var update = []; + + var group_members = []; + dojo.query('[name=group-member-entry-row]', this.editPane.domNode).forEach( + function(row) { + var member_id = row.getAttribute('group_member'); + var cached; + if (member_id) + cached = groupMemberEntryCache.filter(function(i) { return (i.id() == member_id); })[0]; + var stop_depth = byName('group-member-stop-depth', row).value; + var max_depth = byName('group-member-max-depth', row).value; + if (max_depth === '') max_depth = null; + var exclude = byName('group-member-exclude', row).checked; + if (cached) { + group_members.push(member_id); + if((stop_depth != cached.stop_depth()) || (max_depth !== cached.max_depth()) || (exclude != (cached.exclude() == 't'))) { + cached.stop_depth(stop_depth); + cached.max_depth(max_depth); + cached.exclude(exclude ? 't' : 'f'); + cached.ischanged(true); + update.push(cached); + } + } else { + var entry = new fieldmapper.cfgm(); + var org_unit = row.getAttribute('org_unit'); + entry.isnew(true); + entry.floating_group(id); + entry.org_unit(org_unit); + entry.stop_depth(stop_depth); + entry.max_depth(max_depth); + entry.exclude(exclude ? 't' : 'f'); + add.push(entry); + } + } + ); + dojo.forEach(groupMemberEntryCache, function(eMember) { + if(!group_members.filter(function(i) { return (i == eMember.id()); })[0]) { + eMember.isdeleted(true); + remove.push(eMember); + } + } + ); + + function updateEntries() { + pcrud.update(update, { + oncomplete : function () { + progressDialog.hide(); + } + }); + } + + function removeEntries() { + pcrud.eliminate(remove, { + oncomplete : function () { + if(update.length) { + updateEntries(); + } else { + progressDialog.hide(); + } + } + }); + } + + function addEntries() { + pcrud.create(add, { + oncomplete : function () { + if(remove.length) { + removeEntries(); + } else if (update.length) { + updateEntries(); + } else { + progressDialog.hide(); + } + } + }); + } + + if(add.length) + addEntries(); + else if (remove.length) + removeEntries(); + else if (update.length) + updateEntries(); + else + progressDialog.hide(); +} + +openils.Util.addOnLoad(load); + diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 45e88908e7..5706a112cf 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -785,6 +785,7 @@ + @@ -2313,6 +2314,8 @@ + + diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js index fc17229959..8c683476aa 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js @@ -646,6 +646,27 @@ OpenILS.data.prototype = { this.chain.push( function() { var f = gen_fm_retrieval_func( + 'cfg', + [ + api.FM_CFG_RETRIEVE_VIA_PCRUD.app, + api.FM_CFG_RETRIEVE_VIA_PCRUD.method, + [ obj.session.key, {"id":{"!=":null}}, {"order_by":{"cfg":"id"}} ], + false + ] + ); + try { + f(); + } catch(E) { + var error = 'Error: ' + js2JSON(E); + obj.error.sdump('D_ERROR',error); + throw(E); + } + } + ); + + this.chain.push( + function() { + var f = gen_fm_retrieval_func( 'csp', [ api.FM_CSP_PCRUD_SEARCH.app, diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 8ec44a8fe3..902bf51272 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -260,6 +260,7 @@ var api = { 'FM_CNAL_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.net_access_level.retrieve.all', 'secure' : false }, 'FM_CNCT_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.non_cat_types.retrieve.all', 'secure' : false }, 'FM_CRAHP_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.config.rules.age_hold_protect.retrieve.all', 'secure' : false }, + 'FM_CFG_RETRIEVE_VIA_PCRUD' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.cfg.atomic', 'secure' : false }, 'FM_CSC_RETRIEVE_VIA_PCRUD' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.csc.atomic' }, 'FM_CSP_PCRUD_SEARCH' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.csp.atomic', 'secure' : false }, 'FM_CST_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.standings.retrieve', 'secure' : false }, diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index cb8c9a095d..b2532106cd 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -797,6 +797,10 @@ main.menu.prototype = { ['oncommand'], function(event) { open_eg_web_page('conify/global/actor/org_unit_custom_tree', null, event); } ], + 'cmd_server_admin_floating_groups' : [ + ['oncommand'], + function(event) { open_eg_web_page('conify/global/config/floating_groups', 'menu.cmd_server_admin_floating_groups.tab', event); } + ], 'cmd_local_admin_external_text_editor' : [ ['oncommand'], function() { diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul index 43140caecf..d482ca84ba 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul @@ -320,6 +320,9 @@ + @@ -612,6 +615,7 @@ + diff --git a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties index 2405b95450..10607b52e2 100644 --- a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties +++ b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties @@ -331,3 +331,4 @@ util.hide_elements.update_setting.update_success=Successfully updated the settin util.hide_elements.update_setting.delete_success=Successfully deleted the setting. util.hide_elements.update_setting.failure=Setting not changed. util.hide_elements.missing_permission=Missing permission %1$s +menu.cmd_server_admin_floating_groups.tab=Floating Groups diff --git a/Open-ILS/xul/staff_client/server/cat/copy_editor.js b/Open-ILS/xul/staff_client/server/cat/copy_editor.js index 1e826c20c7..67f797106f 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.js @@ -1070,8 +1070,8 @@ g.panes_and_field_names = { [ $('catStrings').getString('staff.cat.copy_editor.field.floating.label'), { - render: 'fm.floating() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( get_bool( fm.floating() ) ? $("catStrings").getString("staff.cat.copy_editor.field.floating.yes_or_true") : $("catStrings").getString("staff.cat.copy_editor.field.floating.no_or_false") )', - input: 'c = function(v){ g.apply("floating",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.floating.yes_or_true"), get_db_true() ], [ $("catStrings").getString("staff.cat.copy_editor.field.floating.no_or_false"), get_db_false() ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);', + render: 'fm.floating() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( typeof fm.floating() == "object" ? fm.floating().name() : g.data.hash.cfg[ fm.floating() ].name() )', + input: 'c = function(v){ g.apply("floating",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.remove_floating"), "" ] ].concat( util.functional.map_list( g.data.list.cfg, function(obj) { return [ obj.name(), obj.id() ]; }).sort() ) ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);', } ], [ diff --git a/Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js b/Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js index 29a7dd80cb..0aa656f7ee 100644 --- a/Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js +++ b/Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js @@ -202,7 +202,7 @@ function load_item() { set("circ_modifier",""); } set("circulate", get_localized_bool( details.copy.circulate() )); - set("floating", get_localized_bool( details.copy.floating() )); + set("floating", (details.copy.floating() && typeof details.copy.floating() == 'object' ? details.copy.floating().name() : get_localized_bool( details.copy.floating() ))); set("copy_number", details.copy.copy_number()); set("copy_create_date", util.date.formatted_date( details.copy.create_date(), '%{localized}' )); set("copy_active_date", util.date.formatted_date( details.copy.active_date(), '%{localized}' )); diff --git a/Open-ILS/xul/staff_client/server/circ/checkin.js b/Open-ILS/xul/staff_client/server/circ/checkin.js index d628861ea3..dfdcef9b80 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkin.js +++ b/Open-ILS/xul/staff_client/server/circ/checkin.js @@ -460,6 +460,18 @@ circ.checkin.prototype = { document.getElementById('checkin_barcode_entry_textbox').focus(); return true; + } ], + 'cmd_checkin_manual_float' : [ ['command'], function(ev) { + dump('in cmd_checkin_manual_float\n'); + var bg = document.getElementById('background'); + var cb = document.getElementById('checkin_manual_float'); + var ind = document.getElementById('checkin_manual_float_indicator'); + var cn = 'checkin_screen_checkin_manual_float'; + if (cb.getAttribute('checked') == 'true') { addCSSClass(bg,cn); } else { removeCSSClass(bg,cn); } + ind.hidden = cb.getAttribute('checked') != 'true'; + document.getElementById('checkin_barcode_entry_textbox').focus(); + return true; + } ] } } @@ -635,6 +647,9 @@ circ.checkin.prototype = { var hold_as_transit = document.getElementById('checkin_local_hold_as_transit'); if (hold_as_transit) hold_as_transit = hold_as_transit.getAttribute('checked') == 'true'; if (hold_as_transit) params.hold_as_transit = 1; + var manual_float = document.getElementById('checkin_manual_float'); + if (manual_float) manual_float = manual_float.getAttribute('checked') == 'true'; + if (manual_float) params.manual_float = 1; circ.util.checkin_via_barcode( ses(), params, diff --git a/Open-ILS/xul/staff_client/server/circ/checkin_overlay.xul b/Open-ILS/xul/staff_client/server/circ/checkin_overlay.xul index 1dc7896812..797e9a37e4 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkin_overlay.xul +++ b/Open-ILS/xul/staff_client/server/circ/checkin_overlay.xul @@ -38,6 +38,7 @@ + @@ -81,6 +82,7 @@ + @@ -188,6 +190,8 @@ label="&staff.circ.checkin_overlay.checkin_auto_retarget_all.label;" accesskey="&staff.circ.checkin_overlay.checkin_auto_retarget_all.accesskey;"/> + diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index 8c6cb75b55..38faaf07af 100644 --- a/Open-ILS/xul/staff_client/server/circ/util.js +++ b/Open-ILS/xul/staff_client/server/circ/util.js @@ -971,10 +971,14 @@ circ.util.columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { - if (get_bool( my.acp.floating() )) { - return document.getElementById('circStrings').getString('staff.circ.utils.yes'); + if (my.acp.floating() && typeof my.acp.floating() == 'object') { + return my.acp.floating().name(); } else { - return document.getElementById('circStrings').getString('staff.circ.utils.no'); + if (get_bool( my.acp.floating() )) { + return document.getElementById('circStrings').getString('staff.circ.utils.yes'); + } else { + return document.getElementById('circStrings').getString('staff.circ.utils.no'); + } } }, 'persist' : 'hidden width ordinal' diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties index f42ec10cd3..ef4772d8aa 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/cat.properties @@ -165,6 +165,7 @@ staff.cat.copy_editor.populate_stat_cat.error=Error populating statistical categ staff.cat.copy_editor.remove_stat_cat_entry= staff.cat.copy_editor.remove_age_based_hold_protection= staff.cat.copy_editor.remove_circulate_as_type= +staff.cat.copy_editor.remove_floating= staff.cat.copy_editor.field.unset_or_null= staff.cat.copy_editor.field.owning_library.label=Owning Lib : Call Number staff.cat.copy_editor.field.creator.label=Creator @@ -183,8 +184,6 @@ staff.cat.copy_editor.field.holdable.label=Holdable? staff.cat.copy_editor.field.holdable.yes_or_true=Yes staff.cat.copy_editor.field.holdable.no_or_false=No staff.cat.copy_editor.field.floating.label=Floating? -staff.cat.copy_editor.field.floating.yes_or_true=Yes -staff.cat.copy_editor.field.floating.no_or_false=No staff.cat.copy_editor.field.age_based_hold_protection.label=Age-based Hold Protection staff.cat.copy_editor.field.loan_duration.label=Loan Duration staff.cat.copy_editor.field.loan_duration.short=Short diff --git a/Open-ILS/xul/staff_client/server/skin/circ.css b/Open-ILS/xul/staff_client/server/skin/circ.css index 347251504d..ef98d990d9 100644 --- a/Open-ILS/xul/staff_client/server/skin/circ.css +++ b/Open-ILS/xul/staff_client/server/skin/circ.css @@ -59,6 +59,7 @@ treechildren::-moz-tree-row(backdate_failed,selected) { #checkin_auto_retarget_indicator { background-color: -moz-dialog; color: -moz-dialog-text; font-size: large; font-weight: bold; } #checkin_auto_retarget_all_indicator { background-color: -moz-dialog; color: -moz-dialog-text; font-size: large; font-weight: bold; } #checkin_local_hold_as_transit_indicator { background-color: -moz-dialog; color: -moz-dialog-text; font-size: large; font-weight: bold; } +#checkin_manual_float_indicator { background-color: -moz-dialog; color: -moz-dialog-text; font-size: large; font-weight: bold; } .big_emphasis1 { font-weight: bold; font-size: x-large; } .big_emphasis2 { font-weight: bold; font-size: large; } diff --git a/docs/floating_groups.txt b/docs/floating_groups.txt new file mode 100644 index 0000000000..a484c5e6fd --- /dev/null +++ b/docs/floating_groups.txt @@ -0,0 +1,122 @@ +Floating Groups +=============== +Thomas Berezansky +:Date: 2012-04-22 + +Before floating groups copies could float or not. If they floated then they floated everywhere, with no restrictions. + +After floating groups where a copy will float is defined by what group it has been assigned to. + +== Floating Groups + +Each floating group comes with a name and a manual flag, plus zero or more group members. The name is used solely for selection and display purposes. + +The manual flag dictates whether or not the "Manual Floating Active" checkin modifier needs to be active for a copy to float. This allows for greater control over when items float. It also prevents automated checkins via SIP2 from triggering floats. + +== Floating Group Members + +Each member of a floating group references an org unit and has a stop depth, an optional max depth, and an exclude flag. + +=== Org Unit + +The org unit and all descendants are included, unless max depth is set, in which case the tree is cut off at the max depth. + +=== Stop Depth + +The stop depth is the highest point from the current copy circ library to the checkin library for the item that will be traversed. If the item has to go higher than the stop depth on the tree the member rule in question is ignored. + +=== Max Depth + +As mentioned with the org unit, the max depth is the furthest down on the tree from the org unit that gets included. This is based on the entire tree, not just off of the org unit. So in the default tree a max depth of 1 will stop at the system level no matter if org unit is set to CONS or SYS1. + +=== Exclude + +Exclude, if set, causes floating to not happen for the member. Excludes always take priority, so you can remove an org unit from floating without having to worry about other rules overriding it. + +== Examples + +=== Float Everywhere + +This is a default floating rule to emulate the previous floating behavior for new installs and upgrades. + +One member: + +* Org Unit: CONS +* Stop Depth: 0 +* Max Depth: Unset +* Exclude: Off + +=== Float Within System + +This would permit a copy to float anywhere within a system, but would return to the system if it was returned elsewhere. + +One member: + +* Org Unit: CONS +* Stop Depth: 1 +* Max Depth: Unset +* Exclude: Off + +=== Float To All Branches + +This would permit a copy to float to any branch, but not to sublibraries or bookmobiles. + +One member: + +* Org Unit: CONS +* Stop Depth: 0 +* Max Depth: 2 +* Exclude: Off + +=== Float To All Branches Within System + +This would permit a copy to float to any branch in a system, but not to sublibraries or bookmobiles, and returning to the system if returned elsewhere. + +One member: + +* Org Unit: CONS +* Stop Depth: 1 +* Max Depth: 2 +* Exclude: Off + +=== Float Between BR1 and BR3 + +This would permit a copy to float between BR1 and BR3 specifically, excluding sublibraries and bookmobiles. + +It would consist of two members, identical other than the org unit: + +* Org Unit: BR1 / BR3 +* Stop Depth: 0 +* Max Depth: 2 +* Exclude: Off + +=== Float Everywhere Except BM1 + +This would allow an item to float anywhere except for BM1. It accomplishes this with two members. + +The first includes all org units, just like Float Everywhere: + +* Org Unit: CONS +* Stop Depth: 0 +* Max Depth: Unset +* Exclude: Off + +The second excludes BM1: + +* Org Unit: BM1 +* Stop Depth: 0 +* Max Depth: Unset +* Exclude: On + +That works because excludes are applied first. + +=== Float into, but not out of, BR2 + +This would allow an item to float into BR2, but once there it would never leave. Why you would want to allow items to float to but not from a single library I dunno, but here it is. This takes advantage of the fact that the rules say where we can float *to*, but outside of stop depth don't care where we are floating *from*. + +One member: + +* Org Unit: BR2 +* Stop Depth: 0 +* Max Depth: Unset +* Exclude: Off -- 2.11.0