settings are now editable. added different widget types for the expected settings...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Sep 2008 15:29:53 +0000 (15:29 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 29 Sep 2008 15:29:53 +0000 (15:29 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@10727 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/server/admin/admin.css
Open-ILS/xul/staff_client/server/admin/org_unit_settings.js
Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml

index a8884ae..4483928 100644 (file)
@@ -48,6 +48,9 @@
 <!ENTITY common.save_transactions.accesskey 'S'>
 <!ENTITY common.save_transactions.label 'Save these transactions'>
 
+<!ENTITY common.true "True">
+<!ENTITY common.false "False">
+
 <!ENTITY ilsevent.1000 "Login failed.  The username or password entered was incorrect.">
 <!ENTITY ilsevent.1001 "Login session has timed out or does not exist">
 <!ENTITY ilsevent.1002 "User was not found in the database">
 <!ENTITY staff.server.admin.index.cash_reports "Cash Reports">
 <!ENTITY staff.server.admin.index.transits "Transits">
 <!ENTITY staff.server.admin.index.transit_list "Transit List">
+
+
 <!ENTITY staff.server.admin.org_settings.title "Evergreen: Library Settings Editor">
 <!-- This will be followed by the user's name -->
 <!ENTITY staff.server.admin.org_settings.greeting "Welcome ">
 <!ENTITY staff.server.admin.org_settings.staff_timeout "Staff Login Inactivity Timeout (in seconds)">
 <!ENTITY staff.server.admin.org_settings.lost_fee "Lost Materials Processing Fee">
 <!ENTITY staff.server.admin.org_settings.default_price "Default Item Price">
-<!ENTITY staff.server.admin.org_settings.from_address '"FROM" email address for patron notices'>
-<!ENTITY staff.server.admin.org_settings.bounce_note "(note: delivery failures will be returned this address)">
+<!ENTITY staff.server.admin.org_settings.from_address 'Sending email address for patron notices'>
+<!ENTITY staff.server.admin.org_settings.bounce_note "Email delivery failures will be returned this address">
 <!ENTITY staff.server.admin.org_settings.apply_all.note 'I. "Apply to all Locations" will force the new setting to be applied to all locations in the location dropdown.'>
 <!ENTITY staff.server.admin.org_settings.update_success "Update succeeded.">
 <!ENTITY staff.server.admin.org_settings.apply_all.confirm "This will update the setting for all of the locations listed in the dropdown menu. Are you sure you wish to continue?">
+
+<!ENTITY staff.server.admin.org_settings.circ.hold_expire_alert_interval "Hold Expiration Alert Interval">
+<!ENTITY staff.server.admin.org_settings.circ.hold_expire_alert_interval.desc "Amount of time before a hold expires at which point the patron should be alerted">
+<!ENTITY staff.server.admin.org_settings.circ.hold_expire_interval "Default Hold Expirate Interval">
+<!ENTITY staff.server.admin.org_settings.circ.hold_expire_interval.desc 'Amount of time after a hold is placed before the hold expires\nExample "100 days"'>
+<!ENTITY staff.server.admin.org_settings.global.credit.allow "Allow Credit Card Payments">
+<!ENTITY staff.server.admin.org_settings.global.credit.allow.desc "If enabled, patrons will be able to pay fines accrued at this location via credit card">
+<!ENTITY staff.server.admin.org_settings.global.default_locale "Default Locale">
+
+
+
 <!ENTITY staff.server.admin.stat_cat.title "Evergreen: Statistical Category Editor">
 <!ENTITY staff.server.admin.stat_cat.greeting "Welcome ">
 <!ENTITY staff.server.admin.stat_cat.heading " Statistical Category Editor">
index 74e3227..166b8dd 100644 (file)
@@ -6,6 +6,9 @@
 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;}
+.hidden { display: none }
+.form_table td { padding: 6px; }
+.form_table thead td { border-bottom: 1px solid #808080; }
 .hide_me { visibility: hidden; display: none }
 .has_color { background: #E0F0E0; color: #000000; }
 .data_grid { font-weight: 500; border-collapse: collapse;}
index 10c727b..8f8773b 100644 (file)
@@ -1,6 +1,7 @@
 dojo.require("dijit.layout.LayoutContainer");
 dojo.require("dijit.layout.ContentPane");
 dojo.require('dijit.form.FilteringSelect');
+dojo.require('dijit.Dialog');
 dojo.require("dojox.grid.Grid");
 dojo.require("fieldmapper.Fieldmapper");
 dojo.require("fieldmapper.dojoData");
@@ -18,8 +19,8 @@ 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();
+    user = new openils.User({authtoken:authtoken});
+    contextOrg = user.user.ws_ou();
 
     fieldmapper.standardRequest(
         [   'open-ils.actor',
@@ -80,7 +81,7 @@ function buildMergedOrgSelector(orgList) {
     var store = new dojo.data.ItemFileReadStore({data:aou.toStoreData(orgNodeList)});
     osContextSelector.store = store;
     osContextSelector.startup();
-    osContextSelector.setValue(user.ws_ou());
+    osContextSelector.setValue(user.user.ws_ou());
 }
 
 function osChangeContext() {
@@ -102,6 +103,15 @@ function osLoadGrid(data) {
         }
         gridData.items.push({name:key});
     }
+    gridData.items = gridData.items.sort(
+        function(a, b) {
+            var seta = osSettings[a.name];
+            var setb = osSettings[b.name];
+            if(seta.label > setb.label) return 1;
+            if(seta.label < setb.label) return -1;
+            return 0;
+        }
+    );
     gridData.identifier = 'name';
     var store = new dojo.data.ItemFileReadStore({data:gridData});
     var model = new dojox.grid.data.DojoData(
@@ -115,11 +125,18 @@ function osLoadGrid(data) {
 function osGetGridData(rowIdx) {
     var data = this.grid.model.getRow(rowIdx);
     if(!data) return '';
-    var value = osSettings[data.name][this.field];
+    var setting = osSettings[data.name];
+    var value = setting[this.field];
     if(value == null) return '';
     switch(this.field) {
         case 'context':
             return fieldmapper.aou.findOrgUnit(value).shortname();
+        case 'value':
+            if(setting.type == 'bool') {
+                if(value) 
+                    return dojo.byId('os-true').innerHTML;
+                return dojo.byId('os-false').innerHTML;
+            }
         default:
             return value;
     }
@@ -132,5 +149,72 @@ function osGetEditLink(rowIdx) {
 }
 
 function osLaunchEditor(name) {
+    osEditDialog._osattr = name;
+    osEditDialog.show();
+    user.buildPermOrgSelector('UPDATE_ORG_UNIT_SETTING.' + name, osEditContextSelector);
+    dojo.byId('os-edit-name').innerHTML = osSettings[name].label;
+    dojo.byId('os-edit-desc').innerHTML = osSettings[name].desc || '';
+
+    dojo.style(osEditTextBox.domNode, 'display', 'none');
+    dojo.style(osEditCurrencyTextBox.domNode, 'display', 'none');
+    dojo.style(osEditNumberTextBox.domNode, 'display', 'none');
+    dojo.style(osEditBoolSelect.domNode, 'display', 'none');
+
+    switch(osSettings[name].type) {
+        case 'number':
+            dojo.style(osEditNumberTextBox.domNode, 'display', 'block');
+            break;
+        case 'currency':
+            dojo.style(osEditCurrencyTextBox.domNode, 'display', 'block');
+            break;
+        case 'bool':
+            dojo.style(osEditBoolSelect.domNode, 'display', 'block');
+            break;
+        default:
+            dojo.style(osEditTextBox.domNode, 'display', 'block');
+    }
+}
+
+function osEditSetting(deleteMe) {
+    osEditDialog.hide();
+    var name = osEditDialog._osattr;
+
+    var obj = {};
+    if(deleteMe) {
+        obj[name] = null;
+
+    } else {
+
+        switch(osSettings[name].type) {
+            case 'number':
+                obj[name] = osEditNumberTextBox.getValue();
+                if(obj[name] == null) return;
+                break;
+            case 'currency':
+                obj[name] = osEditCurrencyTextBox.getValue();
+                if(obj[name] == null) return;
+                break;
+            case 'bool':
+                var val = osEditBoolSelect.getValue();
+                obj[name] = (val == 'true') ? 1 : null;
+                break;
+            default:
+                obj[name] = osEditTextBox.getValue();
+                if(obj[name] == null) return;
+        }
+    }
+
+    fieldmapper.standardRequest(
+        ['open-ils.actor', 'open-ils.actor.org_unit.settings.update'],
+        {   async: true,
+            params: [authtoken, osEditContextSelector.getValue(), obj],
+            oncomplete: function(r) {
+                var res = r.recv().content();
+                if(e = openils.Event.parse(res))
+                    return alert(e);
+                osDraw();
+            }
+        }
+    );
 }
 
index e2c8367..73435cf 100644 (file)
@@ -23,7 +23,7 @@
     <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" djConfig="parseOnLoad: true,isDebug:false" src="/js/dojo/dojo/dojo.js"></script>
         <script type="text/javascript" src='org_unit_settings.js'></script>
         <script>
             var osSettings = {
                 },
                 'org.bounced_emails' : {
                     label : '&staff.server.admin.org_settings.from_address;',
+                    desc : '&staff.server.admin.org_settings.bounce_note;'
                 },
                 'circ.hold_expire_alert_interval' : {
-                    label : 'Hold Expiration Alert Interval',
+                    label : '&staff.server.admin.org_settings.circ.hold_expire_alert_interval;',
+                    desc : '&staff.server.admin.org_settings.circ.hold_expire_alert_interval.desc;',
                 },
                 'circ.hold_expire_interval' : {
-                    label : 'Default Hold Expirate Interval',
+                    label : '&staff.server.admin.org_settings.circ.hold_expire_interval;',
+                    desc : '&staff.server.admin.org_settings.circ.hold_expire_interval.desc;',
                 },
                 'global.credit.allow' : {
-                    label : 'Allow Credit Card Payments',
+                    label : '&staff.server.admin.org_settings.global.credit.allow;',
+                    desc : '&staff.server.admin.org_settings.global.credit.allow.desc;',
                     type : 'bool'
                 },
                 'global.default_locale' : {
-                    label : 'Default Locale',
+                    label : '&staff.server.admin.org_settings.global.default_locale;',
                 },
             };
         </script>
                 <div dojoType='dojox.Grid' jsId='osGrid'> </div>
             </div>
         </div>
+
+        <!-- edit dialog -->
+        <div dojoType="dijit.Dialog" jsId='osEditDialog' title="Edit Setting">
+            <table class='form_table'>
+                <thead>
+                    <tr><td colspan='2' align='center'><div id='os-edit-name'/></td></tr>
+                    <tr><td colspan='2' align='center'><div id='os-edit-desc'/></td></tr>
+                </thead>
+                <tbody>
+                    <tr>
+                        <td>Context</td>
+                        <td> 
+                            <select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='osEditContextSelector'
+                                searchAttr="shortname" autocomplete="true" labelAttr='shortname'> 
+                            </select>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>Value</td>
+                        <td>
+                            <input dojoType='dijit.form.TextBox' jsId='osEditTextBox'/>
+                            <input dojoType='dijit.form.CurrencyTextBox' jsId='osEditCurrencyTextBox'/>
+                            <input dojoType='dijit.form.NumberTextBox' jsId='osEditNumberTextBox'/>
+                            <select dojoType='dijit.form.FilteringSelect' jsId='osEditBoolSelect'>
+                                <option value='true'>&common.true;</option>
+                                <option value='false'>&common.false;</option>
+                            </select>
+                        </td>
+                    </tr>
+                    <tr>
+                        <td> 
+                            <button dojoType='dijit.form.Button' onclick='osEditSetting();'>Update Setting</button>
+                        </td>
+                        <td> 
+                            <button dojoType='dijit.form.Button' onclick='osEditSetting(true);'>Delete Setting</button>
+                        </td>
+                    </tr>
+                </tbody>
+            </table>
+        </div> <!-- edit dialog -->
+        <span id='os-true' class='hidden'>&common.true;</span>
+        <span id='os-false' class='hidden'>&common.false;</span>
     </body>
 </html>