[open-ils-commits] r19173 - in trunk/Open-ILS/web: js/dojo/openils/widget js/ui/default/serial/subscription templates/default/serial/subscription (senator)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Jan 12 17:50:22 EST 2011
Author: senator
Date: 2011-01-12 17:50:16 -0500 (Wed, 12 Jan 2011)
New Revision: 19173
Modified:
trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
trunk/Open-ILS/web/js/dojo/openils/widget/HoldingCode.js
trunk/Open-ILS/web/js/ui/default/serial/subscription/issuance.js
trunk/Open-ILS/web/templates/default/serial/subscription/issuance.tt2
Log:
Serials: In the holding code mini wizard of the alt serials controls, pre-
populate any Year, Season, Month or Day fields based on issuance.date_published
to reduce the need for redundant user input.
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2011-01-12 21:11:08 UTC (rev 19172)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/AutoFieldWidget.js 2011-01-12 22:50:16 UTC (rev 19173)
@@ -184,10 +184,14 @@
if(this.parentNode) // may already be in the "right" place
this.parentNode.appendChild(this.widget.domNode);
if (this.shove) {
- if (this.shove.mode == "update")
- this.widget.attr("value", this.widgetValue);
- else
+ if (this.shove.mode == "update") {
+ if (this.idlField.datatype == "timestamp")
+ this.widgetValue = openils.Util.timeStampAsDateObj(
+ this.widgetValue
+ );
+ } else {
this.widgetValue = this.shove.create;
+ }
this._widgetLoaded();
} else if (this.widget.attr("value") == null) {
this._widgetLoaded();
Modified: trunk/Open-ILS/web/js/dojo/openils/widget/HoldingCode.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/widget/HoldingCode.js 2011-01-12 21:11:08 UTC (rev 19172)
+++ trunk/Open-ILS/web/js/dojo/openils/widget/HoldingCode.js 2011-01-12 22:50:16 UTC (rev 19173)
@@ -77,6 +77,7 @@
dojo.create("td", null, tr)
);
input.startup();
+ wizard.preset_input_by_date(input, field.caption.toLowerCase());
inputs.push({"subfield": field.subfield, "input": input});
}
);
@@ -111,6 +112,30 @@
dojo.place(table, div, "only");
}
+ /* Approximate a season value given a date using the same logic as
+ * OpenILS::Utils::MFHD::Holding::chron_to_date().
+ */
+ function _loose_season(D) {
+ var m = D.getMonth() + 1;
+ var d = D.getDate();
+
+ if (
+ (m == 1 || m == 2) || (m == 12 && d >= 21) || (m == 3 && d < 20)
+ ) {
+ return 24; /* MFHD winter */
+ } else if (
+ (m == 4 || m == 5) || (m == 3 && d >= 20) || (m == 6 && d < 21)
+ ) {
+ return 21; /* spring */
+ } else if (
+ (m == 7 || m == 8) || (m == 6 && d >= 21) || (m == 9 && d < 22)
+ ) {
+ return 22; /* summer */
+ } else {
+ return 23; /* autumn */
+ }
+ }
+
dojo.declare(
"openils.widget.HoldingCode", dijit.layout.ContentPane, {
"constructor": function(args) {
@@ -161,7 +186,31 @@
"update_scap_selector": function(selector) {
this.args.scap_selector = selector;
this.attr("value", "");
- }
+ },
+
+ "preset_input_by_date": function(input, chron_part) {
+ try {
+ input.attr("value", {
+ /* NOTE: week is specifically not covered. I'm
+ * not sure there's an acceptably standard way
+ * to number the weeks in a year. Do we count
+ * from the week of January 1? Or the first week
+ * with a day of the week matching our example
+ * date? Do weeks run Mon-Sun or Sun-Sat?
+ */
+ "year": function(d) { return d.getFullYear(); },
+ "season": function(d) { return _loose_season(d); },
+ "month": function(d) { return d.getMonth() + 1; },
+ "day": function(d) { return d.getDate(); },
+ "hour": function(d) { return d.getHours(); },
+ }[chron_part](this.date_widget.attr("value"))
+ );
+ } catch (E) {
+ ; /* Oh well; can't win them all. */
+ }
+ },
+
+ "date_widget": null
}
);
}
Modified: trunk/Open-ILS/web/js/ui/default/serial/subscription/issuance.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/serial/subscription/issuance.js 2011-01-12 21:11:08 UTC (rev 19172)
+++ trunk/Open-ILS/web/js/ui/default/serial/subscription/issuance.js 2011-01-12 22:50:16 UTC (rev 19173)
@@ -41,6 +41,12 @@
};
grid.overrideEditWidgets.holding_code.startup();
}
+
+ grid.overrideEditWidgets.date_published =
+ new dijit.form.DateTextBox();
+ grid.overrideEditWidgets.date_published.shove = {};
+ grid.overrideEditWidgets.holding_code.date_widget =
+ grid.overrideEditWidgets.date_published;
}
}
);
Modified: trunk/Open-ILS/web/templates/default/serial/subscription/issuance.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/serial/subscription/issuance.tt2 2011-01-12 21:11:08 UTC (rev 19172)
+++ trunk/Open-ILS/web/templates/default/serial/subscription/issuance.tt2 2011-01-12 22:50:16 UTC (rev 19173)
@@ -5,7 +5,7 @@
<span dojoType="dijit.form.Button"
onclick="iss_grid.refresh();">Refresh Grid</span>
<span dojoType="dijit.form.Button"
- onclick="iss_grid.showCreateDialog();">New Issuance</span>
+ onclick="iss_grid.showCreatePane();">New Issuance</span>
<span dojoType="dijit.form.Button"
onclick="iss_grid.deleteSelected();">Delete Selected</span>
</div>
More information about the open-ils-commits
mailing list