dojo.require('openils.PermaCrud');
dojo.require('openils.widget.AutoFieldWidget');
dojo.require('openils.widget.ProgressDialog');
+dojo.require('dijit.Toolbar');
var authtoken;
var contextOrg;
var user;
var osSettings = {};
var ouSettingValues = {};
+var ouSettingNames = {};
var osEditAutoWidget;
var perm_codes = {};
var osGroups = {};
var searchAssist = [];
var pcrud;
-var osHistory = {};
function osInit(data) {
+ showProcessingDialog(true);
+
authtoken = new openils.CGI().param('ses') || dojo.cookie('ses');
user = new openils.User({authtoken:authtoken});
contextOrg = user.user.ws_ou();
var grps = pcrud.retrieveAll('csg');
dojo.forEach(grps, function(grp) { osGroups[grp.name()] = grp.label(); });
- //osHistory = pcrud.retrieveAll('coustl');
-
var connect = function() {
dojo.connect(contextOrg, 'onChange', osChangeContext);
}
}
);
+
+ showProcessingDialog(false);
}
dojo.addOnLoad(osInit);
//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();
+ showAlert(dojo.byId('noresults').innerHTML);
return;
}
ouSettingValues = {}; // Clear the values.
- osDrawNames(names);
+ osDrawNames(names); // Repopulate setting values with the ones we want.
}
function doSearch() {
- var query = dojo.byId("searchBox").value;
+ var query = dojo.byId('searchBox').value;
+
osLimitSeen(query);
return false; //Keep form from submitting
}
function clearSearch() {
- dojo.byId("searchBox").value = "";
- osDraw();
+ if(dojo.byId('searchBox').value != '') { // Don't refresh on blank.
+ dojo.byId('searchBox').value = '';
+ doSearch();
+ }
}
function osToJson() {
osJSONOutDialog.show();
}
+// Copies the text from the json output to the clipboard.
function osJsonOutputCopy() {
document.popupNode = dojo.byId('jsonOutput');
- document.getElementById('jsonOutput').focus();
- document.getElementById('jsonOutput').select();
+ dojo.byId('jsonOutput').focus();
+ dojo.byId('jsonOutput').select();
util.clipboard.copy();
+ showAlert(dojo.byId('os-copy').innerHTML);
}
function osJsonInputPaste() {
}
function osUpdateSetting(obj, context, name) {
-
-
fieldmapper.standardRequest(
['open-ils.actor', 'open-ils.actor.org_unit.settings.update'],
{ async: true,
}
);
}
+
+function osGetHistoryLink(rowIdx) {
+ var data = this.grid.model.getRow(rowIdx);
+ if(!data) return '';
+ return data.name;
+}
+
+function osFormatHistoryLink(name) {
+ return this.value.replace(/SETTING/, name);
+}
+
+function osLaunchHistory(name) {
+ showProcessingDialog(true);
+
+ dojo.byId('osHistName').innerHTML = osSettings[name].label;
+
+ 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>" +
+ thisHist[i].org() + "</td><td>" + thisHist[i].original_value() +
+ "</td><td>" + thisHist[i].new_value() + "</td></tr>";
+ }
+
+ dojo.byId('historyData').innerHTML = data;
+
+ showProcessingDialog(false);
+ osHistDialog.show();
+
+}
+
+function showAlert(message, timeout) {
+ if(timeout == null)
+ timeout = 3000;
+
+ dojo.removeClass('msgCont', 'hidden');
+
+ dojo.byId('msgInner').innerHTML = message;
+
+ var fadeArgs = {
+ node: "msgCont"
+ };
+ dojo.fadeIn(fadeArgs).play();
+
+ window.setTimeout('hideAlert()', timeout);
+
+}
+
+function hideAlert() {
+ var fadeArgs = {
+ node: "msgCont"
+ };
+ dojo.fadeOut(fadeArgs).play();
+ dojo.addClass('msgCont', 'hidden');
+}
<script type="text/javascript" src='org_unit_settings.js' />
<script type="text/javascript" src="/xul/server/util/clipboard.js" />
<style type="text/css">
+ h1 {
+ display:inline;
+ padding:5px;
+ }
+
.form_table textarea {
width:500px;
height:15em;
}
+
+ #searchform {
+ display:inline;
+ }
+
+ .message {
+ float:left;
+ left:-50%;
+ text-align:center;
+
+ padding:5px;
+
+ position:relative;
+ background-color:#D9E8F9;
+
+ /*Standards compliant*/
+ border-bottom-left-radius:5px;
+ border-bottom-right-radius:5px;
+
+ /*Old staff client compliant, It could be worse, we could be using IE!*/
+ -moz-border-radius-bottomleft:5px;
+ -moz-border-radius-bottomright:5px;
+ }
+
+ .message_container {
+ float:left;
+ left:50%;
+ top:0%;
+ position: absolute;
+ opacity:0;
+ }
+
</style>
</head>
- <body class="tundra tall">
- <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_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>
+ <body class='tundra tall'>
+ <div dojoType='dijit.layout.LayoutContainer' orientation='vertical' class='tall'>
+ <div dojoType='dijit.layout.ContentPane' layoutAlign='top'>
+ <div id="toolbar1" dojoType="dijit.Toolbar">
+ <strong>&staff.server.admin.org_unit_settings.title;</strong>
+
+ <span dojoType="dijit.ToolbarSeparator" />
+
+ <span>&staff.server.admin.org_unit_settings.context_loc;</span>
+ <select dojoType='openils.widget.OrgUnitFilteringSelect' jsId='osContextSelector'
+ searchAttr='shortname' autocomplete='true' labelAttr='shortname' onchange='osChangeContext();' />
+
+ <span dojoType="dijit.ToolbarSeparator" />
+
+ <form id='searchform' 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();">&staff.server.admin.org_unit_settings.export;</button>
- <button dojoType='dijit.form.Button' onClick="osFromJson();">&staff.server.admin.org_unit_settings.import;</button>
+
+ <span dojoType="dijit.ToolbarSeparator" />
+
+ <button dojoType='dijit.form.Button' onClick='osToJson();'>&staff.server.admin.org_unit_settings.export;</button>
+ <button dojoType='dijit.form.Button' onClick='osFromJson();'>&staff.server.admin.org_unit_settings.import;</button>
+ </div>
+ <span>&staff.server.admin.org_unit_settings.uninherited;</span>
</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>
get: osGetEditLink,
formatter : osFormatEditLink
},
+ { name: '&staff.server.admin.org_unit_settings.history;',
+ value: '<a href="javascript:void(0);" onclick="osLaunchHistory(\'SETTING\');">&staff.server.admin.org_unit_settings.history;</a>',
+ get: osGetHistoryLink,
+ formatter : osFormatHistoryLink
+ },
{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'},
<div id='noresults' class='hidden'>&staff.server.admin.org_unit_settings.no_results;</div>
<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>
<!--Export Dialog-->
- <div id="jsonOutputDialog" dojoType="dijit.Dialog" jsId='osJSONOutDialog' title="&staff.server.admin.org_unit_settings.export;">
- <table class="form_table">
+ <div id='jsonOutputDialog' dojoType='dijit.Dialog' jsId='osJSONOutDialog' title='&staff.server.admin.org_unit_settings.export;'>
+ <table class='form_table'>
<tr><td>&staff.server.admin.org_unit_settings.export_copy_label;</td></tr>
- <tr><td><textarea id="jsonOutput" /></td></tr>
+ <tr><td><textarea id='jsonOutput' /></td></tr>
<tr><td><button dojoType='dijit.form.Button' onclick='osJsonOutputCopy();'>&staff.server.admin.org_unit_settings.copy;</button></td></tr>
</table>
</div>
<!--Import Dialog-->
- <div id="jsonInputDialog" dojoType="dijit.Dialog" jsId='osJSONInDialog' title="&staff.server.admin.org_unit_settings.import;">
- <table class="form_table">
+ <div id='jsonInputDialog' dojoType='dijit.Dialog' jsId='osJSONInDialog' title='&staff.server.admin.org_unit_settings.import;'>
+ <table class='form_table'>
<tr><td>&staff.server.admin.org_unit_settings.import_paste_label;</td></tr>
- <tr><td><textarea id="jsonInput" /></td></tr>
- <tr><td><button dojoType='dijit.form.Button' onclick='osJsonInputPaste();'>&staff.server.admin.org_unit_settings.paste;</button><button type="submit" dojoType='dijit.form.Button' onclick='osFromJsonSubmit();'>&staff.server.admin.org_unit_settings.submit;</button></td></tr>
+ <tr><td><textarea id='jsonInput' /></td></tr>
+ <tr><td><button dojoType='dijit.form.Button' onclick='osJsonInputPaste();'>&staff.server.admin.org_unit_settings.paste;</button><button type='submit' dojoType='dijit.form.Button' onclick='osFromJsonSubmit();'>&staff.server.admin.org_unit_settings.submit;</button></td></tr>
+ </table>
+ </div>
+
+ <!--History Dialog-->
+ <div id="historyDialog" dojoType="dijit.Dialog" jsId="osHistDialog" title="&staff.server.admin.org_unit_settings.history;">
+ <span id='osHistName' />
+
+ <!--Headers grabbed from this table are put in the next one by the js.-->
+ <table id="histTitle" class="hidden">
+ <tr>
+ <td>&staff.server.admin.org_unit_settings.history_date;</td>
+ <td>&staff.server.admin.org_unit_settings.history_unit;</td>
+ <td>&staff.server.admin.org_unit_settings.history_orig;</td>
+ <td>&staff.server.admin.org_unit_settings.history_new;</td>
+ </tr>
</table>
+
+ <table class="form_table" id="historyData" />
</div>
+ <!--Displays alerts at the top of the screen, much nicer than alert() or dojo equiv.-->
+ <div class="message_container" id="msgCont">
+ <div class="message" id='msgInner' />
+ </div>
</body>
</html>
\ No newline at end of file