Added the following features/imporovements suggested by the community:
authorJoseph Lewis <joehms22@gmail.com>
Thu, 7 Jul 2011 19:21:53 +0000 (13:21 -0600)
committerJason Etheridge <jason@esilibrary.com>
Thu, 15 Sep 2011 16:18:02 +0000 (12:18 -0400)
 * Sort history by date descending.
 * Add revert button to history.
 * Search after pause.
 * Dynamically adjust amount of time message is shown by its length.
 * Fix a bug about things not being shown in history after delete.
 * Fix a problem with user not being shown change if they make a change in a
   context that isn't currently shown.
 * Do i18n on everything.

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/src/sql/Pg/005.schema.actors.sql
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

index 587b785..4306245 100644 (file)
@@ -486,6 +486,25 @@ CREATE TRIGGER log_ous_change
     BEFORE INSERT OR UPDATE ON actor.org_unit_setting
     FOR EACH ROW EXECUTE PROCEDURE ous_change_log();
 
+CREATE OR REPLACE FUNCTION ous_delete_log() RETURNS TRIGGER AS $ous_delete_log$
+    DECLARE
+    original TEXT;
+    BEGIN
+        -- Check for which setting is being updated, and log it.
+        SELECT INTO original value FROM actor.org_unit_setting WHERE name = OLD.name AND org_unit = OLD.org_unit;
+                
+        INSERT INTO config.org_unit_setting_type_log (org,original_value,new_value,field_name) VALUES (OLD.org_unit, original, 'null', OLD.name);
+        
+        RETURN OLD;
+    END;
+$ous_delete_log$ LANGUAGE plpgsql;    
+
+CREATE TRIGGER log_ous_del
+    BEFORE DELETE ON actor.org_unit_setting
+    FOR EACH ROW EXECUTE PROCEDURE ous_delete_log();
+
+
+
 
 CREATE TABLE actor.usr_address (
        id                      SERIAL  PRIMARY KEY,
index 0af38c2..966e8f2 100644 (file)
 <!ENTITY staff.server.admin.org_unit_settings.history_date "Date Changed">
 <!ENTITY staff.server.admin.org_unit_settings.history_orig "Original Value">
 <!ENTITY staff.server.admin.org_unit_settings.history_new "New Value">
+<!ENTITY staff.server.admin.org_unit_settings.history_revert "Revert">
+<!ENTITY staff.server.admin.org_unit_settings.not_chosen "The setting you edited is not the currently chosen org unit, therefore the changes you made are not visible.">
 <!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 1559c1c..55b5164 100644 (file)
@@ -131,6 +131,17 @@ function osDraw(specific_setting) {
     osDrawNames(names);
 }
 
+/**
+ * Auto searches 500ms after entering text.
+ */
+var osCurrentSearchTimeout;
+function osSearchChange() {
+    if(osCurrentSearchTimeout != null)
+        clearTimeout(osCurrentSearchTimeout);
+        
+    osCurrentSearchTimeout = setTimeout("doSearch()", 500);
+}
+
 //Limits those functions seen to the ones that have similar text to 
 //that which is provided. Not case sensitive.
 function osLimitSeen(text) {
@@ -167,6 +178,8 @@ function osLimitSeen(text) {
 }
 
 function doSearch() {
+    osCurrentSearchTimeout = null;
+    
     var query = dojo.byId('searchBox').value;
     
     osLimitSeen(query);
@@ -434,9 +447,7 @@ function osEditSetting(deleteMe) {
     var obj = {};
     if(deleteMe) {
         obj[name] = null;
-
     } else {
-
         if(osSettings[name].fm_class) {
             var val = osEditAutoWidget.attr('value');
             osEditAutoWidget.domNode.parentNode.removeChild(osEditAutoWidget.domNode);
@@ -478,11 +489,26 @@ function osUpdateSetting(obj, context, name) {
                 if(e = openils.Event.parse(res))
                     return alert(e);
                 osDraw(obj);
+                if(context != osContextSelector.getValue())
+                    showAlert(dojo.byId('os-not-chosen').innerHTML);
             }
         }
     );
 }
 
+function osRevertSetting(context, name, value) {
+    osHistDialog.hide();
+
+    var obj = {};
+    
+    if(value == 'null' || value == null)
+        obj[name] = null;
+    else
+        obj[name] = value;
+    
+    osUpdateSetting(obj, context, name);
+}
+
 function osGetHistoryLink(rowIdx) {
     var data = this.grid.model.getRow(rowIdx);
     if(!data) return '';
@@ -500,23 +526,33 @@ function osLaunchHistory(name) {
     
     var data = dojo.byId('histTitle').innerHTML;
     var thisHist = pcrud.search('coustl', {'field_name':name});
-    for(var i in thisHist) {
-         data += "<tr><td>" + thisHist[i].date_applied() + "</td><td>" + 
-         ouNames[thisHist[i].org()] + "</td><td>" + thisHist[i].original_value() +
-         "</td><td>" + thisHist[i].new_value() + "</td></tr>";
+    for(var i in thisHist.reverse()) {
+        d = thisHist[i].date_applied();
+        a = ouNames[thisHist[i].org()];
+        o = thisHist[i].original_value();
+        n = thisHist[i].new_value();
+        r = thisHist[i].org();
+        // Table is: Date | Org Name | Orig Value | New Value | Revert
+        data += "<tr><td>" + d + "</td><td>" + a + "</td><td>" + o +
+        "</td><td>" + n + "</td><td>" +
+        "<a href='javascript:void(0);' onclick='osRevertSetting(" + r + ", &quot;" + name +"&quot;,"+o+");'>"+dojo.byId('os-revert').innerHTML+"</a></td></tr>";
     }
         
     dojo.byId('historyData').innerHTML = data;
     
     showProcessingDialog(false);
     osHistDialog.show();
-
 }
 
 function showAlert(message, timeout) {
-     if(timeout == null)
+    if(timeout == null) {
         timeout = 3000;
-        
+        if(message.length > 50)
+            timeout = 5000;
+        if(message.length > 80)
+            timeout = 8000;
+    }
+    
     dojo.removeClass('msgCont', 'hidden');
     
     dojo.byId('msgInner').innerHTML = message;
index 988ad21..df6d7da 100644 (file)
@@ -88,7 +88,7 @@
                     <span dojoType="dijit.ToolbarSeparator" />
                     
                     <form id='searchform' onSubmit='return doSearch()'>
-                            <input type='text' dojoType='dijit.form.TextBox' id='searchBox' />
+                            <input type='text' dojoType='dijit.form.TextBox' id='searchBox' onkeypress='osSearchChange();' />
                             <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>
                         <td>&staff.server.admin.org_unit_settings.context;</td>
                         <td> 
                             <select dojoType="openils.widget.OrgUnitFilteringSelect" jsId='osEditContextSelector'
-                                searchAttr="shortname" autocomplete="true" labelAttr='shortname'> 
-                            </select>
+                                searchAttr="shortname" autocomplete="true" labelAttr='shortname' />
                         </td>
                     </tr>
                     <tr>
         <span id='os-true' class='hidden'>&common.true;</span>
         <span id='os-false' class='hidden'>&common.false;</span>
         <span id='os-copy' class='hidden'>&staff.server.admin.org_unit_settings.copy;</span>
+        <span id='os-revert' class='hidden'>&staff.server.admin.org_unit_settings.history_revert;</span>
+        <span id='os-not-chosen' class='hidden'>&staff.server.admin.org_unit_settings.not_chosen;</span>
         
         <!--Export Dialog-->
         <div id='jsonOutputDialog' dojoType='dijit.Dialog' jsId='osJSONOutDialog' title='&staff.server.admin.org_unit_settings.export;'>