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();
dojo.create("td", null, tr)
);
input.startup();
+ wizard.preset_input_by_date(input, field.caption.toLowerCase());
inputs.push({"subfield": field.subfield, "input": input});
}
);
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) {
"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
}
);
}