From 4af6d17a09ad214c63724a47ff7113d70fc3f849 Mon Sep 17 00:00:00 2001 From: Joseph Lewis Date: Thu, 7 Jul 2011 13:21:53 -0600 Subject: [PATCH] Added the following features/imporovements suggested by the community: * 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 Signed-off-by: Thomas Berezansky Signed-off-by: Jason Etheridge --- Open-ILS/src/sql/Pg/005.schema.actors.sql | 19 ++++++++ Open-ILS/web/opac/locale/en-US/lang.dtd | 2 + .../staff_client/server/admin/org_unit_settings.js | 54 ++++++++++++++++++---- .../server/admin/org_unit_settings.xhtml | 7 +-- 4 files changed, 70 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/sql/Pg/005.schema.actors.sql b/Open-ILS/src/sql/Pg/005.schema.actors.sql index 587b785b9e..430624571f 100644 --- a/Open-ILS/src/sql/Pg/005.schema.actors.sql +++ b/Open-ILS/src/sql/Pg/005.schema.actors.sql @@ -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, diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 0af38c262d..966e8f2866 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -1822,6 +1822,8 @@ + + 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 index 1559c1c6c7..55b51648ef 100644 --- a/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js +++ b/Open-ILS/xul/staff_client/server/admin/org_unit_settings.js @@ -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 += "" + thisHist[i].date_applied() + "" + - ouNames[thisHist[i].org()] + "" + thisHist[i].original_value() + - "" + thisHist[i].new_value() + ""; + 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 += "" + d + "" + a + "" + o + + "" + n + "" + + ""+dojo.byId('os-revert').innerHTML+""; } 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; 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 index 988ad21ea7..df6d7da66f 100644 --- a/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml +++ b/Open-ILS/xul/staff_client/server/admin/org_unit_settings.xhtml @@ -88,7 +88,7 @@
- +
@@ -141,8 +141,7 @@ &staff.server.admin.org_unit_settings.context; + searchAttr="shortname" autocomplete="true" labelAttr='shortname' /> @@ -178,6 +177,8 @@ + +
-- 2.11.0