From c3d891ddd5b9f0608842a90856857480a8c51d02 Mon Sep 17 00:00:00 2001 From: blake Date: Mon, 5 Jan 2015 10:38:18 -0600 Subject: [PATCH] LP1402018_Acq_Copy_location_UI_scoped_to_registered_workstation This little patch will open up the acq copy location dropdown UI to include other library's copy locations outside of the workstation registration. When the user permissions are scoped to more branches. Signed-off-by: blake Signed-off-by: Chris Sharp Signed-off-by: Kathy Lussier --- .../js/dojo/openils/widget/AutoFieldWidget.js | 60 ++++++++++++------- .../web/js/ui/default/acq/common/li_table.js | 2 +- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js index 9ae36f2b93..149d53d150 100644 --- a/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js +++ b/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js @@ -486,8 +486,29 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { return this._buildPermGrpSelector(); if(linkClass == 'aou') return this._buildOrgSelector(); - if(linkClass == 'acpl') - return this._buildCopyLocSelector(); + if(linkClass == 'acpl'){ + var self2 = this; + var orgs = []; + /* ----------------------------------------------------- + When the copy location dropdown is in a link context + we need to expand the list to the provided permission + branches + ------------------------------------------------------*/ + if(this.orgLimitPerms){ + var buildCopyLocSelector = this._buildCopyLocSelector; + new openils.User().getPermOrgList( + self2.orgLimitPerms, + function(orgsi) { + orgs = orgs.concat(orgsi); + buildCopyLocSelector(orgs,self2); + }, + true, true // descendants, id_list + ); + return true; + } + else + return this._buildCopyLocSelector(orgs,self); + } if(linkClass == 'acqpro') return this._buildAutoCompleteSelector(linkClass, vfield.selector); @@ -693,22 +714,21 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { return true; }, - _buildCopyLocSelector : function() { + _buildCopyLocSelector : function(orgs,self) { dojo.require('dijit.form.FilteringSelect'); - this.widget = new dijit.form.FilteringSelect(this.dijitArgs, this.parentNode); - this.widget.searchAttr = this.widget.labalAttr = 'name'; - this.widget.valueAttr = 'id'; + self.widget = new dijit.form.FilteringSelect(self.dijitArgs, self.parentNode); + self.widget.searchAttr = self.widget.labalAttr = 'name'; + self.widget.valueAttr = 'id'; // my orgs var ws_ou = openils.User.user.ws_ou(); - var orgs = fieldmapper.aou.findOrgUnit(ws_ou).orgNodeTrail().map(function (i) { return i.id() }); + orgs = orgs.concat(fieldmapper.aou.findOrgUnit(ws_ou).orgNodeTrail().map(function (i) { return i.id() })); orgs = orgs.concat(fieldmapper.aou.descendantNodeList(ws_ou).map(function (i) { return i.id() })); - var self = this; var search = {owning_lib : orgs, deleted : 'f'}; - if(this.cache.copyLocStore) { - var store = this.cache.copyLocStore; + if(self.cache.copyLocStore) { + var store = self.cache.copyLocStore; var allGood = false; var locIds = []; @@ -718,7 +738,7 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { // the set of locations to fetch. var allGood = false; - if (this.widgetValue) { + if (self.widgetValue) { store.fetch({ onComplete : function(list) { @@ -736,21 +756,21 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { } if (allGood) { - this.widget.store = this.cache.copyLocStore; - this.widget.startup(); - this.async = false; + self.widget.store = self.cache.copyLocStore; + self.widget.startup(); + self.async = false; return true; } else { - // cached IDs plus id of this.widgetValue; - locIds.push(this.widgetValue); + // cached IDs plus id of self.widgetValue; + locIds.push(self.widgetValue); search = {id : locIds, deleted: 'f'}; } } - new openils.PermaCrud().search('acpl', search, { - async : !this.forceSync, + new openils.PermaCrud().search('acpl', search, { + async : !self.forceSync, order_by : {"acpl": "name"}, oncomplete : function(r) { var list = openils.Util.readResponse(r, false, true); @@ -759,8 +779,8 @@ if(!dojo._hasResource['openils.widget.AutoFieldWidget']) { // if we are including any copy locations outside our org // unit scope, tag them with a context org unit to prevent // confusion caused by having multiple like-named entries - dojo.forEach(list, function(loc) { - if (orgs.indexOf(loc.owning_lib()) < 0) { + dojo.forEach(list, function(loc) { + if (orgs.length>1) { loc.name(loc.name() + ' (' + fieldmapper.aou.findOrgUnit(loc.owning_lib()).shortname() + ')'); } diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js index bf4e4e3eee..af33b034cb 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js @@ -182,7 +182,7 @@ function AcqLiTable() { "labelFormat": (field == 'fund') ? fundLabelFormat : null, "searchFormat": (field == 'fund') ? fundSearchFormat : null, "searchFilter": (field == 'fund') ? fundSearchFilter : null, - "orgLimitPerms": [perms], + "orgLimitPerms": (field == 'location') ? ['CREATE_PICKLIST', 'CREATE_PURCHASE_ORDER'] : [perms], "dijitArgs": { "required": false, "labelType": (field == "fund") ? "html" : null -- 2.43.2