Guyi 5 years ago
parent
commit
1128c0458f
  1. 9
      README.md
  2. 2
      changelog.md
  3. 520
      dist/2.0/fineui.ie.js
  4. 28
      dist/2.0/fineui.ie.min.js
  5. 520
      dist/2.0/fineui.js
  6. 2
      dist/2.0/fineui.min.css
  7. 28
      dist/2.0/fineui.min.js
  8. 520
      dist/bundle.ie.js
  9. 28
      dist/bundle.ie.min.js
  10. 520
      dist/bundle.js
  11. 2
      dist/bundle.min.css
  12. 28
      dist/bundle.min.js
  13. 19
      dist/case.js
  14. 12
      dist/core.js
  15. 520
      dist/fineui.ie.js
  16. 26
      dist/fineui.ie.min.js
  17. 520
      dist/fineui.js
  18. 2
      dist/fineui.min.css
  19. 26
      dist/fineui.min.js
  20. 512
      dist/fineui_without_jquery_polyfill.js
  21. 4
      dist/utils.js
  22. 2
      dist/utils.min.js
  23. 489
      dist/widget.js
  24. 2
      lodash.md
  25. 6
      src/case/trigger/trigger.icon.js
  26. 6
      src/component/treevaluechooser/abstract.treevaluechooser.js
  27. 91
      src/component/valuechooser/combo.valuechooser.insert.js
  28. 2
      src/core/base.js
  29. 2
      src/core/lodash.js
  30. 8
      src/core/platform/web/dom.js
  31. 2
      src/widget/downlist/combo.downlist.js
  32. 13
      src/widget/multilayerselecttree/multilayerselecttree.combo.js
  33. 92
      src/widget/multilayerselecttree/multilayerselecttree.insert.search.pane.js
  34. 90
      src/widget/multilayerselecttree/multilayerselecttree.trigger.js
  35. 13
      src/widget/multilayersingletree/multilayersingletree.combo.js
  36. 92
      src/widget/multilayersingletree/multilayersingletree.insert.search.pane.js
  37. 83
      src/widget/multilayersingletree/multilayersingletree.trigger.js
  38. 2
      src/widget/multitree/multi.tree.combo.js
  39. 2
      src/widget/multitree/multi.tree.insert.combo.js
  40. 2
      src/widget/multitree/multi.tree.list.combo.js
  41. 3
      src/widget/numbereditor/number.editor.js
  42. 4
      src/widget/selecttree/selecttree.expander.js

9
README.md

@ -8,14 +8,7 @@ For more details, see the website [http://www.fanruan.com](http://www.fanruan.co
Documentation
=============
### 教程
http://fanruan.design/fineui-doc/index.html
### Demo
在线Demo地址: [http://fanruan.design/fineui-demo/index.html](http://fanruan.design/fineui-demo/index.html)
http://fanruan.design/doc.html?post=0169cf558d
License
============

2
changelog.md

@ -1,5 +1,7 @@
# 更新日志
2.0(2019-08)
- 单选树可展示并选中不存在的值
- 树类型下拉新增可搜索实际值的配置
- 可编辑的combo新增水印配置
- 单选下拉树同步状态下内置搜索

520
dist/2.0/fineui.ie.js vendored

@ -22,7 +22,7 @@ if(_global.BI.prepares == null) {
}/**
* @license
* Lodash (Custom Build) <https://lodash.com/>
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy"`
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy"`
* Copyright JS Foundation and other contributors <https://js.foundation/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@ -10538,7 +10538,7 @@ if (!_global.BI) {
// 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight"], function (name) {
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) {
BI[name] = _apply(name);
});
_.each(["findIndex", "findLastIndex"], function (name) {
@ -21871,14 +21871,16 @@ BI.prepares.push(function () {
var canvas = document.createElement("canvas");
var ratio = 2;
BI.Widget._renderEngine.createElement("body").append(canvas);
var w = BI.DOM.getTextSizeWidth(param, 12) + 4;
var ctx = canvas.getContext("2d");
ctx.font = "12px Georgia";
var w = ctx.measureText(param).width + 4;
canvas.width = w * ratio;
canvas.height = 16 * ratio;
var ctx = canvas.getContext("2d");
// ctx.fillStyle = "#EAF2FD";
ctx.font = 12 * ratio + "px Georgia";
ctx.fillStyle = fillStyle || "#3685f2";
ctx.textBaseline = "middle";
// ctx.fillStyle = "#EAF2FD";
ctx.fillText(param, 2 * ratio, 9 * ratio);
BI.Widget._renderEngine.createElement(canvas).destroy();
var backColor = backgroundColor || "rgba(54, 133, 242, 0.1)";
@ -52478,7 +52480,7 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, {
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, this.text);
BI.createWidget(BI.extend({
@ -52657,16 +52659,17 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, {
});
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, {
width: 24,
width: 16,
el: icon
}, this.text);
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items
items: items,
rgap: 5
}))));
},
@ -52895,7 +52898,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.count(0, o.layer, function () {
items.push({
type: "bi.layout",
width: 24,
width: 15,
height: o.height
});
});
@ -52903,7 +52906,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.createWidget({
type: "bi.td",
element: this,
columnSize: BI.makeArray(o.layer, 24),
columnSize: BI.makeArray(o.layer, 15),
items: [items]
});
},
@ -61475,7 +61478,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
return BI.extend(BI.IconTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-icon-trigger",
baseCls: "bi-icon-trigger",
extraCls: "pull-down-font",
el: {},
height: 24
});
@ -61487,7 +61491,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
type: "bi.trigger_icon_button",
element: this,
width: o.width,
height: o.height
height: o.height,
extraCls: o.extraCls
});
}
});
@ -63634,7 +63639,7 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "",
extraCls: o.iconCls,
width: o.width,
height: o.height
}),
@ -68588,7 +68593,9 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -68668,6 +68675,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_select_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-select-tree-trigger",
ref: function (_ref) {
@ -68705,6 +68714,13 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -68757,6 +68773,97 @@ BI.MultiLayerSelectTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSelectTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSelectTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSelectTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-select-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_insert_search_pane", BI.MultiLayerSelectTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSelectLevelTree
@ -69025,7 +69132,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -69066,22 +69173,31 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_select_tree_popup",
itemsCreator: function (op, callback) {
type: o.allowInsertValue ? "bi.multilayer_select_tree_insert_search_pane" : "bi.multilayer_select_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
},
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -69123,32 +69239,70 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
var o = this.options;
return o.valueFormatter(v) || o.text;
if(o.itemsCreator === BI.emptyFn) {
var result = BI.find(o.items, function (i, item) {
return item.value === v;
});
return BI.isNotNull(result) ? result.text : o.text;
}
return o.valueFormatter(v);
},
stopEditing: function () {
@ -69178,6 +69332,7 @@ BI.MultiLayerSelectTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger);/**
* 加号表示的组节点
*
@ -69603,7 +69758,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -69683,6 +69840,8 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_single_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-single-tree-trigger",
ref: function (_ref) {
@ -69720,6 +69879,13 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -69772,6 +69938,97 @@ BI.MultiLayerSingleTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSingleTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSingleTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSingleTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-single-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_insert_search_pane", BI.MultiLayerSingleTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSingleLevelTree
@ -70031,7 +70288,8 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
return v;
},
itemsCreator: BI.emptyFn,
watermark: BI.i18nText("BI-Basic_Search")
watermark: BI.i18nText("BI-Basic_Search"),
allowSearchValue: false
};
},
@ -70039,7 +70297,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -70080,7 +70338,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_single_tree_popup",
type: o.allowInsertValue ? "bi.multilayer_single_tree_insert_search_pane" : "bi.multilayer_single_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
@ -70088,14 +70346,23 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -70137,27 +70404,59 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
@ -70198,6 +70497,7 @@ BI.MultiLayerSingleTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger);/**
* 加号表示的组节点
*
@ -75776,7 +76076,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM);
});
@ -76079,7 +76379,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -76395,7 +76695,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -79793,6 +80093,10 @@ BI.SelectTreeExpander = BI.inherit(BI.Widget, {
});
},
getAllLeaves: function () {
return this.expander.getAllLeaves();
},
setValue: function (v) {
if (BI.contains(v, this.trigger.getValue())) {
this.trigger.setSelected(true);
@ -87826,11 +88130,17 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
},
_isMatch: function (parentValues, value, keyword) {
var o = this.options;
var node = this._getTreeNode(parentValues, value);
if (!node) {
return false;
}
var find = BI.Func.getSearchResult([node.text || node.value], keyword);
if(o.allowSearchValue && node.value) {
var valueFind = BI.Func.getSearchResult([node.value], keyword);
return valueFind.find.length > 0 || valueFind.match.length > 0 ||
find.find.length > 0 || find.match.length > 0;
}
return find.find.length > 0 || find.match.length > 0;
},
@ -88581,6 +88891,96 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, {
}
}
});/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*/
BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-insert-combo",
width: 200,
height: 24,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserInsertCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: "bi.multi_select_insert_combo",
element: this,
text: o.text,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height,
listeners: [{
eventName: BI.MultiSelectCombo.EVENT_FOCUS,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_FOCUS);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_BLUR,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_BLUR);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_STOP,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_STOP);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CONFIRM);
}
}]
});
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var val = this.combo.getValue() || {};
return {
type: val.type,
value: val.value
};
},
populate: function (items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
this.items = items;
this.combo.populate.apply(this, arguments);
}
});
BI.ValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
BI.ValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.ValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
BI.ValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.ValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.value_chooser_insert_combo", BI.ValueChooserInsertCombo);/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*

28
dist/2.0/fineui.ie.min.js vendored

File diff suppressed because one or more lines are too long

520
dist/2.0/fineui.js vendored

@ -22,7 +22,7 @@ if(_global.BI.prepares == null) {
}/**
* @license
* Lodash (Custom Build) <https://lodash.com/>
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy"`
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy"`
* Copyright JS Foundation and other contributors <https://js.foundation/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@ -10538,7 +10538,7 @@ if (!_global.BI) {
// 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight"], function (name) {
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) {
BI[name] = _apply(name);
});
_.each(["findIndex", "findLastIndex"], function (name) {
@ -21871,14 +21871,16 @@ BI.prepares.push(function () {
var canvas = document.createElement("canvas");
var ratio = 2;
BI.Widget._renderEngine.createElement("body").append(canvas);
var w = BI.DOM.getTextSizeWidth(param, 12) + 4;
var ctx = canvas.getContext("2d");
ctx.font = "12px Georgia";
var w = ctx.measureText(param).width + 4;
canvas.width = w * ratio;
canvas.height = 16 * ratio;
var ctx = canvas.getContext("2d");
// ctx.fillStyle = "#EAF2FD";
ctx.font = 12 * ratio + "px Georgia";
ctx.fillStyle = fillStyle || "#3685f2";
ctx.textBaseline = "middle";
// ctx.fillStyle = "#EAF2FD";
ctx.fillText(param, 2 * ratio, 9 * ratio);
BI.Widget._renderEngine.createElement(canvas).destroy();
var backColor = backgroundColor || "rgba(54, 133, 242, 0.1)";
@ -52882,7 +52884,7 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, {
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, this.text);
BI.createWidget(BI.extend({
@ -53061,16 +53063,17 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, {
});
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, {
width: 24,
width: 16,
el: icon
}, this.text);
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items
items: items,
rgap: 5
}))));
},
@ -53299,7 +53302,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.count(0, o.layer, function () {
items.push({
type: "bi.layout",
width: 24,
width: 15,
height: o.height
});
});
@ -53307,7 +53310,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.createWidget({
type: "bi.td",
element: this,
columnSize: BI.makeArray(o.layer, 24),
columnSize: BI.makeArray(o.layer, 15),
items: [items]
});
},
@ -61879,7 +61882,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
return BI.extend(BI.IconTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-icon-trigger",
baseCls: "bi-icon-trigger",
extraCls: "pull-down-font",
el: {},
height: 24
});
@ -61891,7 +61895,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
type: "bi.trigger_icon_button",
element: this,
width: o.width,
height: o.height
height: o.height,
extraCls: o.extraCls
});
}
});
@ -64038,7 +64043,7 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "",
extraCls: o.iconCls,
width: o.width,
height: o.height
}),
@ -68992,7 +68997,9 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -69072,6 +69079,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_select_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-select-tree-trigger",
ref: function (_ref) {
@ -69109,6 +69118,13 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -69161,6 +69177,97 @@ BI.MultiLayerSelectTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSelectTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSelectTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSelectTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-select-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_insert_search_pane", BI.MultiLayerSelectTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSelectLevelTree
@ -69429,7 +69536,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -69470,22 +69577,31 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_select_tree_popup",
itemsCreator: function (op, callback) {
type: o.allowInsertValue ? "bi.multilayer_select_tree_insert_search_pane" : "bi.multilayer_select_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
},
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -69527,32 +69643,70 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
var o = this.options;
return o.valueFormatter(v) || o.text;
if(o.itemsCreator === BI.emptyFn) {
var result = BI.find(o.items, function (i, item) {
return item.value === v;
});
return BI.isNotNull(result) ? result.text : o.text;
}
return o.valueFormatter(v);
},
stopEditing: function () {
@ -69582,6 +69736,7 @@ BI.MultiLayerSelectTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger);/**
* 加号表示的组节点
*
@ -70007,7 +70162,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -70087,6 +70244,8 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_single_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-single-tree-trigger",
ref: function (_ref) {
@ -70124,6 +70283,13 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -70176,6 +70342,97 @@ BI.MultiLayerSingleTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSingleTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSingleTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSingleTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-single-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_insert_search_pane", BI.MultiLayerSingleTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSingleLevelTree
@ -70435,7 +70692,8 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
return v;
},
itemsCreator: BI.emptyFn,
watermark: BI.i18nText("BI-Basic_Search")
watermark: BI.i18nText("BI-Basic_Search"),
allowSearchValue: false
};
},
@ -70443,7 +70701,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -70484,7 +70742,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_single_tree_popup",
type: o.allowInsertValue ? "bi.multilayer_single_tree_insert_search_pane" : "bi.multilayer_single_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
@ -70492,14 +70750,23 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -70541,27 +70808,59 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
@ -70602,6 +70901,7 @@ BI.MultiLayerSingleTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger);/**
* 加号表示的组节点
*
@ -76180,7 +76480,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM);
});
@ -76483,7 +76783,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -76799,7 +77099,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -80197,6 +80497,10 @@ BI.SelectTreeExpander = BI.inherit(BI.Widget, {
});
},
getAllLeaves: function () {
return this.expander.getAllLeaves();
},
setValue: function (v) {
if (BI.contains(v, this.trigger.getValue())) {
this.trigger.setSelected(true);
@ -88230,11 +88534,17 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
},
_isMatch: function (parentValues, value, keyword) {
var o = this.options;
var node = this._getTreeNode(parentValues, value);
if (!node) {
return false;
}
var find = BI.Func.getSearchResult([node.text || node.value], keyword);
if(o.allowSearchValue && node.value) {
var valueFind = BI.Func.getSearchResult([node.value], keyword);
return valueFind.find.length > 0 || valueFind.match.length > 0 ||
find.find.length > 0 || find.match.length > 0;
}
return find.find.length > 0 || find.match.length > 0;
},
@ -88985,6 +89295,96 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, {
}
}
});/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*/
BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-insert-combo",
width: 200,
height: 24,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserInsertCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: "bi.multi_select_insert_combo",
element: this,
text: o.text,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height,
listeners: [{
eventName: BI.MultiSelectCombo.EVENT_FOCUS,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_FOCUS);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_BLUR,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_BLUR);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_STOP,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_STOP);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CONFIRM);
}
}]
});
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var val = this.combo.getValue() || {};
return {
type: val.type,
value: val.value
};
},
populate: function (items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
this.items = items;
this.combo.populate.apply(this, arguments);
}
});
BI.ValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
BI.ValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.ValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
BI.ValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.ValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.value_chooser_insert_combo", BI.ValueChooserInsertCombo);/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*

2
dist/2.0/fineui.min.css vendored

File diff suppressed because one or more lines are too long

28
dist/2.0/fineui.min.js vendored

File diff suppressed because one or more lines are too long

520
dist/bundle.ie.js vendored

@ -22,7 +22,7 @@ if(_global.BI.prepares == null) {
}/**
* @license
* Lodash (Custom Build) <https://lodash.com/>
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy"`
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy"`
* Copyright JS Foundation and other contributors <https://js.foundation/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@ -10538,7 +10538,7 @@ if (!_global.BI) {
// 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight"], function (name) {
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) {
BI[name] = _apply(name);
});
_.each(["findIndex", "findLastIndex"], function (name) {
@ -21871,14 +21871,16 @@ BI.prepares.push(function () {
var canvas = document.createElement("canvas");
var ratio = 2;
BI.Widget._renderEngine.createElement("body").append(canvas);
var w = BI.DOM.getTextSizeWidth(param, 12) + 4;
var ctx = canvas.getContext("2d");
ctx.font = "12px Georgia";
var w = ctx.measureText(param).width + 4;
canvas.width = w * ratio;
canvas.height = 16 * ratio;
var ctx = canvas.getContext("2d");
// ctx.fillStyle = "#EAF2FD";
ctx.font = 12 * ratio + "px Georgia";
ctx.fillStyle = fillStyle || "#3685f2";
ctx.textBaseline = "middle";
// ctx.fillStyle = "#EAF2FD";
ctx.fillText(param, 2 * ratio, 9 * ratio);
BI.Widget._renderEngine.createElement(canvas).destroy();
var backColor = backgroundColor || "rgba(54, 133, 242, 0.1)";
@ -52478,7 +52480,7 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, {
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, this.text);
BI.createWidget(BI.extend({
@ -52657,16 +52659,17 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, {
});
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, {
width: 24,
width: 16,
el: icon
}, this.text);
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items
items: items,
rgap: 5
}))));
},
@ -52895,7 +52898,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.count(0, o.layer, function () {
items.push({
type: "bi.layout",
width: 24,
width: 15,
height: o.height
});
});
@ -52903,7 +52906,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.createWidget({
type: "bi.td",
element: this,
columnSize: BI.makeArray(o.layer, 24),
columnSize: BI.makeArray(o.layer, 15),
items: [items]
});
},
@ -61475,7 +61478,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
return BI.extend(BI.IconTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-icon-trigger",
baseCls: "bi-icon-trigger",
extraCls: "pull-down-font",
el: {},
height: 24
});
@ -61487,7 +61491,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
type: "bi.trigger_icon_button",
element: this,
width: o.width,
height: o.height
height: o.height,
extraCls: o.extraCls
});
}
});
@ -63634,7 +63639,7 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "",
extraCls: o.iconCls,
width: o.width,
height: o.height
}),
@ -68588,7 +68593,9 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -68668,6 +68675,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_select_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-select-tree-trigger",
ref: function (_ref) {
@ -68705,6 +68714,13 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -68757,6 +68773,97 @@ BI.MultiLayerSelectTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSelectTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSelectTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSelectTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-select-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_insert_search_pane", BI.MultiLayerSelectTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSelectLevelTree
@ -69025,7 +69132,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -69066,22 +69173,31 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_select_tree_popup",
itemsCreator: function (op, callback) {
type: o.allowInsertValue ? "bi.multilayer_select_tree_insert_search_pane" : "bi.multilayer_select_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
},
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -69123,32 +69239,70 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
var o = this.options;
return o.valueFormatter(v) || o.text;
if(o.itemsCreator === BI.emptyFn) {
var result = BI.find(o.items, function (i, item) {
return item.value === v;
});
return BI.isNotNull(result) ? result.text : o.text;
}
return o.valueFormatter(v);
},
stopEditing: function () {
@ -69178,6 +69332,7 @@ BI.MultiLayerSelectTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger);/**
* 加号表示的组节点
*
@ -69603,7 +69758,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -69683,6 +69840,8 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_single_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-single-tree-trigger",
ref: function (_ref) {
@ -69720,6 +69879,13 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -69772,6 +69938,97 @@ BI.MultiLayerSingleTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSingleTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSingleTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSingleTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-single-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_insert_search_pane", BI.MultiLayerSingleTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSingleLevelTree
@ -70031,7 +70288,8 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
return v;
},
itemsCreator: BI.emptyFn,
watermark: BI.i18nText("BI-Basic_Search")
watermark: BI.i18nText("BI-Basic_Search"),
allowSearchValue: false
};
},
@ -70039,7 +70297,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -70080,7 +70338,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_single_tree_popup",
type: o.allowInsertValue ? "bi.multilayer_single_tree_insert_search_pane" : "bi.multilayer_single_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
@ -70088,14 +70346,23 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -70137,27 +70404,59 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
@ -70198,6 +70497,7 @@ BI.MultiLayerSingleTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger);/**
* 加号表示的组节点
*
@ -75776,7 +76076,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM);
});
@ -76079,7 +76379,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -76395,7 +76695,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -79793,6 +80093,10 @@ BI.SelectTreeExpander = BI.inherit(BI.Widget, {
});
},
getAllLeaves: function () {
return this.expander.getAllLeaves();
},
setValue: function (v) {
if (BI.contains(v, this.trigger.getValue())) {
this.trigger.setSelected(true);
@ -87826,11 +88130,17 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
},
_isMatch: function (parentValues, value, keyword) {
var o = this.options;
var node = this._getTreeNode(parentValues, value);
if (!node) {
return false;
}
var find = BI.Func.getSearchResult([node.text || node.value], keyword);
if(o.allowSearchValue && node.value) {
var valueFind = BI.Func.getSearchResult([node.value], keyword);
return valueFind.find.length > 0 || valueFind.match.length > 0 ||
find.find.length > 0 || find.match.length > 0;
}
return find.find.length > 0 || find.match.length > 0;
},
@ -88581,6 +88891,96 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, {
}
}
});/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*/
BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-insert-combo",
width: 200,
height: 24,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserInsertCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: "bi.multi_select_insert_combo",
element: this,
text: o.text,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height,
listeners: [{
eventName: BI.MultiSelectCombo.EVENT_FOCUS,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_FOCUS);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_BLUR,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_BLUR);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_STOP,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_STOP);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CONFIRM);
}
}]
});
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var val = this.combo.getValue() || {};
return {
type: val.type,
value: val.value
};
},
populate: function (items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
this.items = items;
this.combo.populate.apply(this, arguments);
}
});
BI.ValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
BI.ValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.ValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
BI.ValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.ValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.value_chooser_insert_combo", BI.ValueChooserInsertCombo);/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*

28
dist/bundle.ie.min.js vendored

File diff suppressed because one or more lines are too long

520
dist/bundle.js vendored

@ -22,7 +22,7 @@ if(_global.BI.prepares == null) {
}/**
* @license
* Lodash (Custom Build) <https://lodash.com/>
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy"`
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy"`
* Copyright JS Foundation and other contributors <https://js.foundation/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@ -10538,7 +10538,7 @@ if (!_global.BI) {
// 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight"], function (name) {
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) {
BI[name] = _apply(name);
});
_.each(["findIndex", "findLastIndex"], function (name) {
@ -21871,14 +21871,16 @@ BI.prepares.push(function () {
var canvas = document.createElement("canvas");
var ratio = 2;
BI.Widget._renderEngine.createElement("body").append(canvas);
var w = BI.DOM.getTextSizeWidth(param, 12) + 4;
var ctx = canvas.getContext("2d");
ctx.font = "12px Georgia";
var w = ctx.measureText(param).width + 4;
canvas.width = w * ratio;
canvas.height = 16 * ratio;
var ctx = canvas.getContext("2d");
// ctx.fillStyle = "#EAF2FD";
ctx.font = 12 * ratio + "px Georgia";
ctx.fillStyle = fillStyle || "#3685f2";
ctx.textBaseline = "middle";
// ctx.fillStyle = "#EAF2FD";
ctx.fillText(param, 2 * ratio, 9 * ratio);
BI.Widget._renderEngine.createElement(canvas).destroy();
var backColor = backgroundColor || "rgba(54, 133, 242, 0.1)";
@ -52882,7 +52884,7 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, {
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, this.text);
BI.createWidget(BI.extend({
@ -53061,16 +53063,17 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, {
});
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, {
width: 24,
width: 16,
el: icon
}, this.text);
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items
items: items,
rgap: 5
}))));
},
@ -53299,7 +53302,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.count(0, o.layer, function () {
items.push({
type: "bi.layout",
width: 24,
width: 15,
height: o.height
});
});
@ -53307,7 +53310,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.createWidget({
type: "bi.td",
element: this,
columnSize: BI.makeArray(o.layer, 24),
columnSize: BI.makeArray(o.layer, 15),
items: [items]
});
},
@ -61879,7 +61882,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
return BI.extend(BI.IconTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-icon-trigger",
baseCls: "bi-icon-trigger",
extraCls: "pull-down-font",
el: {},
height: 24
});
@ -61891,7 +61895,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
type: "bi.trigger_icon_button",
element: this,
width: o.width,
height: o.height
height: o.height,
extraCls: o.extraCls
});
}
});
@ -64038,7 +64043,7 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "",
extraCls: o.iconCls,
width: o.width,
height: o.height
}),
@ -68992,7 +68997,9 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -69072,6 +69079,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_select_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-select-tree-trigger",
ref: function (_ref) {
@ -69109,6 +69118,13 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -69161,6 +69177,97 @@ BI.MultiLayerSelectTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSelectTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSelectTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSelectTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-select-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_insert_search_pane", BI.MultiLayerSelectTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSelectLevelTree
@ -69429,7 +69536,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -69470,22 +69577,31 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_select_tree_popup",
itemsCreator: function (op, callback) {
type: o.allowInsertValue ? "bi.multilayer_select_tree_insert_search_pane" : "bi.multilayer_select_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
},
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -69527,32 +69643,70 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
var o = this.options;
return o.valueFormatter(v) || o.text;
if(o.itemsCreator === BI.emptyFn) {
var result = BI.find(o.items, function (i, item) {
return item.value === v;
});
return BI.isNotNull(result) ? result.text : o.text;
}
return o.valueFormatter(v);
},
stopEditing: function () {
@ -69582,6 +69736,7 @@ BI.MultiLayerSelectTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger);/**
* 加号表示的组节点
*
@ -70007,7 +70162,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -70087,6 +70244,8 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_single_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-single-tree-trigger",
ref: function (_ref) {
@ -70124,6 +70283,13 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -70176,6 +70342,97 @@ BI.MultiLayerSingleTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSingleTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSingleTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSingleTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-single-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_insert_search_pane", BI.MultiLayerSingleTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSingleLevelTree
@ -70435,7 +70692,8 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
return v;
},
itemsCreator: BI.emptyFn,
watermark: BI.i18nText("BI-Basic_Search")
watermark: BI.i18nText("BI-Basic_Search"),
allowSearchValue: false
};
},
@ -70443,7 +70701,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -70484,7 +70742,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_single_tree_popup",
type: o.allowInsertValue ? "bi.multilayer_single_tree_insert_search_pane" : "bi.multilayer_single_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
@ -70492,14 +70750,23 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -70541,27 +70808,59 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
@ -70602,6 +70901,7 @@ BI.MultiLayerSingleTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger);/**
* 加号表示的组节点
*
@ -76180,7 +76480,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM);
});
@ -76483,7 +76783,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -76799,7 +77099,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -80197,6 +80497,10 @@ BI.SelectTreeExpander = BI.inherit(BI.Widget, {
});
},
getAllLeaves: function () {
return this.expander.getAllLeaves();
},
setValue: function (v) {
if (BI.contains(v, this.trigger.getValue())) {
this.trigger.setSelected(true);
@ -88230,11 +88534,17 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
},
_isMatch: function (parentValues, value, keyword) {
var o = this.options;
var node = this._getTreeNode(parentValues, value);
if (!node) {
return false;
}
var find = BI.Func.getSearchResult([node.text || node.value], keyword);
if(o.allowSearchValue && node.value) {
var valueFind = BI.Func.getSearchResult([node.value], keyword);
return valueFind.find.length > 0 || valueFind.match.length > 0 ||
find.find.length > 0 || find.match.length > 0;
}
return find.find.length > 0 || find.match.length > 0;
},
@ -88985,6 +89295,96 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, {
}
}
});/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*/
BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-insert-combo",
width: 200,
height: 24,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserInsertCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: "bi.multi_select_insert_combo",
element: this,
text: o.text,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height,
listeners: [{
eventName: BI.MultiSelectCombo.EVENT_FOCUS,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_FOCUS);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_BLUR,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_BLUR);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_STOP,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_STOP);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CONFIRM);
}
}]
});
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var val = this.combo.getValue() || {};
return {
type: val.type,
value: val.value
};
},
populate: function (items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
this.items = items;
this.combo.populate.apply(this, arguments);
}
});
BI.ValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
BI.ValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.ValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
BI.ValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.ValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.value_chooser_insert_combo", BI.ValueChooserInsertCombo);/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*

2
dist/bundle.min.css vendored

File diff suppressed because one or more lines are too long

28
dist/bundle.min.js vendored

File diff suppressed because one or more lines are too long

19
dist/case.js vendored

@ -456,7 +456,7 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, {
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, this.text);
BI.createWidget(BI.extend({
@ -635,16 +635,17 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, {
});
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, {
width: 24,
width: 16,
el: icon
}, this.text);
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items
items: items,
rgap: 5
}))));
},
@ -873,7 +874,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.count(0, o.layer, function () {
items.push({
type: "bi.layout",
width: 24,
width: 15,
height: o.height
});
});
@ -881,7 +882,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.createWidget({
type: "bi.td",
element: this,
columnSize: BI.makeArray(o.layer, 24),
columnSize: BI.makeArray(o.layer, 15),
items: [items]
});
},
@ -9453,7 +9454,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
return BI.extend(BI.IconTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-icon-trigger",
baseCls: "bi-icon-trigger",
extraCls: "pull-down-font",
el: {},
height: 24
});
@ -9465,7 +9467,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
type: "bi.trigger_icon_button",
element: this,
width: o.width,
height: o.height
height: o.height,
extraCls: o.extraCls
});
}
});

12
dist/core.js vendored

@ -22,7 +22,7 @@ if(_global.BI.prepares == null) {
}/**
* @license
* Lodash (Custom Build) <https://lodash.com/>
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy"`
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy"`
* Copyright JS Foundation and other contributors <https://js.foundation/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@ -10538,7 +10538,7 @@ if (!_global.BI) {
// 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight"], function (name) {
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) {
BI[name] = _apply(name);
});
_.each(["findIndex", "findLastIndex"], function (name) {
@ -21871,14 +21871,16 @@ BI.prepares.push(function () {
var canvas = document.createElement("canvas");
var ratio = 2;
BI.Widget._renderEngine.createElement("body").append(canvas);
var w = BI.DOM.getTextSizeWidth(param, 12) + 4;
var ctx = canvas.getContext("2d");
ctx.font = "12px Georgia";
var w = ctx.measureText(param).width + 4;
canvas.width = w * ratio;
canvas.height = 16 * ratio;
var ctx = canvas.getContext("2d");
// ctx.fillStyle = "#EAF2FD";
ctx.font = 12 * ratio + "px Georgia";
ctx.fillStyle = fillStyle || "#3685f2";
ctx.textBaseline = "middle";
// ctx.fillStyle = "#EAF2FD";
ctx.fillText(param, 2 * ratio, 9 * ratio);
BI.Widget._renderEngine.createElement(canvas).destroy();
var backColor = backgroundColor || "rgba(54, 133, 242, 0.1)";

520
dist/fineui.ie.js vendored

@ -267,7 +267,7 @@ if(_global.BI.prepares == null) {
}/**
* @license
* Lodash (Custom Build) <https://lodash.com/>
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy"`
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy"`
* Copyright JS Foundation and other contributors <https://js.foundation/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@ -10783,7 +10783,7 @@ if (!_global.BI) {
// 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight"], function (name) {
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) {
BI[name] = _apply(name);
});
_.each(["findIndex", "findLastIndex"], function (name) {
@ -22116,14 +22116,16 @@ BI.prepares.push(function () {
var canvas = document.createElement("canvas");
var ratio = 2;
BI.Widget._renderEngine.createElement("body").append(canvas);
var w = BI.DOM.getTextSizeWidth(param, 12) + 4;
var ctx = canvas.getContext("2d");
ctx.font = "12px Georgia";
var w = ctx.measureText(param).width + 4;
canvas.width = w * ratio;
canvas.height = 16 * ratio;
var ctx = canvas.getContext("2d");
// ctx.fillStyle = "#EAF2FD";
ctx.font = 12 * ratio + "px Georgia";
ctx.fillStyle = fillStyle || "#3685f2";
ctx.textBaseline = "middle";
// ctx.fillStyle = "#EAF2FD";
ctx.fillText(param, 2 * ratio, 9 * ratio);
BI.Widget._renderEngine.createElement(canvas).destroy();
var backColor = backgroundColor || "rgba(54, 133, 242, 0.1)";
@ -52723,7 +52725,7 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, {
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, this.text);
BI.createWidget(BI.extend({
@ -52902,16 +52904,17 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, {
});
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, {
width: 24,
width: 16,
el: icon
}, this.text);
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items
items: items,
rgap: 5
}))));
},
@ -53140,7 +53143,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.count(0, o.layer, function () {
items.push({
type: "bi.layout",
width: 24,
width: 15,
height: o.height
});
});
@ -53148,7 +53151,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.createWidget({
type: "bi.td",
element: this,
columnSize: BI.makeArray(o.layer, 24),
columnSize: BI.makeArray(o.layer, 15),
items: [items]
});
},
@ -61720,7 +61723,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
return BI.extend(BI.IconTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-icon-trigger",
baseCls: "bi-icon-trigger",
extraCls: "pull-down-font",
el: {},
height: 24
});
@ -61732,7 +61736,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
type: "bi.trigger_icon_button",
element: this,
width: o.width,
height: o.height
height: o.height,
extraCls: o.extraCls
});
}
});
@ -63879,7 +63884,7 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "",
extraCls: o.iconCls,
width: o.width,
height: o.height
}),
@ -68833,7 +68838,9 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -68913,6 +68920,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_select_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-select-tree-trigger",
ref: function (_ref) {
@ -68950,6 +68959,13 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -69002,6 +69018,97 @@ BI.MultiLayerSelectTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSelectTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSelectTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSelectTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-select-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_insert_search_pane", BI.MultiLayerSelectTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSelectLevelTree
@ -69270,7 +69377,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -69311,22 +69418,31 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_select_tree_popup",
itemsCreator: function (op, callback) {
type: o.allowInsertValue ? "bi.multilayer_select_tree_insert_search_pane" : "bi.multilayer_select_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
},
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -69368,32 +69484,70 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
var o = this.options;
return o.valueFormatter(v) || o.text;
if(o.itemsCreator === BI.emptyFn) {
var result = BI.find(o.items, function (i, item) {
return item.value === v;
});
return BI.isNotNull(result) ? result.text : o.text;
}
return o.valueFormatter(v);
},
stopEditing: function () {
@ -69423,6 +69577,7 @@ BI.MultiLayerSelectTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger);/**
* 加号表示的组节点
*
@ -69848,7 +70003,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -69928,6 +70085,8 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_single_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-single-tree-trigger",
ref: function (_ref) {
@ -69965,6 +70124,13 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -70017,6 +70183,97 @@ BI.MultiLayerSingleTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSingleTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSingleTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSingleTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-single-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_insert_search_pane", BI.MultiLayerSingleTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSingleLevelTree
@ -70276,7 +70533,8 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
return v;
},
itemsCreator: BI.emptyFn,
watermark: BI.i18nText("BI-Basic_Search")
watermark: BI.i18nText("BI-Basic_Search"),
allowSearchValue: false
};
},
@ -70284,7 +70542,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -70325,7 +70583,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_single_tree_popup",
type: o.allowInsertValue ? "bi.multilayer_single_tree_insert_search_pane" : "bi.multilayer_single_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
@ -70333,14 +70591,23 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -70382,27 +70649,59 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
@ -70443,6 +70742,7 @@ BI.MultiLayerSingleTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger);/**
* 加号表示的组节点
*
@ -76021,7 +76321,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM);
});
@ -76324,7 +76624,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -76640,7 +76940,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -80038,6 +80338,10 @@ BI.SelectTreeExpander = BI.inherit(BI.Widget, {
});
},
getAllLeaves: function () {
return this.expander.getAllLeaves();
},
setValue: function (v) {
if (BI.contains(v, this.trigger.getValue())) {
this.trigger.setSelected(true);
@ -88071,11 +88375,17 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
},
_isMatch: function (parentValues, value, keyword) {
var o = this.options;
var node = this._getTreeNode(parentValues, value);
if (!node) {
return false;
}
var find = BI.Func.getSearchResult([node.text || node.value], keyword);
if(o.allowSearchValue && node.value) {
var valueFind = BI.Func.getSearchResult([node.value], keyword);
return valueFind.find.length > 0 || valueFind.match.length > 0 ||
find.find.length > 0 || find.match.length > 0;
}
return find.find.length > 0 || find.match.length > 0;
},
@ -88826,6 +89136,96 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, {
}
}
});/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*/
BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-insert-combo",
width: 200,
height: 24,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserInsertCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: "bi.multi_select_insert_combo",
element: this,
text: o.text,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height,
listeners: [{
eventName: BI.MultiSelectCombo.EVENT_FOCUS,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_FOCUS);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_BLUR,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_BLUR);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_STOP,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_STOP);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CONFIRM);
}
}]
});
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var val = this.combo.getValue() || {};
return {
type: val.type,
value: val.value
};
},
populate: function (items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
this.items = items;
this.combo.populate.apply(this, arguments);
}
});
BI.ValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
BI.ValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.ValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
BI.ValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.ValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.value_chooser_insert_combo", BI.ValueChooserInsertCombo);/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*

26
dist/fineui.ie.min.js vendored

File diff suppressed because one or more lines are too long

520
dist/fineui.js vendored

@ -267,7 +267,7 @@ if(_global.BI.prepares == null) {
}/**
* @license
* Lodash (Custom Build) <https://lodash.com/>
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy"`
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy"`
* Copyright JS Foundation and other contributors <https://js.foundation/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@ -10783,7 +10783,7 @@ if (!_global.BI) {
// 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight"], function (name) {
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) {
BI[name] = _apply(name);
});
_.each(["findIndex", "findLastIndex"], function (name) {
@ -22116,14 +22116,16 @@ BI.prepares.push(function () {
var canvas = document.createElement("canvas");
var ratio = 2;
BI.Widget._renderEngine.createElement("body").append(canvas);
var w = BI.DOM.getTextSizeWidth(param, 12) + 4;
var ctx = canvas.getContext("2d");
ctx.font = "12px Georgia";
var w = ctx.measureText(param).width + 4;
canvas.width = w * ratio;
canvas.height = 16 * ratio;
var ctx = canvas.getContext("2d");
// ctx.fillStyle = "#EAF2FD";
ctx.font = 12 * ratio + "px Georgia";
ctx.fillStyle = fillStyle || "#3685f2";
ctx.textBaseline = "middle";
// ctx.fillStyle = "#EAF2FD";
ctx.fillText(param, 2 * ratio, 9 * ratio);
BI.Widget._renderEngine.createElement(canvas).destroy();
var backColor = backgroundColor || "rgba(54, 133, 242, 0.1)";
@ -53127,7 +53129,7 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, {
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, this.text);
BI.createWidget(BI.extend({
@ -53306,16 +53308,17 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, {
});
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, {
width: 24,
width: 16,
el: icon
}, this.text);
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items
items: items,
rgap: 5
}))));
},
@ -53544,7 +53547,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.count(0, o.layer, function () {
items.push({
type: "bi.layout",
width: 24,
width: 15,
height: o.height
});
});
@ -53552,7 +53555,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.createWidget({
type: "bi.td",
element: this,
columnSize: BI.makeArray(o.layer, 24),
columnSize: BI.makeArray(o.layer, 15),
items: [items]
});
},
@ -62124,7 +62127,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
return BI.extend(BI.IconTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-icon-trigger",
baseCls: "bi-icon-trigger",
extraCls: "pull-down-font",
el: {},
height: 24
});
@ -62136,7 +62140,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
type: "bi.trigger_icon_button",
element: this,
width: o.width,
height: o.height
height: o.height,
extraCls: o.extraCls
});
}
});
@ -64283,7 +64288,7 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "",
extraCls: o.iconCls,
width: o.width,
height: o.height
}),
@ -69237,7 +69242,9 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -69317,6 +69324,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_select_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-select-tree-trigger",
ref: function (_ref) {
@ -69354,6 +69363,13 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -69406,6 +69422,97 @@ BI.MultiLayerSelectTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSelectTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSelectTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSelectTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-select-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_insert_search_pane", BI.MultiLayerSelectTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSelectLevelTree
@ -69674,7 +69781,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -69715,22 +69822,31 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_select_tree_popup",
itemsCreator: function (op, callback) {
type: o.allowInsertValue ? "bi.multilayer_select_tree_insert_search_pane" : "bi.multilayer_select_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
},
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -69772,32 +69888,70 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
var o = this.options;
return o.valueFormatter(v) || o.text;
if(o.itemsCreator === BI.emptyFn) {
var result = BI.find(o.items, function (i, item) {
return item.value === v;
});
return BI.isNotNull(result) ? result.text : o.text;
}
return o.valueFormatter(v);
},
stopEditing: function () {
@ -69827,6 +69981,7 @@ BI.MultiLayerSelectTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger);/**
* 加号表示的组节点
*
@ -70252,7 +70407,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -70332,6 +70489,8 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_single_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-single-tree-trigger",
ref: function (_ref) {
@ -70369,6 +70528,13 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -70421,6 +70587,97 @@ BI.MultiLayerSingleTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSingleTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSingleTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSingleTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-single-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_insert_search_pane", BI.MultiLayerSingleTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSingleLevelTree
@ -70680,7 +70937,8 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
return v;
},
itemsCreator: BI.emptyFn,
watermark: BI.i18nText("BI-Basic_Search")
watermark: BI.i18nText("BI-Basic_Search"),
allowSearchValue: false
};
},
@ -70688,7 +70946,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -70729,7 +70987,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_single_tree_popup",
type: o.allowInsertValue ? "bi.multilayer_single_tree_insert_search_pane" : "bi.multilayer_single_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
@ -70737,14 +70995,23 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -70786,27 +71053,59 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
@ -70847,6 +71146,7 @@ BI.MultiLayerSingleTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger);/**
* 加号表示的组节点
*
@ -76425,7 +76725,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM);
});
@ -76728,7 +77028,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -77044,7 +77344,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -80442,6 +80742,10 @@ BI.SelectTreeExpander = BI.inherit(BI.Widget, {
});
},
getAllLeaves: function () {
return this.expander.getAllLeaves();
},
setValue: function (v) {
if (BI.contains(v, this.trigger.getValue())) {
this.trigger.setSelected(true);
@ -88475,11 +88779,17 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
},
_isMatch: function (parentValues, value, keyword) {
var o = this.options;
var node = this._getTreeNode(parentValues, value);
if (!node) {
return false;
}
var find = BI.Func.getSearchResult([node.text || node.value], keyword);
if(o.allowSearchValue && node.value) {
var valueFind = BI.Func.getSearchResult([node.value], keyword);
return valueFind.find.length > 0 || valueFind.match.length > 0 ||
find.find.length > 0 || find.match.length > 0;
}
return find.find.length > 0 || find.match.length > 0;
},
@ -89230,6 +89540,96 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, {
}
}
});/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*/
BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-insert-combo",
width: 200,
height: 24,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserInsertCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: "bi.multi_select_insert_combo",
element: this,
text: o.text,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height,
listeners: [{
eventName: BI.MultiSelectCombo.EVENT_FOCUS,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_FOCUS);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_BLUR,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_BLUR);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_STOP,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_STOP);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CONFIRM);
}
}]
});
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var val = this.combo.getValue() || {};
return {
type: val.type,
value: val.value
};
},
populate: function (items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
this.items = items;
this.combo.populate.apply(this, arguments);
}
});
BI.ValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
BI.ValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.ValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
BI.ValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.ValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.value_chooser_insert_combo", BI.ValueChooserInsertCombo);/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*

2
dist/fineui.min.css vendored

File diff suppressed because one or more lines are too long

26
dist/fineui.min.js vendored

File diff suppressed because one or more lines are too long

512
dist/fineui_without_jquery_polyfill.js vendored

@ -22,7 +22,7 @@ if(_global.BI.prepares == null) {
}/**
* @license
* Lodash (Custom Build) <https://lodash.com/>
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy"`
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy"`
* Copyright JS Foundation and other contributors <https://js.foundation/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@ -10538,7 +10538,7 @@ if (!_global.BI) {
// 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight"], function (name) {
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) {
BI[name] = _apply(name);
});
_.each(["findIndex", "findLastIndex"], function (name) {
@ -37258,7 +37258,7 @@ BI.ArrowNode = BI.inherit(BI.NodeButton, {
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, this.text);
BI.createWidget(BI.extend({
@ -37437,16 +37437,17 @@ BI.IconArrowNode = BI.inherit(BI.NodeButton, {
});
var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left);
var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, {
width: 24,
width: 16,
el: this.checkbox
}, {
width: 24,
width: 16,
el: icon
}, this.text);
BI.createWidget(BI.extend({
element: this
}, BI.LogicFactory.createLogic(type, BI.extend(o.logic, {
items: items
items: items,
rgap: 5
}))));
},
@ -37675,7 +37676,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.count(0, o.layer, function () {
items.push({
type: "bi.layout",
width: 24,
width: 15,
height: o.height
});
});
@ -37683,7 +37684,7 @@ BI.shortcut("bi.mid_plus_group_node", BI.MidPlusGroupNode);BI.MultiLayerIconArro
BI.createWidget({
type: "bi.td",
element: this,
columnSize: BI.makeArray(o.layer, 24),
columnSize: BI.makeArray(o.layer, 15),
items: [items]
});
},
@ -44426,7 +44427,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
return BI.extend(BI.IconTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-icon-trigger",
baseCls: "bi-icon-trigger",
extraCls: "pull-down-font",
el: {},
height: 24
});
@ -44438,7 +44440,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
type: "bi.trigger_icon_button",
element: this,
width: o.width,
height: o.height
height: o.height,
extraCls: o.extraCls
});
}
});
@ -46585,7 +46588,7 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "",
extraCls: o.iconCls,
width: o.width,
height: o.height
}),
@ -51539,7 +51542,9 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -51619,6 +51624,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_select_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-select-tree-trigger",
ref: function (_ref) {
@ -51656,6 +51663,13 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -51708,6 +51722,97 @@ BI.MultiLayerSelectTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSelectTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSelectTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSelectTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-select-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_insert_search_pane", BI.MultiLayerSelectTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSelectLevelTree
@ -51976,7 +52081,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -52017,22 +52122,31 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_select_tree_popup",
itemsCreator: function (op, callback) {
type: o.allowInsertValue ? "bi.multilayer_select_tree_insert_search_pane" : "bi.multilayer_select_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
},
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -52074,32 +52188,70 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
}
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
var o = this.options;
return o.valueFormatter(v) || o.text;
if(o.itemsCreator === BI.emptyFn) {
var result = BI.find(o.items, function (i, item) {
return item.value === v;
});
return BI.isNotNull(result) ? result.text : o.text;
}
return o.valueFormatter(v);
},
stopEditing: function () {
@ -52129,6 +52281,7 @@ BI.MultiLayerSelectTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger);/**
* 加号表示的组节点
*
@ -52554,7 +52707,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -52634,6 +52789,8 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_single_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-single-tree-trigger",
ref: function (_ref) {
@ -52671,6 +52828,13 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -52723,6 +52887,97 @@ BI.MultiLayerSingleTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSingleTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSingleTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSingleTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-single-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_insert_search_pane", BI.MultiLayerSingleTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSingleLevelTree
@ -52982,7 +53237,8 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
return v;
},
itemsCreator: BI.emptyFn,
watermark: BI.i18nText("BI-Basic_Search")
watermark: BI.i18nText("BI-Basic_Search"),
allowSearchValue: false
};
},
@ -52990,7 +53246,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -53031,7 +53287,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_single_tree_popup",
type: o.allowInsertValue ? "bi.multilayer_single_tree_insert_search_pane" : "bi.multilayer_single_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
@ -53039,14 +53295,23 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -53088,27 +53353,59 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
}
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
@ -53149,6 +53446,7 @@ BI.MultiLayerSingleTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger);/**
* 加号表示的组节点
*
@ -58727,7 +59025,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM);
});
@ -59030,7 +59328,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -59346,7 +59644,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -62744,6 +63042,10 @@ BI.SelectTreeExpander = BI.inherit(BI.Widget, {
});
},
getAllLeaves: function () {
return this.expander.getAllLeaves();
},
setValue: function (v) {
if (BI.contains(v, this.trigger.getValue())) {
this.trigger.setSelected(true);
@ -70777,11 +71079,17 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
},
_isMatch: function (parentValues, value, keyword) {
var o = this.options;
var node = this._getTreeNode(parentValues, value);
if (!node) {
return false;
}
var find = BI.Func.getSearchResult([node.text || node.value], keyword);
if(o.allowSearchValue && node.value) {
var valueFind = BI.Func.getSearchResult([node.value], keyword);
return valueFind.find.length > 0 || valueFind.match.length > 0 ||
find.find.length > 0 || find.match.length > 0;
}
return find.find.length > 0 || find.match.length > 0;
},
@ -71532,6 +71840,96 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, {
}
}
});/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*/
BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-insert-combo",
width: 200,
height: 24,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserInsertCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: "bi.multi_select_insert_combo",
element: this,
text: o.text,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height,
listeners: [{
eventName: BI.MultiSelectCombo.EVENT_FOCUS,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_FOCUS);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_BLUR,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_BLUR);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_STOP,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_STOP);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CONFIRM);
}
}]
});
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var val = this.combo.getValue() || {};
return {
type: val.type,
value: val.value
};
},
populate: function (items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
this.items = items;
this.combo.populate.apply(this, arguments);
}
});
BI.ValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
BI.ValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.ValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
BI.ValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.ValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.value_chooser_insert_combo", BI.ValueChooserInsertCombo);/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*

4
dist/utils.js vendored

@ -22,7 +22,7 @@ if(_global.BI.prepares == null) {
}/**
* @license
* Lodash (Custom Build) <https://lodash.com/>
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy"`
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy"`
* Copyright JS Foundation and other contributors <https://js.foundation/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
@ -11317,7 +11317,7 @@ if (!_global.BI) {
// 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight"], function (name) {
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) {
BI[name] = _apply(name);
});
_.each(["findIndex", "findLastIndex"], function (name) {

2
dist/utils.min.js vendored

File diff suppressed because one or more lines are too long

489
dist/widget.js vendored

@ -1699,7 +1699,7 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "",
extraCls: o.iconCls,
width: o.width,
height: o.height
}),
@ -6653,7 +6653,9 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -6733,6 +6735,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_select_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-select-tree-trigger",
ref: function (_ref) {
@ -6770,6 +6774,13 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -6822,6 +6833,97 @@ BI.MultiLayerSelectTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSelectTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSelectTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSelectTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-select-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_insert_search_pane", BI.MultiLayerSelectTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSelectLevelTree
@ -7090,7 +7192,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -7131,22 +7233,31 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_select_tree_popup",
itemsCreator: function (op, callback) {
type: o.allowInsertValue ? "bi.multilayer_select_tree_insert_search_pane" : "bi.multilayer_select_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
},
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -7188,32 +7299,70 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
}
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
var o = this.options;
return o.valueFormatter(v) || o.text;
if(o.itemsCreator === BI.emptyFn) {
var result = BI.find(o.items, function (i, item) {
return item.value === v;
});
return BI.isNotNull(result) ? result.text : o.text;
}
return o.valueFormatter(v);
},
stopEditing: function () {
@ -7243,6 +7392,7 @@ BI.MultiLayerSelectTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger);/**
* 加号表示的组节点
*
@ -7668,7 +7818,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -7748,6 +7900,8 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_single_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-single-tree-trigger",
ref: function (_ref) {
@ -7785,6 +7939,13 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {
@ -7837,6 +7998,97 @@ BI.MultiLayerSingleTreeCombo.EVENT_BLUR = "EVENT_BLUR";
BI.MultiLayerSingleTreeCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSingleTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSingleTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-single-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_insert_search_pane", BI.MultiLayerSingleTreeInsertSearchPane);/**
* guy
* 二级树
* @class BI.MultiLayerSingleLevelTree
@ -8096,7 +8348,8 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
return v;
},
itemsCreator: BI.emptyFn,
watermark: BI.i18nText("BI-Basic_Search")
watermark: BI.i18nText("BI-Basic_Search"),
allowSearchValue: false
};
},
@ -8104,7 +8357,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -8145,7 +8398,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_single_tree_popup",
type: o.allowInsertValue ? "bi.multilayer_single_tree_insert_search_pane" : "bi.multilayer_single_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
@ -8153,14 +8406,23 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -8202,27 +8464,59 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
@ -8263,6 +8557,7 @@ BI.MultiLayerSingleTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger);/**
* 加号表示的组节点
*
@ -13841,7 +14136,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM);
});
@ -14144,7 +14439,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -14460,7 +14755,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});
@ -17858,6 +18153,10 @@ BI.SelectTreeExpander = BI.inherit(BI.Widget, {
});
},
getAllLeaves: function () {
return this.expander.getAllLeaves();
},
setValue: function (v) {
if (BI.contains(v, this.trigger.getValue())) {
this.trigger.setSelected(true);
@ -25891,11 +26190,17 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
},
_isMatch: function (parentValues, value, keyword) {
var o = this.options;
var node = this._getTreeNode(parentValues, value);
if (!node) {
return false;
}
var find = BI.Func.getSearchResult([node.text || node.value], keyword);
if(o.allowSearchValue && node.value) {
var valueFind = BI.Func.getSearchResult([node.value], keyword);
return valueFind.find.length > 0 || valueFind.match.length > 0 ||
find.find.length > 0 || find.match.length > 0;
}
return find.find.length > 0 || find.match.length > 0;
},
@ -26646,6 +26951,96 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, {
}
}
});/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*/
BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-insert-combo",
width: 200,
height: 24,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserInsertCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: "bi.multi_select_insert_combo",
element: this,
text: o.text,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height,
listeners: [{
eventName: BI.MultiSelectCombo.EVENT_FOCUS,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_FOCUS);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_BLUR,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_BLUR);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_STOP,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_STOP);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CONFIRM);
}
}]
});
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var val = this.combo.getValue() || {};
return {
type: val.type,
value: val.value
};
},
populate: function (items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
this.items = items;
this.combo.populate.apply(this, arguments);
}
});
BI.ValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
BI.ValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.ValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
BI.ValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.ValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.value_chooser_insert_combo", BI.ValueChooserInsertCombo);/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*

2
lodash.md

@ -1 +1 @@
lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy"
lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy"

6
src/case/trigger/trigger.icon.js

@ -9,7 +9,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
_defaultConfig: function () {
return BI.extend(BI.IconTrigger.superclass._defaultConfig.apply(this, arguments), {
extraCls: "bi-icon-trigger",
baseCls: "bi-icon-trigger",
extraCls: "pull-down-font",
el: {},
height: 24
});
@ -21,7 +22,8 @@ BI.IconTrigger = BI.inherit(BI.Trigger, {
type: "bi.trigger_icon_button",
element: this,
width: o.width,
height: o.height
height: o.height,
extraCls: o.extraCls
});
}
});

6
src/component/treevaluechooser/abstract.treevaluechooser.js

@ -694,11 +694,17 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
},
_isMatch: function (parentValues, value, keyword) {
var o = this.options;
var node = this._getTreeNode(parentValues, value);
if (!node) {
return false;
}
var find = BI.Func.getSearchResult([node.text || node.value], keyword);
if(o.allowSearchValue && node.value) {
var valueFind = BI.Func.getSearchResult([node.value], keyword);
return valueFind.find.length > 0 || valueFind.match.length > 0 ||
find.find.length > 0 || find.match.length > 0;
}
return find.find.length > 0 || find.match.length > 0;
},

91
src/component/valuechooser/combo.valuechooser.insert.js

@ -0,0 +1,91 @@
/**
* 简单的复选下拉框控件, 适用于数据量少的情况
* 封装了字段处理逻辑
*/
BI.ValueChooserInsertCombo = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserInsertCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-insert-combo",
width: 200,
height: 24,
items: null,
itemsCreator: BI.emptyFn,
cache: true
});
},
_init: function () {
BI.ValueChooserInsertCombo.superclass._init.apply(this, arguments);
var self = this, o = this.options;
if (BI.isNotNull(o.items)) {
this.items = o.items;
}
this.combo = BI.createWidget({
type: "bi.multi_select_insert_combo",
element: this,
text: o.text,
itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width,
height: o.height,
listeners: [{
eventName: BI.MultiSelectCombo.EVENT_FOCUS,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_FOCUS);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_BLUR,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_BLUR);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_STOP,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_STOP);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CLICK_ITEM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_SEARCHING,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiSelectCombo.EVENT_CONFIRM,
action: function () {
self.fireEvent(BI.ValueChooserInsertCombo.EVENT_CONFIRM);
}
}]
});
},
setValue: function (v) {
this.combo.setValue(v);
},
getValue: function () {
var val = this.combo.getValue() || {};
return {
type: val.type,
value: val.value
};
},
populate: function (items) {
// 直接用combo的populate不会作用到AbstractValueChooser上
this.items = items;
this.combo.populate.apply(this, arguments);
}
});
BI.ValueChooserInsertCombo.EVENT_BLUR = "EVENT_BLUR";
BI.ValueChooserInsertCombo.EVENT_FOCUS = "EVENT_FOCUS";
BI.ValueChooserInsertCombo.EVENT_STOP = "EVENT_STOP";
BI.ValueChooserInsertCombo.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.ValueChooserInsertCombo.EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM";
BI.ValueChooserInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM";
BI.shortcut("bi.value_chooser_insert_combo", BI.ValueChooserInsertCombo);

2
src/core/base.js

@ -359,7 +359,7 @@ if (!_global.BI) {
// 数组相关的方法
_.each(["first", "initial", "last", "rest", "compact", "flatten", "without", "union", "intersection",
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight"], function (name) {
"difference", "zip", "unzip", "object", "indexOf", "lastIndexOf", "sortedIndex", "range", "take", "takeRight", "uniqBy"], function (name) {
BI[name] = _apply(name);
});
_.each(["findIndex", "findLastIndex"], function (name) {

2
src/core/lodash.js

@ -1,7 +1,7 @@
/**
* @license
* Lodash (Custom Build) <https://lodash.com/>
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy"`
* Build: `lodash core plus="debounce,throttle,get,findIndex,findLastIndex,findKey,findLastKey,isArrayLike,invert,invertBy,uniq,uniqBy,omit,omitBy,zip,unzip,rest,range,random,reject,intersection,drop,countBy,union,zipObject,initial,cloneDeep,clamp,isPlainObject,take,takeRight,without,difference,defaultsDeep,trim,merge,groupBy,uniqBy"`
* Copyright JS Foundation and other contributors <https://js.foundation/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>

8
src/core/platform/web/dom.js

@ -125,14 +125,16 @@
var canvas = document.createElement("canvas");
var ratio = 2;
BI.Widget._renderEngine.createElement("body").append(canvas);
var w = BI.DOM.getTextSizeWidth(param, 12) + 4;
var ctx = canvas.getContext("2d");
ctx.font = "12px Georgia";
var w = ctx.measureText(param).width + 4;
canvas.width = w * ratio;
canvas.height = 16 * ratio;
var ctx = canvas.getContext("2d");
// ctx.fillStyle = "#EAF2FD";
ctx.font = 12 * ratio + "px Georgia";
ctx.fillStyle = fillStyle || "#3685f2";
ctx.textBaseline = "middle";
// ctx.fillStyle = "#EAF2FD";
ctx.fillText(param, 2 * ratio, 9 * ratio);
BI.Widget._renderEngine.createElement(canvas).destroy();
var backColor = backgroundColor || "rgba(54, 133, 242, 0.1)";

2
src/widget/downlist/combo.downlist.js

@ -48,7 +48,7 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
stopPropagation: o.stopPropagation,
el: BI.createWidget(o.el, {
type: "bi.icon_trigger",
extraCls: o.iconCls ? o.iconCls : "",
extraCls: o.iconCls,
width: o.width,
height: o.height
}),

13
src/widget/multilayerselecttree/multilayerselecttree.combo.js

@ -16,7 +16,9 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -96,6 +98,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_select_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-select-tree-trigger",
ref: function (_ref) {
@ -133,6 +137,13 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {

92
src/widget/multilayerselecttree/multilayerselecttree.insert.search.pane.js

@ -0,0 +1,92 @@
/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSelectTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSelectTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-select-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSelectTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_select_tree_insert_search_pane", BI.MultiLayerSelectTreeInsertSearchPane);

90
src/widget/multilayerselecttree/multilayerselecttree.trigger.js

@ -19,7 +19,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -60,22 +60,31 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_select_tree_popup",
itemsCreator: function (op, callback) {
type: o.allowInsertValue ? "bi.multilayer_select_tree_insert_search_pane" : "bi.multilayer_select_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
},
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSelectTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -117,32 +126,70 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
var o = this.options;
return o.valueFormatter(v) || o.text;
if(o.itemsCreator === BI.emptyFn) {
var result = BI.find(o.items, function (i, item) {
return item.value === v;
});
return BI.isNotNull(result) ? result.text : o.text;
}
return o.valueFormatter(v);
},
stopEditing: function () {
@ -172,4 +219,5 @@ BI.MultiLayerSelectTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSelectTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSelectTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSelectTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSelectTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_select_tree_trigger", BI.MultiLayerSelectTreeTrigger);

13
src/widget/multilayersingletree/multilayersingletree.combo.js

@ -19,7 +19,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
attributes: {
tabIndex: 0
},
allowEdit: false
allowEdit: false,
allowSearchValue: false,
allowInsertValue: false
});
},
@ -99,6 +101,8 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
return {
el: {
type: "bi.multilayer_single_tree_trigger",
allowInsertValue: o.allowInsertValue,
allowSearchValue: o.allowSearchValue,
allowEdit: o.allowEdit,
cls: "multilayer-single-tree-trigger",
ref: function (_ref) {
@ -136,6 +140,13 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, {
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_SEARCHING);
}
}, {
eventName: BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM,
action: function () {
var value = self.trigger.getSearcher().getKeyword();
self.combo.setValue(value);
self.combo.hideView();
}
}]
},
hideChecker: function (e) {

92
src/widget/multilayersingletree/multilayersingletree.insert.search.pane.js

@ -0,0 +1,92 @@
/**
* Created by GUY on 2016/1/26.
*
* @class BI.MultiLayerSingleTreeInsertSearchPane
* @extends BI.Pane
*/
BI.MultiLayerSingleTreeInsertSearchPane = BI.inherit(BI.Widget, {
props: function() {
return {
baseCls: "bi-multilayer-single-tree-popup",
tipText: BI.i18nText("BI-No_Selected_Item"),
isDefaultInit: false,
itemsCreator: BI.emptyFn,
items: [],
value: ""
};
},
render: function() {
var self = this, o = this.options;
this.tree = BI.createWidget({
type: "bi.multilayer_select_level_tree",
isDefaultInit: o.isDefaultInit,
items: o.items,
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
o.itemsCreator(op, function (res) {
callback(res);
self.setKeyword(o.keywordGetter());
});
},
keywordGetter: o.keywordGetter,
value: o.value,
scrollable: null,
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.Controller.EVENT_CHANGE, arguments);
}
}, {
eventName: BI.MultiLayerSelectLevelTree.EVENT_CHANGE,
action: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE);
}
}]
});
return {
type: "bi.vertical",
scrolly: false,
scrollable: true,
vgap: 5,
items: [{
type: "bi.text_button",
invisible: true,
text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""),
height: 24,
cls: "bi-high-light",
hgap: 5,
ref: function (_ref) {
self.addNotMatchTip = _ref;
},
handler: function () {
self.fireEvent(BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM, o.keywordGetter());
}
}, this.tree]
};
},
setKeyword: function (keyword) {
var showTip = BI.isEmptyArray(this.tree.getAllLeaves());
this.addNotMatchTip.setVisible(showTip);
showTip && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword));
},
getValue: function () {
return this.tree.getValue();
},
setValue: function (v) {
v = BI.isArray(v) ? v : [v];
this.tree.setValue(v);
},
populate: function (items) {
this.tree.populate(items);
}
});
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.MultiLayerSingleTreeInsertSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multilayer_single_tree_insert_search_pane", BI.MultiLayerSingleTreeInsertSearchPane);

83
src/widget/multilayersingletree/multilayersingletree.trigger.js

@ -11,7 +11,8 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
return v;
},
itemsCreator: BI.emptyFn,
watermark: BI.i18nText("BI-Basic_Search")
watermark: BI.i18nText("BI-Basic_Search"),
allowSearchValue: false
};
},
@ -19,7 +20,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
var self = this, o = this.options;
if(o.itemsCreator === BI.emptyFn) {
this.tree = new BI.Tree();
this.tree.initTree(BI.deepClone(BI.Tree.treeFormat(BI.deepClone(o.items))));
this.tree.initTree(BI.Tree.treeFormat(o.items));
}
var content = {
type: "bi.htape",
@ -60,7 +61,7 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
}]
},
popup: {
type: "bi.multilayer_single_tree_popup",
type: o.allowInsertValue ? "bi.multilayer_single_tree_insert_search_pane" : "bi.multilayer_single_tree_popup",
itemsCreator: o.itemsCreator === BI.emptyFn ? BI.emptyFn : function (op, callback) {
op.keyword = self.editor.getValue();
o.itemsCreator(op, callback);
@ -68,14 +69,23 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
keywordGetter: function () {
return self.editor.getValue();
},
cls: "bi-card"
cls: "bi-card",
listeners: [{
eventName: BI.MultiLayerSingleTreeInsertSearchPane.EVENT_ADD_ITEM,
action: function () {
self.options.text = self.getSearcher().getKeyword();
self.fireEvent(BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM);
}
}],
ref: function (_ref) {
self.popup = _ref;
}
},
onSearch: function (obj, callback) {
var keyword = obj.keyword;
if(o.itemsCreator === BI.emptyFn) {
var finding = BI.Func.getSearchResult(o.items, keyword);
var matched = finding.match, find = finding.find;
callback(self._fillTreeStructure4Search(find.concat(matched)));
callback(self._getSearchItems(keyword));
o.allowInsertValue && self.popup.setKeyword(keyword);
} else {
callback();
}
@ -117,27 +127,59 @@ BI.MultiLayerSingleTreeTrigger = BI.inherit(BI.Trigger, {
};
},
_getSearchItems: function(keyword) {
var o = this.options;
var findingText = BI.Func.getSearchResult(o.items, keyword, "text");
var findingValue = o.allowSearchValue ? BI.Func.getSearchResult(o.items, keyword, "value") : {find: [], match: []};
var textItems = findingText.find.concat(findingText.match);
var valueItems = findingValue.find.concat(findingValue.match);
return this._fillTreeStructure4Search(BI.uniqBy(textItems.concat(valueItems), "id"));
},
_createJson: function(node, open) {
return {
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
isParent: BI.isNotEmptyArray(node.children),
open: open
}
},
_getChildren: function(node) {
var self = this;
node.children = node.children || [];
var nodes = [];
BI.each(node.children, function (idx, child) {
var children = self._getChildren(child);
nodes = nodes.concat(children);
});
return node.children.concat(nodes);
},
// 将搜索到的节点进行补充,构造成一棵完整的树
_fillTreeStructure4Search: function (leaves) {
var result = BI.map(leaves, "id");
var queue = leaves.reverse() || [];
var self = this;
var result = [];
var queue = [];
BI.each(leaves, function (idx, node) {
queue.push({pId: node.pId});
result.push(node);
result = result.concat(self._getChildren(node));
});
while (BI.isNotEmptyArray(queue)) {
var node = queue.pop();
var pNode = this.tree.search(this.tree.getRoot(), node.pId, "id");
if (pNode != null) {
queue.push(pNode);
result.push(pNode.id);
}
pNode.open = true;
queue.push({pId: pNode.pId});
result.push(pNode);
}
var nodes = [];
BI.each(this.options.items, function (idx, item) {
if(BI.contains(result, item.id)) {
nodes.push(BI.extend({}, item, {
open: true
}))
}
});
return nodes;
return BI.uniqBy(BI.map(result, function (idx, node) {
return self._createJson(node, node.open);
}), "id");
},
_digest: function (v) {
@ -178,4 +220,5 @@ BI.MultiLayerSingleTreeTrigger.EVENT_SEARCHING = "EVENT_SEARCHING";
BI.MultiLayerSingleTreeTrigger.EVENT_STOP = "EVENT_STOP";
BI.MultiLayerSingleTreeTrigger.EVENT_START = "EVENT_START";
BI.MultiLayerSingleTreeTrigger.EVENT_CHANGE = "EVENT_CHANGE";
BI.MultiLayerSingleTreeTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM";
BI.shortcut("bi.multilayer_single_tree_trigger", BI.MultiLayerSingleTreeTrigger);

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

@ -189,7 +189,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeCombo.EVENT_CLICK_ITEM);
});

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

@ -206,7 +206,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});

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

@ -214,7 +214,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, {
type: BI.Selection.Multi,
value: checked ? this.getValue() : {}
};
this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None);
this.getSearcher().setState(val);
this.getCounter().setButtonChecked(val);
self.fireEvent(BI.MultiTreeListCombo.EVENT_CLICK_ITEM, self.combo.getValue());
});

3
src/widget/numbereditor/number.editor.js

@ -31,11 +31,10 @@ BI.NumberEditor = BI.inherit(BI.Widget, {
errorText: o.errorText
});
this.editor.on(BI.TextEditor.EVENT_CHANGE, function () {
o.value = BI.parseFloat(this.getValue());
self.fireEvent(BI.NumberEditor.EVENT_CHANGE);
});
this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () {
this.setValue(BI.parseFloat(this.getValue()));
o.value = BI.parseFloat(this.getValue());
self.fireEvent(BI.NumberEditor.EVENT_CONFIRM);
});
this.topBtn = BI.createWidget({

4
src/widget/selecttree/selecttree.expander.js

@ -48,6 +48,10 @@ BI.SelectTreeExpander = BI.inherit(BI.Widget, {
});
},
getAllLeaves: function () {
return this.expander.getAllLeaves();
},
setValue: function (v) {
if (BI.contains(v, this.trigger.getValue())) {
this.trigger.setSelected(true);

Loading…
Cancel
Save