From 63690271ab0b211f76abbacccd719b90ec874f45 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Sun, 6 May 2018 20:14:07 +0800 Subject: [PATCH] BI-18672 --- dist/bundle.js | 41 +++++++++++++------ dist/fineui.js | 41 +++++++++++++------ dist/widget.js | 41 +++++++++++++------ src/widget/yearmonth/trigger.yearmonth.js | 33 ++++++++++++--- .../yearmonthinterval/yearmonthinterval.js | 8 +--- 5 files changed, 116 insertions(+), 48 deletions(-) diff --git a/dist/bundle.js b/dist/bundle.js index 4838084ac..fb96eb555 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -109309,6 +109309,12 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY height: 24 }, + beforeInit: function (callback) { + var o = this.options; + o.title = BI.bind(this._titleCreator, this); + callback(); + }, + _init: function () { BI.DynamicYearMonthTrigger.superclass._init.apply(this, arguments); var o = this.options; @@ -109416,6 +109422,27 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY return editor; }, + _titleCreator: function () { + var storeValue = this.storeValue || {}; + var type = storeValue.type || BI.DynamicDateCombo.Static; + var value = storeValue.value; + if(!this.monthEditor.isValid() || !this.yearEditor.isValid()) { + return ""; + } + switch (type) { + case BI.DynamicDateCombo.Dynamic: + var text = this._getText(value); + var date = BI.getDate(); + date = BI.DynamicDateHelper.getCalculation(value); + var dateStr = date.print("%Y-%x"); + return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); + case BI.DynamicDateCombo.Static: + default: + value = value || {}; + return this._getStaticTitle(value); + } + }, + _doEditorConfirm: function (editor) { var value = editor.getValue(); if (BI.isNotNull(value)) { @@ -109429,7 +109456,6 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY month: BI.isEmptyString(this.monthEditor.getValue()) ? "" : monthValue } }; - this.setTitle(this._getStaticTitle(this.storeValue.value)); }, _yearCheck: function (v) { @@ -109460,10 +109486,8 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY }, _setInnerValue: function (date, text) { - var dateStr = date.print("%Y-%x"); this.yearEditor.setValue(date.getFullYear()); this.monthEditor.setValue(date.getMonth() + 1); - this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr)); }, _getStaticTitle: function (value) { @@ -109492,10 +109516,7 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY value = value || {}; var month = BI.isNull(value.month) ? null : value.month; this.yearEditor.setValue(value.year); - this.yearEditor.setTitle(value.year); this.monthEditor.setValue(month); - this.monthEditor.setTitle(month); - this.setTitle(this._getStaticTitle(value)); break; } }, @@ -109685,14 +109706,10 @@ BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);BI.Year return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate; }, _setTitle: function (v) { - this.left.setTitle(v); - this.right.setTitle(v); - this.label.setTitle(v); + this.setTitle(v); }, _clearTitle: function () { - this.left.setTitle(""); - this.right.setTitle(""); - this.label.setTitle(""); + this.setTitle(""); }, setValue: function (date) { date = date || {}; diff --git a/dist/fineui.js b/dist/fineui.js index c7cd73c05..a5ad2fa29 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -109552,6 +109552,12 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY height: 24 }, + beforeInit: function (callback) { + var o = this.options; + o.title = BI.bind(this._titleCreator, this); + callback(); + }, + _init: function () { BI.DynamicYearMonthTrigger.superclass._init.apply(this, arguments); var o = this.options; @@ -109659,6 +109665,27 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY return editor; }, + _titleCreator: function () { + var storeValue = this.storeValue || {}; + var type = storeValue.type || BI.DynamicDateCombo.Static; + var value = storeValue.value; + if(!this.monthEditor.isValid() || !this.yearEditor.isValid()) { + return ""; + } + switch (type) { + case BI.DynamicDateCombo.Dynamic: + var text = this._getText(value); + var date = BI.getDate(); + date = BI.DynamicDateHelper.getCalculation(value); + var dateStr = date.print("%Y-%x"); + return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); + case BI.DynamicDateCombo.Static: + default: + value = value || {}; + return this._getStaticTitle(value); + } + }, + _doEditorConfirm: function (editor) { var value = editor.getValue(); if (BI.isNotNull(value)) { @@ -109672,7 +109699,6 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY month: BI.isEmptyString(this.monthEditor.getValue()) ? "" : monthValue } }; - this.setTitle(this._getStaticTitle(this.storeValue.value)); }, _yearCheck: function (v) { @@ -109703,10 +109729,8 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY }, _setInnerValue: function (date, text) { - var dateStr = date.print("%Y-%x"); this.yearEditor.setValue(date.getFullYear()); this.monthEditor.setValue(date.getMonth() + 1); - this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr)); }, _getStaticTitle: function (value) { @@ -109735,10 +109759,7 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY value = value || {}; var month = BI.isNull(value.month) ? null : value.month; this.yearEditor.setValue(value.year); - this.yearEditor.setTitle(value.year); this.monthEditor.setValue(month); - this.monthEditor.setTitle(month); - this.setTitle(this._getStaticTitle(value)); break; } }, @@ -109928,14 +109949,10 @@ BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);BI.Year return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate; }, _setTitle: function (v) { - this.left.setTitle(v); - this.right.setTitle(v); - this.label.setTitle(v); + this.setTitle(v); }, _clearTitle: function () { - this.left.setTitle(""); - this.right.setTitle(""); - this.label.setTitle(""); + this.setTitle(""); }, setValue: function (date) { date = date || {}; diff --git a/dist/widget.js b/dist/widget.js index 9a2b33a96..ee5ddfebd 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -21841,6 +21841,12 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY height: 24 }, + beforeInit: function (callback) { + var o = this.options; + o.title = BI.bind(this._titleCreator, this); + callback(); + }, + _init: function () { BI.DynamicYearMonthTrigger.superclass._init.apply(this, arguments); var o = this.options; @@ -21948,6 +21954,27 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY return editor; }, + _titleCreator: function () { + var storeValue = this.storeValue || {}; + var type = storeValue.type || BI.DynamicDateCombo.Static; + var value = storeValue.value; + if(!this.monthEditor.isValid() || !this.yearEditor.isValid()) { + return ""; + } + switch (type) { + case BI.DynamicDateCombo.Dynamic: + var text = this._getText(value); + var date = BI.getDate(); + date = BI.DynamicDateHelper.getCalculation(value); + var dateStr = date.print("%Y-%x"); + return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); + case BI.DynamicDateCombo.Static: + default: + value = value || {}; + return this._getStaticTitle(value); + } + }, + _doEditorConfirm: function (editor) { var value = editor.getValue(); if (BI.isNotNull(value)) { @@ -21961,7 +21988,6 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY month: BI.isEmptyString(this.monthEditor.getValue()) ? "" : monthValue } }; - this.setTitle(this._getStaticTitle(this.storeValue.value)); }, _yearCheck: function (v) { @@ -21992,10 +22018,8 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY }, _setInnerValue: function (date, text) { - var dateStr = date.print("%Y-%x"); this.yearEditor.setValue(date.getFullYear()); this.monthEditor.setValue(date.getMonth() + 1); - this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr)); }, _getStaticTitle: function (value) { @@ -22024,10 +22048,7 @@ BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicY value = value || {}; var month = BI.isNull(value.month) ? null : value.month; this.yearEditor.setValue(value.year); - this.yearEditor.setTitle(value.year); this.monthEditor.setValue(month); - this.monthEditor.setTitle(month); - this.setTitle(this._getStaticTitle(value)); break; } }, @@ -22217,14 +22238,10 @@ BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);BI.Year return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate; }, _setTitle: function (v) { - this.left.setTitle(v); - this.right.setTitle(v); - this.label.setTitle(v); + this.setTitle(v); }, _clearTitle: function () { - this.left.setTitle(""); - this.right.setTitle(""); - this.label.setTitle(""); + this.setTitle(""); }, setValue: function (date) { date = date || {}; diff --git a/src/widget/yearmonth/trigger.yearmonth.js b/src/widget/yearmonth/trigger.yearmonth.js index 233b93ff0..6173a7faa 100644 --- a/src/widget/yearmonth/trigger.yearmonth.js +++ b/src/widget/yearmonth/trigger.yearmonth.js @@ -11,6 +11,12 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { height: 24 }, + beforeInit: function (callback) { + var o = this.options; + o.title = BI.bind(this._titleCreator, this); + callback(); + }, + _init: function () { BI.DynamicYearMonthTrigger.superclass._init.apply(this, arguments); var o = this.options; @@ -118,6 +124,27 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { return editor; }, + _titleCreator: function () { + var storeValue = this.storeValue || {}; + var type = storeValue.type || BI.DynamicDateCombo.Static; + var value = storeValue.value; + if(!this.monthEditor.isValid() || !this.yearEditor.isValid()) { + return ""; + } + switch (type) { + case BI.DynamicDateCombo.Dynamic: + var text = this._getText(value); + var date = BI.getDate(); + date = BI.DynamicDateHelper.getCalculation(value); + var dateStr = date.print("%Y-%x"); + return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); + case BI.DynamicDateCombo.Static: + default: + value = value || {}; + return this._getStaticTitle(value); + } + }, + _doEditorConfirm: function (editor) { var value = editor.getValue(); if (BI.isNotNull(value)) { @@ -131,7 +158,6 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { month: BI.isEmptyString(this.monthEditor.getValue()) ? "" : monthValue } }; - this.setTitle(this._getStaticTitle(this.storeValue.value)); }, _yearCheck: function (v) { @@ -162,10 +188,8 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { }, _setInnerValue: function (date, text) { - var dateStr = date.print("%Y-%x"); this.yearEditor.setValue(date.getFullYear()); this.monthEditor.setValue(date.getMonth() + 1); - this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr)); }, _getStaticTitle: function (value) { @@ -194,10 +218,7 @@ BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { value = value || {}; var month = BI.isNull(value.month) ? null : value.month; this.yearEditor.setValue(value.year); - this.yearEditor.setTitle(value.year); this.monthEditor.setValue(month); - this.monthEditor.setTitle(month); - this.setTitle(this._getStaticTitle(value)); break; } }, diff --git a/src/widget/yearmonthinterval/yearmonthinterval.js b/src/widget/yearmonthinterval/yearmonthinterval.js index 9206cadaa..8610c94fd 100644 --- a/src/widget/yearmonthinterval/yearmonthinterval.js +++ b/src/widget/yearmonthinterval/yearmonthinterval.js @@ -164,14 +164,10 @@ BI.YearMonthInterval = BI.inherit(BI.Single, { return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate; }, _setTitle: function (v) { - this.left.setTitle(v); - this.right.setTitle(v); - this.label.setTitle(v); + this.setTitle(v); }, _clearTitle: function () { - this.left.setTitle(""); - this.right.setTitle(""); - this.label.setTitle(""); + this.setTitle(""); }, setValue: function (date) { date = date || {};