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,
<!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">
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) {
}
function doSearch() {
+ osCurrentSearchTimeout = null;
+
var query = dojo.byId('searchBox').value;
osLimitSeen(query);
var obj = {};
if(deleteMe) {
obj[name] = null;
-
} else {
-
if(osSettings[name].fm_class) {
var val = osEditAutoWidget.attr('value');
osEditAutoWidget.domNode.parentNode.removeChild(osEditAutoWidget.domNode);
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 '';
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 + ", "" + name +"","+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;
<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;'>