created general perm group object and using that in the perm filtering select
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 25 Nov 2008 15:47:19 +0000 (15:47 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 25 Nov 2008 15:47:19 +0000 (15:47 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@11339 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/PermGrp.js [new file with mode: 0644]
Open-ILS/web/js/ui/default/conify/global/permission/grp_penalty_threshold.js

diff --git a/Open-ILS/web/js/dojo/openils/PermGrp.js b/Open-ILS/web/js/dojo/openils/PermGrp.js
new file mode 100644 (file)
index 0000000..a676fc8
--- /dev/null
@@ -0,0 +1,34 @@
+if(!dojo._hasResource["openils.PermGrp"]){
+    dojo.provide("openils.PermGrp");
+    dojo.require('openils.Util');
+
+    dojo.declare( "openils.PermGrp", null, {});
+
+    openils.PermGrp.groupTree = null;
+    openils.PermGrp.groupIdMap = {};
+
+    openils.PermGrp.fetchGroupTree = function(onload) {
+        if(openils.PermGrp.groupTree) 
+            return onload();
+        fieldmapper.standardRequest(
+            ['open-ils.actor', 'open-ils.actor.groups.tree.retrieve'],
+            {   async: true,
+                oncomplete: function(r) {
+                    openils.PermGrp.groupTree = openils.Util.readResponse(r);
+                    onload();
+                }
+            }
+        );
+    };
+
+    /**
+     * Flatten the group tree into a id => object map for easy access
+     */
+    openils.PermGrp.flatten = function(node) {
+        if(!node) node = 
+            openils.PermGrp.groupTree;
+        openils.PermGrp.groupIdMap[node.id()] = node;
+        for(var idx in node.children())
+            openils.PermGrp.flatten(node.children()[idx]);
+    };
+}
index 3bb496f..b26ba8e 100644 (file)
@@ -2,6 +2,7 @@ dojo.require('dojox.grid.DataGrid');
 dojo.require('dojo.data.ItemFileReadStore');
 dojo.require('dijit.form.NumberTextBox');
 dojo.require('dijit.form.FilteringSelect');
+dojo.require('openils.PermGrp');
 dojo.require('openils.widget.OrgUnitFilteringSelect');
 dojo.require('openils.widget.PermGrpFilteringSelect');
 
@@ -23,9 +24,9 @@ var GPT = {
     },
 
     buildGrid  : function() {
-        GPT.grpSelector.fetchGroups(
+        openils.PermGrp.fetchGroupTree(
             function() {
-                GPT.grpSelector.flatten();
+                openils.PermGrp.flatten();
                 fieldmapper.standardRequest(
                     ['open-ils.permacrud', 'open-ils.permacrud.search.pgpt.atomic'],
                     {   async: true,
@@ -63,7 +64,7 @@ var GPT = {
     getGroupName : function(rowIdx, item) {
         if(!item) return '';
         var grpId = this.grid.store.getValue(item, this.field);
-        return GPT.grpSelector.groupMap[grpId].name();
+        return openils.PermGrp.groupIdMap[grpId].name();
     },
 
     _loadCspComplete : function(r) {