guy 8 years ago
parent
commit
e93655a1c1
  1. 384
      bi/widget.js
  2. 384
      docs/widget.js
  3. 164
      src/widget/multistringlist/multistringlist.js
  4. 200
      src/widget/multitreelist/multitreelist.js
  5. 20
      src/widget/multitreelist/multitreelist.popup.js

384
bi/widget.js

@ -10955,7 +10955,7 @@ BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, {
BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE"; BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE";
BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW"; BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW";
BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/** BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/**
* Created by zcf on 2016/12/14. * Created by zcf_1 on 2017/5/2.
*/ */
BI.MultiStringList = BI.inherit(BI.Widget, { BI.MultiStringList = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
@ -10963,33 +10963,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
baseCls: 'bi-multi-string-list', baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn, valueFormatter: BI.emptyFn,
height: 25 el: {}
}) })
}, },
_init: function () { _init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments); BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () { var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.getSearcher().setState(self.storeValue);
self.trigger.getCounter().setButtonChecked(self.storeValue);
}; };
this.storeValue = {};
this.adapter = BI.createWidget({
this.popup = BI.createWidget({
type: "bi.multi_select_loader", type: "bi.multi_select_loader",
cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom", cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded, // onLoaded: o.onLoaded,
el: { el: {
height: "" height: ""
} }
}); });
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(function () { self._adjust(function () {
assertShowValue(); assertShowValue();
@ -10997,74 +10994,92 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
}); });
}); });
this.trigger = BI.createWidget({ this.searcherPane = BI.createWidget({
type: "bi.multi_select_trigger", type: "bi.multi_select_search_pane",
height: o.height, cls: "bi-border-left bi-border-right bi-border-bottom",
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) { op.keyword = self.trigger.getKeyword();
if (op.times === 1 && BI.isNotNull(op.keyword)) { this.setKeyword(op.keyword);
self.trigger.setValue(self.getValue()); o.itemsCreator(op, callback);
}
callback.apply(self, arguments);
});
} }
}); });
this.searcherPane.setVisible(false);
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback();
},
adapter: this.adapter,
popup: this.searcherPane,
height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self._setStartValue(""); self._setStartValue("");
this.getSearcher().setValue(self.storeValue); this.setValue(self.storeValue);
}); }
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { }, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue(""); self._setStartValue("");
}); self.adapter.setValue(self.storeValue);
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { }
if (this.getSearcher().hasMatched()) { }, {
var keyword = this.getSearcher().getKeyword(); eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
if (this.hasMatched()) {
var keyword = this.getKeyword();
self._join({ self._join({
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: [keyword] value: [keyword]
}, function () { }, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
self._setStartValue(keyword); self._setStartValue(keyword);
assertShowValue(); assertShowValue();
self.populate();
self._setStartValue(""); self._setStartValue("");
self.fireEvent(BI.MultiStringList.EVENT_CHANGE); self.fireEvent(BI.MultiStringList.EVENT_CHANGE);
}) })
} else {
self._showAdapter();
} }
}); }
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { }, {
eventName: BI.Searcher.EVENT_SEARCHING,
action: function () {
var keywords = this.getKeyword();
var last = BI.last(keywords); var last = BI.last(keywords);
keywords = BI.initial(keywords || []); keywords = BI.initial(keywords || []);
if (keywords.length > 0) { if (keywords.length > 0) {
self._joinKeywords(keywords, function () { self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) { if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
self.popup.populate(); self.adapter.populate();
self._setStartValue(""); self._setStartValue("");
} else { } else {
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
} }
}); });
} }
}); }
}, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { eventName: BI.Searcher.EVENT_CHANGE,
action: function (value, obj) {
if (obj instanceof BI.MultiSelectBar) { if (obj instanceof BI.MultiSelectBar) {
self._joinAll(this.getValue(), function () { self._joinAll(this.getValue(), function () {
assertShowValue(); assertShowValue();
@ -11074,13 +11089,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
assertShowValue(); assertShowValue();
}); });
} }
}
}]
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
this.getCounter().setValue(self.storeValue);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({ BI.createWidget({
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
@ -11088,16 +11100,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
width: "100%", width: "100%",
items: [{ items: [{
el: this.trigger, el: this.trigger,
height: 25 height: 30
}, {
el: div,
height: 2
}, { }, {
el: this.popup, el: this.adapter,
height: "fill" height: "fill"
}] }]
}); });
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
})
},
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
}, },
_defaultState: function () { _defaultState: function () {
this.trigger.stopEditing(); this.trigger.stopEditing();
}, },
@ -11142,7 +11175,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this._assertValue(res); this._assertValue(res);
o.itemsCreator({ o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA, type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey() keyword: self.trigger.getKeyword()
}, function (ob) { }, function (ob) {
var items = BI.pluck(ob.items, "value"); var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) { if (self.storeValue.type === res.type) {
@ -11231,22 +11264,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
_setStartValue: function (value) { _setStartValue: function (value) {
this._startValue = value; this._startValue = value;
this.popup.setStartValue(value); this.adapter.setStartValue(value);
}, },
// isAllSelected: function () { isAllSelected: function () {
// return this.popup.isAllSelected(); return this.adapter.isAllSelected();
// }, },
resize: function () { resize: function () {
this.trigger.getCounter().adjustView(); // this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView(); // this.trigger.adjustView();
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue = v || {}; this.storeValue = v || {};
this._assertValue(this.storeValue); this._assertValue(this.storeValue);
this.popup.setValue(this.storeValue); this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue); this.trigger.setValue(this.storeValue);
}, },
@ -11257,7 +11289,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this._count = null; this._count = null;
this._allData = null; this._allData = null;
this.popup.populate.apply(this.popup, arguments); this.adapter.populate.apply(this.adapter, arguments);
this.trigger.populate.apply(this.trigger, arguments); this.trigger.populate.apply(this.trigger, arguments);
} }
}); });
@ -12008,130 +12040,96 @@ BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/** BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/**
* Created by zcf on 2016/12/20. * Created by zcf_1 on 2017/5/11.
*/ */
BI.MultiTreeList = BI.inherit(BI.Widget, { BI.MultiSelectTree = BI.inherit(BI.Widget, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.MultiTreeList.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-tree-combo', baseCls: 'bi-multi-tree-combo',
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
height: 25 height: 25
}); })
}, },
_init: function () { _init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments); BI.MultiSelectTree.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = {value: {}};
var isInit = false; this.adapter = BI.createWidget({
var want2showCounter = false; type: "bi.multi_select_tree_popup",
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () { if (self.trigger.isSearching()) {
self.trigger.getCounter().adjustView(); self.storeValue = {value: self.searcherPane.getValue()};
isInit = true; } else {
if (want2showCounter === true) { self.storeValue = {value: self.adapter.getValue()};
showCounter();
} }
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}); });
this.trigger = BI.createWidget({ this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_select_trigger", type: "bi.multi_tree_search_pane",
height: o.height, cls: "bi-border-left bi-border-right bi-border-bottom",
adapter: this.popup, keywordGetter: function () {
masker: { return self.trigger.getKeyword();
offset: this.constants.offset
},
searcher: {
type: "bi.multi_tree_searcher",
itemsCreator: o.itemsCreator
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button"
}, },
popup: { itemsCreator: function (op, callback) {
type: "bi.multi_tree_check_pane", op.keyword = self.trigger.getKeyword();
itemsCreator: o.itemsCreator o.itemsCreator(op, callback);
}
} }
}); });
this.searcherPane.setVisible(false);
this.storeValue = {value: {}}; this.trigger = BI.createWidget({
type: "bi.searcher",
var isSearching = function () { isAutoSearch: false,
return self.trigger.getSearcher().isSearching(); isAutoSync: false,
}; onSearch: function (op, callback) {
callback({
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { keyword: self.trigger.getKeyword()
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { },
self.storeValue = {value: this.getValue()}; adapter: this.adapter,
self.trigger.setValue(self.storeValue); popup: this.searcherPane,
self.popup.setValue(self.storeValue); height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setValue(self.storeValue);
BI.nextTick(function () { BI.nextTick(function () {
self.trigger.populate(); self.adapter.populate();
self.popup.populate();
}); });
});
function showCounter() {
if (isSearching()) {
self.storeValue = {value: self.trigger.getValue()};
} else {
self.storeValue = {value: self.popup.getValue()};
} }
self.trigger.setValue(self.storeValue); }, {
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
if (self.trigger.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else {
self.storeValue = {value: self.adapter.getValue()};
} }
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
} }
if (isInit === true) { }, {
want2showCounter = null; eventName: BI.Searcher.EVENT_PAUSE,
showCounter(); action: function () {
self._showAdapter();
} }
}]
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
var val = {
type: BI.Selection.Multi,
value: this.getSearcher().hasChecked() ? {1: 1} : {}
};
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
});
this.popup.on(BI.MultiStringListPopup.EVENT_CHANGE, function () {
showCounter();
var val = {
type: BI.Selection.Multi,
value: this.hasChecked() ? {1: 1} : {}
};
self.trigger.getSearcher().setState(val);
self.trigger.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeList.EVENT_CHANGE);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({ BI.createWidget({
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
@ -12139,29 +12137,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
width: "100%", width: "100%",
items: [{ items: [{
el: this.trigger, el: this.trigger,
height: 25 height: 30
}, {
el: div,
height: 2
}, { }, {
el: this.popup, el: this.adapter,
height: "fill" height: "fill"
}] }]
});
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
}) })
}, },
_defaultState: function () { _showAdapter: function () {
this.trigger.stopEditing(); this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
}, },
resize: function () { resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue.value = v || {}; this.storeValue.value = v || {};
this.popup.setValue({ this.adapter.setValue({
value: v || {} value: v || {}
}); });
this.trigger.setValue({ this.trigger.setValue({
@ -12175,22 +12189,22 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this.trigger.populate.apply(this.trigger, arguments); this.trigger.populate.apply(this.trigger, arguments);
this.popup.populate.apply(this.popup, arguments); this.adapter.populate.apply(this.adapter, arguments);
} }
}); });
BI.MultiTreeList.EVENT_CHANGE = "MultiTreeList.EVENT_CHANGE"; BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
BI.shortcut('bi.multi_tree_list', BI.MultiTreeList);/** BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
* Created by zcf on 2016/12/21. * Created by zcf on 2016/12/21.
*/ */
BI.MultiStringListPopup=BI.inherit(BI.Widget,{ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
_defaultConfig:function () { _defaultConfig: function () {
return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom", baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom",
itemsCreator: BI.emptyFn itemsCreator: BI.emptyFn
}); });
}, },
_init:function () { _init: function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments); BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.popup = BI.createWidget({ this.popup = BI.createWidget({
type: "bi.sync_tree", type: "bi.sync_tree",
@ -12199,10 +12213,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_AFTER_INIT) self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT)
}); });
this.popup.on(BI.TreeView.EVENT_CHANGE, function () { this.popup.on(BI.TreeView.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_CHANGE) self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE)
}); });
}, },
@ -12224,9 +12238,9 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
} }
}); });
BI.MultiStringListPopup.EVENT_AFTER_INIT="BI.MultiStringListPopup.EVENT_AFTER_INIT"; BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
BI.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE"; BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);//小于号的值为:0,小于等于号的值为:1 BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);//小于号的值为:0,小于等于号的值为:1
//closeMIn:最小值的符号,closeMax:最大值的符号 //closeMIn:最小值的符号,closeMax:最大值的符号
/** /**
* Created by roy on 15/9/17. * Created by roy on 15/9/17.

384
docs/widget.js

@ -10955,7 +10955,7 @@ BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, {
BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE"; BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE";
BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW"; BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW";
BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/** BI.shortcut('bi.multi_select_check_selected_switcher', BI.MultiSelectCheckSelectedSwitcher);/**
* Created by zcf on 2016/12/14. * Created by zcf_1 on 2017/5/2.
*/ */
BI.MultiStringList = BI.inherit(BI.Widget, { BI.MultiStringList = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
@ -10963,33 +10963,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
baseCls: 'bi-multi-string-list', baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn, valueFormatter: BI.emptyFn,
height: 25 el: {}
}) })
}, },
_init: function () { _init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments); BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () { var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.getSearcher().setState(self.storeValue);
self.trigger.getCounter().setButtonChecked(self.storeValue);
}; };
this.storeValue = {};
this.adapter = BI.createWidget({
this.popup = BI.createWidget({
type: "bi.multi_select_loader", type: "bi.multi_select_loader",
cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom", cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded, // onLoaded: o.onLoaded,
el: { el: {
height: "" height: ""
} }
}); });
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(function () { self._adjust(function () {
assertShowValue(); assertShowValue();
@ -10997,74 +10994,92 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
}); });
}); });
this.trigger = BI.createWidget({ this.searcherPane = BI.createWidget({
type: "bi.multi_select_trigger", type: "bi.multi_select_search_pane",
height: o.height, cls: "bi-border-left bi-border-right bi-border-bottom",
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) { op.keyword = self.trigger.getKeyword();
if (op.times === 1 && BI.isNotNull(op.keyword)) { this.setKeyword(op.keyword);
self.trigger.setValue(self.getValue()); o.itemsCreator(op, callback);
}
callback.apply(self, arguments);
});
} }
}); });
this.searcherPane.setVisible(false);
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback();
},
adapter: this.adapter,
popup: this.searcherPane,
height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self._setStartValue(""); self._setStartValue("");
this.getSearcher().setValue(self.storeValue); this.setValue(self.storeValue);
}); }
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { }, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue(""); self._setStartValue("");
}); self.adapter.setValue(self.storeValue);
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { }
if (this.getSearcher().hasMatched()) { }, {
var keyword = this.getSearcher().getKeyword(); eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
if (this.hasMatched()) {
var keyword = this.getKeyword();
self._join({ self._join({
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: [keyword] value: [keyword]
}, function () { }, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
self._setStartValue(keyword); self._setStartValue(keyword);
assertShowValue(); assertShowValue();
self.populate();
self._setStartValue(""); self._setStartValue("");
self.fireEvent(BI.MultiStringList.EVENT_CHANGE); self.fireEvent(BI.MultiStringList.EVENT_CHANGE);
}) })
} else {
self._showAdapter();
} }
}); }
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { }, {
eventName: BI.Searcher.EVENT_SEARCHING,
action: function () {
var keywords = this.getKeyword();
var last = BI.last(keywords); var last = BI.last(keywords);
keywords = BI.initial(keywords || []); keywords = BI.initial(keywords || []);
if (keywords.length > 0) { if (keywords.length > 0) {
self._joinKeywords(keywords, function () { self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) { if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
self.popup.populate(); self.adapter.populate();
self._setStartValue(""); self._setStartValue("");
} else { } else {
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
} }
}); });
} }
}); }
}, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { eventName: BI.Searcher.EVENT_CHANGE,
action: function (value, obj) {
if (obj instanceof BI.MultiSelectBar) { if (obj instanceof BI.MultiSelectBar) {
self._joinAll(this.getValue(), function () { self._joinAll(this.getValue(), function () {
assertShowValue(); assertShowValue();
@ -11074,13 +11089,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
assertShowValue(); assertShowValue();
}); });
} }
}
}]
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
this.getCounter().setValue(self.storeValue);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({ BI.createWidget({
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
@ -11088,16 +11100,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
width: "100%", width: "100%",
items: [{ items: [{
el: this.trigger, el: this.trigger,
height: 25 height: 30
}, {
el: div,
height: 2
}, { }, {
el: this.popup, el: this.adapter,
height: "fill" height: "fill"
}] }]
}); });
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
})
},
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
}, },
_defaultState: function () { _defaultState: function () {
this.trigger.stopEditing(); this.trigger.stopEditing();
}, },
@ -11142,7 +11175,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this._assertValue(res); this._assertValue(res);
o.itemsCreator({ o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA, type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey() keyword: self.trigger.getKeyword()
}, function (ob) { }, function (ob) {
var items = BI.pluck(ob.items, "value"); var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) { if (self.storeValue.type === res.type) {
@ -11231,22 +11264,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
_setStartValue: function (value) { _setStartValue: function (value) {
this._startValue = value; this._startValue = value;
this.popup.setStartValue(value); this.adapter.setStartValue(value);
}, },
// isAllSelected: function () { isAllSelected: function () {
// return this.popup.isAllSelected(); return this.adapter.isAllSelected();
// }, },
resize: function () { resize: function () {
this.trigger.getCounter().adjustView(); // this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView(); // this.trigger.adjustView();
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue = v || {}; this.storeValue = v || {};
this._assertValue(this.storeValue); this._assertValue(this.storeValue);
this.popup.setValue(this.storeValue); this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue); this.trigger.setValue(this.storeValue);
}, },
@ -11257,7 +11289,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this._count = null; this._count = null;
this._allData = null; this._allData = null;
this.popup.populate.apply(this.popup, arguments); this.adapter.populate.apply(this.adapter, arguments);
this.trigger.populate.apply(this.trigger, arguments); this.trigger.populate.apply(this.trigger, arguments);
} }
}); });
@ -12008,130 +12040,96 @@ BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/** BI.shortcut('bi.multi_tree_searcher', BI.MultiTreeSearcher);/**
* Created by zcf on 2016/12/20. * Created by zcf_1 on 2017/5/11.
*/ */
BI.MultiTreeList = BI.inherit(BI.Widget, { BI.MultiSelectTree = BI.inherit(BI.Widget, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.MultiTreeList.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-tree-combo', baseCls: 'bi-multi-tree-combo',
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
height: 25 height: 25
}); })
}, },
_init: function () { _init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments); BI.MultiSelectTree.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = {value: {}};
var isInit = false; this.adapter = BI.createWidget({
var want2showCounter = false; type: "bi.multi_select_tree_popup",
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () { if (self.trigger.isSearching()) {
self.trigger.getCounter().adjustView(); self.storeValue = {value: self.searcherPane.getValue()};
isInit = true; } else {
if (want2showCounter === true) { self.storeValue = {value: self.adapter.getValue()};
showCounter();
} }
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}); });
this.trigger = BI.createWidget({ this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_select_trigger", type: "bi.multi_tree_search_pane",
height: o.height, cls: "bi-border-left bi-border-right bi-border-bottom",
adapter: this.popup, keywordGetter: function () {
masker: { return self.trigger.getKeyword();
offset: this.constants.offset
},
searcher: {
type: "bi.multi_tree_searcher",
itemsCreator: o.itemsCreator
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button"
}, },
popup: { itemsCreator: function (op, callback) {
type: "bi.multi_tree_check_pane", op.keyword = self.trigger.getKeyword();
itemsCreator: o.itemsCreator o.itemsCreator(op, callback);
}
} }
}); });
this.searcherPane.setVisible(false);
this.storeValue = {value: {}}; this.trigger = BI.createWidget({
type: "bi.searcher",
var isSearching = function () { isAutoSearch: false,
return self.trigger.getSearcher().isSearching(); isAutoSync: false,
}; onSearch: function (op, callback) {
callback({
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { keyword: self.trigger.getKeyword()
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { },
self.storeValue = {value: this.getValue()}; adapter: this.adapter,
self.trigger.setValue(self.storeValue); popup: this.searcherPane,
self.popup.setValue(self.storeValue); height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setValue(self.storeValue);
BI.nextTick(function () { BI.nextTick(function () {
self.trigger.populate(); self.adapter.populate();
self.popup.populate();
}); });
});
function showCounter() {
if (isSearching()) {
self.storeValue = {value: self.trigger.getValue()};
} else {
self.storeValue = {value: self.popup.getValue()};
} }
self.trigger.setValue(self.storeValue); }, {
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
if (self.trigger.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else {
self.storeValue = {value: self.adapter.getValue()};
} }
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
} }
if (isInit === true) { }, {
want2showCounter = null; eventName: BI.Searcher.EVENT_PAUSE,
showCounter(); action: function () {
self._showAdapter();
} }
}]
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
var val = {
type: BI.Selection.Multi,
value: this.getSearcher().hasChecked() ? {1: 1} : {}
};
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
});
this.popup.on(BI.MultiStringListPopup.EVENT_CHANGE, function () {
showCounter();
var val = {
type: BI.Selection.Multi,
value: this.hasChecked() ? {1: 1} : {}
};
self.trigger.getSearcher().setState(val);
self.trigger.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeList.EVENT_CHANGE);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({ BI.createWidget({
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
@ -12139,29 +12137,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
width: "100%", width: "100%",
items: [{ items: [{
el: this.trigger, el: this.trigger,
height: 25 height: 30
}, {
el: div,
height: 2
}, { }, {
el: this.popup, el: this.adapter,
height: "fill" height: "fill"
}] }]
});
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
}) })
}, },
_defaultState: function () { _showAdapter: function () {
this.trigger.stopEditing(); this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
}, },
resize: function () { resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue.value = v || {}; this.storeValue.value = v || {};
this.popup.setValue({ this.adapter.setValue({
value: v || {} value: v || {}
}); });
this.trigger.setValue({ this.trigger.setValue({
@ -12175,22 +12189,22 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this.trigger.populate.apply(this.trigger, arguments); this.trigger.populate.apply(this.trigger, arguments);
this.popup.populate.apply(this.popup, arguments); this.adapter.populate.apply(this.adapter, arguments);
} }
}); });
BI.MultiTreeList.EVENT_CHANGE = "MultiTreeList.EVENT_CHANGE"; BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
BI.shortcut('bi.multi_tree_list', BI.MultiTreeList);/** BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
* Created by zcf on 2016/12/21. * Created by zcf on 2016/12/21.
*/ */
BI.MultiStringListPopup=BI.inherit(BI.Widget,{ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
_defaultConfig:function () { _defaultConfig: function () {
return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom", baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom",
itemsCreator: BI.emptyFn itemsCreator: BI.emptyFn
}); });
}, },
_init:function () { _init: function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments); BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.popup = BI.createWidget({ this.popup = BI.createWidget({
type: "bi.sync_tree", type: "bi.sync_tree",
@ -12199,10 +12213,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_AFTER_INIT) self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT)
}); });
this.popup.on(BI.TreeView.EVENT_CHANGE, function () { this.popup.on(BI.TreeView.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_CHANGE) self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE)
}); });
}, },
@ -12224,9 +12238,9 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
} }
}); });
BI.MultiStringListPopup.EVENT_AFTER_INIT="BI.MultiStringListPopup.EVENT_AFTER_INIT"; BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
BI.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE"; BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);//小于号的值为:0,小于等于号的值为:1 BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);//小于号的值为:0,小于等于号的值为:1
//closeMIn:最小值的符号,closeMax:最大值的符号 //closeMIn:最小值的符号,closeMax:最大值的符号
/** /**
* Created by roy on 15/9/17. * Created by roy on 15/9/17.

164
src/widget/multistringlist/multistringlist.js

@ -1,5 +1,5 @@
/** /**
* Created by zcf on 2016/12/14. * Created by zcf_1 on 2017/5/2.
*/ */
BI.MultiStringList = BI.inherit(BI.Widget, { BI.MultiStringList = BI.inherit(BI.Widget, {
_defaultConfig: function () { _defaultConfig: function () {
@ -7,33 +7,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
baseCls: 'bi-multi-string-list', baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn, valueFormatter: BI.emptyFn,
height: 25 el: {}
}) })
}, },
_init: function () { _init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments); BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () { var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.getSearcher().setState(self.storeValue);
self.trigger.getCounter().setButtonChecked(self.storeValue);
}; };
this.storeValue = {};
this.popup = BI.createWidget({ this.adapter = BI.createWidget({
type: "bi.multi_select_loader", type: "bi.multi_select_loader",
cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom", cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded, // onLoaded: o.onLoaded,
el: { el: {
height: "" height: ""
} }
}); });
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue(); self.storeValue = this.getValue();
self._adjust(function () { self._adjust(function () {
assertShowValue(); assertShowValue();
@ -41,74 +38,92 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
}); });
}); });
this.trigger = BI.createWidget({ this.searcherPane = BI.createWidget({
type: "bi.multi_select_trigger", type: "bi.multi_select_search_pane",
height: o.height, cls: "bi-border-left bi-border-right bi-border-bottom",
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) { op.keyword = self.trigger.getKeyword();
if (op.times === 1 && BI.isNotNull(op.keyword)) { this.setKeyword(op.keyword);
self.trigger.setValue(self.getValue()); o.itemsCreator(op, callback);
}
callback.apply(self, arguments);
});
} }
}); });
this.searcherPane.setVisible(false);
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback();
},
adapter: this.adapter,
popup: this.searcherPane,
height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self._setStartValue(""); self._setStartValue("");
this.getSearcher().setValue(self.storeValue); this.setValue(self.storeValue);
}); }
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { }, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue(""); self._setStartValue("");
}); self.adapter.setValue(self.storeValue);
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { }
if (this.getSearcher().hasMatched()) { }, {
var keyword = this.getSearcher().getKeyword(); eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
if (this.hasMatched()) {
var keyword = this.getKeyword();
self._join({ self._join({
type: BI.Selection.Multi, type: BI.Selection.Multi,
value: [keyword] value: [keyword]
}, function () { }, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
self._setStartValue(keyword); self._setStartValue(keyword);
assertShowValue(); assertShowValue();
self.populate();
self._setStartValue(""); self._setStartValue("");
self.fireEvent(BI.MultiStringList.EVENT_CHANGE); self.fireEvent(BI.MultiStringList.EVENT_CHANGE);
}) })
} else {
self._showAdapter();
} }
}); }
this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { }, {
eventName: BI.Searcher.EVENT_SEARCHING,
action: function () {
var keywords = this.getKeyword();
var last = BI.last(keywords); var last = BI.last(keywords);
keywords = BI.initial(keywords || []); keywords = BI.initial(keywords || []);
if (keywords.length > 0) { if (keywords.length > 0) {
self._joinKeywords(keywords, function () { self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) { if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
self.popup.populate(); self.adapter.populate();
self._setStartValue(""); self._setStartValue("");
} else { } else {
self.trigger.setValue(self.storeValue); self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue); self.adapter.setValue(self.storeValue);
assertShowValue(); assertShowValue();
} }
}); });
} }
}); }
}, {
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { eventName: BI.Searcher.EVENT_CHANGE,
action: function (value, obj) {
if (obj instanceof BI.MultiSelectBar) { if (obj instanceof BI.MultiSelectBar) {
self._joinAll(this.getValue(), function () { self._joinAll(this.getValue(), function () {
assertShowValue(); assertShowValue();
@ -118,13 +133,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
assertShowValue(); assertShowValue();
}); });
} }
}
}]
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
this.getCounter().setValue(self.storeValue);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({ BI.createWidget({
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
@ -132,16 +144,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
width: "100%", width: "100%",
items: [{ items: [{
el: this.trigger, el: this.trigger,
height: 25 height: 30
}, {
el: div,
height: 2
}, { }, {
el: this.popup, el: this.adapter,
height: "fill" height: "fill"
}] }]
}); });
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
})
},
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
}, },
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
},
_defaultState: function () { _defaultState: function () {
this.trigger.stopEditing(); this.trigger.stopEditing();
}, },
@ -186,7 +219,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this._assertValue(res); this._assertValue(res);
o.itemsCreator({ o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA, type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey() keyword: self.trigger.getKeyword()
}, function (ob) { }, function (ob) {
var items = BI.pluck(ob.items, "value"); var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) { if (self.storeValue.type === res.type) {
@ -275,22 +308,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
_setStartValue: function (value) { _setStartValue: function (value) {
this._startValue = value; this._startValue = value;
this.popup.setStartValue(value); this.adapter.setStartValue(value);
}, },
// isAllSelected: function () { isAllSelected: function () {
// return this.popup.isAllSelected(); return this.adapter.isAllSelected();
// }, },
resize: function () { resize: function () {
this.trigger.getCounter().adjustView(); // this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView(); // this.trigger.adjustView();
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue = v || {}; this.storeValue = v || {};
this._assertValue(this.storeValue); this._assertValue(this.storeValue);
this.popup.setValue(this.storeValue); this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue); this.trigger.setValue(this.storeValue);
}, },
@ -301,7 +333,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this._count = null; this._count = null;
this._allData = null; this._allData = null;
this.popup.populate.apply(this.popup, arguments); this.adapter.populate.apply(this.adapter, arguments);
this.trigger.populate.apply(this.trigger, arguments); this.trigger.populate.apply(this.trigger, arguments);
} }
}); });

200
src/widget/multitreelist/multitreelist.js

@ -1,128 +1,94 @@
/** /**
* Created by zcf on 2016/12/20. * Created by zcf_1 on 2017/5/11.
*/ */
BI.MultiTreeList = BI.inherit(BI.Widget, { BI.MultiSelectTree = BI.inherit(BI.Widget, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.MultiTreeList.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), {
baseCls: 'bi-multi-tree-combo', baseCls: 'bi-multi-tree-combo',
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
height: 25 height: 25
}); })
}, },
_init: function () { _init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments); BI.MultiSelectTree.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.storeValue = {value: {}};
var isInit = false; this.adapter = BI.createWidget({
var want2showCounter = false; type: "bi.multi_select_tree_popup",
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () {
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () { if (self.trigger.isSearching()) {
self.trigger.getCounter().adjustView(); self.storeValue = {value: self.searcherPane.getValue()};
isInit = true; } else {
if (want2showCounter === true) { self.storeValue = {value: self.adapter.getValue()};
showCounter();
} }
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}); });
this.trigger = BI.createWidget({ this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_select_trigger", type: "bi.multi_tree_search_pane",
height: o.height, cls: "bi-border-left bi-border-right bi-border-bottom",
adapter: this.popup, keywordGetter: function () {
masker: { return self.trigger.getKeyword();
offset: this.constants.offset
},
searcher: {
type: "bi.multi_tree_searcher",
itemsCreator: o.itemsCreator
},
switcher: {
el: {
type: "bi.multi_tree_check_selected_button"
}, },
popup: { itemsCreator: function (op, callback) {
type: "bi.multi_tree_check_pane", op.keyword = self.trigger.getKeyword();
itemsCreator: o.itemsCreator o.itemsCreator(op, callback);
}
} }
}); });
this.searcherPane.setVisible(false);
this.storeValue = {value: {}}; this.trigger = BI.createWidget({
type: "bi.searcher",
var isSearching = function () { isAutoSearch: false,
return self.trigger.getSearcher().isSearching(); isAutoSync: false,
}; onSearch: function (op, callback) {
callback({
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { keyword: self.trigger.getKeyword()
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { },
self.storeValue = {value: this.getValue()}; adapter: this.adapter,
self.trigger.setValue(self.storeValue); popup: this.searcherPane,
self.popup.setValue(self.storeValue); height: 200,
masker: false,
listeners: [{
eventName: BI.Searcher.EVENT_START,
action: function () {
self._showSearcherPane();
self.storeValue = {value: self.adapter.getValue()};
self.searcherPane.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
// self.storeValue = {value: self.searcherPane.getValue()};
self.adapter.setValue(self.storeValue);
BI.nextTick(function () { BI.nextTick(function () {
self.trigger.populate(); self.adapter.populate();
self.popup.populate();
});
}); });
function showCounter() {
if (isSearching()) {
self.storeValue = {value: self.trigger.getValue()};
} else {
self.storeValue = {value: self.popup.getValue()};
} }
self.trigger.setValue(self.storeValue); }, {
eventName: BI.Searcher.EVENT_CHANGE,
action: function () {
if (self.trigger.isSearching()) {
self.storeValue = {value: self.searcherPane.getValue()};
} else {
self.storeValue = {value: self.adapter.getValue()};
} }
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
} }
if (isInit === true) { }, {
want2showCounter = null; eventName: BI.Searcher.EVENT_PAUSE,
showCounter(); action: function () {
self._showAdapter();
} }
}]
}); });
this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () {
var val = {
type: BI.Selection.Multi,
value: this.getSearcher().hasChecked() ? {1: 1} : {}
};
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
});
this.popup.on(BI.MultiStringListPopup.EVENT_CHANGE, function () {
showCounter();
var val = {
type: BI.Selection.Multi,
value: this.hasChecked() ? {1: 1} : {}
};
self.trigger.getSearcher().setState(val);
self.trigger.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeList.EVENT_CHANGE);
});
var div = BI.createWidget({
type: "bi.layout"
});
BI.createWidget({ BI.createWidget({
type: "bi.vtape", type: "bi.vtape",
element: this, element: this,
@ -130,29 +96,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
width: "100%", width: "100%",
items: [{ items: [{
el: this.trigger, el: this.trigger,
height: 25 height: 30
}, { }, {
el: div, el: this.adapter,
height: 2
}, {
el: this.popup,
height: "fill" height: "fill"
}] }]
});
BI.createWidget({
type: "bi.absolute",
element: this,
height: "100%",
width: "100%",
items: [{
el: this.searcherPane,
top: 30,
bottom: 0,
left: 0,
right: 0
}]
}) })
}, },
_defaultState: function () { _showAdapter: function () {
this.trigger.stopEditing(); this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
}, },
resize: function () { resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
}, },
setValue: function (v) { setValue: function (v) {
this.storeValue.value = v || {}; this.storeValue.value = v || {};
this.popup.setValue({ this.adapter.setValue({
value: v || {} value: v || {}
}); });
this.trigger.setValue({ this.trigger.setValue({
@ -166,8 +148,8 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
populate: function () { populate: function () {
this.trigger.populate.apply(this.trigger, arguments); this.trigger.populate.apply(this.trigger, arguments);
this.popup.populate.apply(this.popup, arguments); this.adapter.populate.apply(this.adapter, arguments);
} }
}); });
BI.MultiTreeList.EVENT_CHANGE = "MultiTreeList.EVENT_CHANGE"; BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
BI.shortcut('bi.multi_tree_list', BI.MultiTreeList); BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);

20
src/widget/multitreelist/multitreelist.popup.js

@ -1,15 +1,15 @@
/** /**
* Created by zcf on 2016/12/21. * Created by zcf on 2016/12/21.
*/ */
BI.MultiStringListPopup=BI.inherit(BI.Widget,{ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
_defaultConfig:function () { _defaultConfig: function () {
return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom", baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom",
itemsCreator: BI.emptyFn itemsCreator: BI.emptyFn
}); });
}, },
_init:function () { _init: function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments); BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
var self = this, o = this.options; var self = this, o = this.options;
this.popup = BI.createWidget({ this.popup = BI.createWidget({
type: "bi.sync_tree", type: "bi.sync_tree",
@ -18,10 +18,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
itemsCreator: o.itemsCreator itemsCreator: o.itemsCreator
}); });
this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_AFTER_INIT) self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT)
}); });
this.popup.on(BI.TreeView.EVENT_CHANGE, function () { this.popup.on(BI.TreeView.EVENT_CHANGE, function () {
self.fireEvent(BI.MultiStringListPopup.EVENT_CHANGE) self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE)
}); });
}, },
@ -43,6 +43,6 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
} }
}); });
BI.MultiStringListPopup.EVENT_AFTER_INIT="BI.MultiStringListPopup.EVENT_AFTER_INIT"; BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
BI.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE"; BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup); BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);
Loading…
Cancel
Save