From: senator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Mon, 24 Jan 2011 22:14:57 +0000 (+0000) Subject: Serials: A batch of improvements to the caption/pattern wizard X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0862a6cf6739c74a648a8cac2fd448c8c358dd99;p=evergreen%2Fmasslnc.git Serials: A batch of improvements to the caption/pattern wizard - Using a numeric frequency ($w) now pre-selects the regularity page - Switch the regularity page from a box layout to a grid layout for legibility - Simplify and unify month/date control pairs, enforcing correct limits on days in each month - Scrollbars! - If the user creates $y data in the regularity page, but then unchecks the "use specific regularity information" box, the $y stuff will be correctly excluded from the compiled pattern code. - "Display in Holding Field" replaced with text that better explains what it means - The wizard's dialog window has a title now - In alternate serials control -> subscription details -> captions/patterns tab, if the user has already typed something in the Pattern Code field, they now get a warning that using the wizard will erase their existing work if they click the Wizard button - The captions/pattern tab now treats pattern codes as immutable once created, which is what was apparently intended from the beginning. See http://list.georgialibraries.org/pipermail/open-ils-dev/2010-May/006079.html git-svn-id: svn://svn.open-ils.org/ILS/trunk@19272 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/web/css/skin/default/serial.css b/Open-ILS/web/css/skin/default/serial.css index 625ad67fc4..b1b486ef2f 100644 --- a/Open-ILS/web/css/skin/default/serial.css +++ b/Open-ILS/web/css/skin/default/serial.css @@ -25,3 +25,4 @@ .serial-holding-code tr { border: 0 !important; margin: 0 !important; } .serial-holding-code td { border: 0 !important; padding: 3px; margin: 0 !important; } .serial-holding-code td[colspan="2"] { text-align:center; } +input[readonly] { color: #999; } diff --git a/Open-ILS/web/js/dojo/openils/Util.js b/Open-ILS/web/js/dojo/openils/Util.js index faae916ae6..3ea7d747fa 100644 --- a/Open-ILS/web/js/dojo/openils/Util.js +++ b/Open-ILS/web/js/dojo/openils/Util.js @@ -289,6 +289,13 @@ if(!dojo._hasResource["openils.Util"]) { }; /** + * Convenience function to trim leading and trailing whitespace at once. + */ + openils.Util.trimString = function(s) { + return s.replace(/^\s*(.+)?\s*$/,"$1"); + } + + /** * Assume a space-separated interval string, with optional comma * E.g. "1 year, 2 days" "3 days 6 hours" */ diff --git a/Open-ILS/web/js/ui/default/serial/subscription/caption_and_pattern.js b/Open-ILS/web/js/ui/default/serial/subscription/caption_and_pattern.js index ef7b507a9d..5382de9002 100644 --- a/Open-ILS/web/js/ui/default/serial/subscription/caption_and_pattern.js +++ b/Open-ILS/web/js/ui/default/serial/subscription/caption_and_pattern.js @@ -28,6 +28,17 @@ function SCAPRow() { "[name='pattern_code'] button", this.element )[0]; this.wizard_button.onclick = function() { + if ( + openils.Util.trimString( + self.controls.pattern_code.value + ).length && + !confirm( + "Are you sure you want to erase this pattern code\n" + + "and create a new one via the Wizard?" /* XXX i18n */ + ) + ) { + return; + } try { netscape.security.PrivilegeManager.enablePrivilege( "UniversalXPConnect" @@ -35,7 +46,7 @@ function SCAPRow() { window.openDialog( xulG.url_prefix("/xul/server/serial/pattern_wizard.xul"), "pattern_wizard", - "scrollbars=yes,width=1024", + "width=800", function(value) { self.controls.pattern_code.value = value; self.controls.pattern_code.onchange(); @@ -74,6 +85,18 @@ function SCAPRow() { this.controls.create_date.innerHTML = openils.Util.timeStamp(datum.create_date()); + /* Once created, scap objects' pattern_code field is meant to + * be immutable. + * + * See http://list.georgialibraries.org/pipermail/open-ils-dev/2010-May/006079.html + * + * The DB trigger mentioned was never created to enforce this + * immutability at that level, but this should keep users from + * doing the wrong thing by mistake. + */ + this.controls.pattern_code.readOnly = true; + this.wizard_button.disabled = true; + this.has_changed(false); } else { this.datum = new scap(); @@ -334,7 +357,6 @@ function SCAPImporter() { ); progress_dialog.hide(); } - }; this.init.apply(this, arguments); diff --git a/Open-ILS/xul/staff_client/server/serial/pattern_wizard.js b/Open-ILS/xul/staff_client/server/serial/pattern_wizard.js index c7c42605a2..6874719d83 100644 --- a/Open-ILS/xul/staff_client/server/serial/pattern_wizard.js +++ b/Open-ILS/xul/staff_client/server/serial/pattern_wizard.js @@ -49,24 +49,23 @@ function _menulist(values, labels, items_only) { } } -function _date_validate(date_val, month_val) { - /* general purpose date validation irrespective of year */ - date_val = date_val.trim(); - - if (!date_val.match(/^[0123]?\d$/)) - return false; - - date_val = Number(date_val); /* do NOT use parseInt */ - month_val = Number(month_val); - - if (date_val < 1) { - return false; - } else if (month_val == 2) { - return date_val <= 29; - } else if ([1,3,5,7,8,10,12].indexOf(month_val) != -1) { - return date_val <= 31; +function _cap_number_textbox_value(node, max) { + if (node.value > max) node.value = max; + node.max = max; +} + +function _cap_to_month(month, date_box) { + if (!date_box) + return; + + if (month == "02") { + _cap_number_textbox_value(date_box, 29); + } else if ( + ["09", "04", "06", "11"].indexOf(month) != -1 + ) { + _cap_number_textbox_value(date_box, 30); } else { - return date_val <= 30; + _cap_number_textbox_value(date_box, 31); } } @@ -91,17 +90,13 @@ function CalendarChangeRow() { } ); - var date_month_selector = node_by_name("date_month", this.element); - dojo.attr( - node_by_name("date_day", this.element), "onchange", function(ev) { - if (_date_validate(ev.target.value,date_month_selector.value)){ - return true; - } else { - alert(S("bad_date_value")); - ev.target.focus(); - return false; - } + node_by_name("date_month", this.element), + "oncommand", + function(ev){ + _cap_to_month( + ev.target.value, node_by_name("date_day", self.element) + ); } ); @@ -291,9 +286,22 @@ function RegularityRow() { ); }, "MM": function() { - return _menulist( + var mm = _menulist( _chronstants.month.values, _chronstants.month.names ); + dojo.attr( + mm, "oncommand", function(ev) { + _cap_to_month( + dojo.attr(ev.target, "value"), + dojo.query( + 'textbox[type="number"]', + ev.target.parentNode.parentNode.parentNode + /* ev.target is the menuITEM node */ + )[0] + ); + } + ); + return mm; }, "SS": function() { return _menulist( @@ -372,7 +380,7 @@ function RegularityEditor() { this.rows[id] = new RegularityRow(this.template, id, this); - dojo.place(this.rows[id].element, "y_row_before_this", "before"); + dojo.place(this.rows[id].element, "y_rows_here", "last"); }; this.remove_row = function(id) { @@ -384,10 +392,14 @@ function RegularityEditor() { }; this.compile = function() { - return openils.Util.objectProperties(this.rows).sort().reduce( - function(a, b) { return a.concat(["y", self.rows[b].compile()]); }, - [] - ); + if (!this.active) { + return []; + } else { + return openils.Util.objectProperties(this.rows).sort().reduce( + function(a, b){return a.concat(["y",self.rows[b].compile()]);}, + [] + ); + } }; this._init.apply(this, arguments); @@ -822,6 +834,15 @@ function Wizard() { this.regularity_editor = new RegularityEditor(); this.field_w = dojo.byId("hard_w"); + dojo.attr( + dojo.byId("soft_w"), "onchange", function(ev) { + var use_regularity = dojo.byId("use_regularity"); + if (ev.target.value && !use_regularity.checked) { + use_regularity.checked = true; + use_regularity.doCommand(); + } + } + ); }; this.reset = function() { diff --git a/Open-ILS/xul/staff_client/server/serial/pattern_wizard.xul b/Open-ILS/xul/staff_client/server/serial/pattern_wizard.xul index 4dcf3f9469..7b0469bcc2 100644 --- a/Open-ILS/xul/staff_client/server/serial/pattern_wizard.xul +++ b/Open-ILS/xul/staff_client/server/serial/pattern_wizard.xul @@ -9,6 +9,7 @@ <?xul-overlay href="/xul/server/serial/pattern_wizard_overlay.xul"?> <window id="pattern_wizard_win" + title="Pattern Code Wizard" onload="try{my_init();font_helper();persist_helper();}catch(E){alert(E);}" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> diff --git a/Open-ILS/xul/staff_client/server/serial/pattern_wizard_overlay.xul b/Open-ILS/xul/staff_client/server/serial/pattern_wizard_overlay.xul index a28a40bdf9..37ae93661b 100644 --- a/Open-ILS/xul/staff_client/server/serial/pattern_wizard_overlay.xul +++ b/Open-ILS/xul/staff_client/server/serial/pattern_wizard_overlay.xul @@ -135,7 +135,8 @@ <menupopup> </menupopup> </menulist> - <textbox name="date_day" size="3" /> + <textbox name="date_day" size="3" + type="number" min="1" max="31" /> </hbox> </hbox> <button icon="remove" name="remover" label="Remove" /> @@ -171,7 +172,7 @@ <row id="chron_row_headings"> <label /> <label value="Caption" /> - <label value="Display in holding field?" /> + <label value="Include this actual word in the caption?" /> <label /> </row> <row id="chron_row_template"> @@ -277,47 +278,57 @@ <vbox id="wizard_step_regularity" class="hideme"> <checkbox id="use_regularity" oncommand="wizard.regularity_editor.toggle(event);" - label="Specify regularity information (extra, omitted, - and/or combined issues)?" /> + label="Use specific regularity information (published, + omitted, and/or combined issues)?" /> <vbox id="regularity_editor_here" class="hideme"> - <hbox id="regularity_template_y" align="top"> - <menulist name="poc"> - <menupopup> - <menuitem disabled="true" label="---" /> - <menuitem value="p" label="Published" /> - <menuitem value="o" label="Omitted" /> - <menuitem value="c" label="Combined" /> - </menupopup> - </menulist> - <menulist name="type_and_code_pattern"> - <menupopup> - <menuitem disabled="true" label="---" /> - <menuitem value="d:dd" - label="Day of the week" /> - <menuitem value="d:DD" - label="Day of the month" /> - <menuitem value="d:MMDD" - label="Date of the year" /> - <menuitem value="m:MM" label="Month" /> - <menuitem value="s:SS" label="Season" /> - <menuitem value="w:WWdd" - label="Weekday of the month" /> - <menuitem value="w:MMWWdd" - label="Weekday of specific month" /> - <menuitem value="w:MMWW" - label="Week of specific month" /> - <menuitem value="y:YYYY" - label="Span over two years" /> - </menupopup> - </menulist> - <vbox name="sub_rows_here"></vbox> - <vbox align="top"> - <button label="Add sub-row" icon="add" - disabled="true" name="add_sub_row" /> - <button label="Remove whole row" - icon="remove" name="remove" /> - </vbox> - </hbox> + <grid> + <columns> + <column /> + <column /> + <column /> + <column /> + </columns> + <rows id="y_rows_here"> + <row id="regularity_template_y" align="top"> + <menulist name="poc"> + <menupopup> + <menuitem disabled="true" label="---" /> + <menuitem value="p" label="Published" /> + <menuitem value="o" label="Omitted" /> + <menuitem value="c" label="Combined" /> + </menupopup> + </menulist> + <menulist name="type_and_code_pattern"> + <menupopup> + <menuitem disabled="true" label="---" /> + <menuitem value="d:dd" + label="Day of the week" /> + <menuitem value="d:DD" + label="Day of the month" /> + <menuitem value="d:MMDD" + label="Date of the year" /> + <menuitem value="m:MM" label="Month" /> + <menuitem value="s:SS" label="Season" /> + <menuitem value="w:WWdd" + label="Weekday of the month" /> + <menuitem value="w:MMWWdd" + label="Weekday of specific month" /> + <menuitem value="w:MMWW" + label="Week of specific month" /> + <menuitem value="y:YYYY" + label="Span over two years" /> + </menupopup> + </menulist> + <vbox name="sub_rows_here"></vbox> + <vbox align="top"> + <button label="Add sub-row" icon="add" + disabled="true" name="add_sub_row" /> + <button label="Remove whole row" + icon="remove" name="remove" /> + </vbox> + </row> + </rows> + </grid> <hbox id="y_row_before_this" pack="center" style="padding-top: 1ex;"> <button id="regularity_add_y" diff --git a/Open-ILS/xul/staff_client/server/serial/scap_editor.js b/Open-ILS/xul/staff_client/server/serial/scap_editor.js index 1a54084d8c..73c60217ea 100644 --- a/Open-ILS/xul/staff_client/server/serial/scap_editor.js +++ b/Open-ILS/xul/staff_client/server/serial/scap_editor.js @@ -146,7 +146,7 @@ serial.scap_editor.prototype = { window.openDialog( xulG.url_prefix("/xul/server/serial/pattern_wizard.xul"), "pattern_wizard", - "scrollbars=yes", /* XXX FIXME: scrollbars aren't working. what to do? */ + "width=800", onsubmit ); }, diff --git a/Open-ILS/xul/staff_client/server/skin/serial.css b/Open-ILS/xul/staff_client/server/skin/serial.css index 2ebfa2b6bf..b96bc9902d 100644 --- a/Open-ILS/xul/staff_client/server/skin/serial.css +++ b/Open-ILS/xul/staff_client/server/skin/serial.css @@ -21,3 +21,5 @@ checkbox:focus:not([label]) .checkbox-label-box { } .padded_bottom { padding-bottom: 10px; } description#print_routing_desc { margin: 0; padding: 0 1em; } +#pattern_wizard_main > vbox { padding: 0.5em 0; } +#pattern_wizard_main { overflow: auto; }