diff --git a/changelog.md b/changelog.md index f6824f6d6..dbcca9ccd 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,19 @@ # 更新日志 + +3.0(2022-05) +- 下拉选择框支持清空 + +3.0(2022-03) +- 支持响应式 +- 全面支持Typescript +- 增加JSX支持 +- 布局组件支持更多动态特性 +- 底层API支持动画 +- 增加WebWorker支持 +- 支持路由 +- 插件支持版本控制 +- Fix数据流支持proxy版本 + 2.0(2022-01) - 提供自定义表单 diff --git a/package.json b/package.json index b3355d4f6..de865fa9e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fineui", - "version": "2.0.20220505161347", + "version": "2.0.20220511141337", "description": "fineui", "main": "dist/fineui.min.js", "types": "dist/lib/index.d.ts", diff --git a/src/base/single/input/input.js b/src/base/single/input/input.js index 41e1ca0de..e868a5747 100644 --- a/src/base/single/input/input.js +++ b/src/base/single/input/input.js @@ -206,14 +206,29 @@ BI.Input = BI.inherit(BI.Single, { this._lastValue = this.getValue(); }, - _checkValidationOnValueChange: function () { - var o = this.options; + _checkValidationOnValueChange: function (callback) { + var self = this, o = this.options; var v = this.getValue(); - this.setValid( - (o.allowBlank === true && BI.trim(v) == "") || ( - BI.isNotEmptyString(BI.trim(v)) && o.validationChecker.apply(this, [BI.trim(v)]) !== false - ) - ); + if (o.allowBlank === true && BI.trim(v) == "") { + this.setValid(true); + callback && callback(); + return; + } + if (BI.trim(v) == "") { + this.setValid(false); + callback && callback(); + return; + } + var checker = o.validationChecker.apply(this, [BI.trim(v)]); + if (checker instanceof Promise) { + checker.then(function (validate) { + self.setValid(validate !== false); + callback && callback(); + }) + } else { + this.setValid(checker !== false); + callback && callback(); + } }, focus: function () { @@ -245,14 +260,16 @@ BI.Input = BI.inherit(BI.Single, { }, setValue: function (textValue) { + var self = this; this.element.val(textValue); - BI.nextTick(BI.bind(function () { - this._checkValidationOnValueChange(); - this._defaultState(); - if (this.isValid()) { - this._lastValidValue = this._lastSubmitValue = this.getValue(); - } - }, this)); + BI.nextTick(function () { + self._checkValidationOnValueChange(function () { + self._defaultState(); + if (self.isValid()) { + self._lastValidValue = self._lastSubmitValue = self.getValue(); + } + }); + }); }, getValue: function () { diff --git a/src/case/checkbox/check.first.treenode.js b/src/case/checkbox/check.first.treenode.js index aa808488f..40568e700 100644 --- a/src/case/checkbox/check.first.treenode.js +++ b/src/case/checkbox/check.first.treenode.js @@ -7,8 +7,8 @@ BI.FirstTreeNodeCheckbox = BI.inherit(BI.IconButton, { _defaultConfig: function () { return BI.extend( BI.FirstTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type2" : "tree-collapse-icon-type2", - iconWidth: 24, - iconHeight: 24 + iconWidth: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, + iconHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT }); }, diff --git a/src/case/checkbox/check.last.treenode.js b/src/case/checkbox/check.last.treenode.js index cb536f8cc..653dd785d 100644 --- a/src/case/checkbox/check.last.treenode.js +++ b/src/case/checkbox/check.last.treenode.js @@ -7,8 +7,8 @@ BI.LastTreeNodeCheckbox = BI.inherit(BI.IconButton, { _defaultConfig: function () { return BI.extend(BI.LastTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type4" : "tree-collapse-icon-type4", - iconWidth: 24, - iconHeight: 24 + iconWidth: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, + iconHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT }); }, diff --git a/src/case/checkbox/check.mid.treenode.js b/src/case/checkbox/check.mid.treenode.js index 7ec4e5230..716cb0142 100644 --- a/src/case/checkbox/check.mid.treenode.js +++ b/src/case/checkbox/check.mid.treenode.js @@ -7,8 +7,8 @@ BI.MidTreeNodeCheckbox = BI.inherit(BI.IconButton, { _defaultConfig: function () { return BI.extend( BI.MidTreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type3" : "tree-collapse-icon-type3", - iconWidth: 24, - iconHeight: 24 + iconWidth: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, + iconHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT }); }, diff --git a/src/case/checkbox/check.treenode.js b/src/case/checkbox/check.treenode.js index 128bb73c6..ab186f4fb 100644 --- a/src/case/checkbox/check.treenode.js +++ b/src/case/checkbox/check.treenode.js @@ -7,8 +7,8 @@ BI.TreeNodeCheckbox = BI.inherit(BI.IconButton, { _defaultConfig: function () { return BI.extend( BI.TreeNodeCheckbox.superclass._defaultConfig.apply(this, arguments), { extraCls: BI.STYLE_CONSTANTS.LINK_LINE_TYPE === "solid" ? "tree-solid-collapse-icon-type1" : "tree-collapse-icon-type1", - iconWidth: 24, - iconHeight: 24 + iconWidth: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, + iconHeight: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT }); }, diff --git a/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js b/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js index ac3fad335..cb4aa29f8 100644 --- a/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js +++ b/src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js @@ -11,6 +11,7 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, { items: [], tipType: "", warningTitle: "", + allowClear: false, }, render: function () { @@ -48,6 +49,7 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, { tipType: o.tipType, warningTitle: o.warningTitle, title: o.title, + allowClear: o.allowClear, listeners: [{ eventName: BI.SearchTextValueTrigger.EVENT_CHANGE, action: function () { @@ -55,6 +57,13 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, { self.combo.hideView(); self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); } + }, { + eventName: BI.SearchTextValueTrigger.EVENT_CLEAR, + action: function () { + self.setValue(); + self.combo.hideView(); + self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE); + } }] }, popup: { diff --git a/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js b/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js index 7e84a4452..5673d3f47 100644 --- a/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js +++ b/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js @@ -111,4 +111,5 @@ BI.SearchTextValueTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; BI.SearchTextValueTrigger.EVENT_STOP = "EVENT_STOP"; BI.SearchTextValueTrigger.EVENT_START = "EVENT_START"; BI.SearchTextValueTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.SearchTextValueTrigger.EVENT_CLEAR = "EVENT_CLEAR"; BI.shortcut("bi.search_text_value_trigger", BI.SearchTextValueTrigger); diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index 6b9ef321b..69075f739 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -12,6 +12,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, text: "", value: "", + allowClear: false, }); }, @@ -33,7 +34,16 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { height: o.height, text: o.text, value: o.value, - warningTitle: o.warningTitle + warningTitle: o.warningTitle, + allowClear: o.allowClear, + listeners: [ + { + eventName: BI.SelectTextTrigger.EVENT_CLEAR, + action: function () { + self._clear(); + } + } + ], }); this.popup = BI.createWidget({ type: "bi.text_value_combo_popup", @@ -62,15 +72,20 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { minHeight: 25 } }); - if(BI.isKey(o.value)) { + if (BI.isKey(o.value)) { this._checkError(o.value); } }, + _clear: function () { + this.setValue(); + }, + _checkError: function (v) { - if(BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { + if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { this.trigger.options.tipType = "success"; - this.element.removeClass("combo-error"); + this.element.removeClass("error"); + this.trigger.element.removeClass("error"); } else { v = BI.isArray(v) ? v : [v]; var result = BI.find(this.options.items, function (idx, item) { @@ -78,10 +93,12 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }); if (BI.isNull(result)) { this.trigger.setTipType("warning"); - this.element.removeClass("combo-error").addClass("combo-error"); + this.element.addClass("error"); + this.trigger.element.addClass("error"); } else { this.trigger.setTipType("success"); - this.element.removeClass("combo-error"); + this.element.removeClass("error"); + this.trigger.element.removeClass("error"); } } }, diff --git a/src/case/list/list.select.js b/src/case/list/list.select.js index 12037b9a9..bab4a15af 100644 --- a/src/case/list/list.select.js +++ b/src/case/list/list.select.js @@ -94,7 +94,7 @@ BI.SelectList = BI.inherit(BI.Widget, { var hasNext = this.list.hasNext(); var isAlreadyAllSelected = this.toolbar.isSelected(); var isHalf = selectLength > 0 && notSelectLength > 0; - var allSelected = isAlreadyAllSelected; + var allSelected = selectLength > 0 && notSelectLength <= 0 && (!hasNext || isAlreadyAllSelected); if (this.isAllSelected() === false) { hasNext && (isHalf = selectLength > 0); diff --git a/src/case/trigger/trigger.text.js b/src/case/trigger/trigger.text.js index e8ee789df..b9a51cc6f 100644 --- a/src/case/trigger/trigger.text.js +++ b/src/case/trigger/trigger.text.js @@ -7,25 +7,27 @@ */ BI.TextTrigger = BI.inherit(BI.Trigger, { - _defaultConfig: function () { + props: function () { var self = this; - var conf = BI.TextTrigger.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-text-trigger", + return { + baseCls: "bi-text-trigger", height: 24, textHgap: 6, textCls: "", + allowClear: false, title: function () { return self.text.getText(); } - }); + }; }, - _init: function () { - BI.TextTrigger.superclass._init.apply(this, arguments); + render: function () { var self = this, o = this.options, c = this._const; - this.text = BI.createWidget({ + var text = { type: "bi.label", + ref: function (_ref) { + self.text = _ref; + }, cls: "select-text-label" + (BI.isKey(o.textCls) ? (" " + o.textCls) : ""), textAlign: "left", height: o.height, @@ -39,32 +41,56 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { tgap: o.textTgap, bgap: o.textBgap, readonly: o.readonly - }); - this.trigerButton = BI.createWidget({ + }; + + var triggerButton = { type: "bi.trigger_icon_button", + ref: function (_ref) { + self.triggerButton = _ref; + }, width: o.triggerWidth || o.height - }); + }; - BI.createWidget({ - element: this, + return ({ type: "bi.horizontal_fill", + columnSize: ["fill", o.triggerWidth || o.height], items: [ { - el: this.text, + el: text, width: "fill" }, { - el: this.trigerButton, - width: o.triggerWidth || o.height + el: o.allowClear ? { + type: "bi.vertical_adapt", + horizontalAlign: "left", + scrollable: false, + items: [ + { + el: { + type: "bi.icon_button", + ref: function (_ref) { + self.clearBtn = _ref; + }, + cls: "close-h-font " + (o.allowClear ? "clear-button" : ""), + stopPropagation: true, + handler: function () { + self.fireEvent(BI.TextTrigger.EVENT_CLEAR); + }, + }, + }, { + el: triggerButton, + } + ] + } : triggerButton, } ] }); }, - getTextor: function() { + getTextor: function () { return this.text; }, - setTextCls: function(cls) { + setTextCls: function (cls) { var o = this.options; var oldCls = o.textCls; o.textCls = cls; @@ -73,6 +99,9 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { setText: function (text) { this.text.setText(text); + if (this.options.allowClear) { + this.clearBtn.setVisible(BI.isNotEmptyString(text)); + } }, setTipType: function (v) { @@ -80,4 +109,6 @@ BI.TextTrigger = BI.inherit(BI.Trigger, { this.options.tipType = v; } }); + +BI.TextTrigger.EVENT_CLEAR = "EVENT_CLEAR"; BI.shortcut("bi.text_trigger", BI.TextTrigger); diff --git a/src/case/trigger/trigger.text.select.js b/src/case/trigger/trigger.text.select.js index 8b24c1c9c..5461292c1 100644 --- a/src/case/trigger/trigger.text.select.js +++ b/src/case/trigger/trigger.text.select.js @@ -11,6 +11,7 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { return BI.extend(BI.SelectTextTrigger.superclass._defaultConfig.apply(this, arguments), { baseCls: "bi-select-text-trigger", height: 24, + allowClear: false, }); }, @@ -32,11 +33,21 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { textTgap: o.textTgap, textBgap: o.textBgap, tipType: o.tipType, - warningTitle: o.warningTitle + warningTitle: o.warningTitle, + allowClear: o.allowClear, + listeners: [ + { + eventName: BI.TextTrigger.EVENT_CLEAR, + action: function () { + self.setText(""); + self.fireEvent(BI.SelectTextTrigger.EVENT_CLEAR); + } + } + ] }); }, - _digest: function(vals, items){ + _digest: function (vals, items) { var o = this.options; vals = BI.isArray(vals) ? vals : [vals]; var result = []; @@ -51,15 +62,20 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { return { textCls: "", text: result.join(",") - } + }; } else { return { textCls: "bi-water-mark", text: BI.isFunction(o.text) ? o.text() : o.text - } + }; } }, + setText: function (text) { + this.options.text = text; + this.trigger.setText(text); + }, + setValue: function (vals) { var formatValue = this._digest(vals, this.options.items); this.trigger.setTextCls(formatValue.textCls); @@ -67,10 +83,11 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { }, setTipType: function (v) { + this.options.tipType = v; this.trigger.setTipType(v); }, - getTextor: function() { + getTextor: function () { return this.trigger.getTextor(); }, @@ -78,4 +95,6 @@ BI.SelectTextTrigger = BI.inherit(BI.Trigger, { this.options.items = items; } }); + +BI.SelectTextTrigger.EVENT_CLEAR = "EVENT_CLEAR"; BI.shortcut("bi.select_text_trigger", BI.SelectTextTrigger); diff --git a/src/core/wrapper/layout/layout.inline.js b/src/core/wrapper/layout/layout.inline.js index a1d889337..04b38a47a 100644 --- a/src/core/wrapper/layout/layout.inline.js +++ b/src/core/wrapper/layout/layout.inline.js @@ -40,7 +40,7 @@ BI.InlineLayout = BI.inherit(BI.Layout, { _addElement: function (i, item) { var o = this.options; var w = BI.InlineLayout.superclass._addElement.apply(this, arguments); - var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width >= 1 ? null : item.width; + var columnSize = o.columnSize.length > 0 ? o.columnSize[i] : item.width; if (o.columnSize.length > 0) { if (item.width >= 1 && o.columnSize[i] >= 1 && o.columnSize[i] !== item.width) { columnSize = null; diff --git a/src/less/base/combo/combo.less b/src/less/base/combo/combo.less index 9725ac58a..206953d4b 100644 --- a/src/less/base/combo/combo.less +++ b/src/less/base/combo/combo.less @@ -1,19 +1,22 @@ @import "../../index.less"; + @val: transform .3s ease; .bi-combo { & > .bi-trigger { - & .bi-trigger-icon-button{ + & .bi-trigger-icon-button { & .x-icon { .rotate(0deg); .transition(@val); } } } + &.bi-combo-popup { display: block !important; visibility: visible !important; + & > .bi-trigger { - & .bi-trigger-icon-button{ + & .bi-trigger-icon-button { & .x-icon { .rotate(180deg); .transition(@val); @@ -21,11 +24,13 @@ } } } + &.bi-combo-popup, &.bi-combo-hover, &:hover { &.bi-border, &.bi-border-bottom { border-color: @color-bi-border-hover-combo; } } + &.disabled { &.bi-combo-hover, &:hover { &.bi-border, &.bi-border-bottom { @@ -33,6 +38,36 @@ } } } + + &.error { + &.bi-combo-hover, &:hover { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-negative; + } + } + } + + + // 将来统一变成combo的特性 + //&.status-error { + // &.bi-border, &.bi-border-bottom { + // border-color: @border-color-negative; + // } + // + // .bi-trigger .select-text-label { + // color: @color-bi-text-error-text-trigger; + // } + //} + // + //&.status-warning { + // &.bi-border, &.bi-border-bottom { + // border-color: @border-color-warning; + // } + // + // .bi-trigger .select-text-label { + // color: @font-color-warning; + // } + //} } .bi-theme-dark { diff --git a/src/less/base/combo/combo.textvalue.less b/src/less/base/combo/combo.textvalue.less deleted file mode 100644 index 1feec1972..000000000 --- a/src/less/base/combo/combo.textvalue.less +++ /dev/null @@ -1,14 +0,0 @@ -@import "../../index.less"; - -.bi-text-value-combo { - &.combo-error { - & .bi-select-text-trigger { - & .select-text-label { - color: @color-bi-text-error-hover-text-value-combo; - } - } - &.bi-border, &.bi-border-bottom { - border-color: @border-color-negative; - } - } -} \ No newline at end of file diff --git a/src/less/base/trigger/trigger.text.less b/src/less/base/trigger/trigger.text.less new file mode 100644 index 000000000..9e2040512 --- /dev/null +++ b/src/less/base/trigger/trigger.text.less @@ -0,0 +1,11 @@ +@import "../../index.less"; + +.bi-text-trigger { + &.error .select-text-label { + color: @color-bi-text-error-text-trigger; + } + + &:where(:not(&:hover)) .clear-button { + display: none; + } +} diff --git a/src/less/core/wrapper/flex.horizontal.less b/src/less/core/wrapper/flex.horizontal.less index a6a38704d..24d8862f6 100644 --- a/src/less/core/wrapper/flex.horizontal.less +++ b/src/less/core/wrapper/flex.horizontal.less @@ -169,7 +169,9 @@ } > .f-f { - min-width: 0; + &:not(.f-s-n) { + min-width: 0; + } -webkit-flex-grow: 1; -moz-flex-grow: 1; -ms-flex-grow: 1; diff --git a/src/less/core/wrapper/flex.vertical.less b/src/less/core/wrapper/flex.vertical.less index 5b97ea999..007396436 100644 --- a/src/less/core/wrapper/flex.vertical.less +++ b/src/less/core/wrapper/flex.vertical.less @@ -168,7 +168,9 @@ } > .f-f { - min-height: 0; + &:not(.f-s-n) { + min-height: 0; + } -webkit-flex-grow: 1; -moz-flex-grow: 1; -ms-flex-grow: 1; diff --git a/src/less/core/wrapper/flex.wrapper.horizontal.less b/src/less/core/wrapper/flex.wrapper.horizontal.less index 1b38fa0be..09926f54b 100644 --- a/src/less/core/wrapper/flex.wrapper.horizontal.less +++ b/src/less/core/wrapper/flex.wrapper.horizontal.less @@ -265,7 +265,9 @@ } > .f-f { - min-width: 0; + &:not(.f-s-n) { + min-width: 0; + } -webkit-flex-grow: 1; -moz-flex-grow: 1; -ms-flex-grow: 1; diff --git a/src/less/core/wrapper/flex.wrapper.vertical.less b/src/less/core/wrapper/flex.wrapper.vertical.less index 09693c348..118759152 100644 --- a/src/less/core/wrapper/flex.wrapper.vertical.less +++ b/src/less/core/wrapper/flex.wrapper.vertical.less @@ -259,7 +259,9 @@ } > .f-f { - min-height: 0; + &:not(.f-s-n) { + min-height: 0; + } -webkit-flex-grow: 1; -moz-flex-grow: 1; -ms-flex-grow: 1; diff --git a/src/less/lib/theme.less b/src/less/lib/theme.less index db42c9ef4..3c85b8031 100644 --- a/src/less/lib/theme.less +++ b/src/less/lib/theme.less @@ -179,6 +179,7 @@ @color-bi-border-hover-text-value-down-list-combo: @color-bi-border-highlight; @color-bi-border-hover-text-value-check-combo: @color-bi-border-highlight; @color-bi-text-error-hover-text-value-combo: @color-bi-text-failure; +@color-bi-text-error-text-trigger: @color-bi-text-failure; @color-bi-text-error-hover-text-value-icon-combo: @color-bi-text-failure; @color-bi-text-error-hover-search-text-value-combo: @color-bi-text-failure; @color-bi-background-bubble-combo-triangle: @color-bi-background-default; diff --git a/src/less/widget/multilayerselecttree/multilayerselecttree.combo.less b/src/less/widget/multilayerselecttree/multilayerselecttree.combo.less index ca3a79fbc..4ac60cf49 100644 --- a/src/less/widget/multilayerselecttree/multilayerselecttree.combo.less +++ b/src/less/widget/multilayerselecttree/multilayerselecttree.combo.less @@ -1,20 +1,24 @@ @import "../../index.less"; -@val: transform .3s ease; + .bi-multilayer-select-tree-combo { - & .trigger-icon-button{ - font-size: @font-size-16; - } - // 此combo的trigger_button是absolute上去的,与bi-combo在同一层级,独立写一下 - & .bi-combo.bi-combo-popup + .bi-trigger-icon-button { - & .x-icon { - .rotate(180deg); - .transition(@val); + + &.status-error { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-negative; + } + + .bi-trigger .select-text-label { + color: @color-bi-text-error-text-trigger; } } - & .bi-combo + .bi-trigger-icon-button { - & .x-icon { - .rotate(0deg); - .transition(@val); + + &.status-warning { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-warning; + } + + .bi-trigger .select-text-label { + color: @font-color-warning; } } } diff --git a/src/less/widget/multilayersingletree/multilayersingletree.combo.less b/src/less/widget/multilayersingletree/multilayersingletree.combo.less index af046bc74..6a1390230 100644 --- a/src/less/widget/multilayersingletree/multilayersingletree.combo.less +++ b/src/less/widget/multilayersingletree/multilayersingletree.combo.less @@ -1,20 +1,23 @@ @import "../../index.less"; -@val: transform .3s ease; + .bi-multilayer-single-tree-combo { - & .trigger-icon-button{ - font-size: @font-size-16; - } - // 此combo的trigger_button是absolute上去的,与bi-combo在同一层级,独立写一下 - & .bi-combo.bi-combo-popup + .bi-trigger-icon-button { - & .x-icon { - .rotate(180deg); - .transition(@val); + &.status-error { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-negative; + } + + .bi-trigger .select-text-label { + color: @color-bi-text-error-text-trigger; } } - & .bi-combo + .bi-trigger-icon-button { - & .x-icon { - .rotate(0deg); - .transition(@val); + + &.status-warning { + &.bi-border, &.bi-border-bottom { + border-color: @border-color-warning; + } + + .bi-trigger .select-text-label { + color: @font-color-warning; } } } diff --git a/src/widget/multilayerselecttree/multilayerselecttree.combo.js b/src/widget/multilayerselecttree/multilayerselecttree.combo.js index 6365ef484..8230ace71 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.combo.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.combo.js @@ -16,66 +16,29 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { allowEdit: false, allowSearchValue: false, allowInsertValue: false, - isNeedAdjustWidth: true + isNeedAdjustWidth: true, + status: "", // "error","warning" }); }, _init: function () { var o = this.options; - if (this._shouldWrapper()) { - o.height -= 2; - BI.isNumeric(o.width) && (o.width -= 2); - } + BI.isNumeric(o.width) && (o.width -= 2); + BI.isNumeric(o.height) && (o.height -= 2); BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments); }, render: function () { var self = this, o = this.options; - var combo = (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); - - return this._shouldWrapper() ? combo : { - type: "bi.absolute", - items: [{ - el: combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.trigger_icon_button", - cls: "trigger-icon-button", - ref: function (_ref) { - self.triggerBtn = _ref; - }, - width: o.height, - height: o.height, - handler: function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - } - }, - right: 0, - bottom: 0, - top: 0 - }] - }; - }, - - _shouldWrapper: function () { - var o = this.options; - return !o.allowEdit && o.itemsCreator === BI.emptyFn; + return (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); }, _getBaseConfig: function () { var self = this, o = this.options; return { type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius " + (BI.isKey(o.status) ? ("status-" + o.status) : ""), container: o.container, destroyWhenHide: o.destroyWhenHide, adjustLength: 2, @@ -122,7 +85,7 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { }; }, - _getSearchConfig: function() { + _getSearchConfig: function () { var self = this, o = this.options; return { el: { @@ -139,7 +102,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, watermark: o.watermark, - height: o.height - (o.simple ? 1 : 2), + // height: o.height - (o.simple ? 1 : 2), + height: o.height, text: o.text, value: o.value, tipType: o.tipType, @@ -184,7 +148,7 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { // IE11下,popover(position: fixed)下放置下拉控件(position: fixed), 滚动的时候会异常卡顿 // 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以 // 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪 - return (o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0) ? false : self.triggerBtn.element.find(e.target).length === 0; + return !(o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0); }, listeners: [{ @@ -198,7 +162,7 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_BEFORE_POPUPVIEW); } }] - } + }; }, _getSyncConfig: function () { @@ -207,13 +171,15 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : { el: { type: "bi.single_tree_trigger", - ref: function(_ref) { + ref: function (_ref) { self.textTrigger = _ref; }, text: o.text, height: o.height, items: o.items, - value: o.value + value: o.value, + tipType: o.tipType, + warningTitle: o.warningTitle, } }); }, @@ -236,6 +202,22 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { return this.trigger ? this.trigger.getSearcher() : this.textTrigger.getTextor(); }, + clear: function () { + // do some work + }, + + setStatus: function (status) { + if (BI.isKey(this.options.status)) { + this.element.removeClass("status-" + this.options.status); + } + this.element.addClass("status-" + status); + this.options.status = status; + }, + + setTipType: function (v) { + this.trigger ? this.trigger.setTipType(v) : this.textTrigger.setTipType(v); + }, + populate: function (items) { this.combo.populate(items); }, diff --git a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js index 4b66b58f7..11789b5ac 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js @@ -3,7 +3,7 @@ */ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { - props: function() { + props: function () { return { extraCls: "bi-multi-layer-select-tree-trigger", height: 24, @@ -16,11 +16,12 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { render: function () { var self = this, o = this.options; - if(o.itemsCreator === BI.emptyFn) { + if (o.itemsCreator === BI.emptyFn) { this._initData(); } - var content = { - type: "bi.htape", + + return { + type: "bi.horizontal_fill", items: [ { el: { @@ -86,7 +87,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }, onSearch: function (obj, callback) { var keyword = obj.keyword; - if(o.itemsCreator === BI.emptyFn) { + if (o.itemsCreator === BI.emptyFn) { callback(self._getSearchItems(keyword)); o.allowInsertValue && self.popup.setKeyword(keyword); } else { @@ -99,51 +100,37 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE); } }] - } + }, + width: "fill", }, { el: { - type: "bi.layout", - width: 24 + type: "bi.trigger_icon_button", + cls: "trigger-icon-button", + ref: function (_ref) { + self.triggerBtn = _ref; + }, + width: 24, }, - width: 24 + width: 24, } ] }; - - return o.allowEdit ? content : { - type: "bi.absolute", - items: [{ - el: content, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.layout" - }, - left: 0, - right: 24, - top: 0, - bottom: 0 - }] - }; }, - _initData: function() { + _initData: function () { var o = this.options; this.tree = new BI.Tree(); this.nodes = BI.Tree.treeFormat(BI.deepClone(o.items)); this.tree.initTree(this.nodes); }, - _getSearchItems: function(keyword) { + _getSearchItems: function (keyword) { var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); - if(find.find.length > 0 || find.match.length > 0) { + if (find.find.length > 0 || find.match.length > 0) { items.push(node); return true; } @@ -151,7 +138,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { return this._fillTreeStructure4Search(items, "id"); }, - _createJson: function(node, open) { + _createJson: function (node, open) { return { id: node.id, pId: node.pId, @@ -159,10 +146,10 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { value: node.value, isParent: BI.isNotEmptyArray(node.children), open: open - } + }; }, - _getChildren: function(node) { + _getChildren: function (node) { var self = this; node.children = node.children || []; var nodes = []; @@ -179,7 +166,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { var result = []; var queue = []; BI.each(leaves, function (idx, node) { - queue.push({pId: node.pId}); + queue.push({ pId: node.pId }); result.push(node); result = result.concat(self._getChildren(node)); }); @@ -188,7 +175,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id"); if (pNode != null) { pNode.open = true; - queue.push({pId: pNode.pId}); + queue.push({ pId: pNode.pId }); result.push(pNode); } } @@ -259,4 +246,4 @@ BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP"; BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START"; BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; -BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger); \ No newline at end of file +BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger); diff --git a/src/widget/multilayersingletree/multilayersingletree.combo.js b/src/widget/multilayersingletree/multilayersingletree.combo.js index 779e645bf..2060eeaa6 100644 --- a/src/widget/multilayersingletree/multilayersingletree.combo.js +++ b/src/widget/multilayersingletree/multilayersingletree.combo.js @@ -25,17 +25,15 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { _init: function () { var o = this.options; - if (this._shouldWrapper()) { - o.height -= 2; - BI.isNumeric(o.width) && (o.width -= 2); - } + BI.isNumeric(o.width) && (o.width -= 2); + BI.isNumeric(o.height) && (o.height -= 2); BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments); }, render: function () { var self = this, o = this.options; - var combo = (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); + return (o.itemsCreator === BI.emptyFn) ? this._getSyncConfig() : this._getAsyncConfig(); return this._shouldWrapper() ? combo : { type: "bi.absolute", @@ -79,7 +77,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { var self = this, o = this.options; return { type: "bi.combo", - cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius", + cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-border-radius " + (BI.isKey(o.status) ? ("status-" + o.status) : ""), container: o.container, destroyWhenHide: o.destroyWhenHide, adjustLength: 2, @@ -125,7 +123,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { }; }, - _getSearchConfig: function() { + _getSearchConfig: function () { var self = this, o = this.options; return { el: { @@ -142,7 +140,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { items: o.items, itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, - height: o.height - (o.simple ? 1 : 2), + height: o.height, text: o.text, value: o.value, tipType: o.tipType, @@ -186,7 +184,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { // IE11下,popover(position: fixed)下放置下拉控件(position: fixed), 滚动的时候会异常卡顿 // 通过container参数将popup放置于popover之外解决此问题, 其他下拉控件由于元素少或者有分页,所以 // 卡顿不明显, 先在此做尝试, 并在FineUI特殊处理待解决文档中标记跟踪 - return (o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0) ? false : self.triggerBtn.element.find(e.target).length === 0 + return !(o.container && self.trigger.getSearcher().isSearching() && self.trigger.getSearcher().getView().element.find(e.target).length > 0); }, listeners: [{ eventName: BI.Combo.EVENT_AFTER_HIDEVIEW, @@ -199,7 +197,7 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_BEFORE_POPUPVIEW); } }] - } + }; }, _getSyncConfig: function () { @@ -208,13 +206,15 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { return BI.extend(baseConfig, o.allowEdit ? this._getSearchConfig() : { el: { type: "bi.single_tree_trigger", - ref: function(_ref) { + ref: function (_ref) { self.textTrigger = _ref; }, text: o.text, height: o.height, items: o.items, - value: o.value + value: o.value, + tipType: o.tipType, + warningTitle: o.warningTitle, } }); }, @@ -237,6 +237,18 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { return this.combo.getValue(); }, + setStatus: function (status) { + if (BI.isKey(this.options.status)) { + this.element.removeClass("status-" + this.options.status); + } + this.element.addClass("status-" + status); + this.options.status = status; + }, + + setTipType: function (v) { + this.trigger ? this.trigger.setTipType(v) : this.textTrigger.setTipType(v); + }, + populate: function (items) { this.combo.populate(items); }, diff --git a/src/widget/multilayersingletree/multilayersingletree.trigger.js b/src/widget/multilayersingletree/multilayersingletree.trigger.js index 75a515129..8c58b0c8c 100644 --- a/src/widget/multilayersingletree/multilayersingletree.trigger.js +++ b/src/widget/multilayersingletree/multilayersingletree.trigger.js @@ -3,7 +3,7 @@ */ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { - props: function() { + props: function () { return { extraCls: "bi-multi-layer-single-tree-trigger", height: 24, @@ -16,11 +16,12 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { render: function () { var self = this, o = this.options; - if(o.itemsCreator === BI.emptyFn) { + if (o.itemsCreator === BI.emptyFn) { this._initData(); } - var content = { - type: "bi.htape", + + return { + type: "bi.horizontal_fill", items: [ { el: { @@ -86,7 +87,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { }, onSearch: function (obj, callback) { var keyword = obj.keyword; - if(o.itemsCreator === BI.emptyFn) { + if (o.itemsCreator === BI.emptyFn) { callback(self._getSearchItems(keyword)); o.allowInsertValue && self.popup.setKeyword(keyword); } else { @@ -99,51 +100,37 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE); } }] - } + }, + width: "fill", }, { el: { - type: "bi.layout", - width: 24 + type: "bi.trigger_icon_button", + cls: "trigger-icon-button", + ref: function (_ref) { + self.triggerBtn = _ref; + }, + width: 24, }, width: 24 } ] }; - - return o.allowEdit ? content : { - type: "bi.absolute", - items: [{ - el: content, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: { - type: "bi.layout" - }, - left: 0, - right: 24, - top: 0, - bottom: 0 - }] - }; }, - _initData: function() { + _initData: function () { var o = this.options; this.tree = new BI.Tree(); this.nodes = BI.Tree.treeFormat(BI.deepClone(o.items)); this.tree.initTree(this.nodes); }, - _getSearchItems: function(keyword) { + _getSearchItems: function (keyword) { var self = this, o = this.options; // 把数组搜索换成用BI.tree搜索节点, 搜到了就不再往下搜索 var items = []; this.tree.traverse(function (node) { var find = BI.Func.getSearchResult(self.tree.isRoot(node) ? [] : BI.concat([node.text], (o.allowSearchValue ? [node.value] : [])), keyword); - if(find.find.length > 0 || find.match.length > 0) { + if (find.find.length > 0 || find.match.length > 0) { items.push(node); return true; } @@ -151,7 +138,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { return this._fillTreeStructure4Search(items, "id"); }, - _createJson: function(node, open) { + _createJson: function (node, open) { return { id: node.id, pId: node.pId, @@ -159,10 +146,10 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { value: node.value, isParent: BI.isNotEmptyArray(node.children), open: open - } + }; }, - _getChildren: function(node) { + _getChildren: function (node) { var self = this; node.children = node.children || []; var nodes = []; @@ -179,7 +166,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { var result = []; var queue = []; BI.each(leaves, function (idx, node) { - queue.push({pId: node.pId}); + queue.push({ pId: node.pId }); result.push(node); result = result.concat(self._getChildren(node)); }); @@ -188,7 +175,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, { var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id"); if (pNode != null) { pNode.open = true; - queue.push({pId: pNode.pId}); + queue.push({ pId: pNode.pId }); result.push(pNode); } } @@ -260,4 +247,4 @@ BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP"; BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START"; BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; -BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger); \ No newline at end of file +BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger); diff --git a/src/widget/selecttree/selecttree.combo.js b/src/widget/selecttree/selecttree.combo.js index 98c542686..c6aca0c62 100644 --- a/src/widget/selecttree/selecttree.combo.js +++ b/src/widget/selecttree/selecttree.combo.js @@ -11,6 +11,7 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, { text: "", items: [], value: "", + allowClear: false, }); }, @@ -25,7 +26,13 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, { text: o.text, height: o.height, items: o.items, - value: o.value + value: o.value, + allowClear: o.allowClear, + warningTitle: o.warningTitle, + }); + + this.trigger.on(BI.SingleTreeTrigger.EVENT_CLEAR, function () { + self._clear(); }); this.popup = BI.createWidget({ @@ -53,12 +60,43 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, { self.setValue(self.popup.getValue()); self.combo.hideView(); }); + + if (BI.isKey(o.value)) { + this._checkError(o.value); + } + }, + + _checkError: function (v) { + if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { + this.trigger.options.tipType = "success"; + this.trigger.element.removeClass("error"); + this.element.removeClass("error"); + } else { + v = BI.isArray(v) ? v : [v]; + var result = BI.find(this.options.items, function (idx, item) { + return BI.contains(v, item.value); + }); + if (BI.isNull(result)) { + this.trigger.setTipType("warning"); + this.element.removeClass("error").addClass("error"); + this.trigger.element.removeClass("error").addClass("error"); + } else { + this.trigger.setTipType("success"); + this.trigger.element.removeClass("error"); + this.element.removeClass("error"); + } + } + }, + + _clear: function () { + this.setValue([]); }, setValue: function (v) { v = BI.isArray(v) ? v : [v]; this.trigger.setValue(v); this.popup.setValue(v); + this._checkError(v); }, getValue: function () { @@ -71,4 +109,4 @@ BI.SelectTreeCombo = BI.inherit(BI.Widget, { }); -BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo); \ No newline at end of file +BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo); diff --git a/src/widget/singletree/singletree.combo.js b/src/widget/singletree/singletree.combo.js index ce6d255d4..32d39d338 100644 --- a/src/widget/singletree/singletree.combo.js +++ b/src/widget/singletree/singletree.combo.js @@ -12,6 +12,7 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { text: "", items: [], value: "", + allowClear: false, }); }, @@ -26,9 +27,15 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { text: o.text, height: o.height, items: o.items, - value: o.value + value: o.value, + allowClear: o.allowClear, + warningTitle: o.warningTitle, }, o.trigger)); + this.trigger.on(BI.SingleTreeTrigger.EVENT_CLEAR, function () { + self._clear(); + }); + this.popup = BI.createWidget({ type: "bi.single_level_tree", items: o.items, @@ -58,6 +65,36 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { self.combo.hideView(); self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE); }); + + if (BI.isKey(o.value)) { + this._checkError(o.value); + } + }, + + _checkError: function (v) { + if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) { + this.trigger.options.tipType = "success"; + this.trigger.element.removeClass("error"); + this.element.removeClass("error"); + } else { + v = BI.isArray(v) ? v : [v]; + var result = BI.find(this.options.items, function (idx, item) { + return BI.contains(v, item.value); + }); + if (BI.isNull(result)) { + this.trigger.setTipType("warning"); + this.element.removeClass("error").addClass("error"); + this.trigger.element.removeClass("error").addClass("error"); + } else { + this.trigger.setTipType("success"); + this.trigger.element.removeClass("error"); + this.element.removeClass("error"); + } + } + }, + + _clear: function () { + this.setValue([]); }, populate: function (items) { @@ -68,6 +105,7 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { v = BI.isArray(v) ? v : [v]; this.trigger.setValue(v); this.popup.setValue(v); + this._checkError(v); }, getValue: function () { @@ -77,4 +115,4 @@ BI.SingleTreeCombo = BI.inherit(BI.Widget, { BI.SingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo); \ No newline at end of file +BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo); diff --git a/src/widget/singletree/singletree.trigger.js b/src/widget/singletree/singletree.trigger.js index 91183c033..f4a4ca7df 100644 --- a/src/widget/singletree/singletree.trigger.js +++ b/src/widget/singletree/singletree.trigger.js @@ -11,7 +11,8 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { height: 24, text: "", items: [], - value: "" + value: "", + allowClear: false, }); }, @@ -26,7 +27,18 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { text: o.text, items: o.items, height: o.height, - value: o.value + warningTitle: o.warningTitle, + tipType: o.tipType, + value: o.value, + allowClear: o.allowClear, + listeners: [ + { + eventName: BI.SelectTextTrigger.EVENT_CLEAR, + action: function () { + self.fireEvent(BI.SingleTreeTrigger.EVENT_CLEAR); + } + } + ] }); }, @@ -47,11 +59,16 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { this._checkTitle(); }, + setTipType: function (v) { + this.options.tipType = v; + this.trigger.setTipType(v); + }, + getValue: function () { return this.options.value || []; }, - getTextor: function() { + getTextor: function () { return this.trigger.getTextor(); }, @@ -61,4 +78,5 @@ BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { }); +BI.SingleTreeTrigger.EVENT_CLEAR = "EVENT_CLEAR"; BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger); diff --git a/src/widget/year/combo.year.js b/src/widget/year/combo.year.js index 62a498d54..1774ca384 100644 --- a/src/widget/year/combo.year.js +++ b/src/widget/year/combo.year.js @@ -24,7 +24,8 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, { min: o.minDate, max: o.maxDate, height: o.height - border, - value: o.value || "" + value: o.value || "", + watermark: o.watermark }); this.trigger.on(BI.DynamicYearTrigger.EVENT_KEY_DOWN, function () { if (self.combo.isViewVisible()) { @@ -211,8 +212,11 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, { isStateValid: function () { return this.trigger.isValid(); - } + }, + setWaterMark: function (v) { + this.trigger.setWaterMark(v); + } }); BI.DynamicYearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; diff --git a/src/widget/year/trigger.year.js b/src/widget/year/trigger.year.js index 91b80a431..fe8976b2f 100644 --- a/src/widget/year/trigger.year.js +++ b/src/widget/year/trigger.year.js @@ -10,7 +10,8 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { extraCls: "bi-year-trigger", min: "1900-01-01", // 最小日期 max: "2099-12-31", // 最大日期 - height: 24 + height: 24, + watermark: BI.i18nText("BI-Basic_Unrestricted") }); }, @@ -35,7 +36,7 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { }, hgap: c.hgap, vgap: c.vgap, - watermark: BI.i18nText("BI-Basic_Unrestricted"), + watermark: o.watermark, allowBlank: true, errorText: function (v) { if (BI.isPositiveInteger(v)) { @@ -188,6 +189,10 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { getKey: function () { return this.editor.getValue() | 0; + }, + + setWaterMark: function (v) { + this.editor.setWaterMark(v); } }); BI.DynamicYearTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; diff --git a/typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts b/typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts index 1fc9e1519..6146190b8 100644 --- a/typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts +++ b/typescript/widget/multilayerselecttree/multilayerselecttree.combo.ts @@ -21,4 +21,6 @@ export declare class MultiLayerSelectTreeCombo extends Widget { blur(): void; showView(): void; + + setStatus(status: "error" | "warning"): void; } diff --git a/typescript/widget/multilayersingletree/multilayersingletree.combo.ts b/typescript/widget/multilayersingletree/multilayersingletree.combo.ts index fcecc32c4..ebbf5c607 100644 --- a/typescript/widget/multilayersingletree/multilayersingletree.combo.ts +++ b/typescript/widget/multilayersingletree/multilayersingletree.combo.ts @@ -21,4 +21,6 @@ export declare class MultiLayerSingleTreeCombo extends Widget { blur(): void; showView(): void; + + setStatus(status: "error" | "warning"): void; }