Browse Source

KERNEL-12033 feat: 复选列表添加itemFormatter属性,支持自定义节点类型

es6
zsmj 2 years ago
parent
commit
1e73eb486d
  1. 6
      src/widget/multiselect/multiselect.loader.js
  2. 3
      src/widget/multiselect/search/multiselect.search.insert.pane.js
  3. 8
      src/widget/multiselect/search/multiselect.search.loader.js
  4. 3
      src/widget/multiselect/search/multiselect.search.pane.js
  5. 4
      src/widget/multiselectlist/multiselectlist.insert.js

6
src/widget/multiselect/multiselect.loader.js

@ -62,7 +62,8 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
text: txt,
value: v,
title: txt,
selected: self.storeValue.type === BI.Selection.Multi
selected: self.storeValue.type === BI.Selection.Multi,
...opts.itemFormatter(v),
};
});
if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) {
@ -71,7 +72,8 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
text: txt,
value: startValue,
title: txt,
selected: true
selected: true,
...opts.itemFormatter(startValue),
});
}
firstItems = self._createItems(json);

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

@ -39,6 +39,7 @@ BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, {
type: "bi.multi_select_search_loader",
keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
itemsCreator: function (op, callback) {
o.itemsCreator.apply(self, [op, function (res) {
callback(res);
@ -95,4 +96,4 @@ BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, {
BI.MultiSelectSearchInsertPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multi_select_search_insert_pane", BI.MultiSelectSearchInsertPane);
BI.shortcut("bi.multi_select_search_insert_pane", BI.MultiSelectSearchInsertPane);

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

@ -12,6 +12,7 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
itemsCreator: BI.emptyFn,
keywordGetter: BI.emptyFn,
valueFormatter: BI.emptyFn,
itemFormatter: BI.emptyFn,
itemHeight: 24
});
},
@ -113,7 +114,7 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
var newValues = BI.map(values, function (i, v) {
return {
text: o.valueFormatter(v) || v,
value: v
value: v,
};
});
if (BI.isKey(keyword)) {
@ -125,7 +126,8 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
text: v.text,
title: v.text,
value: v.value,
selected: src.type === BI.Selection.All
selected: src.type === BI.Selection.All,
...o.itemFormatter(v.value),
};
});
},
@ -162,4 +164,4 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
});
BI.MultiSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multi_select_search_loader", BI.MultiSelectSearchLoader);
BI.shortcut("bi.multi_select_search_loader", BI.MultiSelectSearchLoader);

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

@ -31,6 +31,7 @@ BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
type: "bi.multi_select_search_loader",
keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
itemsCreator: function (op, callback) {
o.itemsCreator.apply(self, [op, function (res) {
callback(res);
@ -82,4 +83,4 @@ BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane);
BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane);

4
src/widget/multiselectlist/multiselectlist.insert.js

@ -28,6 +28,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
itemsCreator: o.itemsCreator,
itemHeight: o.itemHeight,
valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
logic: {
dynamic: false
},
@ -45,6 +46,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
type: "bi.multi_select_search_insert_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
@ -240,7 +242,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
digest();
function digest () {
function digest() {
BI.each(keywords, function (i, val) {
self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
});

Loading…
Cancel
Save