From b37406b60d38dc0eb25ba042490d2bd930e84d7c Mon Sep 17 00:00:00 2001 From: zsmj Date: Fri, 19 Aug 2022 11:10:28 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-12033=20feat:=20=E5=A4=8D=E9=80=89?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=B7=BB=E5=8A=A0itemFormatter=E5=B1=9E?= =?UTF-8?q?=E6=80=A7,=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselect/multiselect.combo.js | 2 ++ src/widget/multiselect/multiselect.loader.js | 21 +++++++++++-------- .../multiselect/multiselect.loader.nobar.js | 18 +++++++++------- .../multiselect/multiselect.popup.view.js | 1 + .../multiselect.popup.view.nobar.js | 1 + .../search/multiselect.search.loader.js | 2 +- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/widget/multiselect/multiselect.combo.js b/src/widget/multiselect/multiselect.combo.js index c370a48ee..00b035096 100644 --- a/src/widget/multiselect/multiselect.combo.js +++ b/src/widget/multiselect/multiselect.combo.js @@ -57,6 +57,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { }, }, valueFormatter: o.valueFormatter, + itemFormatter: o.itemFormatter, itemsCreator: BI.bind(this._itemsCreator4Trigger, this), itemHeight: o.itemHeight, value: this.storeValue, @@ -162,6 +163,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { itemsCreator: o.itemsCreator, itemHeight: o.itemHeight, valueFormatter: o.valueFormatter, + itemFormatter: o.itemFormatter, onLoaded: function () { BI.nextTick(function () { self.combo.adjustWidth(); diff --git a/src/widget/multiselect/multiselect.loader.js b/src/widget/multiselect/multiselect.loader.js index 3dc7229bb..7c45c68c1 100644 --- a/src/widget/multiselect/multiselect.loader.js +++ b/src/widget/multiselect/multiselect.loader.js @@ -64,7 +64,6 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { value: v, title: txt, selected: self.storeValue.type === BI.Selection.Multi, - ...opts.itemFormatter(v), }; }); if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { @@ -74,7 +73,6 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { value: startValue, title: txt, selected: true, - ...opts.itemFormatter(startValue), }); } firstItems = self._createItems(json); @@ -111,13 +109,18 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, { _createItems: function (items) { var allSelected = this.isAllSelected(); - return BI.createItems(items, { - type: "bi.multi_select_item", - logic: this.options.logic, - cls: "bi-list-item-active", - height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - selected: allSelected, - iconWrapperWidth: 36 + var itemFormatter = this.options.itemFormatter; + return BI.map(items, (i, item) => { + return { + type: "bi.multi_select_item", + logic: this.options.logic, + cls: "bi-list-item-active", + height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, + selected: allSelected, + iconWrapperWidth: 36, + ...item, + ...itemFormatter(item), + }; }); }, diff --git a/src/widget/multiselect/multiselect.loader.nobar.js b/src/widget/multiselect/multiselect.loader.nobar.js index d7744d042..6d9852a35 100644 --- a/src/widget/multiselect/multiselect.loader.nobar.js +++ b/src/widget/multiselect/multiselect.loader.nobar.js @@ -113,12 +113,16 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { }, _createItems: function (items) { - return BI.createItems(items, { - type: "bi.multi_select_item", - cls: "bi-list-item-active", - logic: this.options.logic, - height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, - iconWrapperWidth: 36 + return BI.map(items, (index, item) => { + return { + type: "bi.multi_select_item", + cls: "bi-list-item-active", + logic: this.options.logic, + height: this.options.itemHeight || BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, + iconWrapperWidth: 36, + ...item, + ...this.options.itemFormatter(item), + }; }); }, @@ -168,7 +172,7 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { }, resetHeight: function (h) { - this.button_group.element.css({"max-height": h / BI.pixRatio + BI.pixUnit}); + this.button_group.element.css({ "max-height": h / BI.pixRatio + BI.pixUnit }); }, resetWidth: function () { diff --git a/src/widget/multiselect/multiselect.popup.view.js b/src/widget/multiselect/multiselect.popup.view.js index cefe9f0b2..1e11376d2 100644 --- a/src/widget/multiselect/multiselect.popup.view.js +++ b/src/widget/multiselect/multiselect.popup.view.js @@ -27,6 +27,7 @@ BI.MultiSelectPopupView = BI.inherit(BI.Widget, { itemsCreator: opts.itemsCreator, itemHeight: opts.itemHeight, valueFormatter: opts.valueFormatter, + itemFormatter: opts.itemFormatter, onLoaded: opts.onLoaded, value: opts.value }); diff --git a/src/widget/multiselect/multiselect.popup.view.nobar.js b/src/widget/multiselect/multiselect.popup.view.nobar.js index 9132ae5ee..c0007f85a 100644 --- a/src/widget/multiselect/multiselect.popup.view.nobar.js +++ b/src/widget/multiselect/multiselect.popup.view.nobar.js @@ -27,6 +27,7 @@ BI.MultiSelectNoBarPopupView = BI.inherit(BI.Widget, { itemsCreator: opts.itemsCreator, itemHeight: opts.itemHeight, valueFormatter: opts.valueFormatter, + itemFormatter: opts.itemFormatter, onLoaded: opts.onLoaded, value: opts.value }); diff --git a/src/widget/multiselect/search/multiselect.search.loader.js b/src/widget/multiselect/search/multiselect.search.loader.js index 07d4cfbea..89e4cb318 100644 --- a/src/widget/multiselect/search/multiselect.search.loader.js +++ b/src/widget/multiselect/search/multiselect.search.loader.js @@ -128,7 +128,7 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, { title: v.text, value: v.value, selected: src.type === BI.Selection.All, - ...o.itemFormatter(v.value), + ...o.itemFormatter(v), }; }); },