From 8fa616a1ea7395e313168e7b2ca575a43a6483f9 Mon Sep 17 00:00:00 2001 From: James Fournie Date: Wed, 31 Aug 2011 10:37:21 -0700 Subject: [PATCH] Adding org unit context selector to providers screen This helps alleviate the bug reported in LP 731510 and generally improves usability. Signed-off-by: James Fournie Signed-off-by: Mike Rylander --- .../js/ui/default/conify/global/acq/provider.js | 28 +++++++++++++++++++++- .../default/conify/global/acq/provider.tt2 | 8 +++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/js/ui/default/conify/global/acq/provider.js b/Open-ILS/web/js/ui/default/conify/global/acq/provider.js index 76c63a516f..2dbe1da1b9 100644 --- a/Open-ILS/web/js/ui/default/conify/global/acq/provider.js +++ b/Open-ILS/web/js/ui/default/conify/global/acq/provider.js @@ -3,6 +3,7 @@ dojo.require('openils.widget.AutoGrid'); dojo.require('dijit.form.FilteringSelect'); dojo.require('openils.PermaCrud'); dojo.require('openils.MarcXPathParser'); +dojo.require('openils.widget.OrgUnitFilteringSelect'); var provider; @@ -10,6 +11,19 @@ var xpathParser = new openils.MarcXPathParser(); var subFields= []; function draw() { + var org_id = openils.User.user.ws_ou(); + var list = fieldmapper.aou.findOrgUnit(org_id).orgNodeTrail().map( + function (i) {return i.id() } + ); + + new openils.User().buildPermOrgSelector( + 'VIEW_PROVIDER', contextOrgSelector, null, + function() { + dojo.connect(contextOrgSelector, 'onChange', filterGrid); + } + ); + + if(providerId) { openils.Util.addCSSClass(dojo.byId('provider-list-div'), 'hidden'); @@ -31,7 +45,7 @@ function draw() { } else { openils.Util.addCSSClass(dojo.byId('provider-details-div'), 'hidden'); console.log('in else block'); - pListGrid.loadAll({order_by:{acqpro : 'name'}}); + pListGrid.loadAll({order_by:{acqpro : 'name'}},{'owner':list}); pListGrid.onPostCreate = function(fmObject) { location.href = location.href + '/' + fmObject.id(); } @@ -120,4 +134,16 @@ function getParsedSubf(rowIndex, item) { } return''; } + +function filterGrid() { + pListGrid.resetStore(); + var unit = contextOrgSelector.getValue(); + var list = fieldmapper.aou.findOrgUnit(unit).orgNodeTrail().map( function (i) {return i.id() } ); + + if(unit){ + pListGrid.loadAll({order_by:{acqpro : 'name'}}, { 'owner' : list }); + } else { + pListGrid.loadAll({order_by:{acqpro : 'name'}}); + } +} openils.Util.addOnLoad(draw); diff --git a/Open-ILS/web/templates/default/conify/global/acq/provider.tt2 b/Open-ILS/web/templates/default/conify/global/acq/provider.tt2 index 05f9e6b04f..5d559cd658 100644 --- a/Open-ILS/web/templates/default/conify/global/acq/provider.tt2 +++ b/Open-ILS/web/templates/default/conify/global/acq/provider.tt2 @@ -26,6 +26,14 @@
+ Context Org Unit + +
+