moved some JS to an external lib file for ease of sharing
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 25 Jan 2006 19:04:24 +0000 (19:04 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 25 Jan 2006 19:04:24 +0000 (19:04 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2833 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/admin/adminlib.js [new file with mode: 0644]
Open-ILS/xul/staff_client/server/admin/stat_cat_editor.js
Open-ILS/xul/staff_client/server/admin/stat_cat_editor.xml

diff --git a/Open-ILS/xul/staff_client/server/admin/adminlib.js b/Open-ILS/xul/staff_client/server/admin/adminlib.js
new file mode 100644 (file)
index 0000000..e00ee30
--- /dev/null
@@ -0,0 +1,34 @@
+var USER;
+var SESSION;
+var PERMS = {};
+
+function fetchUser(session) {
+       if(session == null ) {
+               cgi = new CGI();
+               session = cgi.param('ses');
+       }
+       if(!session) throw "User session is not defined";
+       SESSION = session;
+       var request = new Request(FETCH_SESSION, session, 1 );
+       request.send(true);
+       var user = request.result();
+       if(checkILSEvent(user)) throw user;
+       USER = user;
+       return user;
+}
+
+/**
+  * Fetches the highest org at for each perm  and stores the value in
+  * PERMS[ permName ].  It also returns the org list to the caller
+  */
+function fetchHighestPermOrgs( session, userId, perms ) {
+       var req = new RemoteRequest(
+               'open-ils.actor',
+               'open-ils.actor.user.perm.highest_org.batch', 
+               session, userId, perms  );
+       req.send(true);
+       var orgs = req.getResultObject();
+       for( var i = 0; i != orgs.length; i++ ) 
+               PERMS[ perms[i] ] = ( orgs[i] != null ) ? orgs[i] : -1 ;
+       return 
+}
index 467ad2e..dd60cb3 100644 (file)
@@ -31,7 +31,6 @@ function scEditorInit() {
 
 function scGo() {
 
-
        var show = cgi.param('show');
        if(!show) show = ASSET;
        scShow(show);
@@ -41,9 +40,7 @@ function scGo() {
 
 function scFetchPerms() {
 
-       var req = new RemoteRequest(
-               'open-ils.actor',
-               'open-ils.actor.user.perm.highest_org.batch', session, user.id(), 
+       var orgs = fetchHighestPermOrgs( session, user.id(), 
                [       'CREATE_PATRON_STAT_CAT',
                        'UPDATE_PATRON_STAT_CAT',
                        'DELETE_PATRON_STAT_CAT',
@@ -58,9 +55,6 @@ function scFetchPerms() {
                        'UPDATE_COPY_STAT_CAT_ENTRY',
                        'DELETE_COPY_STAT_CAT_ENTRY' ] );
 
-       req.send(true);
-       var orgs = req.getResultObject();
-
        PERMS[ACTOR].create_stat_cat = orgs[0];
        PERMS[ACTOR].update_stat_cat = orgs[1];
        PERMS[ACTOR].delete_stat_cat = orgs[2];
@@ -93,14 +87,6 @@ function _cleanTbody(tbody) {
        }
 }
 
-function fetchUser(session) {
-       var request = new Request(FETCH_SESSION, session, 1 );
-       request.send(true);
-       var user = request.result();
-       if(checkILSEvent(user)) throw user;
-       return user;
-}
-
 
 function scFetchAll( session, type, orgid, callback, args ) {
        var req = new Request( 
index 99be66d..931d179 100644 (file)
@@ -16,6 +16,7 @@
                <script language='javascript' src='/opac/common/js/org_utils.js'> </script>
                <script language='javascript' src='/opac/common/js/init.js'> </script>
                <script language='javascript' src='/opac/common/js/RemoteRequest.js'> </script>
+               <script language='javascript' src='adminlib.js'> </script>
                <script language='javascript' src='stat_cat_editor.js'> </script>
 
                <style type='text/css'>