From 37b324f53adb4fb90fe17ada72d44fca1d606e9f Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Mon, 26 Mar 2012 16:28:04 -0400 Subject: [PATCH] Serial Control: Use Dijit-based issuance editor The serial control interfaces use editors derived from the XUL copy editor, while the alternate control uses Dijit editors. This commit takes a small step toward unification by using the Dijit issuance editor within the serial control interface, with the following benefits: 1) Both controls will have a very similar editor look and feel 2) Takes advantage of custom holding code wizard widget 3) Future fixes and enhancements to the editors will apply easily to both controls 4) Begin deprecating XUL serial editors This commit doesn't yet rip out the old issuance editor code, as that should wait until the transition is more complete. Signed-off-by: Dan Wells Signed-off-by: Mike Rylander --- Open-ILS/src/templates/serial/edit_siss.tt2 | 17 ++++ .../web/js/dojo/openils/serial/nls/serial.js | 5 ++ .../web/js/ui/default/serial/edit_siss.js | 84 +++++++++++++++++++ .../staff_client/server/serial/manage_subs.js | 37 +++++--- .../server/serial/siss_editor.xul | 25 +----- 5 files changed, 134 insertions(+), 34 deletions(-) create mode 100644 Open-ILS/src/templates/serial/edit_siss.tt2 create mode 100644 Open-ILS/web/js/dojo/openils/serial/nls/serial.js create mode 100644 Open-ILS/web/js/ui/default/serial/edit_siss.js diff --git a/Open-ILS/src/templates/serial/edit_siss.tt2 b/Open-ILS/src/templates/serial/edit_siss.tt2 new file mode 100644 index 0000000000..55732899b2 --- /dev/null +++ b/Open-ILS/src/templates/serial/edit_siss.tt2 @@ -0,0 +1,17 @@ +[% WRAPPER 'base.tt2' %] + + + + + +
+
+
+ +[% END %] diff --git a/Open-ILS/web/js/dojo/openils/serial/nls/serial.js b/Open-ILS/web/js/dojo/openils/serial/nls/serial.js new file mode 100644 index 0000000000..482e9144ba --- /dev/null +++ b/Open-ILS/web/js/dojo/openils/serial/nls/serial.js @@ -0,0 +1,5 @@ +{ + "CREATE_ISSUANCE": "Create Issuance", + "MODIFY_ISSUANCE": "Modify Issuance", + "SAVE_SUCCESSFUL": "Save Successful" +} diff --git a/Open-ILS/web/js/ui/default/serial/edit_siss.js b/Open-ILS/web/js/ui/default/serial/edit_siss.js new file mode 100644 index 0000000000..2fd84952df --- /dev/null +++ b/Open-ILS/web/js/ui/default/serial/edit_siss.js @@ -0,0 +1,84 @@ +dojo.require('dijit.form.TextBox'); +dojo.require('dijit.form.Button'); +dojo.require('dijit.form.FilteringSelect'); +dojo.require('openils.PermaCrud'); +dojo.require('openils.widget.EditPane'); +dojo.require("openils.widget.HoldingCode"); + +dojo.requireLocalization('openils.serial', 'serial'); +var localeStrings = dojo.i18n.getLocalization('openils.serial', 'serial'); + +// fresh_scap_selector needs these defined as globals XXX rework? +var pcrud; +var sub_id; + +function drawSiss(siss_id, ssub_id) { + var iss_grid = { overrideEditWidgets : {} }; + + iss_grid.overrideEditWidgets.creator = + new dijit.form.TextBox({"disabled": true}); + iss_grid.overrideEditWidgets.creator.shove = { + "create": openils.User.user.id() + }; + + iss_grid.overrideEditWidgets.editor = + new dijit.form.TextBox({ + "disabled": true, "value": openils.User.user.id() + }); + + iss_grid.overrideEditWidgets.holding_type = + new dijit.form.TextBox({"disabled": true}); + + var pane_args = { + hideActionButtons : true, + overrideWidgets : iss_grid.overrideEditWidgets + } + + var button_label; + pcrud = new openils.PermaCrud(); + if (siss_id == 'new') { + sub_id = ssub_id; + pane_args.fmClass = 'siss'; + pane_args.mode = 'create'; + pane_args.onPostSubmit = function(req, cudResults){ + //TODO: better success check + alert(localeStrings.SAVE_SUCCESSFUL); + //location.href = location.href.replace(/new\/.*/, cudResults[0].id()); + parent.document.getElementById(window.name).refresh_command(); + } + button_label = localeStrings.CREATE_ISSUANCE; + } else { + pane_args.fmObject = pcrud.retrieve('siss', siss_id); + pane_args.onPostSubmit = function(req, cudResults){ + //alert('req: '+req.toSource()); + //alert('cudResults: '+cudResults); + //TODO: better success check + alert(localeStrings.SAVE_SUCCESSFUL); + parent.document.getElementById(window.name).refresh_command(); + } + sub_id = pane_args.fmObject.subscription(); + button_label = localeStrings.MODIFY_ISSUANCE; + } + iss_grid.overrideEditWidgets.subscription = + new dijit.form.TextBox({ + "disabled": true, "value": sub_id + }); + fresh_scap_selector(iss_grid); // embed scap wizard into generated form + + var pane = new openils.widget.EditPane( + pane_args, dojo.byId('edit-pane') + ); + + pane.fieldOrder = ['subscription','creator','editor','label','date_published','caption_and_pattern','holding_type']; + pane.suppressFields = ['id', 'holding_link_id','create_date','edit_date']; + pane.startup(); + + var tbody = pane.table.getElementsByTagName('tbody')[0]; + var applySpan = document.createElement('span'); + tbody.appendChild(document.createElement('tr').appendChild(document.createElement('td').appendChild(applySpan))); + new dijit.form.Button({ + label: button_label, + onClick: function() {pane.performAutoEditAction();} + }, applySpan); + +} diff --git a/Open-ILS/xul/staff_client/server/serial/manage_subs.js b/Open-ILS/xul/staff_client/server/serial/manage_subs.js index 74ca397796..5c7f83f159 100644 --- a/Open-ILS/xul/staff_client/server/serial/manage_subs.js +++ b/Open-ILS/xul/staff_client/server/serial/manage_subs.js @@ -45,19 +45,36 @@ serial.manage_subs.prototype = { var obj = this; try { $('serial_manage_subs_editor_deck').selectedIndex = obj.editor_indexes[type]; - var editor_type = type + '_editor'; - if (typeof obj[editor_type] == 'undefined') { - JSAN.use('serial.' + editor_type); - obj[editor_type] = new serial[editor_type](); - } - params.do_edit = true; - params.handle_update = true; - if (mode == 'add') { + if (type == "siss") { // begin transition from xul to dojo editors + var iframe = dojo.byId('alt_siss_editor'); + var src; + if (mode == "add") { + src = '/eg/serial/edit_siss/new/' + params.sisses[0].subscription(); + iframe.refresh_command = function () {obj.refresh_list();}; + } else { + src = '/eg/serial/edit_siss/' + params.siss_ids[0]; + iframe.refresh_command = function () { /* TODO: redraw tree node */ }; + } + iframe.setAttribute("src", src); + } else { + var editor_type = type + '_editor'; + if (typeof obj[editor_type] == 'undefined') { + JSAN.use('serial.' + editor_type); + obj[editor_type] = new serial[editor_type](); + } + + params.do_edit = true; + params.handle_update = true; params.trigger_refresh = true; - params.refresh_command = function () {obj.refresh_list();}; + if (mode == 'add') { + params.refresh_command = function () {obj.refresh_list();}; + } else { + params.refresh_command = function () {obj.remap_node(type, this);}; + } + + obj[editor_type].init(params); } - obj[editor_type].init(params); } catch(E) { obj.error.standard_unexpected_error_alert('editor_init() error',E); } diff --git a/Open-ILS/xul/staff_client/server/serial/siss_editor.xul b/Open-ILS/xul/staff_client/server/serial/siss_editor.xul index 3e80105999..85dd84d9ed 100644 --- a/Open-ILS/xul/staff_client/server/serial/siss_editor.xul +++ b/Open-ILS/xul/staff_client/server/serial/siss_editor.xul @@ -11,30 +11,7 @@ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - - - - - - - - -