Browse Source

Pull request #2686: DESIGN-4103 feat: "bi.search_text_value_combo" 也支持清空

Merge in VISUAL/fineui from ~DAILER/fineui:master to master

* commit '97dffab756ef5ae0681db5be9f55322ed57b1670':
  DESIGN-4103 feat: "bi.search_text_value_combo" 也支持清空
es6
Dailer 3 years ago
parent
commit
ecd2365ffc
  1. 43
      src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js
  2. 52
      src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js
  3. 2
      src/case/trigger/trigger.text.js

43
src/case/combo/searchtextvaluecombo/combo.searchtextvalue.js

@ -22,10 +22,8 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
o.items = BI.isFunction(o.items) ? this.__watch(o.items, function (context, newValue) {
self.populate(newValue);
}) : o.items;
return {
type: "bi.absolute",
items: [{
el: {
type: "bi.combo",
cls: (o.simple ? "bi-border-bottom" : "bi-border") + " bi-focus-shadow",
container: o.container,
@ -64,6 +62,11 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
self.combo.hideView();
self.fireEvent(BI.SearchTextValueCombo.EVENT_CHANGE);
}
}, {
eventName: BI.SearchTextValueTrigger.EVENT_CLEAR,
action: function () {
self._clear();
}
}]
},
popup: {
@ -100,35 +103,6 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
self.fireEvent(BI.SearchTextValueCombo.EVENT_BEFORE_POPUPVIEW);
}
}],
hideChecker: function (e) {
return self.triggerBtn.element.find(e.target).length === 0;
}
},
left: 0,
right: 0,
bottom: 0,
top: 0
}, {
el: {
type: "bi.trigger_icon_button",
cls: "trigger-icon-button",
ref: function () {
self.triggerBtn = this;
},
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
}]
};
},
@ -139,6 +113,11 @@ BI.SearchTextValueCombo = BI.inherit(BI.Widget, {
}
},
_clear: function () {
this.trigger.attr("text", "");
this.setValue([]);
},
_checkError: function (v) {
if (BI.isNull(v) || BI.isEmptyArray(v) || BI.isEmptyString(v)) {
this.trigger.options.tipType = "success";

52
src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js

@ -5,16 +5,32 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
props: function () {
return {
extraCls: "bi-search-text-value-trigger",
baseCls: "bi-search-text-value-trigger",
height: 24,
watermark: BI.i18nText("BI-Basic_Search")
watermark: BI.i18nText("BI-Basic_Search"),
allowClear: false,
};
},
render: function () {
var self = this, o = this.options;
var triggerButton = {
type: "bi.trigger_icon_button",
cls: "trigger-icon-button",
ref: function () {
self.triggerBtn = this;
},
width: o.height,
height: o.height,
width: 24,
};
var stateText = this._digest(o.value, o.items);
return {
type: "bi.htape",
type: "bi.horizontal_fill",
columnSize: ["fill", 24],
items: [
{
el: {
@ -30,7 +46,7 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
},
watermark: o.watermark,
defaultText: o.defaultText,
text: this._digest(o.value, o.items),
text: stateText,
value: o.value,
height: o.height,
tipText: ""
@ -55,10 +71,30 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
}]
}
}, {
el: o.allowClear ? {
type: "bi.vertical_adapt",
horizontalAlign: "left",
scrollable: false,
items: [
{
el: {
type: "bi.layout",
width: 24
type: "bi.icon_button",
ref: function (_ref) {
self.clearBtn = _ref;
},
cls: "close-h-font " + (o.allowClear ? "clear-button" : ""),
stopPropagation: true,
invisible: !BI.isNotEmptyString(stateText),
width: o.height,
handler: function () {
self.fireEvent(BI.SearchTextValueTrigger.EVENT_CLEAR);
},
},
}, {
el: triggerButton,
}
]
} : triggerButton,
width: 24
}
]
@ -100,7 +136,9 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, {
},
setValue: function (vals) {
this._setState(this._digest(vals, this.options.items));
var stateText = this._digest(vals, this.options.items);
this._setState(stateText);
this.options.allowClear && this.clearBtn.setVisible(BI.isNotEmptyString(stateText));
},
getValue: function () {

2
src/case/trigger/trigger.text.js

@ -72,6 +72,8 @@ BI.TextTrigger = BI.inherit(BI.Trigger, {
},
cls: "close-h-font " + (o.allowClear ? "clear-button" : ""),
stopPropagation: true,
width: o.triggerWidth || o.height,
invisible: !BI.isNotEmptyString(o.text),
handler: function () {
self.fireEvent(BI.TextTrigger.EVENT_CLEAR);
},

Loading…
Cancel
Save