From 2fa03a827f271c08084cd2bfed702bcd5fb7afdf Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Tue, 15 May 2018 19:52:14 +0800 Subject: [PATCH] BI-21411 --- dist/bundle.js | 30 ++++++++++++++++++++++++++++-- dist/fineui.js | 30 ++++++++++++++++++++++++++++-- dist/widget.js | 30 ++++++++++++++++++++++++++++-- src/widget/year/trigger.year.js | 30 ++++++++++++++++++++++++++++-- 4 files changed, 112 insertions(+), 8 deletions(-) diff --git a/dist/bundle.js b/dist/bundle.js index c9a34ad8d..c486cb63c 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -108714,6 +108714,13 @@ BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);BI.DynamicYearTrigger height: 24 }); }, + + beforeInit: function (callback) { + var o = this.options; + o.title = BI.bind(this._titleCreator, this); + callback(); + }, + _init: function () { BI.DynamicYearTrigger.superclass._init.apply(this, arguments); var self = this, o = this.options, c = this._const; @@ -108803,7 +108810,27 @@ BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);BI.DynamicYearTrigger var dateStr = date.print("%Y"); this.editor.setState(dateStr); this.editor.setValue(dateStr); - this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr)); + }, + + _titleCreator: function () { + var storeValue = this.storeValue || {}; + var type = storeValue.type || BI.DynamicDateCombo.Static; + var value = storeValue.value; + if(!this.editor.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"); + return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); + case BI.DynamicDateCombo.Static: + default: + value = value || {}; + return value.year; + } }, setValue: function (v) { @@ -108825,7 +108852,6 @@ BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);BI.DynamicYearTrigger value = value || {}; this.editor.setState(value.year); this.editor.setValue(value.year); - this.setTitle(value.year); break; } }, diff --git a/dist/fineui.js b/dist/fineui.js index 9a6ea191c..4006f0dfd 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -108957,6 +108957,13 @@ BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);BI.DynamicYearTrigger height: 24 }); }, + + beforeInit: function (callback) { + var o = this.options; + o.title = BI.bind(this._titleCreator, this); + callback(); + }, + _init: function () { BI.DynamicYearTrigger.superclass._init.apply(this, arguments); var self = this, o = this.options, c = this._const; @@ -109046,7 +109053,27 @@ BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);BI.DynamicYearTrigger var dateStr = date.print("%Y"); this.editor.setState(dateStr); this.editor.setValue(dateStr); - this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr)); + }, + + _titleCreator: function () { + var storeValue = this.storeValue || {}; + var type = storeValue.type || BI.DynamicDateCombo.Static; + var value = storeValue.value; + if(!this.editor.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"); + return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); + case BI.DynamicDateCombo.Static: + default: + value = value || {}; + return value.year; + } }, setValue: function (v) { @@ -109068,7 +109095,6 @@ BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);BI.DynamicYearTrigger value = value || {}; this.editor.setState(value.year); this.editor.setValue(value.year); - this.setTitle(value.year); break; } }, diff --git a/dist/widget.js b/dist/widget.js index d7f1acdf2..fa650436d 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -21154,6 +21154,13 @@ BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);BI.DynamicYearTrigger height: 24 }); }, + + beforeInit: function (callback) { + var o = this.options; + o.title = BI.bind(this._titleCreator, this); + callback(); + }, + _init: function () { BI.DynamicYearTrigger.superclass._init.apply(this, arguments); var self = this, o = this.options, c = this._const; @@ -21243,7 +21250,27 @@ BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);BI.DynamicYearTrigger var dateStr = date.print("%Y"); this.editor.setState(dateStr); this.editor.setValue(dateStr); - this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr)); + }, + + _titleCreator: function () { + var storeValue = this.storeValue || {}; + var type = storeValue.type || BI.DynamicDateCombo.Static; + var value = storeValue.value; + if(!this.editor.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"); + return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); + case BI.DynamicDateCombo.Static: + default: + value = value || {}; + return value.year; + } }, setValue: function (v) { @@ -21265,7 +21292,6 @@ BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);BI.DynamicYearTrigger value = value || {}; this.editor.setState(value.year); this.editor.setValue(value.year); - this.setTitle(value.year); break; } }, diff --git a/src/widget/year/trigger.year.js b/src/widget/year/trigger.year.js index 6b7b958de..f4e51e7bd 100644 --- a/src/widget/year/trigger.year.js +++ b/src/widget/year/trigger.year.js @@ -12,6 +12,13 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { height: 24 }); }, + + beforeInit: function (callback) { + var o = this.options; + o.title = BI.bind(this._titleCreator, this); + callback(); + }, + _init: function () { BI.DynamicYearTrigger.superclass._init.apply(this, arguments); var self = this, o = this.options, c = this._const; @@ -101,7 +108,27 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { var dateStr = date.print("%Y"); this.editor.setState(dateStr); this.editor.setValue(dateStr); - this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr)); + }, + + _titleCreator: function () { + var storeValue = this.storeValue || {}; + var type = storeValue.type || BI.DynamicDateCombo.Static; + var value = storeValue.value; + if(!this.editor.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"); + return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); + case BI.DynamicDateCombo.Static: + default: + value = value || {}; + return value.year; + } }, setValue: function (v) { @@ -123,7 +150,6 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { value = value || {}; this.editor.setState(value.year); this.editor.setValue(value.year); - this.setTitle(value.year); break; } },