diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index f027474dd..022739fb3 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -13,6 +13,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { text: "", value: "", defaultText: "", + el: {}, allowClear: false, status: "success", // success | warning | error, title: null, @@ -71,6 +72,7 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { } } ], + ...o.el }; let changeTag = false; const popup = { @@ -150,11 +152,9 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { var vals = BI.isArray(v) ? v : [v]; - var result = BI.find(this.options.items, function (idx, item) { - return BI.contains(vals, item.value); - }); + var result = BI.intersection(BI.map(this.options.items, (i, item) => item.value), vals); - if (BI.isNull(result)) { + if (result.length !== vals.length) { this.setStatus("error"); } else { this.setStatus("success"); diff --git a/src/case/combo/textvaluecombo/combo.textvaluesmall.js b/src/case/combo/textvaluecombo/combo.textvaluesmall.js index b6609544b..155b124ce 100644 --- a/src/case/combo/textvaluecombo/combo.textvaluesmall.js +++ b/src/case/combo/textvaluecombo/combo.textvaluesmall.js @@ -15,65 +15,45 @@ BI.SmallTextValueCombo = BI.inherit(BI.Widget, { }); }, - _init: function () { - var self = this, o = this.options; - o.value = BI.isFunction(o.value) ? this.__watch(o.value, function (context, newValue) { - self.setValue(newValue); - }) : o.value; - o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) { - self.populate(newValue); - }) : o.items; - BI.SmallTextValueCombo.superclass._init.apply(this, arguments); - this.trigger = BI.createWidget(o.el, { - type: "bi.small_select_text_trigger", - items: o.items, + render: function () { + var o = this.options; + return { + type: "bi.text_value_combo", + ref: (_ref) => { + this.combo = _ref; + }, height: o.height, - text: o.text - }); - this.popup = BI.createWidget({ - type: "bi.text_value_combo_popup", chooseType: o.chooseType, - items: o.items - }); - this.popup.on(BI.TextValueComboPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.SmallTextValueCombo.hideView(); - self.fireEvent(BI.SmallTextValueCombo.EVENT_CHANGE); - }); - this.popup.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.SmallTextValueCombo = BI.createWidget({ - type: "bi.combo", - element: this, - container: o.container, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup, - maxHeight: 240, - minHeight: 25 - } - }); - - if(BI.isKey(o.value)){ - this.setValue(o.value); + el: { + type: "bi.small_select_text_trigger", + ...o.el + }, + text: o.text, + value: o.value, + defaultText: o.defaultText, + allowClear: o.allowClear, + status: o.status, + title: o.title, + listeners: [{ + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: (...args) => { + this.fireEvent(BI.SmallTextValueCombo.EVENT_CHANGE, ...args); + } + }] } }, setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); + this.combo.setValue(v); }, getValue: function () { - return this.popup.getValue(); + return this.combo.getValue(); }, populate: function (items) { - this.options.items = items; - this.SmallTextValueCombo.populate(items); + this.combo.populate(items); } }); BI.SmallTextValueCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo); \ No newline at end of file +BI.shortcut("bi.small_text_value_combo", BI.SmallTextValueCombo); diff --git a/src/core/4.widget.js b/src/core/4.widget.js index df560dc24..957ae836f 100644 --- a/src/core/4.widget.js +++ b/src/core/4.widget.js @@ -743,6 +743,7 @@ }, _unMount: function () { + this._assetMounted(); this.__destroy(); this.fireEvent(BI.Events.UNMOUNT); this.purgeListeners();