Browse Source

Merge pull request #1159 in VISUAL/fineui from ~WINDY/fineui:master to master

* commit 'c3cf4709f202713fb754907930c99a1c1f7ff775':
  changelog
  KERNEL-1479 refactor:  复选下拉系的counter从trigger搬到外面 &&  BI-52072 test: 部件单测
es6
windy 5 years ago
parent
commit
f729a55639
  1. 3
      changelog.md
  2. 95
      src/component/treevaluechooser/__test__/combo.listtreevaluechooser.test.js
  3. 132
      src/component/treevaluechooser/__test__/combo.treevaluechooser.insert.test.js
  4. 132
      src/component/treevaluechooser/__test__/combo.treevaluechooser.test.js
  5. 140
      src/component/treevaluechooser/__test__/pane.treevaluechooser.test.js
  6. 86
      src/widget/multiselect/multiselect.combo.js
  7. 91
      src/widget/multiselect/multiselect.insert.combo.js
  8. 95
      src/widget/multiselect/multiselect.insert.combo.nobar.js
  9. 50
      src/widget/multiselect/multiselect.insert.trigger.js
  10. 50
      src/widget/multiselect/multiselect.trigger.js
  11. 4
      src/widget/multiselect/trigger/switcher.checkselected.js
  12. 105
      src/widget/multitree/multi.tree.combo.js
  13. 111
      src/widget/multitree/multi.tree.insert.combo.js
  14. 105
      src/widget/multitree/multi.tree.list.combo.js

3
changelog.md

@ -1,4 +1,7 @@
# 更新日志
2.0(2019-10)
- 复选下拉系列的计数器从trigger中拆分, 作为独立的部分
2.0(2019-09)
- [视觉]popover弹出框增加圆角
- 文本列表通过复制粘贴的形式选中值的时候发送事件

95
src/component/treevaluechooser/__test__/combo.listtreevaluechooser.test.js

@ -0,0 +1,95 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/25
*/
describe("list_tree_value_chooser_insert_combo", function () {
var items = [{pId: "0", id: "0_0", text: "中国", value: "", open: true}, {
pId: "0_0",
id: "0_0_0",
text: "安徽省( 共1个 )",
value: "安徽省",
open: true
}, {pId: "0_0_0", id: "0_0_0_0", text: "芜湖市", value: "芜湖市", open: true}, {
pId: "0_0",
id: "0_0_1",
text: "北京市( 共6个 )",
value: "北京市",
open: true
}, {pId: "0_0_1", id: "0_0_1_0", text: "北京市区", value: "北京市区", open: true}, {
pId: "0_0_1",
id: "0_0_1_1",
text: "朝阳区",
value: "朝阳区",
open: true
}, {pId: "0_0_1", id: "0_0_1_2", text: "东城区", value: "东城区", open: true}, {
pId: "0_0_1",
id: "0_0_1_3",
text: "海淀区4内",
value: "海淀区4内",
open: true
}, {pId: "0_0_1", id: "0_0_1_4", text: "海淀区4外", value: "海淀区4外", open: true}, {
pId: "0_0_1",
id: "0_0_1_5",
text: "石景山区",
value: "石景山区",
open: true
}, {pId: "0_0", id: "0_0_2", text: "福建省( 共2个 )", value: "福建省", open: true}, {
pId: "0_0_2",
id: "0_0_2_0",
text: "莆田市",
value: "莆田市",
open: true
}, {pId: "0_0_2", id: "0_0_2_1", text: "泉州市", value: "泉州市", open: true}, {
pId: "0_0",
id: "0_0_3",
text: "甘肃省( 共1个 )",
value: "甘肃省",
open: true
}, {pId: "0_0_3", id: "0_0_3_0", text: "兰州市", value: "兰州市", open: true}, {
pId: "0_0",
id: "0_0_4",
text: "广东省( 共5个 )",
value: "广东省",
open: true
}, {pId: "0_0_4", id: "0_0_4_0", text: "东莞市", value: "东莞市", open: true}, {
pId: "0_0_4",
id: "0_0_4_1",
text: "广州市",
value: "广州市",
open: true
}];
/**
* test_author_windy
**/
it("setValue", function () {
var widget = BI.Test.createWidget({
type: "bi.list_tree_value_chooser_insert_combo",
width: 220,
itemsCreator: function (op, callback) {
callback(items);
}
});
widget.setValue([["中国", "北京市", "朝阳区"]]);
expect(widget.getValue()).to.deep.equal([["中国", "北京市", "朝阳区"]]);
widget.destroy();
});
/**
* test_author_windy
**/
it("getValue", function () {
var widget = BI.Test.createWidget({
type: "bi.list_tree_value_chooser_insert_combo",
width: 220,
itemsCreator: function (op, callback) {
callback(items);
},
value: [["中国", "北京市", "朝阳区"]]
});
expect(widget.getValue()).to.deep.equal([["中国", "北京市", "朝阳区"]]);
widget.destroy();
});
});

132
src/component/treevaluechooser/__test__/combo.treevaluechooser.insert.test.js

@ -0,0 +1,132 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/25
*/
describe("tree_value_chooser_insert_combo", function () {
var items = [{pId: "0", id: "0_0", text: "中国", value: "", open: true}, {
pId: "0_0",
id: "0_0_0",
text: "安徽省( 共1个 )",
value: "安徽省",
open: true
}, {pId: "0_0_0", id: "0_0_0_0", text: "芜湖市", value: "芜湖市", open: true}, {
pId: "0_0",
id: "0_0_1",
text: "北京市( 共6个 )",
value: "北京市",
open: true
}, {pId: "0_0_1", id: "0_0_1_0", text: "北京市区", value: "北京市区", open: true}, {
pId: "0_0_1",
id: "0_0_1_1",
text: "朝阳区",
value: "朝阳区",
open: true
}, {pId: "0_0_1", id: "0_0_1_2", text: "东城区", value: "东城区", open: true}, {
pId: "0_0_1",
id: "0_0_1_3",
text: "海淀区4内",
value: "海淀区4内",
open: true
}, {pId: "0_0_1", id: "0_0_1_4", text: "海淀区4外", value: "海淀区4外", open: true}, {
pId: "0_0_1",
id: "0_0_1_5",
text: "石景山区",
value: "石景山区",
open: true
}, {pId: "0_0", id: "0_0_2", text: "福建省( 共2个 )", value: "福建省", open: true}, {
pId: "0_0_2",
id: "0_0_2_0",
text: "莆田市",
value: "莆田市",
open: true
}, {pId: "0_0_2", id: "0_0_2_1", text: "泉州市", value: "泉州市", open: true}, {
pId: "0_0",
id: "0_0_3",
text: "甘肃省( 共1个 )",
value: "甘肃省",
open: true
}, {pId: "0_0_3", id: "0_0_3_0", text: "兰州市", value: "兰州市", open: true}, {
pId: "0_0",
id: "0_0_4",
text: "广东省( 共5个 )",
value: "广东省",
open: true
}, {pId: "0_0_4", id: "0_0_4_0", text: "东莞市", value: "东莞市", open: true}, {
pId: "0_0_4",
id: "0_0_4_1",
text: "广州市",
value: "广州市",
open: true
}];
var itemSelectorGetter = function (array) {
return BI.map(array, function (idx, num) {
return ".bi-multi-select-popup-view .bi-loader .bi-button-group .bi-multi-select-item:nth-child(" + num + ")";
});
};
var searchItemSelectorGetter = function (array) {
return BI.map(array, function (idx, num) {
return ".bi-multi-select-search-pane .bi-loader .bi-button-group .bi-multi-select-item:nth-child(" + num + ")";
});
};
/**
* test_author_windy
**/
it("setValue", function () {
var widget = BI.Test.createWidget({
type: "bi.tree_value_chooser_insert_combo",
width: 220,
itemsCreator: function (op, callback) {
callback(items);
}
});
widget.setValue({
"中国": {
"北京市": {
"朝阳区": {}
}
}
});
expect(widget.getValue()).to.deep.equal({
"中国": {
"北京市": {
"朝阳区": {}
}
}
});
widget.destroy();
});
/**
* test_author_windy
**/
it("getValue", function () {
var widget = BI.Test.createWidget({
type: "bi.tree_value_chooser_insert_combo",
width: 220,
itemsCreator: function (op, callback) {
callback(items);
},
value: {
"中国": {
"北京市": {
"朝阳区": {}
}
}
}
});
expect(widget.getValue()).to.deep.equal({
"中国": {
"北京市": {
"朝阳区": {}
}
}
});
widget.destroy();
});
});

132
src/component/treevaluechooser/__test__/combo.treevaluechooser.test.js

@ -0,0 +1,132 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/25
*/
describe("tree_value_chooser_combo", function () {
var items = [{pId: "0", id: "0_0", text: "中国", value: "", open: true}, {
pId: "0_0",
id: "0_0_0",
text: "安徽省( 共1个 )",
value: "安徽省",
open: true
}, {pId: "0_0_0", id: "0_0_0_0", text: "芜湖市", value: "芜湖市", open: true}, {
pId: "0_0",
id: "0_0_1",
text: "北京市( 共6个 )",
value: "北京市",
open: true
}, {pId: "0_0_1", id: "0_0_1_0", text: "北京市区", value: "北京市区", open: true}, {
pId: "0_0_1",
id: "0_0_1_1",
text: "朝阳区",
value: "朝阳区",
open: true
}, {pId: "0_0_1", id: "0_0_1_2", text: "东城区", value: "东城区", open: true}, {
pId: "0_0_1",
id: "0_0_1_3",
text: "海淀区4内",
value: "海淀区4内",
open: true
}, {pId: "0_0_1", id: "0_0_1_4", text: "海淀区4外", value: "海淀区4外", open: true}, {
pId: "0_0_1",
id: "0_0_1_5",
text: "石景山区",
value: "石景山区",
open: true
}, {pId: "0_0", id: "0_0_2", text: "福建省( 共2个 )", value: "福建省", open: true}, {
pId: "0_0_2",
id: "0_0_2_0",
text: "莆田市",
value: "莆田市",
open: true
}, {pId: "0_0_2", id: "0_0_2_1", text: "泉州市", value: "泉州市", open: true}, {
pId: "0_0",
id: "0_0_3",
text: "甘肃省( 共1个 )",
value: "甘肃省",
open: true
}, {pId: "0_0_3", id: "0_0_3_0", text: "兰州市", value: "兰州市", open: true}, {
pId: "0_0",
id: "0_0_4",
text: "广东省( 共5个 )",
value: "广东省",
open: true
}, {pId: "0_0_4", id: "0_0_4_0", text: "东莞市", value: "东莞市", open: true}, {
pId: "0_0_4",
id: "0_0_4_1",
text: "广州市",
value: "广州市",
open: true
}];
var itemSelectorGetter = function (array) {
return BI.map(array, function (idx, num) {
return ".bi-multi-select-popup-view .bi-loader .bi-button-group .bi-multi-select-item:nth-child(" + num + ")";
});
};
var searchItemSelectorGetter = function (array) {
return BI.map(array, function (idx, num) {
return ".bi-multi-select-search-pane .bi-loader .bi-button-group .bi-multi-select-item:nth-child(" + num + ")";
});
};
/**
* test_author_windy
**/
it("setValue", function () {
var widget = BI.Test.createWidget({
type: "bi.tree_value_chooser_combo",
width: 220,
itemsCreator: function (op, callback) {
callback(items);
}
});
widget.setValue({
"中国": {
"北京市": {
"朝阳区": {}
}
}
});
expect(widget.getValue()).to.deep.equal({
"中国": {
"北京市": {
"朝阳区": {}
}
}
});
widget.destroy();
});
/**
* test_author_windy
**/
it("getValue", function () {
var widget = BI.Test.createWidget({
type: "bi.tree_value_chooser_combo",
width: 220,
itemsCreator: function (op, callback) {
callback(items);
},
value: {
"中国": {
"北京市": {
"朝阳区": {}
}
}
}
});
expect(widget.getValue()).to.deep.equal({
"中国": {
"北京市": {
"朝阳区": {}
}
}
});
widget.destroy();
});
});

140
src/component/treevaluechooser/__test__/pane.treevaluechooser.test.js

@ -0,0 +1,140 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2019/9/25
*/
describe("tree_value_chooser_pane", function () {
var items = [{pId: "0", id: "0_0", text: "中国", value: "", open: true}, {
pId: "0_0",
id: "0_0_0",
text: "安徽省( 共1个 )",
value: "安徽省",
open: true
}, {pId: "0_0_0", id: "0_0_0_0", text: "芜湖市", value: "芜湖市", open: true}, {
pId: "0_0",
id: "0_0_1",
text: "北京市( 共6个 )",
value: "北京市",
open: true
}, {pId: "0_0_1", id: "0_0_1_0", text: "北京市区", value: "北京市区", open: true}, {
pId: "0_0_1",
id: "0_0_1_1",
text: "朝阳区",
value: "朝阳区",
open: true
}, {pId: "0_0_1", id: "0_0_1_2", text: "东城区", value: "东城区", open: true}, {
pId: "0_0_1",
id: "0_0_1_3",
text: "海淀区4内",
value: "海淀区4内",
open: true
}, {pId: "0_0_1", id: "0_0_1_4", text: "海淀区4外", value: "海淀区4外", open: true}, {
pId: "0_0_1",
id: "0_0_1_5",
text: "石景山区",
value: "石景山区",
open: true
}, {pId: "0_0", id: "0_0_2", text: "福建省( 共2个 )", value: "福建省", open: true}, {
pId: "0_0_2",
id: "0_0_2_0",
text: "莆田市",
value: "莆田市",
open: true
}, {pId: "0_0_2", id: "0_0_2_1", text: "泉州市", value: "泉州市", open: true}, {
pId: "0_0",
id: "0_0_3",
text: "甘肃省( 共1个 )",
value: "甘肃省",
open: true
}, {pId: "0_0_3", id: "0_0_3_0", text: "兰州市", value: "兰州市", open: true}, {
pId: "0_0",
id: "0_0_4",
text: "广东省( 共5个 )",
value: "广东省",
open: true
}, {pId: "0_0_4", id: "0_0_4_0", text: "东莞市", value: "东莞市", open: true}, {
pId: "0_0_4",
id: "0_0_4_1",
text: "广州市",
value: "广州市",
open: true
}];
var itemSelectorGetter = function (array) {
return BI.map(array, function (idx, num) {
return ".bi-multi-select-popup-view .bi-loader .bi-button-group .bi-multi-select-item:nth-child(" + num + ")";
});
};
var searchItemSelectorGetter = function (array) {
return BI.map(array, function (idx, num) {
return ".bi-multi-select-search-pane .bi-loader .bi-button-group .bi-multi-select-item:nth-child(" + num + ")";
});
};
/**
* test_author_windy
**/
it("setValue", function () {
var widget = BI.Test.createWidget({
type: "bi.tree_value_chooser_pane",
width: 220,
items: items,
// itemsCreator: function (op, callback) {
// callback(items);
// }
});
widget.setSelectedValue({
"中国": {
"北京市": {
"朝阳区": {}
}
}
});
expect(widget.getValue()).to.deep.equal({
"中国": {
"北京市": {
"朝阳区": {}
}
}
});
widget.destroy();
});
/**
* test_author_windy
**/
it("getValue", function () {
var widget = BI.Test.createWidget({
type: "bi.tree_value_chooser_pane",
width: 220,
itemsCreator: function (op, callback) {
callback(items);
},
value: {
"中国": {
"北京市": {
"朝阳区": {}
}
}
}
});
widget.setSelectedValue({
"中国": {
"北京市": {
"朝阳区": {}
}
}
});
expect(widget.getValue()).to.deep.equal({
"中国": {
"北京市": {
"朝阳区": {}
}
}
});
widget.destroy();
});
});

86
src/widget/multiselect/multiselect.combo.js

@ -25,7 +25,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
var assertShowValue = function () {
BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue));
self.trigger.getSearcher().setState(self.storeValue);
self.trigger.getCounter().setButtonChecked(self.storeValue);
self.numberCounter.setButtonChecked(self.storeValue);
};
this.storeValue = o.value || {};
@ -49,15 +49,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
}
},
valueFormatter: o.valueFormatter,
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) {
// 预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue()));
}
callback.apply(self, arguments);
});
},
itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
value: this.storeValue
});
@ -125,7 +117,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
// counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
this.getCounter().updateSelectedValue(self.storeValue);
self.numberCounter.updateSelectedValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
if (!self.combo.isViewVisible()) {
@ -144,6 +136,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
ref: function () {
self.popup = this;
self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this);
},
listeners: [{
eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
@ -172,14 +165,14 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
BI.nextTick(function () {
self.combo.adjustWidth();
self.combo.adjustHeight();
self.trigger.getCounter().adjustView();
self.numberCounter.adjustView();
self.trigger.getSearcher().adjustView();
});
}
},
value: o.value,
hideChecker: function (e) {
return triggerBtn.element.find(e.target).length === 0;
return triggerBtn.element.find(e.target).length === 0 && self.numberCounter.element.find(e.target).length === 0;
}
});
@ -193,7 +186,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
this.wants2Quit = false;
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
// important:关闭弹出时又可能没有退出编辑状态
self.trigger.stopEditing();
self._stopEditing();
if (self.requesting === true) {
self.wants2Quit = true;
} else {
@ -208,13 +201,49 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
cls: "multi-select-trigger-icon-button"
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
self.trigger.getCounter().hideView();
self.numberCounter.hideView();
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
this.numberCounter = BI.createWidget({
type: "bi.multi_select_check_selected_switcher",
masker: {
offset: {
left: 0,
top: 0,
right: 0,
bottom: 25
}
},
valueFormatter: o.valueFormatter,
itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
value: this.storeValue
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
this.updateSelectedValue(self.storeValue);
});
this.numberCounter.on(BI.Events.VIEW, function (b) {
BI.nextTick(function () {// 自动调整宽度
self.trigger.refreshPlaceHolderWidth((b === true ? self.numberCounter.element.outerWidth() + 8 : 0));
});
});
this.trigger.element.click(function (e) {
if (self.trigger.element.find(e.target).length > 0) {
self.numberCounter.hideView();
}
});
BI.createWidget({
type: "bi.absolute",
element: this,
@ -229,12 +258,36 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
right: 0,
top: 0,
bottom: 0
}, {
el: {
type: "bi.vertical_adapt",
items: [this.numberCounter]
},
right: o.height,
top: 0,
height: o.height,
}]
});
},
_defaultState: function () {
_itemsCreator4Trigger: function(op, callback) {
var self = this, o = this.options;
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) {
// 预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue()));
}
callback.apply(self, arguments);
});
},
_stopEditing: function() {
this.trigger.stopEditing();
this.numberCounter.hideView();
},
_defaultState: function () {
this._stopEditing();
this.combo.hideView();
},
@ -362,6 +415,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
this.storeValue = v || {};
this._assertValue(this.storeValue);
this.combo.setValue(this.storeValue);
this.numberCounter.setValue(this.storeValue);
},
getValue: function () {

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

@ -25,7 +25,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
var assertShowValue = function () {
BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue));
self.trigger.getSearcher().setState(self.storeValue);
self.trigger.getCounter().setButtonChecked(self.storeValue);
self.numberCounter.setButtonChecked(self.storeValue);
};
this.storeValue = o.value || {};
// 标记正在请求数据
@ -47,15 +47,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
}
},
valueFormatter: o.valueFormatter,
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) {
// 预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue()));
}
callback.apply(self, arguments);
});
},
itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
value: o.value
});
@ -82,7 +74,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM, function () {
if (!this.getSearcher().hasMatched()) {
self._addItem(assertShowValue);
self.trigger.stopEditing();
self._stopEditing();
}
});
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) {
@ -119,7 +111,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
// counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
this.getCounter().updateSelectedValue(self.storeValue);
self.numberCounter.updateSelectedValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () {
if (!self.combo.isViewVisible()) {
@ -138,6 +130,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
ref: function () {
self.popup = this;
self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this);
},
listeners: [{
eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
@ -166,14 +159,15 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
BI.nextTick(function () {
self.combo.adjustWidth();
self.combo.adjustHeight();
self.trigger.getCounter().adjustView();
self.numberCounter.adjustView();
self.trigger.getSearcher().adjustView();
});
}
},
value: o.value,
hideChecker: function (e) {
return triggerBtn.element.find(e.target).length === 0;
return triggerBtn.element.find(e.target).length === 0 &&
self.numberCounter.element.find(e.target).length === 0;
}
});
@ -187,7 +181,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
this.wants2Quit = false;
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
// important:关闭弹出时又可能没有退出编辑状态
self.trigger.stopEditing();
self._stopEditing();
if (self.requesting === true) {
self.wants2Quit = true;
} else {
@ -202,13 +196,51 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
cls: "multi-select-trigger-icon-button"
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
self.trigger.getCounter().hideView();
self.numberCounter.hideView();
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
this.numberCounter = BI.createWidget({
type: "bi.multi_select_check_selected_switcher",
masker: {
offset: {
left: 0,
top: 0,
right: 0,
bottom: 25
}
},
valueFormatter: o.valueFormatter,
itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
value: o.value
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
this.updateSelectedValue(self.storeValue);
});
this.numberCounter.on(BI.Events.VIEW, function (b) {
BI.nextTick(function () {// 自动调整宽度
self.trigger.refreshPlaceHolderWidth((b === true ? self.numberCounter.element.outerWidth() + 8 : 0));
});
});
this.trigger.element.click(function (e) {
if (self.trigger.element.find(e.target).length > 0) {
self.numberCounter.hideView();
}
});
BI.createWidget({
type: "bi.absolute",
element: this,
@ -223,10 +255,29 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
right: 0,
top: 0,
bottom: 0
}, {
el: {
type: "bi.vertical_adapt",
items: [this.numberCounter]
},
right: o.height,
top: 0,
height: o.height,
}]
});
},
_itemsCreator4Trigger: function(op, callback) {
var self = this, o = this.options;
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) {
// 预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue()));
}
callback.apply(self, arguments);
});
},
_addItem: function (assertShowValue) {
var self = this;
var keyword = this.trigger.getSearcher().getKeyword();
@ -246,8 +297,13 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
});
},
_defaultState: function () {
_stopEditing: function() {
this.trigger.stopEditing();
this.numberCounter.hideView();
},
_defaultState: function () {
this._stopEditing();
this.combo.hideView();
},
@ -376,6 +432,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, {
this.storeValue = v || {};
this._assertValue(this.storeValue);
this.combo.setValue(this.storeValue);
this.numberCounter.setValue(this.storeValue);
},
getValue: function () {

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

@ -24,7 +24,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
var assertShowValue = function () {
BI.isKey(self._startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, self._startValue) : BI.pushDistinct(self.storeValue.value, self._startValue));
self.trigger.getSearcher().setState(self.storeValue);
self.trigger.getCounter().setButtonChecked(self.storeValue);
self.numberCounter.setButtonChecked(self.storeValue);
};
this.storeValue = {
type: BI.Selection.Multi,
@ -47,18 +47,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
}
},
valueFormatter: o.valueFormatter,
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) {
// 预防trigger内部把当前的storeValue改掉
self.trigger.setValue({
type: BI.Selection.Multi,
value: self.getValue()
});
}
callback.apply(self, arguments);
});
},
itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
value: {
type: BI.Selection.Multi,
value: o.value
@ -80,7 +69,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM, function () {
if (!this.getSearcher().hasMatched()) {
self._addItem(assertShowValue);
self.trigger.stopEditing();
self._stopEditing();
}
});
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) {
@ -115,7 +104,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
// counter的值随点击项的改变而改变, 点击counter的时候不需要setValue(counter会请求刷新计数)
// 只需要更新查看面板的selectedValue用以请求已选数据
this.getCounter().updateSelectedValue(self.storeValue);
self.numberCounter.updateSelectedValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () {
if (!self.combo.isViewVisible()) {
@ -134,6 +123,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
ref: function () {
self.popup = this;
self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this);
},
listeners: [{
eventName: BI.MultiSelectPopupView.EVENT_CHANGE,
@ -161,7 +151,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
BI.nextTick(function () {
self.combo.adjustWidth();
self.combo.adjustHeight();
self.trigger.getCounter().adjustView();
self.numberCounter.adjustView();
self.trigger.getSearcher().adjustView();
});
}
@ -171,7 +161,8 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
value: o.value
},
hideChecker: function (e) {
return triggerBtn.element.find(e.target).length === 0;
return triggerBtn.element.find(e.target).length === 0 &&
self.numberCounter.element.find(e.target).length === 0;
}
});
@ -185,7 +176,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
this.wants2Quit = false;
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
// important:关闭弹出时又可能没有退出编辑状态
self.trigger.stopEditing();
self._stopEditing();
if (self.requesting === true) {
self.wants2Quit = true;
} else {
@ -200,13 +191,52 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
cls: "multi-select-trigger-icon-button"
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
self.trigger.getCounter().hideView();
self.numberCounter.hideView();
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
this.numberCounter = BI.createWidget({
type: "bi.multi_select_check_selected_switcher",
masker: {
offset: {
left: 0,
top: 0,
right: 0,
bottom: 25
}
},
valueFormatter: o.valueFormatter,
itemsCreator: BI.bind(this._itemsCreator4Trigger, this),
value: {
type: BI.Selection.Multi,
value: o.value
}
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
this.updateSelectedValue(self.storeValue);
});
this.numberCounter.on(BI.Events.VIEW, function (b) {
BI.nextTick(function () {// 自动调整宽度
self.trigger.refreshPlaceHolderWidth((b === true ? self.numberCounter.element.outerWidth() + 8 : 0));
});
});
this.trigger.element.click(function (e) {
if (self.trigger.element.find(e.target).length > 0) {
self.numberCounter.hideView();
}
});
BI.createWidget({
type: "bi.absolute",
element: this,
@ -221,10 +251,29 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
right: 0,
top: 0,
bottom: 0
}, {
el: {
type: "bi.vertical_adapt",
items: [this.numberCounter]
},
right: o.height,
top: 0,
height: o.height,
}]
});
},
_itemsCreator4Trigger: function(op, callback) {
var self = this, o = this.options;
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keywords)) {
// 预防trigger内部把当前的storeValue改掉
self.trigger.setValue(BI.deepClone(self.getValue()));
}
callback.apply(self, arguments);
});
},
_addItem: function (assertShowValue) {
var self = this;
var keyword = this.trigger.getSearcher().getKeyword();
@ -244,8 +293,13 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
});
},
_defaultState: function () {
_stopEditing: function() {
this.trigger.stopEditing();
this.numberCounter.hideView();
},
_defaultState: function () {
this._stopEditing();
this.combo.hideView();
},
@ -375,6 +429,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, {
value: v || []
};
this.combo.setValue(this.storeValue);
this.numberCounter.setValue(this.storeValue);
},
getValue: function () {

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

@ -71,30 +71,12 @@ BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, {
this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_FOCUS, function () {
self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_FOCUS);
});
this.numberCounter = BI.createWidget(o.switcher, {
type: "bi.multi_select_check_selected_switcher",
valueFormatter: o.valueFormatter,
itemsCreator: o.itemsCreator,
adapter: o.adapter,
masker: o.masker,
value: o.value
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK);
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW);
});
var wrapNumberCounter = BI.createWidget({
type: "bi.right_vertical_adapt",
hgap: 4,
items: [{
el: this.numberCounter
}]
this.wrapNumberCounter = BI.createWidget({
type: "bi.layout"
});
var wrapper = BI.createWidget({
this.wrapper = BI.createWidget({
type: "bi.htape",
element: this,
items: [
@ -102,7 +84,7 @@ BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, {
el: this.searcher,
width: "fill"
}, {
el: wrapNumberCounter,
el: this.wrapNumberCounter,
width: 0
}, {
el: BI.createWidget(),
@ -123,23 +105,14 @@ BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, {
bottom: 0
}]
});
this.numberCounter.on(BI.Events.VIEW, function (b) {
BI.nextTick(function () {// 自动调整宽度
wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
wrapper.resize();
});
});
this.element.click(function (e) {
if (self.element.find(e.target).length > 0) {
self.numberCounter.hideView();
}
});
},
getCounter: function () {
return this.numberCounter;
/**
* 重新调整numberCounter的空白占位符
*/
refreshPlaceHolderWidth: function(width) {
this.wrapper.attr("items")[1].width = width;
this.wrapper.resize();
},
getSearcher: function () {
@ -148,17 +121,14 @@ BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, {
stopEditing: function () {
this.searcher.stopSearch();
this.numberCounter.hideView();
},
setAdapter: function (adapter) {
this.searcher.setAdapter(adapter);
this.numberCounter.setAdapter(adapter);
},
setValue: function (ob) {
this.searcher.setValue(ob);
this.numberCounter.setValue(ob);
},
getKey: function () {

50
src/widget/multiselect/multiselect.trigger.js

@ -68,30 +68,12 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
this.searcher.on(BI.MultiSelectSearcher.EVENT_FOCUS, function () {
self.fireEvent(BI.MultiSelectTrigger.EVENT_FOCUS);
});
this.numberCounter = BI.createWidget(o.switcher, {
type: "bi.multi_select_check_selected_switcher",
valueFormatter: o.valueFormatter,
itemsCreator: o.itemsCreator,
adapter: o.adapter,
masker: o.masker,
value: o.value
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
self.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK);
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
self.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW);
});
var wrapNumberCounter = BI.createWidget({
type: "bi.right_vertical_adapt",
hgap: 4,
items: [{
el: this.numberCounter
}]
this.wrapNumberCounter = BI.createWidget({
type: "bi.layout"
});
var wrapper = BI.createWidget({
this.wrapper = BI.createWidget({
type: "bi.htape",
element: this,
items: [
@ -99,7 +81,7 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
el: this.searcher,
width: "fill"
}, {
el: wrapNumberCounter,
el: this.wrapNumberCounter,
width: 0
}, {
el: BI.createWidget(),
@ -120,23 +102,14 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
bottom: 0
}]
});
this.numberCounter.on(BI.Events.VIEW, function (b) {
BI.nextTick(function () {// 自动调整宽度
wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0);
wrapper.resize();
});
});
this.element.click(function (e) {
if (self.element.find(e.target).length > 0) {
self.numberCounter.hideView();
}
});
},
getCounter: function () {
return this.numberCounter;
/**
* 重新调整numberCounter的空白占位符
*/
refreshPlaceHolderWidth: function(width) {
this.wrapper.attr("items")[1].width = width;
this.wrapper.resize();
},
getSearcher: function () {
@ -145,17 +118,14 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, {
stopEditing: function () {
this.searcher.stopSearch();
this.numberCounter.hideView();
},
setAdapter: function (adapter) {
this.searcher.setAdapter(adapter);
this.numberCounter.setAdapter(adapter);
},
setValue: function (ob) {
this.searcher.setValue(ob);
this.numberCounter.setValue(ob);
},
getKey: function () {

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

@ -62,10 +62,6 @@ BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, {
me.populate();
});
});
this.switcher.element.click(function (e) {
e.stopPropagation();
});
},
adjustView: function () {

105
src/widget/multitree/multi.tree.combo.js

@ -41,24 +41,11 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
text: o.text,
watermark: o.watermark,
// adapter: this.popup,
masker: {
offset: this.constants.offset
},
searcher: {
type: "bi.multi_tree_searcher",
itemsCreator: o.itemsCreator
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button"
},
popup: {
type: "bi.multi_tree_check_pane",
itemsCreator: o.itemsCreator
}
},
value: {value: o.value || {}}
});
this.combo = BI.createWidget({
@ -72,11 +59,12 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
ref: function () {
self.popup = this;
self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this);
},
listeners: [{
eventName: BI.MultiTreePopup.EVENT_AFTERINIT,
action: function () {
self.trigger.getCounter().adjustView();
self.numberCounter.adjustView();
isInit = true;
if (want2showCounter === true) {
showCounter();
@ -91,7 +79,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
value: this.hasChecked() ? this.getValue() : {}
};
self.trigger.getSearcher().setState(val);
self.trigger.getCounter().setButtonChecked(val);
self.numberCounter.setButtonChecked(val);
self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM);
}
}, {
@ -110,14 +98,15 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
itemsCreator: o.itemsCreator,
onLoaded: function () {
BI.nextTick(function () {
self.trigger.getCounter().adjustView();
self.numberCounter.adjustView();
self.trigger.getSearcher().adjustView();
});
}
},
value: {value: o.value || {}},
hideChecker: function (e) {
return triggerBtn.element.find(e.target).length === 0;
return triggerBtn.element.find(e.target).length === 0 &&
self.numberCounter.element.find(e.target).length === 0;
}
});
@ -142,10 +131,12 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
self.storeValue = {value: self.combo.getValue()};
this.setValue(self.storeValue);
self.numberCounter.setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self.storeValue = {value: this.getValue()};
self.combo.setValue(self.storeValue);
self.numberCounter.setValue(self.storeValue);
BI.nextTick(function () {
if (isPopupView()) {
self.combo.populate();
@ -165,17 +156,9 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
self.storeValue = {value: self.combo.getValue()};
}
self.trigger.setValue(self.storeValue);
self.numberCounter.setValue(self.storeValue);
}
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
});
@ -192,7 +175,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
value: checked ? {1: 1} : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getCounter().setButtonChecked(val);
self.numberCounter.setButtonChecked(val);
self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM);
});
@ -205,16 +188,17 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
change = false;
}
self.combo.setValue(self.storeValue);
self.numberCounter.setValue(self.storeValue);
self.populate();
});
this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () {
if (isSearching()) {
self.trigger.stopEditing();
self._stopEditing();
self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM);
} else {
if (isPopupView()) {
self.trigger.stopEditing();
self._stopEditing();
self.storeValue = {value: self.combo.getValue()};
if (clear === true) {
self.storeValue = {value: {}};
@ -233,13 +217,56 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
cls: "multi-select-trigger-icon-button"
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
self.trigger.getCounter().hideView();
self.numberCounter.hideView();
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
this.numberCounter = BI.createWidget({
type: "bi.multi_select_check_selected_switcher",
el: {
type: "bi.multi_tree_check_selected_button"
},
popup: {
type: "bi.multi_tree_check_pane"
},
masker: {
offset: this.constants.offset
},
itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter,
value: {value: o.value || {}}
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}
});
this.numberCounter.on(BI.Events.VIEW, function (b) {
BI.nextTick(function () {// 自动调整宽度
self.trigger.refreshPlaceHolderWidth((b === true ? self.numberCounter.element.outerWidth() + 8 : 0));
});
});
this.trigger.element.click(function (e) {
if (self.trigger.element.find(e.target).length > 0) {
self.numberCounter.hideView();
}
});
BI.createWidget({
type: "bi.absolute",
element: this,
@ -254,12 +281,25 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
right: 0,
top: 0,
bottom: 0
}, {
el: {
type: "bi.vertical_adapt",
items: [this.numberCounter]
},
right: o.height,
top: 0,
height: o.height,
}]
});
},
_defaultState: function () {
_stopEditing: function() {
this.trigger.stopEditing();
this.numberCounter.hideView();
},
_defaultState: function () {
this._stopEditing();
this.combo.hideView();
},
@ -268,6 +308,9 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
this.combo.setValue({
value: v || {}
});
this.numberCounter.setValue({
value: v || {}
});
},
getValue: function () {

111
src/widget/multitree/multi.tree.insert.combo.js

@ -58,20 +58,12 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
self._assertShowValue();
// setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了
self.combo.setValue(self.storeValue);
self.trigger.stopEditing();
self.numberCounter.setValue(self.storeValue);
self._stopEditing();
}
}]
}
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button"
},
popup: {
type: "bi.multi_tree_check_pane",
itemsCreator: o.itemsCreator
}
},
value: {value: o.value || {}}
});
@ -87,11 +79,12 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
ref: function () {
self.popup = this;
self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this);
},
listeners: [{
eventName: BI.MultiTreePopup.EVENT_AFTERINIT,
action: function () {
self.trigger.getCounter().adjustView();
self.numberCounter.adjustView();
isInit = true;
if (want2showCounter === true) {
showCounter();
@ -106,7 +99,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
value: this.hasChecked() ? this.getValue() : {}
};
self.trigger.getSearcher().setState(val);
self.trigger.getCounter().setButtonChecked(val);
self.numberCounter.setButtonChecked(val);
self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
}
}, {
@ -125,14 +118,15 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
itemsCreator: o.itemsCreator,
onLoaded: function () {
BI.nextTick(function () {
self.trigger.getCounter().adjustView();
self.numberCounter.adjustView();
self.trigger.getSearcher().adjustView();
});
}
},
value: {value: o.value || {}},
hideChecker: function (e) {
return triggerBtn.element.find(e.target).length === 0;
return triggerBtn.element.find(e.target).length === 0 &&
self.numberCounter.element.find(e.target).length === 0;
}
});
@ -157,10 +151,12 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
self.storeValue = {value: self.combo.getValue()};
this.setValue(self.storeValue);
self.numberCounter.setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self.storeValue = {value: this.getValue()};
self.combo.setValue(self.storeValue);
self.numberCounter.setValue(self.storeValue);
BI.nextTick(function () {
if (isPopupView()) {
self.combo.populate();
@ -180,25 +176,12 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
self.storeValue = {value: self.combo.getValue()};
}
self.trigger.setValue(self.storeValue);
self.numberCounter.setValue(self.storeValue);
}
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
var checked = this.getSearcher().hasChecked();
@ -207,7 +190,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
value: checked ? {1: 1} : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getCounter().setButtonChecked(val);
self.numberCounter.setButtonChecked(val);
self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -220,16 +203,17 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
change = false;
}
self.combo.setValue(self.storeValue);
self.numberCounter.setValue(self.storeValue);
self.populate();
});
this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () {
if (isSearching()) {
self.trigger.stopEditing();
self._stopEditing();
self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CONFIRM);
} else {
if (isPopupView()) {
self.trigger.stopEditing();
self._stopEditing();
self.storeValue = {value: self.combo.getValue()};
if (clear === true) {
self.storeValue = {value: {}};
@ -248,13 +232,56 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
cls: "multi-select-trigger-icon-button"
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
self.trigger.getCounter().hideView();
self.numberCounter.hideView();
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
this.numberCounter = BI.createWidget({
type: "bi.multi_select_check_selected_switcher",
el: {
type: "bi.multi_tree_check_selected_button"
},
popup: {
type: "bi.multi_tree_check_pane"
},
itemsCreator: o.itemsCreator,
masker: {
offset: this.constants.offset
},
valueFormatter: o.valueFormatter,
value: o.value
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}
});
this.numberCounter.on(BI.Events.VIEW, function (b) {
BI.nextTick(function () {// 自动调整宽度
self.trigger.refreshPlaceHolderWidth((b === true ? self.numberCounter.element.outerWidth() + 8 : 0));
});
});
this.trigger.element.click(function (e) {
if (self.trigger.element.find(e.target).length > 0) {
self.numberCounter.hideView();
}
});
BI.createWidget({
type: "bi.absolute",
element: this,
@ -269,17 +296,30 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
right: 0,
top: 0,
bottom: 0
}, {
el: {
type: "bi.vertical_adapt",
items: [this.numberCounter]
},
right: o.height,
top: 0,
height: o.height,
}]
});
},
_assertShowValue: function () {
this.trigger.getSearcher().setState(this.storeValue);
this.trigger.getCounter().setButtonChecked(this.storeValue);
this.numberCounter.setButtonChecked(this.storeValue);
},
_defaultState: function () {
_stopEditing: function() {
this.trigger.stopEditing();
this.numberCounter.hideView();
},
_defaultState: function () {
this._stopEditing();
this.combo.hideView();
},
@ -288,6 +328,9 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
this.combo.setValue({
value: v || {}
});
this.numberCounter.setValue({
value: v || {}
});
},
getValue: function () {

105
src/widget/multitree/multi.tree.list.combo.js

@ -62,7 +62,8 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
self._assertShowValue();
// setValue以更新paras.value, 之后从search popup中拿到的就能有add的值了
self.combo.setValue(self.storeValue);
self.trigger.stopEditing();
self.numberCounter.setValue(self.storeValue);
self._stopEditing();
}
}]
}
@ -94,6 +95,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
ref: function () {
self.popup = this;
self.trigger.setAdapter(this);
self.numberCounter.setAdapter(this);
},
el: {
type: "bi.list_async_tree"
@ -101,7 +103,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
listeners: [{
eventName: BI.MultiTreePopup.EVENT_AFTERINIT,
action: function () {
self.trigger.getCounter().adjustView();
self.numberCounter.adjustView();
isInit = true;
if (want2showCounter === true) {
showCounter();
@ -116,7 +118,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
value: this.hasChecked() ? this.getValue() : []
};
self.trigger.getSearcher().setState(val);
self.trigger.getCounter().setButtonChecked(val);
self.numberCounter.setButtonChecked(val);
self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
}
}, {
@ -135,14 +137,15 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
itemsCreator: o.itemsCreator,
onLoaded: function () {
BI.nextTick(function () {
self.trigger.getCounter().adjustView();
self.numberCounter.adjustView();
self.trigger.getSearcher().adjustView();
});
}
},
value: {value: o.value || {}},
hideChecker: function (e) {
return triggerBtn.element.find(e.target).length === 0;
return triggerBtn.element.find(e.target).length === 0 &&
self.numberCounter.element.find(e.target).length === 0;
}
});
@ -167,10 +170,12 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
self.storeValue = {value: self.combo.getValue()};
this.setValue(self.storeValue);
self.numberCounter.setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self.storeValue = {value: this.getValue()};
self.combo.setValue(self.storeValue);
self.numberCounter.setValue(self.storeValue);
BI.nextTick(function () {
if (isPopupView()) {
self.combo.populate();
@ -190,25 +195,12 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
self.storeValue = {value: self.combo.getValue()};
}
self.trigger.setValue(self.storeValue);
self.numberCounter.setValue(self.storeValue);
}
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK, function () {
self.combo.toggle();
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
var checked = this.getSearcher().hasChecked();
@ -217,7 +209,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
value: checked ? {1: 1} : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getCounter().setButtonChecked(val);
self.numberCounter.setButtonChecked(val);
self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -230,6 +222,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
change = false;
}
self.combo.setValue(self.storeValue);
self.numberCounter.setValue(self.storeValue);
self.populate();
});
@ -239,7 +232,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
self.fireEvent(BI.MultiTreeListCombo.EVENT_CONFIRM);
} else {
if (isPopupView()) {
self.trigger.stopEditing();
self._stopEditing();
self.storeValue = {value: self.combo.getValue()};
if (clear === true) {
self.storeValue = {value: []};
@ -258,13 +251,61 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
cls: "multi-select-trigger-icon-button"
});
triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () {
self.trigger.getCounter().hideView();
self.numberCounter.hideView();
if (self.combo.isViewVisible()) {
self.combo.hideView();
} else {
self.combo.showView();
}
});
this.numberCounter = BI.createWidget({
type: "bi.multi_select_check_selected_switcher",
el: {
type: "bi.multi_tree_check_selected_button"
},
popup: {
type: "bi.multi_tree_check_pane"
},
itemsCreator: o.itemsCreator,
masker: {
offset: {
left: 0,
top: 0,
right: 0,
bottom: 25
}
},
valueFormatter: o.valueFormatter,
value: o.value
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () {
if (!self.combo.isViewVisible()) {
self.combo.showView();
}
});
this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}
});
this.numberCounter.on(BI.Events.VIEW, function (b) {
BI.nextTick(function () {// 自动调整宽度
self.trigger.refreshPlaceHolderWidth((b === true ? self.numberCounter.element.outerWidth() + 8 : 0));
});
});
this.trigger.element.click(function (e) {
if (self.trigger.element.find(e.target).length > 0) {
self.numberCounter.hideView();
}
});
BI.createWidget({
type: "bi.absolute",
element: this,
@ -279,17 +320,30 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
right: 0,
top: 0,
bottom: 0
}, {
el: {
type: "bi.vertical_adapt",
items: [this.numberCounter]
},
right: o.height,
top: 0,
height: o.height,
}]
});
},
_assertShowValue: function () {
this.trigger.getSearcher().setState(this.storeValue);
this.trigger.getCounter().setButtonChecked(this.storeValue);
this.numberCounter.setButtonChecked(this.storeValue);
},
_defaultState: function () {
_stopEditing: function() {
this.trigger.stopEditing();
this.numberCounter.hideView();
},
_defaultState: function () {
this._stopEditing();
this.combo.hideView();
},
@ -298,6 +352,9 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
this.combo.setValue({
value: v || []
});
this.numberCounter.setValue({
value: v || []
});
},
getValue: function () {

Loading…
Cancel
Save