Browse Source

BI-87205 feat: fineui搜索功能支持搜索空格

master
windy 4 years ago
parent
commit
dcf4b1df8b
  1. 1
      changelog.md
  2. 2
      i18n/i18n.cn.js
  3. 11
      src/base/combination/searcher.js
  4. 48
      src/base/single/editor/editor.textarea.js
  5. 5
      src/case/editor/editor.state.js
  6. 3
      src/core/constant/var.js
  7. 2
      src/widget/editor/editor.search.js
  8. 18
      src/widget/multiselect/multiselect.combo.js
  9. 9
      src/widget/multiselect/multiselect.combo.nobar.js
  10. 31
      src/widget/multiselect/multiselect.insert.combo.js
  11. 31
      src/widget/multiselect/multiselect.insert.combo.nobar.js
  12. 4
      src/widget/multiselect/multiselect.insert.trigger.js
  13. 49
      src/widget/multiselect/search/multiselect.search.insert.pane.js
  14. 48
      src/widget/multiselect/search/multiselect.search.pane.js
  15. 34
      src/widget/multiselect/trigger/editor.multiselect.js
  16. 199
      src/widget/multiselect/trigger/editor/editor.patch.js
  17. 18
      src/widget/multiselect/trigger/searcher.multiselect.insert.js
  18. 6
      src/widget/multiselect/trigger/searcher.multiselect.js
  19. 58
      src/widget/multiselectlist/multiselectlist.insert.js
  20. 55
      src/widget/multiselectlist/multiselectlist.insert.nobar.js
  21. 39
      src/widget/multiselectlist/multiselectlist.js
  22. 18
      src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js
  23. 2
      src/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue.js
  24. 20
      src/widget/singleselect/search/singleselect.search.pane.insert.js
  25. 14
      src/widget/singleselect/search/singleselect.search.pane.js
  26. 12
      src/widget/singleselect/singleselect.combo.js
  27. 22
      src/widget/singleselect/singleselect.insert.combo.js
  28. 16
      src/widget/singleselect/singleselectlist.insert.js
  29. 35
      src/widget/singleselect/trigger/editor.singleselect.js
  30. 5
      src/widget/singleselect/trigger/searcher.singleselect.js
  31. 1
      typescript/core/var.ts

1
changelog.md

@ -1,5 +1,6 @@
# 更新日志
2.0(2021-05)
- 支持搜索的控件支持搜索包含空格的字符串
- 解决了树列表populate调用两次itemsCreator的问题
2.0(2021-03)

2
i18n/i18n.cn.js

@ -166,7 +166,7 @@ BI.i18n = {
"BI-More_Than": "大于",
"BI-More_And_Equal": "大于等于",
"BI-Please_Enter_SQL": "请输入SQL",
"BI-Basic_Click_To_Add_Text": "+点击新增\"{R1}\"",
"BI-Basic_Click_To_Add_Text": "点按回车键添加\"{R1}\"",
"BI-Basic_Please_Select": "请选择",
"BI-Basic_Font_Color": "文字颜色",
"BI-Basic_Background_Color": "背景色",

11
src/base/combination/searcher.js

@ -21,7 +21,6 @@ BI.Searcher = BI.inherit(BI.Widget, {
isAutoSearch: true, // 是否自动搜索
isAutoSync: true, // 是否自动同步数据, 即是否保持搜索面板和adapter面板状态值的统一
chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE,
allowSearchBlank: true, // 是否能够搜索包含空格的字符串
// isAutoSearch为false时启用
onSearch: function (op, callback) {
@ -80,10 +79,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
search();
break;
case BI.Events.PAUSE:
// 可以搜索空格的情况下输入空格不做处理, 展示上一次的结果
if (!o.allowSearchBlank) {
self._pauseSearch();
}
break;
}
});
@ -167,7 +163,7 @@ BI.Searcher = BI.inherit(BI.Widget, {
},
_search: function () {
var self = this, o = this.options, keyword = o.allowSearchBlank ? this.editor.getValue() : this._getLastSearchKeyword();
var self = this, o = this.options, keyword = this.editor.getValue();
if (keyword === "" || this._stop) {
return;
}
@ -202,7 +198,10 @@ BI.Searcher = BI.inherit(BI.Widget, {
_getLastSearchKeyword: function () {
if (this.isValid()) {
var res = this.editor.getValue().match(/[\S]+/g);
var res = this.editor.getValue().split(/\u200b\s\u200b/);
if (BI.isEmptyString(res[res.length - 1])) {
res = res.slice(0, res.length - 1);
}
return BI.isNull(res) ? "" : res[res.length - 1];
}
},

48
src/base/single/editor/editor.textarea.js

@ -16,6 +16,7 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
validationChecker: function () {
return true;
},
scrolly: true,
});
},
@ -26,7 +27,10 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
tagName: "textarea",
width: "100%",
height: "100%",
cls: "bi-textarea textarea-editor-content display-block"
cls: "bi-textarea textarea-editor-content display-block",
css: o.scrolly ? null : {
overflowY: "hidden",
},
});
this.content.element.css({ resize: "none" });
BI.createWidget({
@ -47,7 +51,11 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
this.content.element.on("input propertychange", function (e) {
self._checkError();
self._checkWaterMark();
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, self.getValue(), self);
self.fireEvent(BI.TextAreaEditor.EVENT_CHANGE);
if (BI.isEmptyString(self.getValue())) {
self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, self.getValue(), self);
}
});
this.content.element.focus(function () {
@ -64,9 +72,19 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
this.content.element.blur(function () {
self._setErrorVisible(false);
self._blur();
if (!self._isError()) {
self.fireEvent(BI.TextAreaEditor.EVENT_CONFIRM);
}
self.fireEvent(BI.TextAreaEditor.EVENT_BLUR);
BI.Widget._renderEngine.createElement(document).unbind("mousedown." + self.getName());
});
this.content.element.keydown(function () {
// 水印快速消失
self.watermark && self.watermark.setVisible(false);
});
this.content.element.click(function (e) {
e.stopPropagation();
});
if (BI.isKey(o.value)) {
this.setValue(o.value);
}
@ -93,8 +111,8 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
text: o.watermark,
invalid: o.invalid,
disabled: o.disabled,
hgap: 4,
vgap: 4
hgap: 6,
vgap: o.height > 24 ? 4 : 2,
});
this.watermark.element.bind({
mousedown: function (e) {
@ -104,7 +122,10 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
self.blur();
}
e.stopEvent();
}
},
click: function (e) {
e.stopPropagation();
},
});
BI.createWidget({
type: "bi.absolute",
@ -125,13 +146,20 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
}
},
_isError: function () {
return this.isEnabled() && !this.options.validationChecker(this.getValue());
},
_checkError: function () {
this._setErrorVisible(this.isEnabled() && !this.options.validationChecker(this.getValue()));
this._setErrorVisible(this._isError());
},
_focus: function () {
this.content.element.addClass("textarea-editor-focus");
this._checkWaterMark();
if (BI.isEmptyString(this.getValue())) {
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
}
},
_blur: function () {
@ -155,6 +183,13 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
}
},
_defaultState: function () {
if (BI.isEmptyString(this.getValue())) {
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY, this.getValue(), this);
this.fireEvent(BI.TextAreaEditor.EVENT_EMPTY);
}
},
focus: function () {
this._focus();
this.content.element.focus();
@ -173,6 +208,7 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
this.content.element.val(value);
this._checkError();
this._checkWaterMark();
this._defaultState();
},
setStyle: function (style) {
@ -206,4 +242,6 @@ BI.TextAreaEditor = BI.inherit(BI.Single, {
BI.TextAreaEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.TextAreaEditor.EVENT_BLUR = "EVENT_BLUR";
BI.TextAreaEditor.EVENT_FOCUS = "EVENT_FOCUS";
BI.TextAreaEditor.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.TextAreaEditor.EVENT_EMPTY = "EVENT_EMPTY";
BI.shortcut("bi.textarea_editor", BI.TextAreaEditor);

5
src/case/editor/editor.state.js

@ -22,14 +22,15 @@ BI.StateEditor = BI.inherit(BI.Widget, {
errorText: "",
height: 24,
defaultText: "", // 默认显示值,默认显示值与显示值的区别是默认显示值标记灰色
text: BI.i18nText("BI-Basic_Unrestricted") // 显示值
text: BI.i18nText("BI-Basic_Unrestricted"), // 显示值
el: {}
});
},
_init: function () {
BI.StateEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
this.editor = BI.createWidget(o.el, {
type: "bi.editor",
height: o.height,
hgap: o.hgap,

3
src/core/constant/var.js

@ -135,5 +135,6 @@ _.extend(BI, {
Bottom: "bottom",
Stretch: "stretch"
},
StartOfWeek: 1
StartOfWeek: 1,
BlankSplitChar: "\u200b \u200b",
});

2
src/widget/editor/editor.search.js

@ -17,7 +17,7 @@ BI.SearchEditor = BI.inherit(BI.Widget, {
this.options.height -= 2;
BI.SearchEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget({
this.editor = BI.createWidget(o.el, {
type: "bi.editor",
height: o.height,
watermark: o.watermark,

18
src/widget/multiselect/multiselect.combo.js

@ -76,28 +76,12 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
self._setStartValue("");
self.fireEvent(BI.MultiSelectCombo.EVENT_STOP);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getMatchedItemValue();
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
self.combo.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.populate();
self._setStartValue("");
self._dataChange = true;
});
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
var last = BI.last(keywords);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
if (BI.endWith(last, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();

9
src/widget/multiselect/multiselect.combo.nobar.js

@ -76,18 +76,13 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
self._setStartValue("");
self.fireEvent(BI.MultiSelectNoBarCombo.EVENT_STOP);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
self._addItem(assertShowValue, true);
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
var last = BI.last(keywords);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
if (BI.endWith(last, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();
@ -292,7 +287,7 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
_addItem: function (assertShowValue, matched) {
var self = this;
var keyword = matched ? this.trigger.getSearcher().getMatchedItemValue() : this.trigger.getSearcher().getKeyword();
var keyword = this.trigger.getSearcher().getKeyword();
this._join({
type: BI.Selection.Multi,
value: [keyword]

31
src/widget/multiselect/multiselect.insert.combo.js

@ -74,24 +74,14 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
self.fireEvent(BI.MultiSelectInsertCombo.EVENT_STOP);
});
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
self._addItem(assertShowValue, true);
}
});
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM, function () {
if (!this.getSearcher().hasMatched()) {
self._addItem(assertShowValue);
var addedValue = this.getSearcher().getKeyword();
self._stopEditing();
self.fireEvent(BI.MultiSelectInsertCombo.EVENT_ADD_ITEM, addedValue);
}
});
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) {
var last = BI.last(keywords);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
if (BI.endWith(last, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();
@ -300,9 +290,9 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
});
},
_addItem: function (assertShowValue, matched) {
_addItem: function (assertShowValue) {
var self = this;
var keyword = matched ? this.trigger.getSearcher().getMatchedItemValue() : this.trigger.getSearcher().getKeyword();
var keyword = this.trigger.getSearcher().getKeyword();
this._join({
type: BI.Selection.Multi,
value: [keyword]
@ -344,20 +334,12 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
var self = this, o = this.options;
this._assertValue(this.storeValue);
this.requesting = true;
o.itemsCreator({
type: BI.MultiSelectInsertCombo.REQ_GET_ALL_DATA,
keywords: keywords
}, function (ob) {
var values = BI.map(ob.items, "value");
digest(values);
});
function digest (items) {
var selectedMap = self._makeMap(items);
digest();
function digest () {
BI.each(keywords, function (i, val) {
if (BI.isNotNull(selectedMap[val])) {
self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
}
});
self._adjust(callback);
}
@ -491,6 +473,5 @@ BI.MultiSelectInsertCombo.EVENT_STOP = "EVENT_STOP";
BI.MultiSelectInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiSelectInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.MultiSelectInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.MultiSelectInsertCombo.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multi_select_insert_combo", BI.MultiSelectInsertCombo);

31
src/widget/multiselect/multiselect.insert.combo.nobar.js

@ -69,24 +69,14 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
self._setStartValue("");
});
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
self._addItem(assertShowValue, true);
}
});
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM, function () {
if (!this.getSearcher().hasMatched()) {
self._addItem(assertShowValue);
var addedValue = this.getSearcher().getKeyword();
self._stopEditing();
self.fireEvent(BI.MultiSelectInsertNoBarCombo.EVENT_ADD_ITEM, addedValue);
}
});
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) {
var last = BI.last(keywords);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
if (BI.endWith(last, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();
@ -298,9 +288,9 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
});
},
_addItem: function (assertShowValue, matched) {
_addItem: function (assertShowValue) {
var self = this;
var keyword = matched ? this.trigger.getSearcher().getMatchedItemValue() : this.trigger.getSearcher().getKeyword();
var keyword = this.trigger.getSearcher().getKeyword();
this._join({
type: BI.Selection.Multi,
value: [keyword]
@ -342,20 +332,12 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
var self = this, o = this.options;
this._assertValue(this.storeValue);
this.requesting = true;
o.itemsCreator({
type: BI.MultiSelectInsertNoBarCombo.REQ_GET_ALL_DATA,
keywords: keywords
}, function (ob) {
var values = BI.map(ob.items, "value");
digest(values);
});
function digest (items) {
var selectedMap = self._makeMap(items);
digest();
function digest () {
BI.each(keywords, function (i, val) {
if (BI.isNotNull(selectedMap[val])) {
self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
}
});
self._adjust(callback);
}
@ -485,6 +467,5 @@ BI.extend(BI.MultiSelectInsertNoBarCombo, {
});
BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.MultiSelectInsertNoBarCombo.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multi_select_insert_no_bar_combo", BI.MultiSelectInsertNoBarCombo);

4
src/widget/multiselect/multiselect.insert.trigger.js

@ -49,9 +49,6 @@ BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, {
this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_START, function () {
self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_START);
});
this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_ADD_ITEM, function () {
self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM);
});
this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_PAUSE, function () {
self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_PAUSE);
});
@ -150,7 +147,6 @@ BI.MultiSelectInsertTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiSelectInsertTrigger.EVENT_PAUSE = "EVENT_PAUSE";
BI.MultiSelectInsertTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW";
BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiSelectInsertTrigger.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiSelectInsertTrigger.EVENT_BLUR = "EVENT_BLUR";

49
src/widget/multiselect/search/multiselect.search.insert.pane.js

@ -27,24 +27,12 @@ BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, {
BI.MultiSelectSearchInsertPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.tooltipClick = BI.createWidget({
type: "bi.label",
invisible: true,
text: BI.i18nText("BI-Click_Blank_To_Select"),
cls: "multi-select-toolbar",
height: this.constants.height
});
this.addNotMatchTip = BI.createWidget({
type: "bi.text_button",
invisible: true,
type: "bi.label",
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: this.constants.height,
cls: "bi-high-light",
hgap: 5,
handler: function () {
self.fireEvent(BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM, o.keywordGetter());
}
});
this.loader = BI.createWidget({
@ -68,38 +56,16 @@ BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, {
type: "bi.vtape",
element: this,
items: [{
type: "bi.vertical",
items: [this.tooltipClick, this.addNotMatchTip],
height: this.constants.height
el: this.addNotMatchTip,
height: this.constants.height,
}, {
el: this.loader
}]
el: this.loader,
}],
});
},
setKeyword: function (keyword) {
var o = this.options;
var hasSameValue = BI.some(this.loader.getAllButtons(), function (idx, btn) {
return keyword === (o.valueFormatter(btn.getValue()) || btn.getValue());
});
var isMatchTipVisible = this.loader.getAllButtons().length > 0 && hasSameValue;
this.tooltipClick.setVisible(isMatchTipVisible);
this.addNotMatchTip.setVisible(!isMatchTipVisible);
!isMatchTipVisible && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getMatchedItemValue: function () {
var value;
var o = this.options;
BI.some(this.loader.getAllButtons(), function (idx, btn) {
var v = btn.getValue();
if (o.keywordGetter() === (o.valueFormatter(v) || v)) {
value = v;
return true;
}
});
return value;
this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
isAllSelected: function () {
@ -107,7 +73,7 @@ BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, {
},
hasMatched: function () {
return this.tooltipClick.isVisible();
return false;
},
setValue: function (v) {
@ -128,6 +94,5 @@ BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, {
});
BI.MultiSelectSearchInsertPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multi_select_search_insert_pane", BI.MultiSelectSearchInsertPane);

48
src/widget/multiselect/search/multiselect.search.pane.js

@ -27,14 +27,6 @@ BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
BI.MultiSelectSearchPane.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.tooltipClick = BI.createWidget({
type: "bi.label",
invisible: true,
text: BI.i18nText("BI-Click_Blank_To_Select"),
cls: "multi-select-toolbar",
height: this.constants.height
});
this.loader = BI.createWidget({
type: "bi.multi_select_search_loader",
keywordGetter: o.keywordGetter,
@ -42,7 +34,6 @@ BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
itemsCreator: function (op, callback) {
o.itemsCreator.apply(self, [op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
}]);
},
itemHeight: o.itemHeight,
@ -53,40 +44,16 @@ BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
});
this.resizer = BI.createWidget({
type: "bi.vtape",
type: "bi.absolute",
element: this,
items: [{
el: this.tooltipClick,
height: 0
}, {
el: this.loader
}]
});
this.tooltipClick.setVisible(false);
},
setKeyword: function (keyword) {
var btn, o = this.options;
var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === (o.valueFormatter(btn.getValue()) || btn.getValue()));
if (isVisible !== this.tooltipClick.isVisible()) {
this.tooltipClick.setVisible(isVisible);
this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0);
this.resizer.resize();
}
},
getMatchedItemValue: function () {
var value;
var o = this.options;
BI.some(this.loader.getAllButtons(), function (idx, btn) {
var v = btn.getValue();
if (o.keywordGetter() === (o.valueFormatter(v) || v)) {
value = v;
return true;
}
el: this.loader,
left: 0,
right: 0,
bottom: 0,
top: 0,
}],
});
return value;
},
isAllSelected: function () {
@ -94,7 +61,6 @@ BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
},
hasMatched: function () {
return this.tooltipClick.isVisible();
},
setValue: function (v) {

34
src/widget/multiselect/trigger/editor.multiselect.js

@ -18,7 +18,7 @@ BI.MultiSelectEditor = BI.inherit(BI.Widget, {
BI.MultiSelectEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget(o.el, {
type: "bi.state_editor",
type: "bi.select_patch_editor",
element: this,
height: o.height,
watermark: o.watermark,
@ -33,10 +33,6 @@ BI.MultiSelectEditor = BI.inherit(BI.Widget, {
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.editor.on(BI.StateEditor.EVENT_PAUSE, function () {
self.fireEvent(BI.MultiSelectEditor.EVENT_PAUSE);
});
this.editor.on(BI.StateEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.MultiSelectEditor.EVENT_FOCUS);
});
@ -66,12 +62,7 @@ BI.MultiSelectEditor = BI.inherit(BI.Widget, {
},
getValue: function () {
var v = this.editor.getState();
if (BI.isArray(v) && v.length > 0) {
return v[v.length - 1];
}
return "";
return this.editor.getValue();
},
getState: function () {
@ -79,14 +70,27 @@ BI.MultiSelectEditor = BI.inherit(BI.Widget, {
},
getKeywords: function () {
var val = this.editor.getLastChangedValue();
var keywords = val.match(/[\S]+/g);
if (BI.isEndWithBlank(val)) {
return keywords.concat([" "]);
var val = this.editor.getValue();
var keywords = val.split(/\u200b\s\u200b/);
if (BI.isEmptyString(keywords[keywords.length - 1])) {
keywords = keywords.slice(0, keywords.length - 1);
}
if (/\u200b\s\u200b$/.test(val)) {
return keywords.concat([BI.BlankSplitChar]);
}
return keywords;
},
getKeyword: function () {
var val = this.editor.getValue();
var keywords = val.split(/\u200b\s\u200b/);
if (BI.isEmptyString(keywords[keywords.length - 1])) {
keywords = keywords.slice(0, keywords.length - 1);
}
return BI.isEmptyArray(keywords) ? "" : keywords[keywords.length - 1];
},
populate: function (items) {
}

199
src/widget/multiselect/trigger/editor/editor.patch.js

@ -0,0 +1,199 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2021/5/18
*/
BI.SelectPatchEditor = BI.inherit(BI.Widget, {
props: {
baseCls: "bi-patch-select-editor",
height: 24,
},
render: function () {
var self = this, o = this.options;
var debounceInputChange = BI.debounce(BI.bind(this._dealChange, this), 300);
return BI.extend({
type: "bi.state_editor",
ref: function (_ref) {
self.editor = _ref;
},
hgap: o.hgap,
vgap: o.vgap,
lgap: o.lgap,
rgap: o.rgap,
tgap: o.tgap,
bgap: o.bgap,
height: o.height,
watermark: o.watermark,
allowBlank: true,
value: o.value,
defaultText: o.text,
text: o.text,
tipType: o.tipType,
warningTitle: o.warningTitle,
el: {
type: 'bi.textarea_editor',
scrolly: false,
validationChecker: function () {
return true;
},
throttle: true,
},
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function (type, v) {
if (BI.contains(v, "\n")) {
self._dealChange(type, v);
} else {
debounceInputChange(type, v);
}
},
}, {
eventName: BI.Editor.EVENT_FOCUS,
action: function () {
self.fireEvent(BI.SelectPatchEditor.EVENT_FOCUS, arguments);
},
}, {
eventName: BI.Editor.EVENT_BLUR,
action: function () {
self.fireEvent(BI.SelectPatchEditor.EVENT_BLUR, arguments);
},
}],
}, o.el);
},
_dealChange: function (type, v) {
var value = "";
if (BI.isKey(v)) {
value = this._formatText(v);
}
if (type === BI.Events.CHANGE) {
this._setValue(value);
if (this._trimValue(value) !== "") {
if (!this._start || !BI.isKey(this._lastValue) || (this._pause === true && !/\u200b\s\u200b$/.test(this.getValue()))) {
this._start = true;
this._pause = false;
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.STARTEDIT, this.getValue(), this);
}
}
if (this._trimValue(this._lastValue) !== this._trimValue(value)) {
this.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
if (BI.endWith(value, BI.BlankSplitChar)) {
this._pause = true;
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.PAUSE, "", this);
}
}
if (type === BI.Events.EMPTY || type === BI.Events.STOPEDIT) {
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.EMPTY);
}
this._lastValue = value;
},
_trimValue: function (v) {
return BI.trim(BI.replaceAll(v || "", BI.BlankSplitChar, ""));
},
_formatText: function (v) {
return BI.replaceAll(v || "", "\n", BI.BlankSplitChar);
},
setWaterMark: function (v) {
this.editor.setWaterMark(v);
},
doRedMark: function () {
this.editor.doRedMark.apply(this.editor, arguments);
},
unRedMark: function () {
this.editor.unRedMark.apply(this.editor, arguments);
},
doHighLight: function () {
this.editor.doHighLight.apply(this.editor, arguments);
},
unHighLight: function () {
this.text.unHighLight.apply(this.text, arguments);
},
focus: function () {
this.editor.focus();
},
blur: function () {
this.editor.blur();
},
_setValue: function (v) {
this.editor.setValue(this._formatText(v));
},
_showInput: function () {
this.editor.visible();
this.text.invisible();
},
_showHint: function () {
this.editor.invisible();
this.text.visible();
},
isValid: function () {
return this.editor.isValid();
},
setErrorText: function (text) {
this.editor.setErrorText(text);
},
getErrorText: function () {
return this.editor.getErrorText();
},
isEditing: function () {
return this.editor.isEditing();
},
getLastValidValue: function () {
return this.editor.getLastValidValue();
},
getLastChangedValue: function () {
return this.editor.getLastChangedValue();
},
setValue: function (v) {
this._setValue(v);
this._lastValue = this._trimValue(v);
},
getValue: function () {
return BI.trim(this.editor.getValue());
},
getState: function () {
return this.editor.getState();
},
setState: function (v) {
this.editor.setState(v);
},
setTipType: function (v) {
this.editor.setTipType(v);
},
getText: function () {
return this.editor.getText();
},
});
BI.SelectPatchEditor.EVENT_CHANGE = "EVENT_CHANGE";
BI.SelectPatchEditor.EVENT_FOCUS = "EVENT_FOCUS";
BI.SelectPatchEditor.EVENT_BLUR = "EVENT_BLUR";
BI.shortcut("bi.select_patch_editor", BI.SelectPatchEditor);

18
src/widget/multiselect/trigger/searcher.multiselect.insert.js

@ -43,7 +43,6 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, {
this.searcher = BI.createWidget({
type: "bi.searcher",
allowSearchBlank: false,
element: this,
height: o.height,
isAutoSearch: false,
@ -57,22 +56,16 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, {
type: "bi.multi_select_search_insert_pane",
valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.editor.getValue();
return self.editor.getKeyword();
},
itemsCreator: function (op, callback) {
var keyword = self.editor.getValue();
var keyword = self.editor.getKeyword();
op.keywords = [keyword];
this.setKeyword(keyword);
o.itemsCreator(op, callback);
},
itemHeight: o.itemHeight,
value: o.value,
listeners: [{
eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM,
action: function () {
self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_ADD_ITEM);
}
}]
}, o.popup),
adapter: o.adapter,
@ -115,7 +108,7 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, {
},
getKeyword: function () {
return this.editor.getValue();
return this.editor.getKeyword();
},
hasMatched: function () {
@ -169,10 +162,6 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, {
}
},
getMatchedItemValue: function() {
return this.searcher.getView().getMatchedItemValue();
},
getState: function() {
return this.editor.getState();
},
@ -201,7 +190,6 @@ BI.MultiSelectInsertSearcher.EVENT_START = "EVENT_START";
BI.MultiSelectInsertSearcher.EVENT_STOP = "EVENT_STOP";
BI.MultiSelectInsertSearcher.EVENT_PAUSE = "EVENT_PAUSE";
BI.MultiSelectInsertSearcher.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiSelectInsertSearcher.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiSelectInsertSearcher.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiSelectInsertSearcher.EVENT_BLUR = "EVENT_BLUR";
BI.shortcut("bi.multi_select_insert_searcher", BI.MultiSelectInsertSearcher);

6
src/widget/multiselect/trigger/searcher.multiselect.js

@ -43,7 +43,6 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
this.searcher = BI.createWidget({
type: "bi.searcher",
allowSearchBlank: false,
element: this,
height: o.height,
isAutoSearch: false,
@ -62,7 +61,6 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
itemsCreator: function (op, callback) {
var keyword = self.editor.getValue();
op.keywords = [keyword];
this.setKeyword(keyword);
o.itemsCreator(op, callback);
},
itemHeight: o.itemHeight,
@ -96,10 +94,6 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
}
},
getMatchedItemValue: function() {
return this.searcher.getView().getMatchedItemValue();
},
adjustView: function () {
this.searcher.adjustView();
},

58
src/widget/multiselectlist/multiselectlist.insert.js

@ -57,32 +57,21 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
}
},
itemHeight: o.itemHeight,
listeners: [{
eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM,
action: function () {
var keyword = self.trigger.getKeyword();
if (!self.trigger.hasMatched()) {
if (self.storeValue.type === BI.Selection.Multi) {
BI.pushDistinct(self.storeValue.value, keyword);
}
self._showAdapter();
self.adapter.setValue(self.storeValue);
self.adapter.populate();
if (self.storeValue.type === BI.Selection.Multi) {
self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
}
}
}
}]
});
this.searcherPane.setVisible(false);
this.trigger = BI.createWidget({
type: "bi.searcher",
el: {
type: "bi.select_patch_editor",
el: {
type: "bi.search_editor",
},
ref: function (ref) {
self.editor = ref;
},
height: o.searcherHeight,
},
allowSearchBlank: false,
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
@ -112,7 +101,6 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
var keyword = this.getKeyword();
if (this.hasMatched()) {
self._join({
type: BI.Selection.Multi,
value: [keyword]
@ -128,18 +116,17 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
self._setStartValue("");
self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE);
});
}
self._showAdapter();
}
}, {
eventName: BI.Searcher.EVENT_SEARCHING,
action: function () {
var keywords = this.getKeywords();
var keywords = self._getKeywords();
var last = BI.last(keywords);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
if (BI.endWith(last, BI.BlankSplitChar)) {
self.adapter.setValue(self.storeValue);
assertShowValue();
self.adapter.populate();
@ -195,6 +182,19 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
});
},
_getKeywords: function () {
var val = this.editor.getValue();
var keywords = val.split(/\u200b\s\u200b/);
if (BI.isEmptyString(keywords[keywords.length - 1])) {
keywords = keywords.slice(0, keywords.length - 1);
}
if (/\u200b\s\u200b$/.test(val)) {
return keywords.concat([BI.BlankSplitChar]);
}
return keywords;
},
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
@ -224,20 +224,12 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
var self = this, o = this.options;
this._assertValue(this.storeValue);
// 和复选下拉框同步,allData做缓存是会爆炸的
o.itemsCreator({
type: BI.MultiSelectInsertList.REQ_GET_ALL_DATA,
keywords: keywords
}, function (ob) {
var values = BI.map(ob.items, "value");
digest(values);
});
function digest (items) {
var selectedMap = self._makeMap(items);
digest();
function digest () {
BI.each(keywords, function (i, val) {
if (BI.isNotNull(selectedMap[val])) {
self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
}
});
callback();
}

55
src/widget/multiselectlist/multiselectlist.insert.nobar.js

@ -61,32 +61,21 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, {
o.itemsCreator(op, callback);
}
},
listeners: [{
eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM,
action: function () {
var keyword = self.trigger.getKeyword();
if (!self.trigger.hasMatched()) {
if (self.storeValue.type === BI.Selection.Multi) {
BI.pushDistinct(self.storeValue.value, keyword);
}
self._showAdapter();
self.adapter.setValue(self.storeValue);
self.adapter.populate();
if (self.storeValue.type === BI.Selection.Multi) {
self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE);
}
}
}
}]
});
this.searcherPane.setVisible(false);
this.trigger = BI.createWidget({
type: "bi.searcher",
el: {
type: "bi.select_patch_editor",
el: {
type: "bi.search_editor",
},
ref: function (ref) {
self.editor = ref;
},
height: o.searcherHeight
},
allowSearchBlank: false,
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
@ -116,7 +105,6 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, {
eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
var keyword = this.getKeyword();
if (this.hasMatched()) {
self._join({
type: BI.Selection.Multi,
value: [keyword]
@ -133,16 +121,15 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, {
self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE);
});
}
}
}, {
eventName: BI.Searcher.EVENT_SEARCHING,
action: function () {
var keywords = this.getKeywords();
var keywords = self._getKeywords();
var last = BI.last(keywords);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
if (BI.endWith(last, BI.BlankSplitChar)) {
self.adapter.setValue(self.storeValue);
assertShowValue();
self.adapter.populate();
@ -201,6 +188,19 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, {
});
},
_getKeywords: function () {
var val = this.editor.getValue();
var keywords = val.split(/\u200b\s\u200b/);
if (BI.isEmptyString(keywords[keywords.length - 1])) {
keywords = keywords.slice(0, keywords.length - 1);
}
if (/\u200b\s\u200b$/.test(val)) {
return keywords.concat([BI.BlankSplitChar]);
}
return keywords;
},
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
@ -229,20 +229,11 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, {
var self = this, o = this.options;
this._assertValue(this.storeValue);
// 和复选下拉框同步,allData做缓存是会爆炸的
o.itemsCreator({
type: BI.MultiSelectInsertNoBarList.REQ_GET_ALL_DATA,
keywords: keywords
}, function (ob) {
var values = BI.map(ob.items, "value");
digest(values);
});
digest();
function digest (items) {
var selectedMap = self._makeMap(items);
BI.each(keywords, function (i, val) {
if (BI.isNotNull(selectedMap[val])) {
self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
}
});
callback();
}

39
src/widget/multiselectlist/multiselectlist.js

@ -53,7 +53,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
var keyword = self.trigger.getKeyword();
if (BI.isNotEmptyString(keyword)) {
op.keywords = [keyword];
this.setKeyword(op.keywords[0]);
o.itemsCreator(op, callback);
}
},
@ -64,9 +63,15 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
this.trigger = BI.createWidget({
type: "bi.searcher",
el: {
type: "bi.select_patch_editor",
el: {
type: "bi.search_editor",
},
ref: function (ref) {
self.editor = ref;
},
height: o.searcherHeight
},
allowSearchBlank: false,
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
@ -95,22 +100,9 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
}, {
eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
var keyword = this.getKeyword();
if (this.hasMatched()) {
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
self._showAdapter();
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.adapter.populate();
self._setStartValue("");
self.fireEvent(BI.MultiSelectList.EVENT_CHANGE);
});
}
}
},
}, {
eventName: BI.Searcher.EVENT_SEARCHING,
action: function () {
@ -119,7 +111,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
if (BI.endWith(last, BI.BlankSplitChar)) {
self.adapter.setValue(self.storeValue);
assertShowValue();
self.adapter.populate();
@ -174,6 +166,19 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
});
},
_getKeywords: function () {
var val = this.editor.getValue();
var keywords = val.split(/\u200b\s\u200b/);
if (BI.isEmptyString(keywords[keywords.length - 1])) {
keywords = keywords.slice(0, keywords.length - 1);
}
if (/\u200b\s\u200b$/.test(val)) {
return keywords.concat([BI.BlankSplitChar]);
}
return keywords;
},
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);

18
src/widget/searchmultitextvaluecombo/multitextvalue.combo.search.js

@ -69,28 +69,12 @@ BI.SearchMultiTextValueCombo = BI.inherit(BI.Single, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self._setStartValue("");
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getKeyword();
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
self.combo.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self._populate();
self._setStartValue("");
self._dataChange = true;
});
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) {
var last = BI.last(keywords);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
if (BI.endWith(last, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();

2
src/widget/searchmultitextvaluecombo/trigger/searcher.multitextvalue.js

@ -25,7 +25,6 @@ BI.SearchMultiSelectSearcher = BI.inherit(BI.Widget, {
this.searcher = BI.createWidget({
type: "bi.searcher",
allowSearchBlank: false,
element: this,
height: o.height,
isAutoSearch: false,
@ -44,7 +43,6 @@ BI.SearchMultiSelectSearcher = BI.inherit(BI.Widget, {
itemsCreator: function (op, callback) {
var keyword = self.editor.getValue();
op.keywords = [keyword];
this.setKeyword(keyword);
o.itemsCreator(op, callback);
},
value: o.value

20
src/widget/singleselect/search/singleselect.search.pane.insert.js

@ -36,15 +36,12 @@ BI.SingleSelectSearchInsertPane = BI.inherit(BI.Widget, {
});
this.addNotMatchTip = BI.createWidget({
type: "bi.text_button",
type: "bi.label",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: this.constants.height,
cls: "bi-high-light",
hgap: 5,
handler: function () {
self.fireEvent(BI.SingleSelectSearchInsertPane.EVENT_ADD_ITEM, o.keywordGetter());
}
});
this.loader = BI.createWidget({
@ -88,20 +85,6 @@ BI.SingleSelectSearchInsertPane = BI.inherit(BI.Widget, {
!isMatchTipVisible && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getMatchedItemValue: function () {
var value;
var o = this.options;
BI.some(this.loader.getAllButtons(), function (idx, btn) {
var v = btn.getValue();
if (o.keywordGetter() === (o.valueFormatter(v) || v)) {
value = v;
return true;
}
});
return value;
},
hasMatched: function () {
return this.tooltipClick.isVisible();
},
@ -124,6 +107,5 @@ BI.SingleSelectSearchInsertPane = BI.inherit(BI.Widget, {
});
BI.SingleSelectSearchInsertPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.SingleSelectSearchInsertPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.single_select_search_insert_pane", BI.SingleSelectSearchInsertPane);

14
src/widget/singleselect/search/singleselect.search.pane.js

@ -75,20 +75,6 @@ BI.SingleSelectSearchPane = BI.inherit(BI.Widget, {
}
},
getMatchedItemValue: function () {
var value;
var o = this.options;
BI.some(this.loader.getAllButtons(), function (idx, btn) {
var v = btn.getValue();
if (o.keywordGetter() === (o.valueFormatter(v) || v)) {
value = v;
return true;
}
});
return value;
},
hasMatched: function () {
return this.tooltipClick.isVisible();
},

12
src/widget/singleselect/singleselect.combo.js

@ -63,22 +63,12 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, {
self._setStartValue();
self.fireEvent(BI.SingleSelectCombo.EVENT_STOP);
});
this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getMatchedItemValue();
self.combo.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.populate();
self._setStartValue();
}
});
this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) {
var last = BI.last(keywords);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
if (BI.endWith(last, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();

22
src/widget/singleselect/singleselect.insert.combo.js

@ -48,16 +48,6 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
searcher: {
popup: {
type: "bi.single_select_search_insert_pane",
listeners: [{
eventName: BI.SingleSelectSearchInsertPane.EVENT_ADD_ITEM,
action: function () {
if (!self.trigger.getSearcher().hasMatched()) {
self.storeValue = self.trigger.getSearcher().getKeyword();
assertShowValue();
self._defaultState();
}
}
}]
}
}
});
@ -78,22 +68,16 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, {
self.fireEvent(BI.SingleSelectInsertCombo.EVENT_STOP);
});
this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getMatchedItemValue();
self.storeValue = keyword;
self.combo.setValue(self.storeValue);
self._setStartValue(keyword);
self.storeValue = self.trigger.getSearcher().getKeyword();
assertShowValue();
self.populate();
self._setStartValue();
}
self._defaultState();
});
this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) {
var last = BI.last(keywords);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
if (BI.endWith(last, BI.BlankSplitChar)) {
self.combo.setValue(self.storeValue);
assertShowValue();
self.combo.populate();

16
src/widget/singleselect/singleselectlist.insert.js

@ -55,25 +55,11 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, {
this.setKeyword(op.keywords[0]);
o.itemsCreator(op, callback);
},
listeners: [{
eventName: BI.SingleSelectSearchInsertPane.EVENT_ADD_ITEM,
action: function () {
var keyword = self.trigger.getKeyword();
if (!self.trigger.hasMatched()) {
self.storeValue = keyword;
self._showAdapter();
self.adapter.setValue(self.storeValue);
self.adapter.populate();
self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE);
}
}
}]
});
this.searcherPane.setVisible(false);
this.trigger = BI.createWidget({
type: "bi.searcher",
allowSearchBlank: false,
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
@ -126,7 +112,7 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, {
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
if (BI.endWith(last, BI.BlankSplitChar)) {
self.adapter.setValue(self.storeValue);
assertShowValue();
self.adapter.populate();

35
src/widget/singleselect/trigger/editor.singleselect.js

@ -18,7 +18,7 @@ BI.SingleSelectEditor = BI.inherit(BI.Widget, {
BI.SingleSelectEditor.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.editor = BI.createWidget(o.el, {
type: "bi.state_editor",
type: "bi.select_patch_editor",
element: this,
height: o.height,
watermark: BI.i18nText("BI-Basic_Search"),
@ -31,10 +31,6 @@ BI.SingleSelectEditor = BI.inherit(BI.Widget, {
this.editor.on(BI.Controller.EVENT_CHANGE, function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
});
this.editor.on(BI.StateEditor.EVENT_PAUSE, function () {
self.fireEvent(BI.SingleSelectEditor.EVENT_PAUSE);
});
this.editor.on(BI.StateEditor.EVENT_FOCUS, function () {
self.fireEvent(BI.SingleSelectEditor.EVENT_FOCUS);
});
@ -60,23 +56,31 @@ BI.SingleSelectEditor = BI.inherit(BI.Widget, {
},
getValue: function () {
var v = this.editor.getState();
if (BI.isArray(v) && v.length > 0) {
return v[v.length - 1];
}
return "";
return this.editor.getValue();
},
getKeywords: function () {
var val = this.editor.getLastChangedValue();
var keywords = val.match(/[\S]+/g);
if (BI.isEndWithBlank(val)) {
return keywords.concat([" "]);
var val = this.editor.getValue();
var keywords = val.split(/\u200b\s\u200b/);
if (BI.isEmptyString(keywords[keywords.length - 1])) {
keywords = keywords.slice(0, keywords.length - 1);
}
if (/\u200b\s\u200b$/.test(val)) {
return keywords.concat([BI.BlankSplitChar]);
}
return keywords;
},
getKeyword: function () {
var val = this.editor.getValue();
var keywords = val.split(/\u200b\s\u200b/);
if (BI.isEmptyString(keywords[keywords.length - 1])) {
keywords = keywords.slice(0, keywords.length - 1);
}
return BI.isEmptyArray(keywords) ? "" : keywords[keywords.length - 1];
},
populate: function (items) {
}
@ -84,5 +88,4 @@ BI.SingleSelectEditor = BI.inherit(BI.Widget, {
BI.SingleSelectEditor.EVENT_FOCUS = "EVENT_FOCUS";
BI.SingleSelectEditor.EVENT_BLUR = "EVENT_BLUR";
BI.SingleSelectEditor.EVENT_PAUSE = "EVENT_PAUSE";
BI.shortcut("bi.single_select_editor", BI.SingleSelectEditor);

5
src/widget/singleselect/trigger/searcher.singleselect.js

@ -41,7 +41,6 @@ BI.SingleSelectSearcher = BI.inherit(BI.Widget, {
this.searcher = BI.createWidget({
type: "bi.searcher",
allowSearchBlank: false,
element: this,
height: o.height,
isAutoSearch: false,
@ -95,10 +94,6 @@ BI.SingleSelectSearcher = BI.inherit(BI.Widget, {
}
},
getMatchedItemValue: function() {
return this.searcher.getView().getMatchedItemValue();
},
adjustView: function () {
this.searcher.adjustView();
},

1
typescript/core/var.ts

@ -129,4 +129,5 @@ export interface _var {
Stretch: string;
},
StartOfWeek: number;
BlankSplitChar: string;
}

Loading…
Cancel
Save