From ae4d19bb1970273a80279af3c84e27e287d636f6 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Wed, 25 Apr 2018 09:02:54 +0800 Subject: [PATCH] BI-18887 && BI-18734 && BI-18828 --- demo/js/widget/date/demo.datepane.js | 16 ++-- demo/js/widget/date/demo.multidate_combo.js | 16 ++-- dist/bundle.js | 92 ++++++++++++------- dist/demo.js | 32 +++---- dist/widget.js | 92 ++++++++++++------- src/widget/date/calendar/picker.date.js | 4 +- src/widget/datepane/card.static.datepane.js | 4 +- src/widget/datepane/datepane.js | 2 +- .../datetimepane/card.static.datetimepane.js | 2 +- .../dynamicdatetime/dynamicdatetime.combo.js | 4 + .../dynamicdatetime.timeselect.js | 37 +++++++- .../dynamicdatetime.trigger.js | 4 + src/widget/timeinterval/timeinterval.js | 21 +---- src/widget/yearmonth/combo.yearmonth.js | 4 + src/widget/yearmonth/trigger.yearmonth.js | 4 + .../yearmonthinterval/yearmonthinterval.js | 6 +- 16 files changed, 215 insertions(+), 125 deletions(-) diff --git a/demo/js/widget/date/demo.datepane.js b/demo/js/widget/date/demo.datepane.js index 025026a1d..0b2e3cec1 100644 --- a/demo/js/widget/date/demo.datepane.js +++ b/demo/js/widget/date/demo.datepane.js @@ -15,14 +15,14 @@ Demo.DatePane = BI.inherit(BI.Widget, { text: "bi.date_pane" }, { type: "bi.dynamic_date_pane", - value: { - type: 1, - value: { - year: 2017, - month: 12, - day: 11 - } - }, + // value: { + // type: 1, + // value: { + // year: 2017, + // month: 12, + // day: 11 + // } + // }, ref: function (_ref) { self.datepane = _ref; }, diff --git a/demo/js/widget/date/demo.multidate_combo.js b/demo/js/widget/date/demo.multidate_combo.js index 7573a4f6b..9e779bbb2 100644 --- a/demo/js/widget/date/demo.multidate_combo.js +++ b/demo/js/widget/date/demo.multidate_combo.js @@ -21,14 +21,14 @@ Demo.Date = BI.inherit(BI.Widget, { self.datecombo = this; }, width: 300, - value: { - type: 1, - value: { - year: 2018, - month: 2, - day: 23 - } - } + // value: { + // type: 1, + // value: { + // year: 2018, + // month: 2, + // day: 23 + // } + // } }, { type: "bi.button", text: "getValue", diff --git a/dist/bundle.js b/dist/bundle.js index c1df69699..051e32686 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -87709,7 +87709,7 @@ BI.DatePicker = BI.inherit(BI.Widget, { BI.DatePicker.superclass._init.apply(this, arguments); var self = this, o = this.options; this._year = BI.getDate().getFullYear(); - this._month = BI.getDate().getMonth(); + this._month = BI.getDate().getMonth() + 1; this.left = BI.createWidget({ type: "bi.icon_button", cls: "pre-page-h-font", @@ -87744,7 +87744,7 @@ BI.DatePicker = BI.inherit(BI.Widget, { if (self._month === 12) { self.setValue({ year: self.year.getValue() + 1, - month: 0 + month: 1 }); } else { self.setValue({ @@ -88621,7 +88621,7 @@ BI.StaticDatePaneCard = BI.inherit(BI.Widget, { this.today = BI.getDate(); this._year = this.today.getFullYear(); - this._month = this.today.getMonth(); + this._month = this.today.getMonth() + 1; this.selectedTime = o.selectedTime || { year: this._year, @@ -88689,7 +88689,7 @@ BI.StaticDatePaneCard = BI.inherit(BI.Widget, { var today = BI.getDate(); return { year: today.getFullYear(), - month: today.getMonth() + month: today.getMonth() + 1 }; }, @@ -88844,7 +88844,7 @@ BI.shortcut("bi.static_date_pane_card", BI.StaticDatePaneCard);BI.DynamicDatePan var date = BI.getDate(); this.ymd.setValue({ year: date.getFullYear(), - month: date.getMonth() + month: date.getMonth() + 1 }); } else { this.ymd.setValue(value); @@ -89414,7 +89414,7 @@ BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);BI.StaticDateTimePaneCar var today = BI.getDate(); return { year: today.getFullYear(), - month: today.getMonth() + month: today.getMonth() + 1 }; }, @@ -91665,6 +91665,10 @@ BI.shortcut("bi.dynamic_date_trigger", BI.DynamicDateTrigger);BI.DynamicDateTime }, hidePopupView: function () { this.combo.hideView(); + }, + + isValid: function () { + return this.trigger.isValid(); } }); @@ -91941,7 +91945,9 @@ BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDat listeners: [{ eventName: BI.SignEditor.EVENT_CONFIRM, action: function () { - this.setValue(self._formatValueToDoubleDigit(this.getValue())); + var value = this.getValue(); + self._checkHour(value); + this.setValue(self._formatValueToDoubleDigit(value)); self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); } }, { @@ -91973,7 +91979,9 @@ BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDat listeners: [{ eventName: BI.SignEditor.EVENT_CONFIRM, action: function () { - this.setValue(self._formatValueToDoubleDigit(this.getValue()), BI.DynamicDateTimeSelect.MINUTE); + var value = this.getValue(); + self._checkMinute(value); + this.setValue(self._formatValueToDoubleDigit(value), BI.DynamicDateTimeSelect.MINUTE); self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); } }, { @@ -92003,7 +92011,9 @@ BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDat listeners: [{ eventName: BI.SignEditor.EVENT_CONFIRM, action: function () { - this.setValue(self._formatValueToDoubleDigit(this.getValue())); + var value = this.getValue(); + self._checkSecond(value); + this.setValue(self._formatValueToDoubleDigit(value)); self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); } }], @@ -92014,6 +92024,28 @@ BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDat }; }, + _checkBorder: function (v) { + v = v || {}; + this._checkHour(v.hour); + this._checkMinute(v.minute); + this._checkSecond(v.second); + }, + + _checkHour: function (value) { + this.hour.setDownEnable(BI.parseInt(value) > 0); + this.hour.setUpEnable(BI.parseInt(value) < 23); + }, + + _checkMinute: function (value) { + this.minute.setDownEnable(BI.parseInt(value) > 0); + this.minute.setUpEnable(BI.parseInt(value) < 59); + }, + + _checkSecond: function (value) { + this.second.setDownEnable(BI.parseInt(value) > 0); + this.second.setUpEnable(BI.parseInt(value) < 59); + }, + _autoSwitch: function (v, type) { var limit = 0; var value = v; @@ -92022,7 +92054,7 @@ BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDat limit = 2; break; case BI.DynamicDateTimeSelect.MINUTE: - limit = 6; + limit = 5; break; default: break; @@ -92068,6 +92100,7 @@ BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDat this.hour.setValue(v.hour); this.minute.setValue(v.minute); this.second.setValue(v.second); + this._checkBorder(v); } }); @@ -92314,6 +92347,10 @@ BI.extend(BI.DynamicDateTimeSelect, { }, getValue: function () { return this.storeValue; + }, + + isValid: function () { + return this.editor.isValid(); } }); @@ -107800,7 +107837,7 @@ BI.TimeInterval = BI.inherit(BI.Single, { combo.on(BI.DynamicDateTimeCombo.EVENT_VALID, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { @@ -107816,7 +107853,7 @@ BI.TimeInterval = BI.inherit(BI.Single, { combo.on(BI.DynamicDateTimeCombo.EVENT_FOCUS, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { @@ -107833,26 +107870,11 @@ BI.TimeInterval = BI.inherit(BI.Single, { self.left.hidePopupView(); self.right.hidePopupView(); }); - // combo.on(BI.DynamicDateTimeCombo.EVENT_CHANGE, function () { - // BI.Bubbles.hide("error"); - // var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - // if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { - // self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); - // self.element.addClass(self.constants.timeErrorCls); - // BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { - // offsetStyle: "center" - // }); - // self.fireEvent(BI.TimeInterval.EVENT_ERROR); - // } else { - // self._clearTitle(); - // self.element.removeClass(self.constants.timeErrorCls); - // } - // }); combo.on(BI.DynamicDateTimeCombo.EVENT_CONFIRM, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); self.fireEvent(BI.TimeInterval.EVENT_ERROR); @@ -108996,6 +109018,10 @@ BI.shortcut("bi.static_year_month_card", BI.StaticYearMonthCard);BI.DynamicYearM getKey: function () { return this.trigger.getKey(); + }, + + isValid: function () { + return this.trigger.isValid(); } }); @@ -109417,6 +109443,10 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY getKey: function () { return this.yearEditor.getValue() + "-" + this.monthEditor.getValue(); + }, + + isValid: function () { + return this.yearEditor.isValid() && this.monthEditor.isValid(); } }); BI.DynamicYearMonthTrigger.EVENT_VALID = "EVENT_FOCUS"; @@ -109509,7 +109539,7 @@ BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);BI.Year combo.on(BI.DynamicYearMonthCombo.EVENT_VALID, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { @@ -109525,7 +109555,7 @@ BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);BI.Year combo.on(BI.DynamicYearMonthCombo.EVENT_FOCUS, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { @@ -109546,7 +109576,7 @@ BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);BI.Year combo.on(BI.DynamicYearMonthCombo.EVENT_CONFIRM, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); self.fireEvent(BI.YearMonthInterval.EVENT_ERROR); diff --git a/dist/demo.js b/dist/demo.js index 6f5cd251b..1abb23970 100644 --- a/dist/demo.js +++ b/dist/demo.js @@ -12161,14 +12161,14 @@ BI.shortcut("demo.tips", Demo.Tips);Demo.DatePane = BI.inherit(BI.Widget, { text: "bi.date_pane" }, { type: "bi.dynamic_date_pane", - value: { - type: 1, - value: { - year: 2017, - month: 12, - day: 11 - } - }, + // value: { + // type: 1, + // value: { + // year: 2017, + // month: 12, + // day: 11 + // } + // }, ref: function (_ref) { self.datepane = _ref; }, @@ -12247,14 +12247,14 @@ Demo.Date = BI.inherit(BI.Widget, { self.datecombo = this; }, width: 300, - value: { - type: 1, - value: { - year: 2018, - month: 2, - day: 23 - } - } + // value: { + // type: 1, + // value: { + // year: 2018, + // month: 2, + // day: 23 + // } + // } }, { type: "bi.button", text: "getValue", diff --git a/dist/widget.js b/dist/widget.js index 74561c52b..2decdcc09 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -562,7 +562,7 @@ BI.DatePicker = BI.inherit(BI.Widget, { BI.DatePicker.superclass._init.apply(this, arguments); var self = this, o = this.options; this._year = BI.getDate().getFullYear(); - this._month = BI.getDate().getMonth(); + this._month = BI.getDate().getMonth() + 1; this.left = BI.createWidget({ type: "bi.icon_button", cls: "pre-page-h-font", @@ -597,7 +597,7 @@ BI.DatePicker = BI.inherit(BI.Widget, { if (self._month === 12) { self.setValue({ year: self.year.getValue() + 1, - month: 0 + month: 1 }); } else { self.setValue({ @@ -1474,7 +1474,7 @@ BI.StaticDatePaneCard = BI.inherit(BI.Widget, { this.today = BI.getDate(); this._year = this.today.getFullYear(); - this._month = this.today.getMonth(); + this._month = this.today.getMonth() + 1; this.selectedTime = o.selectedTime || { year: this._year, @@ -1542,7 +1542,7 @@ BI.StaticDatePaneCard = BI.inherit(BI.Widget, { var today = BI.getDate(); return { year: today.getFullYear(), - month: today.getMonth() + month: today.getMonth() + 1 }; }, @@ -1697,7 +1697,7 @@ BI.shortcut("bi.static_date_pane_card", BI.StaticDatePaneCard);BI.DynamicDatePan var date = BI.getDate(); this.ymd.setValue({ year: date.getFullYear(), - month: date.getMonth() + month: date.getMonth() + 1 }); } else { this.ymd.setValue(value); @@ -2267,7 +2267,7 @@ BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);BI.StaticDateTimePaneCar var today = BI.getDate(); return { year: today.getFullYear(), - month: today.getMonth() + month: today.getMonth() + 1 }; }, @@ -4518,6 +4518,10 @@ BI.shortcut("bi.dynamic_date_trigger", BI.DynamicDateTrigger);BI.DynamicDateTime }, hidePopupView: function () { this.combo.hideView(); + }, + + isValid: function () { + return this.trigger.isValid(); } }); @@ -4794,7 +4798,9 @@ BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDat listeners: [{ eventName: BI.SignEditor.EVENT_CONFIRM, action: function () { - this.setValue(self._formatValueToDoubleDigit(this.getValue())); + var value = this.getValue(); + self._checkHour(value); + this.setValue(self._formatValueToDoubleDigit(value)); self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); } }, { @@ -4826,7 +4832,9 @@ BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDat listeners: [{ eventName: BI.SignEditor.EVENT_CONFIRM, action: function () { - this.setValue(self._formatValueToDoubleDigit(this.getValue()), BI.DynamicDateTimeSelect.MINUTE); + var value = this.getValue(); + self._checkMinute(value); + this.setValue(self._formatValueToDoubleDigit(value), BI.DynamicDateTimeSelect.MINUTE); self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); } }, { @@ -4856,7 +4864,9 @@ BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDat listeners: [{ eventName: BI.SignEditor.EVENT_CONFIRM, action: function () { - this.setValue(self._formatValueToDoubleDigit(this.getValue())); + var value = this.getValue(); + self._checkSecond(value); + this.setValue(self._formatValueToDoubleDigit(value)); self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); } }], @@ -4867,6 +4877,28 @@ BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDat }; }, + _checkBorder: function (v) { + v = v || {}; + this._checkHour(v.hour); + this._checkMinute(v.minute); + this._checkSecond(v.second); + }, + + _checkHour: function (value) { + this.hour.setDownEnable(BI.parseInt(value) > 0); + this.hour.setUpEnable(BI.parseInt(value) < 23); + }, + + _checkMinute: function (value) { + this.minute.setDownEnable(BI.parseInt(value) > 0); + this.minute.setUpEnable(BI.parseInt(value) < 59); + }, + + _checkSecond: function (value) { + this.second.setDownEnable(BI.parseInt(value) > 0); + this.second.setUpEnable(BI.parseInt(value) < 59); + }, + _autoSwitch: function (v, type) { var limit = 0; var value = v; @@ -4875,7 +4907,7 @@ BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDat limit = 2; break; case BI.DynamicDateTimeSelect.MINUTE: - limit = 6; + limit = 5; break; default: break; @@ -4921,6 +4953,7 @@ BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDat this.hour.setValue(v.hour); this.minute.setValue(v.minute); this.second.setValue(v.second); + this._checkBorder(v); } }); @@ -5167,6 +5200,10 @@ BI.extend(BI.DynamicDateTimeSelect, { }, getValue: function () { return this.storeValue; + }, + + isValid: function () { + return this.editor.isValid(); } }); @@ -20653,7 +20690,7 @@ BI.TimeInterval = BI.inherit(BI.Single, { combo.on(BI.DynamicDateTimeCombo.EVENT_VALID, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { @@ -20669,7 +20706,7 @@ BI.TimeInterval = BI.inherit(BI.Single, { combo.on(BI.DynamicDateTimeCombo.EVENT_FOCUS, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { @@ -20686,26 +20723,11 @@ BI.TimeInterval = BI.inherit(BI.Single, { self.left.hidePopupView(); self.right.hidePopupView(); }); - // combo.on(BI.DynamicDateTimeCombo.EVENT_CHANGE, function () { - // BI.Bubbles.hide("error"); - // var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - // if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { - // self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); - // self.element.addClass(self.constants.timeErrorCls); - // BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { - // offsetStyle: "center" - // }); - // self.fireEvent(BI.TimeInterval.EVENT_ERROR); - // } else { - // self._clearTitle(); - // self.element.removeClass(self.constants.timeErrorCls); - // } - // }); combo.on(BI.DynamicDateTimeCombo.EVENT_CONFIRM, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); self.fireEvent(BI.TimeInterval.EVENT_ERROR); @@ -21849,6 +21871,10 @@ BI.shortcut("bi.static_year_month_card", BI.StaticYearMonthCard);BI.DynamicYearM getKey: function () { return this.trigger.getKey(); + }, + + isValid: function () { + return this.trigger.isValid(); } }); @@ -22270,6 +22296,10 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY getKey: function () { return this.yearEditor.getValue() + "-" + this.monthEditor.getValue(); + }, + + isValid: function () { + return this.yearEditor.isValid() && this.monthEditor.isValid(); } }); BI.DynamicYearMonthTrigger.EVENT_VALID = "EVENT_FOCUS"; @@ -22362,7 +22392,7 @@ BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);BI.Year combo.on(BI.DynamicYearMonthCombo.EVENT_VALID, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { @@ -22378,7 +22408,7 @@ BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);BI.Year combo.on(BI.DynamicYearMonthCombo.EVENT_FOCUS, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { @@ -22399,7 +22429,7 @@ BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);BI.Year combo.on(BI.DynamicYearMonthCombo.EVENT_CONFIRM, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); self.fireEvent(BI.YearMonthInterval.EVENT_ERROR); diff --git a/src/widget/date/calendar/picker.date.js b/src/widget/date/calendar/picker.date.js index fe7ecbcef..57700f747 100644 --- a/src/widget/date/calendar/picker.date.js +++ b/src/widget/date/calendar/picker.date.js @@ -18,7 +18,7 @@ BI.DatePicker = BI.inherit(BI.Widget, { BI.DatePicker.superclass._init.apply(this, arguments); var self = this, o = this.options; this._year = BI.getDate().getFullYear(); - this._month = BI.getDate().getMonth(); + this._month = BI.getDate().getMonth() + 1; this.left = BI.createWidget({ type: "bi.icon_button", cls: "pre-page-h-font", @@ -53,7 +53,7 @@ BI.DatePicker = BI.inherit(BI.Widget, { if (self._month === 12) { self.setValue({ year: self.year.getValue() + 1, - month: 0 + month: 1 }); } else { self.setValue({ diff --git a/src/widget/datepane/card.static.datepane.js b/src/widget/datepane/card.static.datepane.js index 650d90bc5..181e73c35 100644 --- a/src/widget/datepane/card.static.datepane.js +++ b/src/widget/datepane/card.static.datepane.js @@ -17,7 +17,7 @@ BI.StaticDatePaneCard = BI.inherit(BI.Widget, { this.today = BI.getDate(); this._year = this.today.getFullYear(); - this._month = this.today.getMonth(); + this._month = this.today.getMonth() + 1; this.selectedTime = o.selectedTime || { year: this._year, @@ -85,7 +85,7 @@ BI.StaticDatePaneCard = BI.inherit(BI.Widget, { var today = BI.getDate(); return { year: today.getFullYear(), - month: today.getMonth() + month: today.getMonth() + 1 }; }, diff --git a/src/widget/datepane/datepane.js b/src/widget/datepane/datepane.js index b46b3b8bc..ee42ffe7d 100644 --- a/src/widget/datepane/datepane.js +++ b/src/widget/datepane/datepane.js @@ -116,7 +116,7 @@ BI.DynamicDatePane = BI.inherit(BI.Widget, { var date = BI.getDate(); this.ymd.setValue({ year: date.getFullYear(), - month: date.getMonth() + month: date.getMonth() + 1 }); } else { this.ymd.setValue(value); diff --git a/src/widget/datetimepane/card.static.datetimepane.js b/src/widget/datetimepane/card.static.datetimepane.js index 385bf5294..24672606d 100644 --- a/src/widget/datetimepane/card.static.datetimepane.js +++ b/src/widget/datetimepane/card.static.datetimepane.js @@ -84,7 +84,7 @@ BI.StaticDateTimePaneCard = BI.inherit(BI.Widget, { var today = BI.getDate(); return { year: today.getFullYear(), - month: today.getMonth() + month: today.getMonth() + 1 }; }, diff --git a/src/widget/dynamicdatetime/dynamicdatetime.combo.js b/src/widget/dynamicdatetime/dynamicdatetime.combo.js index 961497e7c..399d3779f 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.combo.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.combo.js @@ -243,6 +243,10 @@ BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { }, hidePopupView: function () { this.combo.hideView(); + }, + + isValid: function () { + return this.trigger.isValid(); } }); diff --git a/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js b/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js index 83eb9ed4e..f0753d69b 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.timeselect.js @@ -25,7 +25,9 @@ BI.DynamicDateTimeSelect = BI.inherit(BI.Widget, { listeners: [{ eventName: BI.SignEditor.EVENT_CONFIRM, action: function () { - this.setValue(self._formatValueToDoubleDigit(this.getValue())); + var value = this.getValue(); + self._checkHour(value); + this.setValue(self._formatValueToDoubleDigit(value)); self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); } }, { @@ -57,7 +59,9 @@ BI.DynamicDateTimeSelect = BI.inherit(BI.Widget, { listeners: [{ eventName: BI.SignEditor.EVENT_CONFIRM, action: function () { - this.setValue(self._formatValueToDoubleDigit(this.getValue()), BI.DynamicDateTimeSelect.MINUTE); + var value = this.getValue(); + self._checkMinute(value); + this.setValue(self._formatValueToDoubleDigit(value), BI.DynamicDateTimeSelect.MINUTE); self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); } }, { @@ -87,7 +91,9 @@ BI.DynamicDateTimeSelect = BI.inherit(BI.Widget, { listeners: [{ eventName: BI.SignEditor.EVENT_CONFIRM, action: function () { - this.setValue(self._formatValueToDoubleDigit(this.getValue())); + var value = this.getValue(); + self._checkSecond(value); + this.setValue(self._formatValueToDoubleDigit(value)); self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); } }], @@ -98,6 +104,28 @@ BI.DynamicDateTimeSelect = BI.inherit(BI.Widget, { }; }, + _checkBorder: function (v) { + v = v || {}; + this._checkHour(v.hour); + this._checkMinute(v.minute); + this._checkSecond(v.second); + }, + + _checkHour: function (value) { + this.hour.setDownEnable(BI.parseInt(value) > 0); + this.hour.setUpEnable(BI.parseInt(value) < 23); + }, + + _checkMinute: function (value) { + this.minute.setDownEnable(BI.parseInt(value) > 0); + this.minute.setUpEnable(BI.parseInt(value) < 59); + }, + + _checkSecond: function (value) { + this.second.setDownEnable(BI.parseInt(value) > 0); + this.second.setUpEnable(BI.parseInt(value) < 59); + }, + _autoSwitch: function (v, type) { var limit = 0; var value = v; @@ -106,7 +134,7 @@ BI.DynamicDateTimeSelect = BI.inherit(BI.Widget, { limit = 2; break; case BI.DynamicDateTimeSelect.MINUTE: - limit = 6; + limit = 5; break; default: break; @@ -152,6 +180,7 @@ BI.DynamicDateTimeSelect = BI.inherit(BI.Widget, { this.hour.setValue(v.hour); this.minute.setValue(v.minute); this.second.setValue(v.second); + this._checkBorder(v); } }); diff --git a/src/widget/dynamicdatetime/dynamicdatetime.trigger.js b/src/widget/dynamicdatetime/dynamicdatetime.trigger.js index d93378183..7f53564a9 100644 --- a/src/widget/dynamicdatetime/dynamicdatetime.trigger.js +++ b/src/widget/dynamicdatetime/dynamicdatetime.trigger.js @@ -235,6 +235,10 @@ BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { }, getValue: function () { return this.storeValue; + }, + + isValid: function () { + return this.editor.isValid(); } }); diff --git a/src/widget/timeinterval/timeinterval.js b/src/widget/timeinterval/timeinterval.js index 73cf18c42..004739bca 100644 --- a/src/widget/timeinterval/timeinterval.js +++ b/src/widget/timeinterval/timeinterval.js @@ -79,7 +79,7 @@ BI.TimeInterval = BI.inherit(BI.Single, { combo.on(BI.DynamicDateTimeCombo.EVENT_VALID, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { @@ -95,7 +95,7 @@ BI.TimeInterval = BI.inherit(BI.Single, { combo.on(BI.DynamicDateTimeCombo.EVENT_FOCUS, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { @@ -112,26 +112,11 @@ BI.TimeInterval = BI.inherit(BI.Single, { self.left.hidePopupView(); self.right.hidePopupView(); }); - // combo.on(BI.DynamicDateTimeCombo.EVENT_CHANGE, function () { - // BI.Bubbles.hide("error"); - // var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - // if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { - // self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); - // self.element.addClass(self.constants.timeErrorCls); - // BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { - // offsetStyle: "center" - // }); - // self.fireEvent(BI.TimeInterval.EVENT_ERROR); - // } else { - // self._clearTitle(); - // self.element.removeClass(self.constants.timeErrorCls); - // } - // }); combo.on(BI.DynamicDateTimeCombo.EVENT_CONFIRM, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); self.fireEvent(BI.TimeInterval.EVENT_ERROR); diff --git a/src/widget/yearmonth/combo.yearmonth.js b/src/widget/yearmonth/combo.yearmonth.js index 709133946..90d693a19 100644 --- a/src/widget/yearmonth/combo.yearmonth.js +++ b/src/widget/yearmonth/combo.yearmonth.js @@ -162,6 +162,10 @@ BI.DynamicYearMonthCombo = BI.inherit(BI.Single, { getKey: function () { return this.trigger.getKey(); + }, + + isValid: function () { + return this.trigger.isValid(); } }); diff --git a/src/widget/yearmonth/trigger.yearmonth.js b/src/widget/yearmonth/trigger.yearmonth.js index 4b3892302..534c7e568 100644 --- a/src/widget/yearmonth/trigger.yearmonth.js +++ b/src/widget/yearmonth/trigger.yearmonth.js @@ -201,6 +201,10 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { getKey: function () { return this.yearEditor.getValue() + "-" + this.monthEditor.getValue(); + }, + + isValid: function () { + return this.yearEditor.isValid() && this.monthEditor.isValid(); } }); BI.DynamicYearMonthTrigger.EVENT_VALID = "EVENT_FOCUS"; diff --git a/src/widget/yearmonthinterval/yearmonthinterval.js b/src/widget/yearmonthinterval/yearmonthinterval.js index a4f761d90..ede4aa94c 100644 --- a/src/widget/yearmonthinterval/yearmonthinterval.js +++ b/src/widget/yearmonthinterval/yearmonthinterval.js @@ -82,7 +82,7 @@ BI.YearMonthInterval = BI.inherit(BI.Single, { combo.on(BI.DynamicYearMonthCombo.EVENT_VALID, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { @@ -98,7 +98,7 @@ BI.YearMonthInterval = BI.inherit(BI.Single, { combo.on(BI.DynamicYearMonthCombo.EVENT_FOCUS, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { @@ -119,7 +119,7 @@ BI.YearMonthInterval = BI.inherit(BI.Single, { combo.on(BI.DynamicYearMonthCombo.EVENT_CONFIRM, function () { BI.Bubbles.hide("error"); var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); self.element.addClass(self.constants.timeErrorCls); self.fireEvent(BI.YearMonthInterval.EVENT_ERROR);