Browse Source

BI-18932

es6
windy 7 years ago
parent
commit
e55964517a
  1. 38
      src/widget/yearmonth/trigger.yearmonth.js
  2. 35
      src/widget/yearquarter/trigger.yearquarter.js

38
src/widget/yearmonth/trigger.yearmonth.js

@ -86,20 +86,7 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_STOP);
});
editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
var value = editor.getValue();
if (BI.isNotNull(value)) {
editor.setValue(value);
}
var monthValue = self.monthEditor.getValue();
self.storeValue = {
type: BI.DynamicDateCombo.Static,
value: {
year: self.yearEditor.getValue(),
month: BI.isEmptyString(self.monthEditor.getValue()) ? "" : monthValue
}
};
self.setTitle(self._getStaticTitle(self.storeValue.value));
self._doEditorConfirm(editor);
self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_CONFIRM);
});
editor.on(BI.SignEditor.EVENT_SPACE, function () {
@ -124,21 +111,40 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, {
});
editor.on(BI.SignEditor.EVENT_CHANGE, function () {
if(isYear) {
self._autoSwitch(editor.getValue());
self._autoSwitch(editor);
}
});
return editor;
},
_doEditorConfirm: function (editor) {
var value = editor.getValue();
if (BI.isNotNull(value)) {
editor.setValue(value);
}
var monthValue = this.monthEditor.getValue();
this.storeValue = {
type: BI.DynamicDateCombo.Static,
value: {
year: this.yearEditor.getValue(),
month: BI.isEmptyString(this.monthEditor.getValue()) ? "" : monthValue
}
};
this.setTitle(this._getStaticTitle(this.storeValue.value));
},
_yearCheck: function (v) {
var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d");
return BI.parseDateTime(v, "%Y").print("%Y") === v && date >= this.options.min && date <= this.options.max;
},
_autoSwitch: function (v) {
_autoSwitch: function (editor) {
var v = editor.getValue();
if (BI.checkDateLegal(v)) {
if (v.length === 4 && this._yearCheck(v)) {
this._doEditorConfirm(editor);
this.fireEvent(BI.DynamicYearMonthTrigger.EVENT_CONFIRM);
this.monthEditor.focus();
}
}

35
src/widget/yearquarter/trigger.yearquarter.js

@ -87,20 +87,7 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_STOP);
});
editor.on(BI.SignEditor.EVENT_CONFIRM, function () {
var value = editor.getValue();
if (BI.isNotNull(value)) {
editor.setValue(value);
}
var quarterValue = self.quarterEditor.getValue();
self.storeValue = {
type: BI.DynamicYearQuarterCombo.Static,
value: {
year: self.yearEditor.getValue(),
quarter: BI.isEmptyString(self.quarterEditor.getValue()) ? "" : quarterValue
}
};
self.setTitle(self._getStaticTitle(self.storeValue.value));
self._doEditorConfirm(editor);
self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM);
});
editor.on(BI.SignEditor.EVENT_SPACE, function () {
@ -123,14 +110,32 @@ BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, {
return editor;
},
_doEditorConfirm: function (editor) {
var value = editor.getValue();
if (BI.isNotNull(value)) {
editor.setValue(value);
}
var quarterValue = this.quarterEditor.getValue();
this.storeValue = {
type: BI.DynamicYearQuarterCombo.Static,
value: {
year: this.yearEditor.getValue(),
quarter: BI.isEmptyString(this.quarterEditor.getValue()) ? "" : quarterValue
}
};
this.setTitle(this._getStaticTitle(this.storeValue.value));
},
_yearCheck: function (v) {
var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d");
return BI.parseDateTime(v, "%Y").print("%Y") === v && date >= this.options.min && date <= this.options.max;
},
_autoSwitch: function (v) {
_autoSwitch: function (editor) {
var v = editor.getValue();
if (BI.checkDateLegal(v)) {
if (v.length === 4 && this._yearCheck(v)) {
this._doEditorConfirm(editor);
this.quarterEditor.focus();
}
}

Loading…
Cancel
Save