org unit setting editor that is more context-specific, which honors parent settings...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Sep 2008 04:51:39 +0000 (04:51 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Sep 2008 04:51:39 +0000 (04:51 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@10723 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 0c112a1..74e3227 100644 (file)
@@ -1,4 +1,9 @@
-body { font-family: Verdana, Tahoma; font-size: 10pt; background-color: white;}
+@import "/js/dojo/dojo/resources/dojo.css";
+@import "/js/dojo/dijit/themes/tundra/tundra.css";
+@import "/js/dojo/dijit/tests/css/dijitTests.css";
+@import "/js/dojo/dojox/grid/_grid/Grid.css";
+.container:after {content: ""; display: block; height: 0; clear: both; }
+body { font-family: Verdana, Tahoma; font-size: 10pt; background-color: white; margin: 0px; padding: 0px;}
 .welcome_box { position:absolute; top: 5px; right: 5px; }
 .title { font-weight: bold; font-size: 14pt; margin: 10px;}
 .hide_me { visibility: hidden; display: none }
@@ -18,6 +23,7 @@ body { font-family: Verdana, Tahoma; font-size: 10pt; background-color: white;}
 select { width: 12em; }
 select:disabled { color: #555555; }
 input[type="text"]:disabled { color: #555555; }
+.tall { height:100%; }
 
 button {
        color:#050;
diff --git a/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js b/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js
new file mode 100644 (file)
index 0000000..58b6277
--- /dev/null
@@ -0,0 +1,90 @@
+dojo.require("dijit.layout.LayoutContainer");
+dojo.require("dijit.layout.ContentPane");
+dojo.require('dijit.form.FilteringSelect');
+dojo.require("dojox.grid.Grid");
+dojo.require("fieldmapper.Fieldmapper");
+dojo.require("fieldmapper.dojoData");
+dojo.require("fieldmapper.OrgUtils");
+dojo.require('dojo.cookie');
+dojo.require('openils.CGI');
+dojo.require('openils.User');
+dojo.require('openils.Event');
+
+var authtoken;
+var contextOrg;
+var user;
+var contextSelector;
+
+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');
+
+    var names = [];
+    for(var key in osSettings)
+        names.push(key);
+
+    fieldmapper.standardRequest(
+        [   'open-ils.actor', 
+            'open-ils.actor.ou_setting.ancestor_default.batch'],
+        {   async: true,
+            params: [contextOrg, names],
+            oncomplete: function(r) {
+                var data = r.recv().content();
+                if(e = openils.Event.parse(data))
+                    return alert(e);
+                osLoadGrid(data);
+            }
+        }
+    );
+    buildMergedOrgSel(contextSelector, user.ws_ou(), 0);
+    // open-ils.actor.user.get_work_ous.ids
+}
+dojo.addOnLoad(osInit);
+
+function osChangeContect() {
+    contextOrg = getSelectorVal(contextSelector);
+}
+
+function osLoadGrid(data) {
+    var gridData = {items:[]}
+    for(var key in data) {
+        if(data[key]) {
+            osSettings[key].context = data[key].org;
+            osSettings[key].value = data[key].value;
+        }
+        gridData.items.push({name:key});
+    }
+    gridData.identifier = 'name';
+    var store = new dojo.data.ItemFileReadStore({data:gridData});
+    var model = new dojox.grid.data.DojoData(
+        null, store, {rowsPerPage: 100, clientSort: true, query:{name:'*'}});
+
+    osGrid.setModel(model);
+    osGrid.setStructure(osGridLayout);
+    osGrid.update();
+}
+
+function osGetGridData(rowIdx) {
+    var data = this.grid.model.getRow(rowIdx);
+    if(!data) return '';
+    var value = osSettings[data.name][this.field];
+    if(value == null) return '';
+    switch(this.field) {
+        case 'context':
+            return fieldmapper.aou.findOrgUnit(value).shortname();
+        default:
+            return value;
+    }
+}
+
+function osGetEditLink(rowIdx) {
+    var data = this.grid.model.getRow(rowIdx);
+    if(!data) return '';
+    return this.value.replace(/SETTING/, data.name);
+}
+
+function osLaunchEditor(name) {
+}
+
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
new file mode 100644 (file)
index 0000000..be2b891
--- /dev/null
@@ -0,0 +1,88 @@
+<!-- 
+# 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>
+