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);
--- /dev/null
+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;
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;
* 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();
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;
}