Adding org unit context selector to providers screen
authorJames Fournie <jfournie@sitka.bclibraries.ca>
Wed, 31 Aug 2011 17:37:21 +0000 (10:37 -0700)
committerMike Rylander <mrylander@gmail.com>
Wed, 7 Sep 2011 17:55:56 +0000 (13:55 -0400)
This helps alleviate the bug reported in LP 731510 and
generally improves usability.

Signed-off-by: James Fournie <jfournie@sitka.bclibraries.ca>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/web/js/ui/default/conify/global/acq/provider.js
Open-ILS/web/templates/default/conify/global/acq/provider.tt2

index 76c63a5..2dbe1da 100644 (file)
@@ -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);
index 05f9e6b..5d559cd 100644 (file)
         </div>
     </div>
     <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+        <span>Context Org Unit</span>
+        <select dojoType="openils.widget.OrgUnitFilteringSelect"
+            jsId='contextOrgSelector'
+            searchAttr='shortname'
+            labelAttr='shortname'>
+        </select>
+    </div>
+    <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
         <table  jsId="pListGrid"
                 dojoType="openils.widget.AutoGrid"
                 fieldOrder="['id', 'name', 'code', 'owner', 'currency_type']"