Browse Source

tree

master
guy 8 years ago
parent
commit
ef8e473ac3
  1. 28
      bi/widget.js
  2. 28
      docs/widget.js
  3. 11
      src/component/treevaluechooser/abstract.treevaluechooser.js
  4. 17
      src/widget/multiselect/multiselect.combo.js

28
bi/widget.js

@ -7498,6 +7498,8 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
self.trigger.getCounter().setButtonChecked(self.storeValue);
};
this.storeValue = {};
//标记正在请求数据
this.requesting = false;
this.trigger = BI.createWidget({
type: "bi.multi_select_trigger",
@ -7636,10 +7638,16 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
self.populate();
});
});
//当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件
this.wants2Quit = false;
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
//important:关闭弹出时又可能没有退出编辑状态
self.trigger.stopEditing();
self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
if (self.requesting === true) {
self.wants2Quit = true;
} else {
self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
}
});
var triggerBtn = BI.createWidget({
@ -7692,6 +7700,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
_joinKeywords: function (keywords, callback) {
var self = this, o = this.options;
this._assertValue(this.storeValue);
this.requesting = true;
o.itemsCreator({
type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
keywords: keywords
@ -7714,6 +7723,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
_joinAll: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
this.requesting = true;
o.itemsCreator({
type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
keywords: [this.trigger.getKey()]
@ -7774,6 +7784,11 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
value: []
}
}
if (self.wants2Quit === true) {
self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
}
},
@ -15397,7 +15412,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
function search(parents, current, result, searched) {
var newParents = BI.clone(parents);
newParents.push(current);
if (self._isMatch(current, keyword)) {
if (self._isMatch(parents, current, keyword)) {
searched && searched.push(newParents);
return true;
}
@ -15426,7 +15441,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
function isSearchValueInParent(parentValues) {
for (var i = 0, len = parentValues.length; i < len; i++) {
if (self._isMatch(parentValues[i], keyword)) {
if (self._isMatch(parentValues.slice(0, parentValues.length - 1), parentValues[i], keyword)) {
return true;
}
}
@ -15552,7 +15567,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
}
function nodeSearch(deep, parentValues, current, isAllSelect, result) {
if (self._isMatch(current, keyword)) {
if (self._isMatch(parentValues, current, keyword)) {
var checked = isAllSelect || isSelected(parentValues, current);
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked];
@ -15782,8 +15797,9 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
});
},
_isMatch: function (value, keyword) {
var finded = BI.Func.getSearchResult([value], keyword);
_isMatch: function (parentValues, value, keyword) {
var node = this._getTreeNode(parentValues, value);
var finded = BI.Func.getSearchResult([node.text || node.value], keyword);
return finded.finded.length > 0 || finded.matched.length > 0;
},

28
docs/widget.js

@ -7498,6 +7498,8 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
self.trigger.getCounter().setButtonChecked(self.storeValue);
};
this.storeValue = {};
//标记正在请求数据
this.requesting = false;
this.trigger = BI.createWidget({
type: "bi.multi_select_trigger",
@ -7636,10 +7638,16 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
self.populate();
});
});
//当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件
this.wants2Quit = false;
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
//important:关闭弹出时又可能没有退出编辑状态
self.trigger.stopEditing();
self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
if (self.requesting === true) {
self.wants2Quit = true;
} else {
self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
}
});
var triggerBtn = BI.createWidget({
@ -7692,6 +7700,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
_joinKeywords: function (keywords, callback) {
var self = this, o = this.options;
this._assertValue(this.storeValue);
this.requesting = true;
o.itemsCreator({
type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
keywords: keywords
@ -7714,6 +7723,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
_joinAll: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
this.requesting = true;
o.itemsCreator({
type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
keywords: [this.trigger.getKey()]
@ -7774,6 +7784,11 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
value: []
}
}
if (self.wants2Quit === true) {
self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
}
},
@ -15397,7 +15412,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
function search(parents, current, result, searched) {
var newParents = BI.clone(parents);
newParents.push(current);
if (self._isMatch(current, keyword)) {
if (self._isMatch(parents, current, keyword)) {
searched && searched.push(newParents);
return true;
}
@ -15426,7 +15441,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
function isSearchValueInParent(parentValues) {
for (var i = 0, len = parentValues.length; i < len; i++) {
if (self._isMatch(parentValues[i], keyword)) {
if (self._isMatch(parentValues.slice(0, parentValues.length - 1), parentValues[i], keyword)) {
return true;
}
}
@ -15552,7 +15567,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
}
function nodeSearch(deep, parentValues, current, isAllSelect, result) {
if (self._isMatch(current, keyword)) {
if (self._isMatch(parentValues, current, keyword)) {
var checked = isAllSelect || isSelected(parentValues, current);
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked];
@ -15782,8 +15797,9 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
});
},
_isMatch: function (value, keyword) {
var finded = BI.Func.getSearchResult([value], keyword);
_isMatch: function (parentValues, value, keyword) {
var node = this._getTreeNode(parentValues, value);
var finded = BI.Func.getSearchResult([node.text || node.value], keyword);
return finded.finded.length > 0 || finded.matched.length > 0;
},

11
src/component/treevaluechooser/abstract.treevaluechooser.js

@ -227,7 +227,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
function search(parents, current, result, searched) {
var newParents = BI.clone(parents);
newParents.push(current);
if (self._isMatch(current, keyword)) {
if (self._isMatch(parents, current, keyword)) {
searched && searched.push(newParents);
return true;
}
@ -256,7 +256,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
function isSearchValueInParent(parentValues) {
for (var i = 0, len = parentValues.length; i < len; i++) {
if (self._isMatch(parentValues[i], keyword)) {
if (self._isMatch(parentValues.slice(0, parentValues.length - 1), parentValues[i], keyword)) {
return true;
}
}
@ -382,7 +382,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
}
function nodeSearch(deep, parentValues, current, isAllSelect, result) {
if (self._isMatch(current, keyword)) {
if (self._isMatch(parentValues, current, keyword)) {
var checked = isAllSelect || isSelected(parentValues, current);
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked];
@ -612,8 +612,9 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
});
},
_isMatch: function (value, keyword) {
var finded = BI.Func.getSearchResult([value], keyword);
_isMatch: function (parentValues, value, keyword) {
var node = this._getTreeNode(parentValues, value);
var finded = BI.Func.getSearchResult([node.text || node.value], keyword);
return finded.finded.length > 0 || finded.matched.length > 0;
},

17
src/widget/multiselect/multiselect.combo.js

@ -24,6 +24,8 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
self.trigger.getCounter().setButtonChecked(self.storeValue);
};
this.storeValue = {};
//标记正在请求数据
this.requesting = false;
this.trigger = BI.createWidget({
type: "bi.multi_select_trigger",
@ -162,10 +164,16 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
self.populate();
});
});
//当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件
this.wants2Quit = false;
this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () {
//important:关闭弹出时又可能没有退出编辑状态
self.trigger.stopEditing();
self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
if (self.requesting === true) {
self.wants2Quit = true;
} else {
self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
}
});
var triggerBtn = BI.createWidget({
@ -218,6 +226,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
_joinKeywords: function (keywords, callback) {
var self = this, o = this.options;
this._assertValue(this.storeValue);
this.requesting = true;
o.itemsCreator({
type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
keywords: keywords
@ -240,6 +249,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
_joinAll: function (res, callback) {
var self = this, o = this.options;
this._assertValue(res);
this.requesting = true;
o.itemsCreator({
type: BI.MultiSelectCombo.REQ_GET_ALL_DATA,
keywords: [this.trigger.getKey()]
@ -300,6 +310,11 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, {
value: []
}
}
if (self.wants2Quit === true) {
self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM);
self.wants2Quit = false;
}
self.requesting = false;
}
},

Loading…
Cancel
Save