- 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
.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; }
};
/**
+ * 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"
*/
"[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"
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();
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();
);
progress_dialog.hide();
}
-
};
this.init.apply(this, arguments);
}
}
-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);
}
}
}
);
- 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)
+ );
}
);
);
},
"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(
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) {
};
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);
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() {
<?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">
<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" />
<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">
<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"
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
);
},
}
.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; }