Updated to include search.
authorJoseph Lewis <joehms22@gmail.com>
Wed, 8 Jun 2011 20:07:27 +0000 (14:07 -0600)
committerJason Etheridge <jason@esilibrary.com>
Thu, 15 Sep 2011 16:17:10 +0000 (12:17 -0400)
Signed-off-by: Joseph Lewis <joehms22@gmail.com>
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/server/admin/org_unit_settings.js
Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml
Open-ILS/xul/staff_client/server/locale/en-US/common.properties

index 4003508..3c56d5d 100644 (file)
 <!ENTITY staff.server.admin.do_not_auto_attempt_print_setting.transit_slip "Transit Slip">
 <!ENTITY staff.server.admin.do_not_auto_attempt_print_setting.hold_transit_slip "Hold/Transit Slip">
 <!ENTITY staff.server.admin.org_unit_settings.title "Organization Unit Settings">
-<!ENTITY staff.server.admin.org_unit_settings.context "Context Location">
+<!ENTITY staff.server.admin.org_unit_settings.context_loc "Context Location">
 <!ENTITY staff.server.admin.org_unit_settings.uninherited " * Indicates the setting is not inherited from the parent org unit at run time">
 <!ENTITY staff.server.admin.org_unit_settings.no_perms "You do not have permission to view org unit settings">
 <!ENTITY staff.server.admin.org_unit_settings.edit_setting "Edit Setting">
 <!ENTITY staff.server.admin.org_unit_settings.delete_setting "Delete Setting">
 <!ENTITY staff.server.admin.org_unit_settings.update_setting "Update Setting">
+<!ENTITY staff.server.admin.org_unit_settings.processing "Processing...">
+<!ENTITY staff.server.admin.org_unit_settings.filter "Filter">
+<!ENTITY staff.server.admin.org_unit_settings.clear_filter "Clear Filter">
+<!ENTITY staff.server.admin.org_unit_settings.no_results "There are no results for your filter.">
+<!ENTITY staff.server.admin.org_unit_settings.group "Group">
+<!ENTITY staff.server.admin.org_unit_settings.setting "Setting">
+<!ENTITY staff.server.admin.org_unit_settings.context "Context">
+<!ENTITY staff.server.admin.org_unit_settings.value "Value">
+<!ENTITY staff.server.admin.org_unit_settings.edit "Edit">
 <!ENTITY staff.server.admin.offline.xacts.caption "Offline Sessions">
 <!ENTITY staff.server.admin.offline.xacts.refresh.accesskey "R">
 <!ENTITY staff.server.admin.offline.xacts.create.label "Create">
index 696c8e7..a1a5c6a 100644 (file)
@@ -1,12 +1,12 @@
 dojo.require('fieldmapper.AutoIDL');
-dojo.require("dijit.layout.LayoutContainer");
-dojo.require("dijit.layout.ContentPane");
+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");
-dojo.require("fieldmapper.OrgUtils");
+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');
@@ -24,6 +24,7 @@ var ouSettingValues = {};
 var osEditAutoWidget;
 var perm_codes = {};
 var osGroups = {};
+var searchAssist = [];
 
 function osInit(data) {
     authtoken = new openils.CGI().param('ses') || dojo.cookie('ses');
@@ -66,8 +67,16 @@ function osInit(data) {
 }
 dojo.addOnLoad(osInit);
 
+function showProcessingDialog(toggle) {
+    var proc = dojo.byId('proci18n').innerHTML;
+    if(toggle)
+        progressDialog.show(true, proc);
+    else
+        progressDialog.hide();
+}
+
 function osDraw(specific_setting) {
-    progressDialog.show(true, "Processing..."); /* FIXME: I18N */
+    showProcessingDialog(true);
 
     var names = [];
     if (specific_setting) {
@@ -78,6 +87,8 @@ function osDraw(specific_setting) {
     } else {
         var types = new openils.PermaCrud({authtoken:authtoken}).retrieveAll('coust');
 
+        searchAssist =  [];
+        
         dojo.forEach(types, 
             function(type) {
                 osSettings[type.name()] = {
@@ -88,6 +99,11 @@ function osDraw(specific_setting) {
                     update_perm : type.update_perm(),
                     grp : osGroups[type.grp()]
                 }
+                
+                var tmp = "" + type.label() + "" + type.description() + "" + type.fm_class() + "" + 
+                          osGroups[type.grp()] + "" + type.name();
+                
+                searchAssist[type.name()] = tmp.toLowerCase().replace(/[^a-z0-9]+/, '');
             }
         );
         
@@ -95,6 +111,58 @@ function osDraw(specific_setting) {
             names.push(key);
     }
 
+    osDrawNames(names);
+    
+}
+
+//Limits those functions seen to the ones that have similar text to 
+//that which is provided. Not case sensitive.
+function osLimitSeen(text) {
+    showProcessingDialog(true);
+    
+    text = text.toLowerCase().replace(/[^a-z0-9]+/, '');
+    
+    console.log(text);
+    
+    var names = [];
+    for(var n in searchAssist)
+        if(searchAssist[n].indexOf(text) != -1)
+            names.push(n);
+    
+    //Don't update on an empty list as this causes bizarre errors.
+    if(names.length == 0) {
+        showProcessingDialog(false);
+        
+        var noresults = dojo.byId('noresults').innerHTML;
+        myDialog = new dijit.Dialog({ content: noresults});
+        myDialog.show();
+        return;
+    }
+    
+    ouSettingValues = {}; // Clear the values.
+    osDrawNames(names);
+}
+
+function doSearch() {
+    var query = dojo.byId("searchBox").value;
+    osLimitSeen(query);
+    
+    return false; //Keep form from submitting
+}
+
+function clearSearch() {
+    dojo.byId("searchBox").value = "";
+    osDraw();
+}
+
+function osToJson() {
+    //console.log(dojo.toJson(ouSettingValues));
+    dojo.byId('jsonOutput').value = dojo.toJson(ouSettingValues);
+    osJSONOutDialog.show();
+}
+
+//Draws the grid based upon a given array of items to draw.
+function osDrawNames(names) {
     fieldmapper.standardRequest(
         [   'open-ils.actor', 
             'open-ils.actor.ou_setting.ancestor_default.batch'],
@@ -107,7 +175,8 @@ function osDraw(specific_setting) {
                 for(var key in data)
                     ouSettingValues[key] = data[key];
                 osLoadGrid(ouSettingValues);
-                progressDialog.hide();
+                
+                showProcessingDialog(false);
             }
         }
     );
@@ -316,4 +385,3 @@ function osEditSetting(deleteMe) {
         }
     );
 }
-
index 16cdabf..5a3c396 100644 (file)
         <div dojoType="dijit.layout.LayoutContainer" orientation="vertical" class="tall">
             <div dojoType="dijit.layout.ContentPane" layoutAlign='top'>
                 <h1>&staff.server.admin.org_unit_settings.title;</h1><br/>
-                <span>&staff.server.admin.org_unit_settings.context;</span>
+                <span>&staff.server.admin.org_unit_settings.context_loc;</span>
                 <span>
                     <select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='osContextSelector'
                         searchAttr="shortname" autocomplete="true" labelAttr='shortname' onchange='osChangeContext();'> 
                     </select>
                 </span>
                 <span>&staff.server.admin.org_unit_settings.uninherited;</span>
+                    <form onSubmit="return doSearch()">
+                        <input type="text" dojoType="dijit.form.TextBox" id="searchBox" />
+                        <button type="submit" dojoType='dijit.form.Button'>&staff.server.admin.org_unit_settings.filter;</button>
+                        <button dojoType='dijit.form.Button' onClick="clearSearch();">&staff.server.admin.org_unit_settings.clear_filter;</button>
+                    </form>
+                        <button dojoType='dijit.form.Button' onClick="osToJson();">Output</button>
             </div>
             <div dojoType="dijit.layout.ContentPane" layoutAlign='client'>
                 <div class='hide_me' id='no-perms'><b>&staff.server.admin.org_unit_settings.no_perms;</b></div>
                     var osGridLayout = [{
                         defaultCell: {styles: 'text-align: center;'},
                         cells : [[
-                            {   name: 'Edit', 
-                                value: '&lt;a href=&quot;javascript:void(0);&quot; onclick=&quot;osLaunchEditor(\'SETTING\');&quot;>Edit&lt;/a>',
+                            {   name: '&staff.server.admin.org_unit_settings.edit;', 
+                                value: '&lt;a href=&quot;javascript:void(0);&quot; onclick=&quot;osLaunchEditor(\'SETTING\');&quot;>&staff.server.admin.org_unit_settings.edit;&lt;/a>',
                                 get: osGetEditLink, 
                                 formatter : osFormatEditLink
                             },
-                            {name: 'Group', get: osGetGridData, field:'grp'},
-                            {name: 'Setting', get: osGetGridData, field:'label', width:'auto', styles:'text-align:left;'},
-                            {name: 'Context', get: osGetGridData, field:'context'},
-                            {name: 'Value', get: osGetGridData, field:'value', width:'auto'},
+                            {name: '&staff.server.admin.org_unit_settings.group;', get: osGetGridData, field:'grp'},
+                            {name: '&staff.server.admin.org_unit_settings.setting;', get: osGetGridData, field:'label', width:'auto', styles:'text-align:left;'},
+                            {name: '&staff.server.admin.org_unit_settings.context;', get: osGetGridData, field:'context'},
+                            {name: '&staff.server.admin.org_unit_settings.value;', get: osGetGridData, field:'value', width:'auto'},
                         ]]
                     }];
                 </script>
@@ -73,7 +79,7 @@
                 </thead>
                 <tbody>
                     <tr>
-                        <td>Context</td>
+                        <td>&staff.server.admin.org_unit_settings.context;</td>
                         <td> 
                             <select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='osEditContextSelector'
                                 searchAttr="shortname" autocomplete="true" labelAttr='shortname'> 
@@ -81,7 +87,7 @@
                         </td>
                     </tr>
                     <tr>
-                        <td>Value</td>
+                        <td>&staff.server.admin.org_unit_settings.value;</td>
                         <td>
                             <input dojoType='dijit.form.TextBox' jsId='osEditTextBox'/>
                             <input dojoType='dijit.form.CurrencyTextBox' jsId='osEditCurrencyTextBox'/>
         <span id='os-true' class='hidden'>&common.true;</span>
         <span id='os-false' class='hidden'>&common.false;</span>
         <div dojoType="openils.widget.ProgressDialog" jsId="progressDialog" indeterminate="true"></div>
-        <div class="hidden"></div>
+        <div id='proci18n' class="hidden">&staff.server.admin.org_unit_settings.processing;</div>
+        <div id="noresults" class="hidden">&staff.server.admin.org_unit_settings.no_results;</div>
+        <div id="jsonoutput" class='hidden'  dojoType="dijit.Dialog" jsId='osJSONOutDialog'>
+            <table>
+            <tr><td>Copy this to your clipboard and save it to a file to export the settings.</td></tr>
+            <tr><td><textarea id="jsonOutput"></textarea></td></tr>
+            </table>
+        </div>
     </body>
-</html>
-
+</html>
\ No newline at end of file
index 3968a6f..f73ab08 100644 (file)
@@ -20,6 +20,7 @@ common.unimplemented=Not yet implemented
 common.yes=Yes
 common.no=No
 common.check_to_confirm=Check here to confirm this message
+common.processing=Processing
 lang.version=remote v1
 openils.global_util.clear_cache.error=Problem clearing the cache: %1$s
 openils.global_util.clipboard.error=Clipboard action failed: %1$s