<!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.org_unit_settings.export "Export">
+<!ENTITY staff.server.admin.org_unit_settings.import "Import">
+<!ENTITY staff.server.admin.org_unit_settings.export_copy_label "Copy this to your clipboard and save it to a file to export the settings.">
+<!ENTITY staff.server.admin.org_unit_settings.import_paste_label "Paste in your exported settings.">
+<!ENTITY staff.server.admin.org_unit_settings.submit "Submit">
+<!ENTITY staff.server.admin.org_unit_settings.copy "Copy">
+<!ENTITY staff.server.admin.org_unit_settings.paste "Paste">
<!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">
dojo.require('dijit.layout.ContentPane');
dojo.require('dijit.form.FilteringSelect');
dojo.require('dijit.Dialog');
+dojo.require('dijit.form.Textarea');
+dojo.require('dijit.form.ComboBox');
dojo.require('dojox.grid.Grid');
dojo.require('fieldmapper.Fieldmapper');
dojo.require('fieldmapper.dojoData');
}
function osToJson() {
- //console.log(dojo.toJson(ouSettingValues));
- dojo.byId('jsonOutput').value = dojo.toJson(ouSettingValues);
+ var out = dojo.fromJson(dojo.toJson(ouSettingValues)); // Easy deep copy
+ var context = osContextSelector.getValue();
+
+ // Set all of the nulls in the outputs to be part of the current org
+ // this keeps from overwriting later if this file is transfered to another lib.
+ for(key in out)
+ if(out[key] == null)
+ out[key] = {'org':context, 'value':null};
+
+ dojo.byId('jsonOutput').value = dojo.toJson(out);
osJSONOutDialog.show();
}
+function osJsonOutputCopy() {
+ document.popupNode = dojo.byId('jsonOutput');
+ document.getElementById('jsonOutput').focus();
+ document.getElementById('jsonOutput').select();
+ util.clipboard.copy();
+}
+
+function osJsonInputPaste() {
+ document.popupNode = dojo.byId('jsonInput');
+ document.popupNode.focus();
+ document.popupNode.select();
+ util.clipboard.paste();
+}
+
+function osFromJson() {
+ dojo.byId('jsonInput').value = '';
+ osJSONInDialog.show();
+}
+
+function osFromJsonSubmit() {
+ var input = dojo.byId('jsonInput').value;
+ var from = dojo.fromJson(input);
+
+ osJSONInDialog.hide();
+
+ showProcessingDialog(true);
+ for(key in from) {
+
+ //Check that there isn't already set to the same value (speed increase);
+ if( ouSettingValues[key] == null &&
+ from[key]['value'] == null &&
+ osContextSelector.getValue() == from[key]['org'])
+ continue;
+
+ if( ouSettingValues[key] != null &&
+ ouSettingValues[key]['value'] == from[key]['value'] &&
+ ouSettingValues[key]['org'] == from[key]['org'])
+ continue;
+
+ var obj = {};
+ var context;
+
+ if(from[key] != null) {
+ obj[key] = from[key]['value'];
+ context = from[key]['org'];
+ }
+
+ osUpdateSetting(obj, context);
+ }
+ showProcessingDialog(false);
+}
+
//Draws the grid based upon a given array of items to draw.
function osDrawNames(names) {
fieldmapper.standardRequest(
}
}
}
+ osUpdateSetting(obj, osEditContextSelector.getValue());
+}
+function osUpdateSetting(obj, context) {
fieldmapper.standardRequest(
['open-ils.actor', 'open-ils.actor.org_unit.settings.update'],
{ async: true,
- params: [authtoken, osEditContextSelector.getValue(), obj],
+ params: [authtoken, context, obj],
oncomplete: function(r) {
var res = r.recv().content();
if(e = openils.Event.parse(res))
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>&staff.server.admin.org_unit_settings.title;</title>
- <link type='text/css' rel='stylesheet' href='admin.css'/>
- <script type="text/javascript" src='/IDL2js?aou,aout,pgt,au,coust,aous,csg'></script>
- <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:false" src="/js/dojo/dojo/dojo.js"></script>
- <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:false" src="/js/dojo/dojo/openils_dojo.js"></script>
- <script type="text/javascript" src='org_unit_settings.js'></script>
+ <link type='text/css' rel='stylesheet' href='admin.css' />
+ <script type="text/javascript" src='/IDL2js?aou,aout,pgt,au,coust,aous,csg' />
+ <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:false" src="/js/dojo/dojo/dojo.js" />
+ <script type="text/javascript" djConfig="parseOnLoad: true,isDebug:false" src="/js/dojo/dojo/openils_dojo.js" />
+ <script type="text/javascript" src='org_unit_settings.js' />
+ <script type="text/javascript" src="/xul/server/util/clipboard.js" />
+ <style type="text/css">
+ .form_table textarea {
+ width:500px;
+ height:15em;
+ }
+ </style>
</head>
<body class="tundra tall">
<div dojoType="dijit.layout.LayoutContainer" orientation="vertical" class="tall">
<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>
+ <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>
<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>
<div dojoType="openils.widget.ProgressDialog" jsId="progressDialog" indeterminate="true"></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>
+ <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><button dojoType='dijit.form.Button' onclick='osJsonOutputCopy();'>&staff.server.admin.org_unit_settings.copy;</button></td></tr>
+ </table>
+ </div>
+ <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>
</table>
</div>
</body>