From: Lebbeous Fogle-Weekley Date: Thu, 14 Mar 2013 17:58:47 +0000 (-0400) Subject: Org unit prox adjustment tweaks X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bd8e8002cdb6c0c9ee15f88120ef021e9bf8f3aa;p=contrib%2FConifer.git Org unit prox adjustment tweaks 1) UI change - pre-select highest OU where user can edit There's a dropdown in the org unit proximity adjustment interface that affects the scope of what you can see in the table below. Before, that dropdown would be set to the user's home UO (say, BR1 in the example org tree). But you might have the permission to make changes everywhere, so you add a proximity adjustment that affects BR3 in some way. As soon as you'd refresh the interface, your new proximity adjustment would not be visible, because your scope selector would default to BR1. So now the dropdown defaults to the first context where you have the permission, which in all but eccentric setups should be the highest OU (and therefore broadest scope) where you have the permission. This could also improve other interfaces in the future. Anything that invokes openils.User.buildPermOrgSelector() can pass -1 as the third parameter to get the new behavior. 2) Change UNIQUE index at DB layer. This prevents the creation of rows that would give the hold targeter conflicting directives. Signed-off-by: Lebbeous Fogle-Weekley Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/sql/Pg/005.schema.actors.sql b/Open-ILS/src/sql/Pg/005.schema.actors.sql index c92ede4fdc..8d63430acf 100644 --- a/Open-ILS/src/sql/Pg/005.schema.actors.sql +++ b/Open-ILS/src/sql/Pg/005.schema.actors.sql @@ -393,7 +393,15 @@ CREATE TABLE actor.org_unit_proximity_adjustment ( circ_mod TEXT, -- REFERENCES config.circ_modifier (code), CONSTRAINT prox_adj_criterium CHECK (COALESCE(item_circ_lib::TEXT,item_owning_lib::TEXT,copy_location::TEXT,hold_pickup_lib::TEXT,hold_request_lib::TEXT,circ_mod) IS NOT NULL) ); -CREATE UNIQUE INDEX prox_adj_once_idx ON actor.org_unit_proximity_adjustment (item_circ_lib,item_owning_lib,copy_location,hold_pickup_lib,hold_request_lib,circ_mod); +CREATE UNIQUE INDEX prox_adj_once_idx ON actor.org_unit_proximity_adjustment ( + COALESCE(item_circ_lib, -1), + COALESCE(item_owning_lib, -1), + COALESCE(copy_location, -1), + COALESCE(hold_pickup_lib, -1), + COALESCE(hold_request_lib, -1), + COALESCE(circ_mod, ''), + pos +); CREATE INDEX prox_adj_circ_lib_idx ON actor.org_unit_proximity_adjustment (item_circ_lib); CREATE INDEX prox_adj_owning_lib_idx ON actor.org_unit_proximity_adjustment (item_owning_lib); CREATE INDEX prox_adj_copy_location_idx ON actor.org_unit_proximity_adjustment (copy_location); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.aoupa-unique-constraint.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.aoupa-unique-constraint.sql new file mode 100644 index 0000000000..1f5221d2ca --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.aoupa-unique-constraint.sql @@ -0,0 +1,17 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +DROP INDEX actor.prox_adj_once_idx; + +CREATE UNIQUE INDEX prox_adj_once_idx ON actor.org_unit_proximity_adjustment ( + COALESCE(item_circ_lib, -1), + COALESCE(item_owning_lib, -1), + COALESCE(copy_location, -1), + COALESCE(hold_pickup_lib, -1), + COALESCE(hold_request_lib, -1), + COALESCE(circ_mod, ''), + pos +); + +COMMIT; diff --git a/Open-ILS/src/templates/conify/global/config/org_unit_proximity_adjustment.tt2 b/Open-ILS/src/templates/conify/global/config/org_unit_proximity_adjustment.tt2 index 6a0c67b178..9f6f32f69c 100644 --- a/Open-ILS/src/templates/conify/global/config/org_unit_proximity_adjustment.tt2 +++ b/Open-ILS/src/templates/conify/global/config/org_unit_proximity_adjustment.tt2 @@ -72,7 +72,7 @@ new openils.User().buildPermOrgSelector( "ADMIN_PROXIMITY_ADJUSTMENT", context_org_selector, - null, + -1, /* high OU where permission held */ function() { context_org_selector.onChange = reload_grid_from_ou_selector; diff --git a/Open-ILS/web/js/dojo/openils/User.js b/Open-ILS/web/js/dojo/openils/User.js index 60e5f91721..ef17bf8a29 100644 --- a/Open-ILS/web/js/dojo/openils/User.js +++ b/Open-ILS/web/js/dojo/openils/User.js @@ -306,17 +306,18 @@ if(!dojo._hasResource["openils.User"]) { * using the orgs where the user has the requested permission. * @param perm The permission to check * @param selector The pre-created dijit.form.FilteringSelect object. + * @param selectedOrg org to select in FilteringSelect object. null defaults to user ws_ou, -1 will select the first OU where the perm is held, typically the top of a [sub]tree. */ buildPermOrgSelector : function(perm, selector, selectedOrg, onload) { var _u = this; dojo.require('dojo.data.ItemFileReadStore'); - function hookupStore(store) { + function hookupStore(store, useOrg) { selector.store = store; selector.startup(); - if(selectedOrg != null) - selector.setValue(selectedOrg); + if(useOrg != null) + selector.setValue(useOrg); else selector.setValue(_u.user.ws_ou()); if(onload) onload(); @@ -324,7 +325,10 @@ if(!dojo._hasResource["openils.User"]) { function buildTreePicker(orgList) { var store = new dojo.data.ItemFileReadStore({data:aou.toStoreData(orgList)}); - hookupStore(store); + if (selectedOrg == -1 && orgList[0]) + selectedOrg = orgList[0].id(); + + hookupStore(store, selectedOrg); _u.permOrgStoreCache[perm] = store; }