From 34fd4b7df07a823c133d036ad9f274178c3b80ba Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Wed, 1 Jul 2020 13:55:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?BI-67618=20refactor:=20number=5Feditor?= =?UTF-8?q?=E6=94=AF=E6=8C=81min=EF=BC=8Cmax=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 3 +++ src/widget/numbereditor/number.editor.js | 30 ++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index df0987cc0..a6c43db20 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,7 @@ # 更新日志 +2.0(2020-07) +- 数值微调器新增min,max属性自动检测数值范围 + 2.0(2020-06) - 修复了复选下拉树半选节点的子节点未加载的时候,点选该半选节点是取消选中的问题 - 下拉树系列支持isNeedAdjustWidth以动态变化宽度 diff --git a/src/widget/numbereditor/number.editor.js b/src/widget/numbereditor/number.editor.js index 05292867d..9061a2949 100644 --- a/src/widget/numbereditor/number.editor.js +++ b/src/widget/numbereditor/number.editor.js @@ -15,7 +15,9 @@ BI.NumberEditor = BI.inherit(BI.Widget, { value: 0, allowBlank: false, errorText: "", - step: 1 + step: 1, + min: BI.MIN, + max: BI.MAX }); }, @@ -27,10 +29,16 @@ BI.NumberEditor = BI.inherit(BI.Widget, { height: o.height - 2, allowBlank: o.allowBlank, value: o.valueFormatter(o.value), - validationChecker: o.validationChecker, + validationChecker: function (v) { + if(!self._checkValueInRange(v)) { + return false; + } + return o.validationChecker(v); + }, errorText: o.errorText }); this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { + self._checkAdjustDisabled(o.value); self.fireEvent(BI.NumberEditor.EVENT_CHANGE); }); this.editor.on(BI.TextEditor.EVENT_ERROR, function () { @@ -46,10 +54,12 @@ BI.NumberEditor = BI.inherit(BI.Widget, { type: "bi.icon_button", forceNotSelected: true, trigger: "lclick,", - cls: "add-up-font top-button bi-border-left bi-list-item-active2 icon-size-12" + cls: "add-up-font top-button bi-border-left bi-list-item-active2 icon-size-12", + disabled: BI.parseFloat(o.value) >= o.max }); this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { self._finetuning(o.step); + self._checkAdjustDisabled(o.value); self.fireEvent(BI.NumberEditor.EVENT_CHANGE); self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); }); @@ -57,10 +67,12 @@ BI.NumberEditor = BI.inherit(BI.Widget, { type: "bi.icon_button", trigger: "lclick,", forceNotSelected: true, - cls: "minus-down-font bottom-button bi-border-left bi-list-item-active2 icon-size-12" + cls: "minus-down-font bottom-button bi-border-left bi-list-item-active2 icon-size-12", + disabled: BI.parseFloat(o.value) <= o.min }); this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { self._finetuning(-o.step); + self._checkAdjustDisabled(o.value); self.fireEvent(BI.NumberEditor.EVENT_CHANGE); self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); }); @@ -96,6 +108,16 @@ BI.NumberEditor = BI.inherit(BI.Widget, { return this.editor.isEditing(); }, + _checkValueInRange: function(v) { + var o = this.options; + return !!(BI.isNumeric(v) && BI.parseFloat(v) >= o.min && BI.parseFloat(v) <= o.max); + }, + + _checkAdjustDisabled: function(v) { + this.bottomBtn.setEnable(BI.parseFloat(v) > this.options.min); + this.topBtn.setEnable(BI.parseFloat(v) < this.options.max); + }, + // 微调 _finetuning: function (add) { var v = BI.parseFloat(this.getValue()); From 8c71c1635a32c748f933794ef70b50630381e5e8 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Wed, 1 Jul 2020 14:10:33 +0800 Subject: [PATCH 2/3] =?UTF-8?q?Revert=20"BI-67618=20refactor:=20number=5Fe?= =?UTF-8?q?ditor=E6=94=AF=E6=8C=81min=EF=BC=8Cmax=E5=B1=9E=E6=80=A7"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 34fd4b7df07a823c133d036ad9f274178c3b80ba. --- changelog.md | 3 --- src/widget/numbereditor/number.editor.js | 30 ++++-------------------- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/changelog.md b/changelog.md index a6c43db20..df0987cc0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,4 @@ # 更新日志 -2.0(2020-07) -- 数值微调器新增min,max属性自动检测数值范围 - 2.0(2020-06) - 修复了复选下拉树半选节点的子节点未加载的时候,点选该半选节点是取消选中的问题 - 下拉树系列支持isNeedAdjustWidth以动态变化宽度 diff --git a/src/widget/numbereditor/number.editor.js b/src/widget/numbereditor/number.editor.js index 9061a2949..05292867d 100644 --- a/src/widget/numbereditor/number.editor.js +++ b/src/widget/numbereditor/number.editor.js @@ -15,9 +15,7 @@ BI.NumberEditor = BI.inherit(BI.Widget, { value: 0, allowBlank: false, errorText: "", - step: 1, - min: BI.MIN, - max: BI.MAX + step: 1 }); }, @@ -29,16 +27,10 @@ BI.NumberEditor = BI.inherit(BI.Widget, { height: o.height - 2, allowBlank: o.allowBlank, value: o.valueFormatter(o.value), - validationChecker: function (v) { - if(!self._checkValueInRange(v)) { - return false; - } - return o.validationChecker(v); - }, + validationChecker: o.validationChecker, errorText: o.errorText }); this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { - self._checkAdjustDisabled(o.value); self.fireEvent(BI.NumberEditor.EVENT_CHANGE); }); this.editor.on(BI.TextEditor.EVENT_ERROR, function () { @@ -54,12 +46,10 @@ BI.NumberEditor = BI.inherit(BI.Widget, { type: "bi.icon_button", forceNotSelected: true, trigger: "lclick,", - cls: "add-up-font top-button bi-border-left bi-list-item-active2 icon-size-12", - disabled: BI.parseFloat(o.value) >= o.max + cls: "add-up-font top-button bi-border-left bi-list-item-active2 icon-size-12" }); this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { self._finetuning(o.step); - self._checkAdjustDisabled(o.value); self.fireEvent(BI.NumberEditor.EVENT_CHANGE); self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); }); @@ -67,12 +57,10 @@ BI.NumberEditor = BI.inherit(BI.Widget, { type: "bi.icon_button", trigger: "lclick,", forceNotSelected: true, - cls: "minus-down-font bottom-button bi-border-left bi-list-item-active2 icon-size-12", - disabled: BI.parseFloat(o.value) <= o.min + cls: "minus-down-font bottom-button bi-border-left bi-list-item-active2 icon-size-12" }); this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { self._finetuning(-o.step); - self._checkAdjustDisabled(o.value); self.fireEvent(BI.NumberEditor.EVENT_CHANGE); self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); }); @@ -108,16 +96,6 @@ BI.NumberEditor = BI.inherit(BI.Widget, { return this.editor.isEditing(); }, - _checkValueInRange: function(v) { - var o = this.options; - return !!(BI.isNumeric(v) && BI.parseFloat(v) >= o.min && BI.parseFloat(v) <= o.max); - }, - - _checkAdjustDisabled: function(v) { - this.bottomBtn.setEnable(BI.parseFloat(v) > this.options.min); - this.topBtn.setEnable(BI.parseFloat(v) < this.options.max); - }, - // 微调 _finetuning: function (add) { var v = BI.parseFloat(this.getValue()); From 9001ba27b36a803a88077caafa65a15474bbd846 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Wed, 1 Jul 2020 16:31:35 +0800 Subject: [PATCH 3/3] =?UTF-8?q?BI-67721=20fix:=20color=5Fchooser=20setValu?= =?UTF-8?q?e=E4=B8=BAnull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 3 +++ src/case/colorchooser/colorchooser.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index df0987cc0..67fbc34c6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,7 @@ # 更新日志 +2.0(2020-07) +- 修复了颜色选择器设置值为null的时候,trigger和popup表现不一致的问题 + 2.0(2020-06) - 修复了复选下拉树半选节点的子节点未加载的时候,点选该半选节点是取消选中的问题 - 下拉树系列支持isNeedAdjustWidth以动态变化宽度 diff --git a/src/case/colorchooser/colorchooser.js b/src/case/colorchooser/colorchooser.js index 7fe9b367d..50d61bb66 100644 --- a/src/case/colorchooser/colorchooser.js +++ b/src/case/colorchooser/colorchooser.js @@ -19,6 +19,7 @@ BI.ColorChooser = BI.inherit(BI.Widget, { BI.ColorChooser.superclass._init.apply(this, arguments); var self = this, o = this.options; + o.value = o.value || ""; this.combo = BI.createWidget({ type: "bi.combo", element: this, @@ -89,7 +90,7 @@ BI.ColorChooser = BI.inherit(BI.Widget, { }, setValue: function (color) { - this.combo.setValue(color); + this.combo.setValue(color || ""); }, getValue: function () {