added function to flesh out an OrgUnitFilteringSelect based on user perm orgs
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 21 Apr 2008 17:36:38 +0000 (17:36 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 21 Apr 2008 17:36:38 +0000 (17:36 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@9402 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/User.js

index ba7fbb6..2cd8e93 100644 (file)
@@ -137,8 +137,32 @@ if(!dojo._hasResource["openils.User"]) {
 
         fieldmapper.standardRequest(
             ['open-ils.actor', 'open-ils.actor.user.work_perm.org_unit_list'],
-            {
-                params: [openils.User.authtoken, perm],
+            {   params: [openils.User.authtoken, perm],
+                oncomplete: buildTreePicker,
+                async: true
+            }
+        )
+    }
+
+    /**
+     * Sets the store for an existing openils.widget.OrgUnitFilteringSelect 
+     * 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.  
+     */
+    openils.User.buildPermOrgSelector = function(perm, selector) {
+
+        function buildTreePicker(r) {
+            var orgList = r.recv().content();
+            var store = new dojo.data.ItemFileReadStore({data:aou.toStoreData(orgList)});
+            selector.store = store;
+            selector.startup();
+            selector.setValue(openils.User.user.ws_ou());
+        }
+
+        fieldmapper.standardRequest(
+            ['open-ils.actor', 'open-ils.actor.user.work_perm.org_unit_list'],
+            {   params: [openils.User.authtoken, perm],
                 oncomplete: buildTreePicker,
                 async: true
             }