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_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW";
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, {
_defaultConfig: function () {
@ -10963,33 +10963,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
height: 25
el: {}
})
},
_init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () {
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",
cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded,
// onLoaded: o.onLoaded,
el: {
height: ""
}
});
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue();
self._adjust(function () {
assertShowValue();
@ -10997,74 +10994,92 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
});
});
this.trigger = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
this.searcherPane = BI.createWidget({
type: "bi.multi_select_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keyword)) {
self.trigger.setValue(self.getValue());
}
callback.apply(self, arguments);
});
op.keyword = self.trigger.getKeyword();
this.setKeyword(op.keyword);
o.itemsCreator(op, callback);
}
});
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("");
this.getSearcher().setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
this.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue("");
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getKeyword();
self.adapter.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
if (this.hasMatched()) {
var keyword = this.getKeyword();
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.populate();
self._setStartValue("");
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);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
self.popup.populate();
self.adapter.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
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) {
self._joinAll(this.getValue(), function () {
assertShowValue();
@ -11074,13 +11089,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
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({
type: "bi.vtape",
element: this,
@ -11088,16 +11100,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
width: "100%",
items: [{
el: this.trigger,
height: 25
}, {
el: div,
height: 2
height: 30
}, {
el: this.popup,
el: this.adapter,
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 () {
this.trigger.stopEditing();
},
@ -11142,7 +11175,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this._assertValue(res);
o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey()
keyword: self.trigger.getKeyword()
}, function (ob) {
var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) {
@ -11231,22 +11264,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
_setStartValue: function (value) {
this._startValue = value;
this.popup.setStartValue(value);
this.adapter.setStartValue(value);
},
// isAllSelected: function () {
// return this.popup.isAllSelected();
// },
isAllSelected: function () {
return this.adapter.isAllSelected();
},
resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
// this.trigger.getCounter().adjustView();
// this.trigger.adjustView();
},
setValue: function (v) {
this.storeValue = v || {};
this._assertValue(this.storeValue);
this.popup.setValue(this.storeValue);
this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue);
},
@ -11257,7 +11289,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
populate: function () {
this._count = 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);
}
});
@ -12008,130 +12040,96 @@ BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
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, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
BI.MultiSelectTree = BI.inherit(BI.Widget, {
_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',
itemsCreator: BI.emptyFn,
height: 25
});
})
},
_init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments);
BI.MultiSelectTree.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {value: {}};
var isInit = false;
var want2showCounter = false;
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
this.adapter = BI.createWidget({
type: "bi.multi_select_tree_popup",
itemsCreator: o.itemsCreator
});
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () {
self.trigger.getCounter().adjustView();
isInit = true;
if (want2showCounter === true) {
showCounter();
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, 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 = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
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"
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () {
return self.trigger.getKeyword();
},
popup: {
type: "bi.multi_tree_check_pane",
itemsCreator: o.itemsCreator
}
itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword();
o.itemsCreator(op, callback);
}
});
this.searcherPane.setVisible(false);
this.storeValue = {value: {}};
var isSearching = function () {
return self.trigger.getSearcher().isSearching();
};
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback({
keyword: self.trigger.getKeyword()
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self.storeValue = {value: this.getValue()};
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
},
adapter: this.adapter,
popup: this.searcherPane,
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 () {
self.trigger.populate();
self.popup.populate();
self.adapter.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()};
}
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}, {
eventName: BI.Searcher.EVENT_PAUSE,
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({
type: "bi.vtape",
element: this,
@ -12139,29 +12137,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
width: "100%",
items: [{
el: this.trigger,
height: 25
}, {
el: div,
height: 2
height: 30
}, {
el: this.popup,
el: this.adapter,
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 () {
this.trigger.stopEditing();
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
},
resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
},
setValue: function (v) {
this.storeValue.value = v || {};
this.popup.setValue({
this.adapter.setValue({
value: v || {}
});
this.trigger.setValue({
@ -12175,22 +12189,22 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
populate: function () {
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.shortcut('bi.multi_tree_list', BI.MultiTreeList);/**
BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
* Created by zcf on 2016/12/21.
*/
BI.MultiStringListPopup=BI.inherit(BI.Widget,{
_defaultConfig:function () {
return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), {
BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom",
itemsCreator: BI.emptyFn
});
},
_init:function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments);
_init: function () {
BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.popup = BI.createWidget({
type: "bi.sync_tree",
@ -12199,10 +12213,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
itemsCreator: o.itemsCreator
});
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 () {
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.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE";
BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);//小于号的值为:0,小于等于号的值为:1
BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);//小于号的值为:0,小于等于号的值为:1
//closeMIn:最小值的符号,closeMax:最大值的符号
/**
* 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_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW";
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, {
_defaultConfig: function () {
@ -10963,33 +10963,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
height: 25
el: {}
})
},
_init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () {
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",
cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded,
// onLoaded: o.onLoaded,
el: {
height: ""
}
});
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue();
self._adjust(function () {
assertShowValue();
@ -10997,74 +10994,92 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
});
});
this.trigger = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
this.searcherPane = BI.createWidget({
type: "bi.multi_select_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keyword)) {
self.trigger.setValue(self.getValue());
}
callback.apply(self, arguments);
});
op.keyword = self.trigger.getKeyword();
this.setKeyword(op.keyword);
o.itemsCreator(op, callback);
}
});
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("");
this.getSearcher().setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
this.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue("");
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getKeyword();
self.adapter.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
if (this.hasMatched()) {
var keyword = this.getKeyword();
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.populate();
self._setStartValue("");
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);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
self.popup.populate();
self.adapter.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
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) {
self._joinAll(this.getValue(), function () {
assertShowValue();
@ -11074,13 +11089,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
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({
type: "bi.vtape",
element: this,
@ -11088,16 +11100,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
width: "100%",
items: [{
el: this.trigger,
height: 25
}, {
el: div,
height: 2
height: 30
}, {
el: this.popup,
el: this.adapter,
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 () {
this.trigger.stopEditing();
},
@ -11142,7 +11175,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this._assertValue(res);
o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey()
keyword: self.trigger.getKeyword()
}, function (ob) {
var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) {
@ -11231,22 +11264,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
_setStartValue: function (value) {
this._startValue = value;
this.popup.setStartValue(value);
this.adapter.setStartValue(value);
},
// isAllSelected: function () {
// return this.popup.isAllSelected();
// },
isAllSelected: function () {
return this.adapter.isAllSelected();
},
resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
// this.trigger.getCounter().adjustView();
// this.trigger.adjustView();
},
setValue: function (v) {
this.storeValue = v || {};
this._assertValue(this.storeValue);
this.popup.setValue(this.storeValue);
this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue);
},
@ -11257,7 +11289,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
populate: function () {
this._count = 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);
}
});
@ -12008,130 +12040,96 @@ BI.MultiTreeSearcher.EVENT_START = "EVENT_START";
BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP";
BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE";
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, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
BI.MultiSelectTree = BI.inherit(BI.Widget, {
_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',
itemsCreator: BI.emptyFn,
height: 25
});
})
},
_init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments);
BI.MultiSelectTree.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {value: {}};
var isInit = false;
var want2showCounter = false;
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
this.adapter = BI.createWidget({
type: "bi.multi_select_tree_popup",
itemsCreator: o.itemsCreator
});
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () {
self.trigger.getCounter().adjustView();
isInit = true;
if (want2showCounter === true) {
showCounter();
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, 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 = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
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"
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () {
return self.trigger.getKeyword();
},
popup: {
type: "bi.multi_tree_check_pane",
itemsCreator: o.itemsCreator
}
itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword();
o.itemsCreator(op, callback);
}
});
this.searcherPane.setVisible(false);
this.storeValue = {value: {}};
var isSearching = function () {
return self.trigger.getSearcher().isSearching();
};
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback({
keyword: self.trigger.getKeyword()
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self.storeValue = {value: this.getValue()};
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
},
adapter: this.adapter,
popup: this.searcherPane,
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 () {
self.trigger.populate();
self.popup.populate();
self.adapter.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()};
}
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}, {
eventName: BI.Searcher.EVENT_PAUSE,
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({
type: "bi.vtape",
element: this,
@ -12139,29 +12137,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
width: "100%",
items: [{
el: this.trigger,
height: 25
}, {
el: div,
height: 2
height: 30
}, {
el: this.popup,
el: this.adapter,
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 () {
this.trigger.stopEditing();
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
},
resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
},
setValue: function (v) {
this.storeValue.value = v || {};
this.popup.setValue({
this.adapter.setValue({
value: v || {}
});
this.trigger.setValue({
@ -12175,22 +12189,22 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
populate: function () {
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.shortcut('bi.multi_tree_list', BI.MultiTreeList);/**
BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/**
* Created by zcf on 2016/12/21.
*/
BI.MultiStringListPopup=BI.inherit(BI.Widget,{
_defaultConfig:function () {
return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), {
BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom",
itemsCreator: BI.emptyFn
});
},
_init:function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments);
_init: function () {
BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.popup = BI.createWidget({
type: "bi.sync_tree",
@ -12199,10 +12213,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
itemsCreator: o.itemsCreator
});
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 () {
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.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE";
BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);//小于号的值为:0,小于等于号的值为:1
BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);//小于号的值为:0,小于等于号的值为:1
//closeMIn:最小值的符号,closeMax:最大值的符号
/**
* 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, {
_defaultConfig: function () {
@ -7,33 +7,30 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
baseCls: 'bi-multi-string-list',
itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
height: 25
el: {}
})
},
_init: function () {
BI.MultiStringList.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {};
var assertShowValue = function () {
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",
cls: "popup-multi-string-list bi-border-left bi-border-right bi-border-bottom",
itemsCreator: o.itemsCreator,
valueFormatter: o.valueFormatter,
onLoaded: o.onLoaded,
// onLoaded: o.onLoaded,
el: {
height: ""
}
});
this.popup.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () {
self.storeValue = this.getValue();
self._adjust(function () {
assertShowValue();
@ -41,74 +38,92 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
});
});
this.trigger = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
adapter: this.popup,
masker: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
this.searcherPane = BI.createWidget({
type: "bi.multi_select_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter,
keywordGetter: function () {
return self.trigger.getKeyword();
},
itemsCreator: function (op, callback) {
o.itemsCreator(op, function (res) {
if (op.times === 1 && BI.isNotNull(op.keyword)) {
self.trigger.setValue(self.getValue());
}
callback.apply(self, arguments);
});
op.keyword = self.trigger.getKeyword();
this.setKeyword(op.keyword);
o.itemsCreator(op, callback);
}
});
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("");
this.getSearcher().setValue(self.storeValue);
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
this.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_STOP,
action: function () {
self._showAdapter();
self._setStartValue("");
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () {
if (this.getSearcher().hasMatched()) {
var keyword = this.getSearcher().getKeyword();
self.adapter.setValue(self.storeValue);
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
action: function () {
if (this.hasMatched()) {
var keyword = this.getKeyword();
self._join({
type: BI.Selection.Multi,
value: [keyword]
}, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
self.populate();
self._setStartValue("");
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);
keywords = BI.initial(keywords || []);
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
self.popup.populate();
self.adapter.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
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) {
self._joinAll(this.getValue(), function () {
assertShowValue();
@ -118,13 +133,10 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
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({
type: "bi.vtape",
element: this,
@ -132,16 +144,37 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
width: "100%",
items: [{
el: this.trigger,
height: 25
}, {
el: div,
height: 2
height: 30
}, {
el: this.popup,
el: this.adapter,
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 () {
this.trigger.stopEditing();
},
@ -186,7 +219,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
this._assertValue(res);
o.itemsCreator({
type: BI.MultiStringList.REQ_GET_ALL_DATA,
keyword: this.trigger.getKey()
keyword: self.trigger.getKeyword()
}, function (ob) {
var items = BI.pluck(ob.items, "value");
if (self.storeValue.type === res.type) {
@ -275,22 +308,21 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
_setStartValue: function (value) {
this._startValue = value;
this.popup.setStartValue(value);
this.adapter.setStartValue(value);
},
// isAllSelected: function () {
// return this.popup.isAllSelected();
// },
isAllSelected: function () {
return this.adapter.isAllSelected();
},
resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
// this.trigger.getCounter().adjustView();
// this.trigger.adjustView();
},
setValue: function (v) {
this.storeValue = v || {};
this._assertValue(this.storeValue);
this.popup.setValue(this.storeValue);
this.adapter.setValue(this.storeValue);
this.trigger.setValue(this.storeValue);
},
@ -301,7 +333,7 @@ BI.MultiStringList = BI.inherit(BI.Widget, {
populate: function () {
this._count = 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);
}
});

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, {
constants: {
offset: {
left: 1,
top: 0,
right: 2,
bottom: 1
}
},
BI.MultiSelectTree = BI.inherit(BI.Widget, {
_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',
itemsCreator: BI.emptyFn,
height: 25
});
})
},
_init: function () {
BI.MultiTreeList.superclass._init.apply(this, arguments);
BI.MultiSelectTree.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.storeValue = {value: {}};
var isInit = false;
var want2showCounter = false;
this.popup = BI.createWidget({
type: "bi.multi_tree_list_popup",
this.adapter = BI.createWidget({
type: "bi.multi_select_tree_popup",
itemsCreator: o.itemsCreator
});
this.popup.on(BI.MultiStringListPopup.EVENT_AFTER_INIT, function () {
self.trigger.getCounter().adjustView();
isInit = true;
if (want2showCounter === true) {
showCounter();
this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, 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 = BI.createWidget({
type: "bi.multi_select_trigger",
height: o.height,
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"
this.searcherPane = BI.createWidget({//搜索中的时候用的是parttree,同adapter中的synctree不一样
type: "bi.multi_tree_search_pane",
cls: "bi-border-left bi-border-right bi-border-bottom",
keywordGetter: function () {
return self.trigger.getKeyword();
},
popup: {
type: "bi.multi_tree_check_pane",
itemsCreator: o.itemsCreator
}
itemsCreator: function (op, callback) {
op.keyword = self.trigger.getKeyword();
o.itemsCreator(op, callback);
}
});
this.searcherPane.setVisible(false);
this.storeValue = {value: {}};
var isSearching = function () {
return self.trigger.getSearcher().isSearching();
};
this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () {
self.storeValue = {value: self.popup.getValue()};
this.setValue(self.storeValue);
this.trigger = BI.createWidget({
type: "bi.searcher",
isAutoSearch: false,
isAutoSync: false,
onSearch: function (op, callback) {
callback({
keyword: self.trigger.getKeyword()
});
this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () {
self.storeValue = {value: this.getValue()};
self.trigger.setValue(self.storeValue);
self.popup.setValue(self.storeValue);
},
adapter: this.adapter,
popup: this.searcherPane,
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 () {
self.trigger.populate();
self.popup.populate();
});
self.adapter.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()};
}
this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () {
if (want2showCounter === false) {
want2showCounter = true;
self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE);
}
if (isInit === true) {
want2showCounter = null;
showCounter();
}, {
eventName: BI.Searcher.EVENT_PAUSE,
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({
type: "bi.vtape",
element: this,
@ -130,29 +96,45 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
width: "100%",
items: [{
el: this.trigger,
height: 25
height: 30
}, {
el: div,
height: 2
}, {
el: this.popup,
el: this.adapter,
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 () {
this.trigger.stopEditing();
_showAdapter: function () {
this.adapter.setVisible(true);
this.searcherPane.setVisible(false);
},
_showSearcherPane: function () {
this.searcherPane.setVisible(true);
this.adapter.setVisible(false);
},
resize: function () {
this.trigger.getCounter().adjustView();
this.trigger.getSearcher().adjustView();
},
setValue: function (v) {
this.storeValue.value = v || {};
this.popup.setValue({
this.adapter.setValue({
value: v || {}
});
this.trigger.setValue({
@ -166,8 +148,8 @@ BI.MultiTreeList = BI.inherit(BI.Widget, {
populate: function () {
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.shortcut('bi.multi_tree_list', BI.MultiTreeList);
BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE";
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.
*/
BI.MultiStringListPopup=BI.inherit(BI.Widget,{
_defaultConfig:function () {
return BI.extend(BI.MultiStringListPopup.superclass._defaultConfig.apply(this, arguments), {
BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
_defaultConfig: function () {
return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-tree-list-popup bi-border-left bi-border-right bi-border-bottom",
itemsCreator: BI.emptyFn
});
},
_init:function () {
BI.MultiStringListPopup.superclass._init.apply(this, arguments);
_init: function () {
BI.MultiSelectTreePopup.superclass._init.apply(this, arguments);
var self = this, o = this.options;
this.popup = BI.createWidget({
type: "bi.sync_tree",
@ -18,10 +18,10 @@ BI.MultiStringListPopup=BI.inherit(BI.Widget,{
itemsCreator: o.itemsCreator
});
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 () {
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.MultiStringListPopup.EVENT_CHANGE="BI.MultiStringListPopup.EVENT_CHANGE";
BI.shortcut("bi.multi_tree_list_popup",BI.MultiStringListPopup);
BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT";
BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE";
BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);
Loading…
Cancel
Save