Browse Source

BI-119658 feat: MultiSelectCombo支持搜索自定义itemFormatter

research/test
zsmj 2 years ago
parent
commit
a105c140ec
  1. 13
      src/widget/multiselect/multiselect.combo.nobar.js
  2. 14
      src/widget/multiselect/multiselect.insert.combo.js
  3. 13
      src/widget/multiselect/multiselect.insert.combo.nobar.js
  4. 10
      src/widget/multiselect/multiselect.insert.trigger.js
  5. 7
      src/widget/multiselect/multiselect.trigger.js
  6. 16
      src/widget/multiselect/search/multiselect.search.loader.js
  7. 7
      src/widget/multiselect/trigger/searcher.multiselect.insert.js
  8. 7
      src/widget/multiselect/trigger/searcher.multiselect.js

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

@ -54,6 +54,7 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
}, },
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemsCreator: BI.bind(this._itemsCreator4Trigger, this), itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
itemFormatter: o.itemFormatter,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
value: { value: {
type: BI.Selection.Multi, type: BI.Selection.Multi,
@ -134,7 +135,8 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
self.trigger.setAdapter(this); self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this); self.numberCounter.setAdapter(this);
}, },
listeners: [{ listeners: [
{
eventName: BI.MultiSelectPopupView.EVENT_CHANGE, eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
action: function () { action: function () {
self._dataChange = true; self._dataChange = true;
@ -156,7 +158,8 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
self.setValue(); self.setValue();
self._defaultState(); self._defaultState();
} }
}], }
],
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
@ -262,7 +265,8 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
{
el: this.combo, el: this.combo,
left: 0, left: 0,
right: 0, right: 0,
@ -281,7 +285,8 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, {
right: o.height, right: o.height,
top: 0, top: 0,
height: o.height height: o.height
}] }
]
}); });
}, },

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

@ -55,6 +55,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
}, },
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemsCreator: BI.bind(this._itemsCreator4Trigger, this), itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
itemFormatter: o.itemFormatter,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
value: this.storeValue, value: this.storeValue,
}); });
@ -138,7 +139,8 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
self.trigger.setAdapter(this); self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this); self.numberCounter.setAdapter(this);
}, },
listeners: [{ listeners: [
{
eventName: BI.MultiSelectPopupView.EVENT_CHANGE, eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
action: function () { action: function () {
self._dataChange = true; self._dataChange = true;
@ -160,9 +162,11 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
self.setValue(); self.setValue();
self._defaultState(); self._defaultState();
} }
}], }
],
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
onLoaded: function () { onLoaded: function () {
BI.nextTick(function () { BI.nextTick(function () {
@ -260,7 +264,8 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
{
el: this.combo, el: this.combo,
left: 0, left: 0,
right: 0, right: 0,
@ -279,7 +284,8 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
right: o.height, right: o.height,
top: 0, top: 0,
height: o.height, height: o.height,
}] }
]
}); });
}, },

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

@ -54,6 +54,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
}, },
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemsCreator: BI.bind(this._itemsCreator4Trigger, this), itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
itemFormatter: o.itemFormatter,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
value: { value: {
type: BI.Selection.Multi, type: BI.Selection.Multi,
@ -129,7 +130,8 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
self.trigger.setAdapter(this); self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this); self.numberCounter.setAdapter(this);
}, },
listeners: [{ listeners: [
{
eventName: BI.MultiSelectPopupView.EVENT_CHANGE, eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
action: function () { action: function () {
self._dataChange = true; self._dataChange = true;
@ -150,7 +152,8 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
self.setValue(); self.setValue();
self._defaultState(); self._defaultState();
} }
}], }
],
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
@ -256,7 +259,8 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
BI.createWidget({ BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
{
el: this.combo, el: this.combo,
left: 0, left: 0,
right: 0, right: 0,
@ -275,7 +279,8 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
right: o.height, right: o.height,
top: 0, top: 0,
height: o.height height: o.height
}] }
]
}); });
}, },

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

@ -40,6 +40,7 @@ BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, {
defaultText: o.defaultText, defaultText: o.defaultText,
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
watermark: o.watermark, watermark: o.watermark,
popup: {}, popup: {},
@ -86,13 +87,15 @@ BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, {
}, { }, {
el: BI.createWidget(), el: BI.createWidget(),
width: 24 width: 24
}] }
]
}); });
!o.allowEdit && BI.createWidget({ !o.allowEdit && BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
{
el: { el: {
type: "bi.text", type: "bi.text",
title: function () { title: function () {
@ -103,7 +106,8 @@ BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, {
right: 24, right: 24,
top: 0, top: 0,
bottom: 0 bottom: 0
}] }
]
}); });
}, },

7
src/widget/multiselect/multiselect.trigger.js

@ -41,6 +41,7 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
watermark: o.watermark, watermark: o.watermark,
popup: {}, popup: {},
adapter: o.adapter, adapter: o.adapter,
@ -88,7 +89,8 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
!o.allowEdit && BI.createWidget({ !o.allowEdit && BI.createWidget({
type: "bi.absolute", type: "bi.absolute",
element: this, element: this,
items: [{ items: [
{
el: { el: {
type: "bi.text", type: "bi.text",
title: function () { title: function () {
@ -104,7 +106,8 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
right: 24, right: 24,
top: 0, top: 0,
bottom: 0 bottom: 0
}] }
]
}); });
}, },

16
src/widget/multiselect/search/multiselect.search.loader.js

@ -51,9 +51,11 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
return true; return true;
} }
}, },
layouts: [{ layouts: [
{
type: "bi.vertical" type: "bi.vertical"
}] }
]
} }
} }
}, },
@ -92,7 +94,10 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
_createItems: function (items) { _createItems: function (items) {
var allSelected = this.isAllSelected(); var allSelected = this.isAllSelected();
return BI.createItems(items, { var itemFormatter = this.options.itemFormatter;
return BI.map(items, (index, item) => {
return {
type: "bi.multi_select_item", type: "bi.multi_select_item",
logic: { logic: {
dynamic: false dynamic: false
@ -100,7 +105,10 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT,
selected: allSelected, selected: allSelected,
cls: "bi-list-item-active", cls: "bi-list-item-active",
iconWrapperWidth: 36 iconWrapperWidth: 36,
...item,
...itemFormatter(item)
};
}); });
}, },

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

@ -29,7 +29,8 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, {
height: o.height, height: o.height,
text: o.text, text: o.text,
defaultText: o.defaultText, defaultText: o.defaultText,
listeners: [{ listeners: [
{
eventName: BI.MultiSelectEditor.EVENT_FOCUS, eventName: BI.MultiSelectEditor.EVENT_FOCUS,
action: function () { action: function () {
self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_FOCUS); self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_FOCUS);
@ -39,7 +40,8 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, {
action: function () { action: function () {
self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_BLUR); self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_BLUR);
} }
}] }
]
}); });
this.searcher = BI.createWidget({ this.searcher = BI.createWidget({
@ -56,6 +58,7 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, {
popup: BI.extend({ popup: BI.extend({
type: "bi.multi_select_search_insert_pane", type: "bi.multi_select_search_insert_pane",
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
keywordGetter: function () { keywordGetter: function () {
return self.editor.getKeyword(); return self.editor.getKeyword();
}, },

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

@ -29,7 +29,8 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
text: o.text, text: o.text,
defaultText: o.defaultText, defaultText: o.defaultText,
watermark: o.watermark, watermark: o.watermark,
listeners: [{ listeners: [
{
eventName: BI.MultiSelectEditor.EVENT_FOCUS, eventName: BI.MultiSelectEditor.EVENT_FOCUS,
action: function () { action: function () {
self.fireEvent(BI.MultiSelectSearcher.EVENT_FOCUS); self.fireEvent(BI.MultiSelectSearcher.EVENT_FOCUS);
@ -39,7 +40,8 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
action: function () { action: function () {
self.fireEvent(BI.MultiSelectSearcher.EVENT_BLUR); self.fireEvent(BI.MultiSelectSearcher.EVENT_BLUR);
} }
}] }
]
}); });
this.searcher = BI.createWidget({ this.searcher = BI.createWidget({
@ -55,6 +57,7 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, {
popup: BI.extend({ popup: BI.extend({
type: "bi.multi_select_search_pane", type: "bi.multi_select_search_pane",
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
keywordGetter: function () { keywordGetter: function () {
return self.editor.getValue(); return self.editor.getValue();
}, },

Loading…
Cancel
Save