From: Joseph Lewis <joehms22@gmail.com> Date: Thu, 9 Jun 2011 19:17:16 +0000 (-0600) Subject: Finished import/export of settings. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e997eb021386bbce171a5b8fafa3d509b8bf9e54;p=evergreen%2Fmasslnc.git Finished import/export of settings. Signed-off-by: Joseph Lewis <joehms22@gmail.com> Signed-off-by: Thomas Berezansky <tsbere@mvlc.org> Signed-off-by: Jason Etheridge <jason@esilibrary.com> --- diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 3c56d5d6d1..84952d452d 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -1810,6 +1810,13 @@ <!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"> 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 a1a5c6a5f5..d243c1813a 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 @@ -3,6 +3,8 @@ dojo.require('dijit.layout.LayoutContainer'); 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'); @@ -156,11 +158,71 @@ function clearSearch() { } 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( @@ -371,11 +433,14 @@ function osEditSetting(deleteMe) { } } } + 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)) 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 5a3c396f8c..4265fa7464 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 @@ -22,11 +22,18 @@ <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"> @@ -44,7 +51,9 @@ <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> @@ -115,10 +124,18 @@ <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>