diff --git a/changelog.md b/changelog.md index eccb28b37e..70356883d3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-11) +- 修复了颜色选择器hex框不能输入为空的问题 - 增加纯文本组件bi.pure_text - store支持webworker,引入多线程机制 - 修复了Popover小屏幕上看不完整的问题 diff --git a/i18n/i18n.cn.js b/i18n/i18n.cn.js index 1622eab1e6..c1c9bf3163 100644 --- a/i18n/i18n.cn.js +++ b/i18n/i18n.cn.js @@ -9,7 +9,7 @@ BI.i18n = { "BI-Basic_Altogether": "共", "BI-Basic_Sunday": "星期日", "BI-Widget_Background_Colour": "组件背景", - "BI-Color_Picker_Error_Text": "请输入0~255的正整数", + "BI-Color_Picker_Error_Text": "请输入0-255的正整数", "BI-Multi_Date_Month": "月", "BI-No_Selected_Item": "没有可选项", "BI-Multi_Date_Year_Begin": "年初", @@ -91,6 +91,7 @@ BI.i18n = { "BI-Summary_Values": "汇总", "BI-Basic_Clear": "清除", "BI-Upload_File_Size_Error": "文件大小不支持", + "BI-Upload_File_Count_Error": "超出上传数量上限,请重新上传", "BI-Up_Page": "向上翻页", "BI-Basic_Simple_Sunday": "日", "BI-Multi_Date_Relative_Current_Time": "相对当前时间", diff --git a/src/case/colorchooser/colorpicker/editor.colorpicker.hex.js b/src/case/colorchooser/colorpicker/editor.colorpicker.hex.js index 6a2354da3b..14fead2dfc 100644 --- a/src/case/colorchooser/colorpicker/editor.colorpicker.hex.js +++ b/src/case/colorchooser/colorpicker/editor.colorpicker.hex.js @@ -85,15 +85,19 @@ BI.HexColorPickerEditor = BI.inherit(BI.Widget, { }, cls: "color-picker-editor-input", validationChecker: this._hexChecker, + allowBlank: true, errorText: BI.i18nText("BI-Color_Picker_Error_Text_Hex"), width: c.HEX_WIDTH, height: 20, listeners: [{ eventName: "EVENT_CHANGE", action: function () { - self.setValue("#" + this.getValue()); - self.colorShow.element.css("background-color", self.getValue()); - self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); + self._checkHexEditor(); + if (checker(self.storeValue.r) && checker(self.storeValue.g) && checker(self.storeValue.b)) { + self.colorShow.element.css("background-color", self.getValue()); + self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); + } + } }] }, { @@ -238,6 +242,21 @@ BI.HexColorPickerEditor = BI.inherit(BI.Widget, { return BI.isEmptyString(this.storeValue.r) && BI.isEmptyString(this.storeValue.g) && BI.isEmptyString(this.storeValue.b); }, + _checkHexEditor: function () { + if (BI.isEmptyString(this.hexEditor.getValue())) { + this.hexEditor.setValue("000000"); + } + var json = BI.DOM.rgb2json(BI.DOM.hex2rgb("#" + this.hexEditor.getValue())); + this.storeValue = { + r: json.r || 0, + g: json.g || 0, + b: json.b || 0, + }; + this.R.setValue(this.storeValue.r); + this.G.setValue(this.storeValue.g); + this.B.setValue(this.storeValue.b); + }, + _showPreColor: function (color) { if (color === "") { this.colorShow.element.css("background-color", "").removeClass("trans-color-background").addClass("auto-color-normal-background"); diff --git a/src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js b/src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js index cd9e5a3d3d..abeac571c2 100644 --- a/src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js +++ b/src/case/colorchooser/colorpicker/editor.colorpicker.hex.simple.js @@ -82,15 +82,18 @@ BI.SimpleHexColorPickerEditor = BI.inherit(BI.Widget, { }, cls: "color-picker-editor-input", validationChecker: this._hexChecker, + allowBlank: true, errorText: BI.i18nText("BI-Color_Picker_Error_Text_Hex"), width: c.HEX_WIDTH, height: 20, listeners: [{ eventName: "EVENT_CHANGE", action: function () { - self.setValue("#" + this.getValue()); - self.colorShow.element.css("background-color", self.getValue()); - self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); + self._checkHexEditor(); + if (checker(self.storeValue.r) && checker(self.storeValue.g) && checker(self.storeValue.b)) { + self.colorShow.element.css("background-color", self.getValue()); + self.fireEvent(BI.ColorPickerEditor.EVENT_CHANGE); + } } }] }, { @@ -157,6 +160,21 @@ BI.SimpleHexColorPickerEditor = BI.inherit(BI.Widget, { this.hexEditor.setValue(this.getValue().slice(this.constants.HEX_PREFIX_POSITION)); }, + _checkHexEditor: function () { + if (BI.isEmptyString(this.hexEditor.getValue())) { + this.hexEditor.setValue("000000"); + } + var json = BI.DOM.rgb2json(BI.DOM.hex2rgb("#" + this.hexEditor.getValue())); + this.storeValue = { + r: json.r || 0, + g: json.g || 0, + b: json.b || 0, + }; + this.R.setValue(this.storeValue.r); + this.G.setValue(this.storeValue.g); + this.B.setValue(this.storeValue.b); + }, + setValue: function (color) { this.colorShow.element.css({"background-color": color}); var json = BI.DOM.rgb2json(BI.DOM.hex2rgb(color));