Browse Source

BI-46499 refactor: 减少复选下拉的请求次数

es6
windy 5 years ago
parent
commit
5ab1da9614
  1. 4
      src/widget/multiselect/multiselect.combo.js
  2. 4
      src/widget/multiselect/multiselect.insert.combo.js
  3. 4
      src/widget/multiselect/multiselect.insert.combo.nobar.js
  4. 8
      src/widget/multiselect/trigger/switcher.checkselected.js

4
src/widget/multiselect/multiselect.combo.js

@ -123,7 +123,9 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
self.fireEvent(BI.MultiSelectCombo.EVENT_CLICK_ITEM); self.fireEvent(BI.MultiSelectCombo.EVENT_CLICK_ITEM);
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
this.getCounter().setValue(self.storeValue); // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
this.getCounter().updateSelectedValue(self.storeValue);
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () { this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
if (!self.combo.isViewVisible()) { if (!self.combo.isViewVisible()) {

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

@ -116,7 +116,9 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CLICK_ITEM); self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CLICK_ITEM);
}); });
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
this.getCounter().setValue(self.storeValue); // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
this.getCounter().updateSelectedValue(self.storeValue);
}); });
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () { this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () {
if (!self.combo.isViewVisible()) { if (!self.combo.isViewVisible()) {

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

@ -113,7 +113,9 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
} }
}); });
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
this.getCounter().setValue(self.storeValue); // counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
this.getCounter().updateSelectedValue(self.storeValue);
}); });
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () { this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () {
if (!self.combo.isViewVisible()) { if (!self.combo.isViewVisible()) {

8
src/widget/multiselect/trigger/switcher.checkselected.js

@ -42,6 +42,9 @@ BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, {
onClickContinueSelect: function () { onClickContinueSelect: function () {
self.switcher.hideView(); self.switcher.hideView();
}, },
ref: function (_ref) {
self.checkPane = _ref;
},
value: o.value value: o.value
}, o.popup), }, o.popup),
adapter: o.adapter, adapter: o.adapter,
@ -82,6 +85,11 @@ BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, {
this.switcher.setValue(v); this.switcher.setValue(v);
}, },
// 与setValue的区别是只更新查看已选面板的的selectedValue, 不会更新按钮的计数
updateSelectedValue: function (v) {
this.checkPane.setValue(v);
},
setButtonChecked: function (v) { setButtonChecked: function (v) {
this.button.setValue(v); this.button.setValue(v);
}, },

Loading…
Cancel
Save