changed file type to xhtml to match other admin files. added support for choosing...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Sep 2008 13:24:03 +0000 (13:24 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Sep 2008 13:24:03 +0000 (13:24 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@10724 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/admin/org_unit_settings.js
Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml [new file with mode: 0644]
Open-ILS/xul/staff_client/server/admin/org_unit_settings.xml [deleted file]

index 58b6277..10c727b 100644 (file)
@@ -9,18 +9,38 @@ dojo.require('dojo.cookie');
 dojo.require('openils.CGI');
 dojo.require('openils.User');
 dojo.require('openils.Event');
+dojo.require('openils.widget.OrgUnitFilteringSelect');
 
 var authtoken;
 var contextOrg;
 var user;
-var contextSelector;
+var workOrgs;
 
 function osInit(data) {
     authtoken = dojo.cookie('ses') || new openils.CGI().param('ses');
     user = new openils.User({authtoken:authtoken}).user;
     contextOrg = user.ws_ou();
-    contextSelector = dojo.byId('os-context-selector');
 
+    fieldmapper.standardRequest(
+        [   'open-ils.actor',
+            'open-ils.actor.user.get_work_ous.ids'],
+        {   async: true,
+            params: [authtoken],
+            oncomplete: function(r) {
+                var list = r.recv().content();
+                if(e = openils.Event.parse(list))
+                    return alert(e);
+                workOrgs = list;
+                buildMergedOrgSelector(list);
+            }
+        }
+    );
+
+    osDraw();
+}
+dojo.addOnLoad(osInit);
+
+function osDraw() {
     var names = [];
     for(var key in osSettings)
         names.push(key);
@@ -38,21 +58,47 @@ function osInit(data) {
             }
         }
     );
-    buildMergedOrgSel(contextSelector, user.ws_ou(), 0);
-    // open-ils.actor.user.get_work_ous.ids
 }
-dojo.addOnLoad(osInit);
 
-function osChangeContect() {
-    contextOrg = getSelectorVal(contextSelector);
+function buildMergedOrgSelector(orgList) {
+    var orgNodeList = [];
+    for(var i = 0; i < orgList.length; i++) {
+        // add the work org parents
+        var parents = [];
+        var node = fieldmapper.aou.findOrgUnit(orgList[i]);
+        while(node.parent_ou() != null) {
+            node = fieldmapper.aou.findOrgUnit(node.parent_ou());
+            parents.push(node);
+        }
+        orgNodeList = orgNodeList.concat(parents.reverse());
+
+        // add the work org children
+        orgNodeList = orgNodeList.concat(
+            fieldmapper.aou.descendantNodeList(orgList[i]));
+    }
+
+    var store = new dojo.data.ItemFileReadStore({data:aou.toStoreData(orgNodeList)});
+    osContextSelector.store = store;
+    osContextSelector.startup();
+    osContextSelector.setValue(user.ws_ou());
+}
+
+function osChangeContext() {
+    if(contextOrg == osContextSelector.getValue())
+        return;
+    contextOrg = osContextSelector.getValue();
+    osDraw();
 }
 
 function osLoadGrid(data) {
     var gridData = {items:[]}
     for(var key in data) {
+        var setting = osSettings[key];
+        setting.context = null;
+        setting.value = null;
         if(data[key]) {
-            osSettings[key].context = data[key].org;
-            osSettings[key].value = data[key].value;
+            setting.context = data[key].org;
+            setting.value = data[key].value;
         }
         gridData.items.push({name:key});
     }
diff --git a/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml b/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml
new file mode 100644 (file)
index 0000000..e2c8367
--- /dev/null
@@ -0,0 +1,92 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!-- 
+# Copyright (C) 2008  Georgia Public Library Service
+# Bill Erickson <erickson@esilibrary.com>
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+-->
+
+<!DOCTYPE html PUBLIC 
+       "-//W3C//DTD XHTML 1.0 Transitional//EN" 
+       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
+       <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
+]>
+
+<html xmlns='http://www.w3.org/1999/xhtml'>
+    <head>
+        <title>Org Unit Settings</title>
+        <link type='text/css' rel='stylesheet' href='admin.css'/>
+        <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:true" src="/js/dojo/dojo/dojo.js"></script>
+        <script type="text/javascript" src='org_unit_settings.js'></script>
+        <script>
+            var osSettings = {
+                'circ.lost_materials_processing_fee' : {
+                    label : '&staff.server.admin.org_settings.lost_fee;',
+                    type : 'currency',
+                },
+                'cat.default_item_price' : {
+                    label : '&staff.server.admin.org_settings.default_price;',
+                    type : 'currency',
+                },
+                'auth.opac_timeout' : {
+                    label : '&staff.server.admin.org_settings.opac_timeout;',
+                    type : 'number',
+                },
+                'auth.staff_timeout' : {
+                    label : '&staff.server.admin.org_settings.staff_timeout;',
+                    type : 'number',
+                },
+                'org.bounced_emails' : {
+                    label : '&staff.server.admin.org_settings.from_address;',
+                },
+                'circ.hold_expire_alert_interval' : {
+                    label : 'Hold Expiration Alert Interval',
+                },
+                'circ.hold_expire_interval' : {
+                    label : 'Default Hold Expirate Interval',
+                },
+                'global.credit.allow' : {
+                    label : 'Allow Credit Card Payments',
+                    type : 'bool'
+                },
+                'global.default_locale' : {
+                    label : 'Default Locale',
+                },
+            };
+        </script>
+    </head>
+    <body class="tundra tall">
+        <div dojoType="dijit.layout.LayoutContainer" orientation="vertical" class="tall">
+            <div dojoType="dijit.layout.ContentPane" layoutAlign='top'>
+                <h1>Org Unit Settings</h1><br/>
+                Context Location 
+                <select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='osContextSelector'
+                    searchAttr="shortname" autocomplete="true" labelAttr='shortname' onchange='osChangeContext();'> 
+                </select>
+            </div>
+            <div dojoType="dijit.layout.ContentPane" layoutAlign='client' class='tall'>
+                <script>
+                    var osGridLayout = [{
+                        defaultCell: {styles: 'text-align: center;'},
+                        cells : [[
+                            {name: 'Edit', get: osGetEditLink, 
+                                value: '&lt;a href=&quot;javascript:void(0);&quot; onclick=&quot;osLaunchEditor(\'SETTING\');&quot;>Edit&lt;/a>'},
+                            {name: 'Setting', get: osGetGridData, field:'label', width:'auto'},
+                            {name: 'Context', get: osGetGridData, field:'context', width:'auto'},
+                            {name: 'Value', get: osGetGridData, field:'value', width:'auto'},
+                        ]]
+                    }];
+                </script>
+                <div dojoType='dojox.Grid' jsId='osGrid'> </div>
+            </div>
+        </div>
+    </body>
+</html>
+
diff --git a/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xml b/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xml
deleted file mode 100644 (file)
index be2b891..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-<!-- 
-# Copyright (C) 2008  Georgia Public Library Service
-# Bill Erickson <erickson@esilibrary.com>
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
--->
-
-<!--
-XXX load DTD
--->
-
-<html xmlns='http://www.w3.org/1999/xhtml'>
-    <head>
-        <title>Org Unit Settings</title>
-        <link type='text/css' rel='stylesheet' href='admin.css'/>
-        <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:true" src="/js/dojo/dojo/dojo.js"></script>
-        <script type="text/javascript" src='org_unit_settings.js'></script>
-        <script>
-            var osSettings = {
-                'circ.lost_materials_processing_fee' : {
-                    label : '&staff.server.admin.org_settings.lost_fee;',
-                    type : 'currency',
-                },
-                'cat.default_item_price' : {
-                    label : '&staff.server.admin.org_settings.default_price;',
-                    type : 'currency',
-                },
-                'auth.opac_timeout' : {
-                    label : '&staff.server.admin.org_settings.opac_timeout;',
-                    type : 'number',
-                },
-                'auth.staff_timeout' : {
-                    label : '&staff.server.admin.org_settings.staff_timeout;',
-                    type : 'number',
-                },
-                'org.bounced_emails' : {
-                    label : '&staff.server.admin.org_settings.from_address;',
-                },
-                'circ.hold_expire_alert_interval' : {
-                    label : 'Hold Expiration Alert Interval',
-                },
-                'circ.hold_expire_interval' : {
-                    label : 'Default Hold Expirate Interval',
-                },
-                'global.credit.allow' : {
-                    label : 'Allow Credit Card Payments',
-                    type : 'bool'
-                },
-                'global.default_locale' : {
-                    label : 'Default Locale',
-                },
-            };
-        </script>
-    </head>
-    <body class="tundra tall">
-        <div dojoType="dijit.layout.LayoutContainer" orientation="vertical" class="tall">
-            <div dojoType="dijit.layout.ContentPane" layoutAlign='top'>
-                <h1>Org Unit Settings</h1><br/>
-                Context Location 
-                <select id='os-context-selector' onchange='osChangeContext();'> 
-                </select>
-            </div>
-            <div dojoType="dijit.layout.ContentPane" layoutAlign='client' class='tall'>
-                <script>
-                    var osGridLayout = [{
-                        defaultCell: {styles: 'text-align: center;'},
-                        cells : [[
-                            {name: 'Edit', get: osGetEditLink, 
-                                value: '<a href="javascript:void(0);" onclick="osLaunchEditor(\'SETTING\');">Edit</a>'},
-                            {name: 'Setting', get: osGetGridData, field:'label', width:'auto'},
-                            {name: 'Context', get: osGetGridData, field:'context', width:'auto'},
-                            {name: 'Value', get: osGetGridData, field:'value', width:'auto'},
-                        ]]
-                    }];
-                </script>
-                <div dojoType='dojox.Grid' jsId='osGrid'> </div>
-            </div>
-        </div>
-    </body>
-</html>
-