diff --git a/changelog.md b/changelog.md index 207d4db1c..b1127f7b1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ # 更新日志 2.0(2019-08) +- 单选树可展示并选中不存在的值 +- 树类型下拉新增可搜索实际值的配置 - 可编辑的combo新增水印配置 - 单选下拉树同步状态下内置搜索 diff --git a/dist/2.0/fineui.ie.js b/dist/2.0/fineui.ie.js index af0def4e0..c8a5590e9 100644 --- a/dist/2.0/fineui.ie.js +++ b/dist/2.0/fineui.ie.js @@ -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)"; @@ -61475,7 +61477,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 +61490,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 +63638,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 }), @@ -68589,7 +68593,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { tabIndex: 0 }, allowEdit: false, - allowSearchValue: false + allowSearchValue: false, + allowInsertValue: false }); }, @@ -68669,6 +68674,7 @@ 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", @@ -68707,6 +68713,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) { @@ -68759,6 +68772,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 @@ -69068,7 +69172,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }] }, popup: { - type: "bi.multilayer_select_tree_popup", + 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); @@ -69076,12 +69180,23 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { 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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -69216,6 +69331,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);/** * 加号表示的组节点 * @@ -69641,7 +69757,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { attributes: { tabIndex: 0 }, - allowEdit: false + allowEdit: false, + allowSearchValue: false, + allowInsertValue: false }); }, @@ -69721,6 +69839,7 @@ 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", @@ -69759,6 +69878,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) { @@ -69811,6 +69937,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 @@ -70120,7 +70337,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); @@ -70128,12 +70345,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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -70268,6 +70496,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);/** * 加号表示的组节点 * diff --git a/dist/2.0/fineui.js b/dist/2.0/fineui.js index f48221460..dac4eebbf 100644 --- a/dist/2.0/fineui.js +++ b/dist/2.0/fineui.js @@ -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)"; @@ -61879,7 +61881,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 +61894,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 +64042,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 }), @@ -68993,7 +68997,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { tabIndex: 0 }, allowEdit: false, - allowSearchValue: false + allowSearchValue: false, + allowInsertValue: false }); }, @@ -69073,6 +69078,7 @@ 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", @@ -69111,6 +69117,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) { @@ -69163,6 +69176,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 @@ -69472,7 +69576,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }] }, popup: { - type: "bi.multilayer_select_tree_popup", + 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); @@ -69480,12 +69584,23 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { 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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -69620,6 +69735,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);/** * 加号表示的组节点 * @@ -70045,7 +70161,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { attributes: { tabIndex: 0 }, - allowEdit: false + allowEdit: false, + allowSearchValue: false, + allowInsertValue: false }); }, @@ -70125,6 +70243,7 @@ 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", @@ -70163,6 +70282,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) { @@ -70215,6 +70341,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 @@ -70524,7 +70741,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); @@ -70532,12 +70749,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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -70672,6 +70900,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);/** * 加号表示的组节点 * diff --git a/dist/bundle.ie.js b/dist/bundle.ie.js index af0def4e0..c8a5590e9 100644 --- a/dist/bundle.ie.js +++ b/dist/bundle.ie.js @@ -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)"; @@ -61475,7 +61477,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 +61490,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 +63638,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 }), @@ -68589,7 +68593,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { tabIndex: 0 }, allowEdit: false, - allowSearchValue: false + allowSearchValue: false, + allowInsertValue: false }); }, @@ -68669,6 +68674,7 @@ 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", @@ -68707,6 +68713,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) { @@ -68759,6 +68772,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 @@ -69068,7 +69172,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }] }, popup: { - type: "bi.multilayer_select_tree_popup", + 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); @@ -69076,12 +69180,23 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { 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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -69216,6 +69331,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);/** * 加号表示的组节点 * @@ -69641,7 +69757,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { attributes: { tabIndex: 0 }, - allowEdit: false + allowEdit: false, + allowSearchValue: false, + allowInsertValue: false }); }, @@ -69721,6 +69839,7 @@ 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", @@ -69759,6 +69878,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) { @@ -69811,6 +69937,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 @@ -70120,7 +70337,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); @@ -70128,12 +70345,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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -70268,6 +70496,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);/** * 加号表示的组节点 * diff --git a/dist/bundle.js b/dist/bundle.js index f48221460..dac4eebbf 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -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)"; @@ -61879,7 +61881,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 +61894,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 +64042,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 }), @@ -68993,7 +68997,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { tabIndex: 0 }, allowEdit: false, - allowSearchValue: false + allowSearchValue: false, + allowInsertValue: false }); }, @@ -69073,6 +69078,7 @@ 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", @@ -69111,6 +69117,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) { @@ -69163,6 +69176,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 @@ -69472,7 +69576,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }] }, popup: { - type: "bi.multilayer_select_tree_popup", + 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); @@ -69480,12 +69584,23 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { 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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -69620,6 +69735,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);/** * 加号表示的组节点 * @@ -70045,7 +70161,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { attributes: { tabIndex: 0 }, - allowEdit: false + allowEdit: false, + allowSearchValue: false, + allowInsertValue: false }); }, @@ -70125,6 +70243,7 @@ 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", @@ -70163,6 +70282,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) { @@ -70215,6 +70341,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 @@ -70524,7 +70741,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); @@ -70532,12 +70749,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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -70672,6 +70900,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);/** * 加号表示的组节点 * diff --git a/dist/case.js b/dist/case.js index 9d63f0fd3..ec5125ae1 100644 --- a/dist/case.js +++ b/dist/case.js @@ -9453,7 +9453,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 +9466,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 }); } }); diff --git a/dist/core.js b/dist/core.js index 6815d00b6..14bd9fe0d 100644 --- a/dist/core.js +++ b/dist/core.js @@ -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)"; diff --git a/dist/fineui.ie.js b/dist/fineui.ie.js index 6394497ab..810e9f77f 100644 --- a/dist/fineui.ie.js +++ b/dist/fineui.ie.js @@ -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)"; @@ -61720,7 +61722,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 +61735,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 +63883,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 }), @@ -68834,7 +68838,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { tabIndex: 0 }, allowEdit: false, - allowSearchValue: false + allowSearchValue: false, + allowInsertValue: false }); }, @@ -68914,6 +68919,7 @@ 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", @@ -68952,6 +68958,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) { @@ -69004,6 +69017,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 @@ -69313,7 +69417,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }] }, popup: { - type: "bi.multilayer_select_tree_popup", + 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); @@ -69321,12 +69425,23 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { 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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -69461,6 +69576,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);/** * 加号表示的组节点 * @@ -69886,7 +70002,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { attributes: { tabIndex: 0 }, - allowEdit: false + allowEdit: false, + allowSearchValue: false, + allowInsertValue: false }); }, @@ -69966,6 +70084,7 @@ 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", @@ -70004,6 +70123,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) { @@ -70056,6 +70182,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 @@ -70365,7 +70582,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); @@ -70373,12 +70590,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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -70513,6 +70741,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);/** * 加号表示的组节点 * diff --git a/dist/fineui.js b/dist/fineui.js index 682e5e08b..6bfa83752 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -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)"; @@ -62124,7 +62126,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 +62139,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 +64287,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 }), @@ -69238,7 +69242,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { tabIndex: 0 }, allowEdit: false, - allowSearchValue: false + allowSearchValue: false, + allowInsertValue: false }); }, @@ -69318,6 +69323,7 @@ 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", @@ -69356,6 +69362,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) { @@ -69408,6 +69421,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 @@ -69717,7 +69821,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }] }, popup: { - type: "bi.multilayer_select_tree_popup", + 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); @@ -69725,12 +69829,23 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { 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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -69865,6 +69980,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);/** * 加号表示的组节点 * @@ -70290,7 +70406,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { attributes: { tabIndex: 0 }, - allowEdit: false + allowEdit: false, + allowSearchValue: false, + allowInsertValue: false }); }, @@ -70370,6 +70488,7 @@ 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", @@ -70408,6 +70527,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) { @@ -70460,6 +70586,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 @@ -70769,7 +70986,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); @@ -70777,12 +70994,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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -70917,6 +71145,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);/** * 加号表示的组节点 * diff --git a/dist/fineui_without_jquery_polyfill.js b/dist/fineui_without_jquery_polyfill.js index d967eb3a5..0230ac131 100644 --- a/dist/fineui_without_jquery_polyfill.js +++ b/dist/fineui_without_jquery_polyfill.js @@ -44426,7 +44426,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 +44439,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 +46587,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 }), @@ -51540,7 +51542,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { tabIndex: 0 }, allowEdit: false, - allowSearchValue: false + allowSearchValue: false, + allowInsertValue: false }); }, @@ -51620,6 +51623,7 @@ 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", @@ -51658,6 +51662,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) { @@ -51710,6 +51721,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 @@ -52019,7 +52121,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }] }, popup: { - type: "bi.multilayer_select_tree_popup", + 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); @@ -52027,12 +52129,23 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { 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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -52167,6 +52280,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);/** * 加号表示的组节点 * @@ -52592,7 +52706,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { attributes: { tabIndex: 0 }, - allowEdit: false + allowEdit: false, + allowSearchValue: false, + allowInsertValue: false }); }, @@ -52672,6 +52788,7 @@ 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", @@ -52710,6 +52827,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) { @@ -52762,6 +52886,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 @@ -53071,7 +53286,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); @@ -53079,12 +53294,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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -53219,6 +53445,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);/** * 加号表示的组节点 * diff --git a/dist/widget.js b/dist/widget.js index af724dc8f..3775bf873 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -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 }), @@ -6654,7 +6654,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { tabIndex: 0 }, allowEdit: false, - allowSearchValue: false + allowSearchValue: false, + allowInsertValue: false }); }, @@ -6734,6 +6735,7 @@ 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", @@ -6772,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) { @@ -6824,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 @@ -7133,7 +7233,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }] }, popup: { - type: "bi.multilayer_select_tree_popup", + 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); @@ -7141,12 +7241,23 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { 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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -7281,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);/** * 加号表示的组节点 * @@ -7706,7 +7818,9 @@ BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { attributes: { tabIndex: 0 }, - allowEdit: false + allowEdit: false, + allowSearchValue: false, + allowInsertValue: false }); }, @@ -7786,6 +7900,7 @@ 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", @@ -7824,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) { @@ -7876,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 @@ -8185,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); @@ -8193,12 +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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -8333,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);/** * 加号表示的组节点 * diff --git a/src/case/trigger/trigger.icon.js b/src/case/trigger/trigger.icon.js index dc3cbaae6..2da61d480 100644 --- a/src/case/trigger/trigger.icon.js +++ b/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 }); } }); diff --git a/src/widget/downlist/combo.downlist.js b/src/widget/downlist/combo.downlist.js index c483485f1..26bd5c89d 100644 --- a/src/widget/downlist/combo.downlist.js +++ b/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 }), diff --git a/src/widget/multilayerselecttree/multilayerselecttree.combo.js b/src/widget/multilayerselecttree/multilayerselecttree.combo.js index 272fa43d6..6d598af6f 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.combo.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.combo.js @@ -17,7 +17,8 @@ BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { tabIndex: 0 }, allowEdit: false, - allowSearchValue: false + allowSearchValue: false, + allowInsertValue: false }); }, @@ -97,6 +98,7 @@ 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", @@ -135,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) { diff --git a/src/widget/multilayerselecttree/multilayerselecttree.insert.search.pane.js b/src/widget/multilayerselecttree/multilayerselecttree.insert.search.pane.js new file mode 100644 index 000000000..8c59f5992 --- /dev/null +++ b/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); \ No newline at end of file diff --git a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js index 94c506e4d..b4902a055 100644 --- a/src/widget/multilayerselecttree/multilayerselecttree.trigger.js +++ b/src/widget/multilayerselecttree/multilayerselecttree.trigger.js @@ -60,7 +60,7 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { }] }, popup: { - type: "bi.multilayer_select_tree_popup", + 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); @@ -68,12 +68,23 @@ BI.MultiLayerSelectTreeTrigger = BI.inherit(BI.Trigger, { 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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -208,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); \ No newline at end of file diff --git a/src/widget/multilayersingletree/multilayersingletree.combo.js b/src/widget/multilayersingletree/multilayersingletree.combo.js index 9297d10d7..2ab97b10b 100644 --- a/src/widget/multilayersingletree/multilayersingletree.combo.js +++ b/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,7 @@ 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", @@ -137,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) { diff --git a/src/widget/multilayersingletree/multilayersingletree.insert.search.pane.js b/src/widget/multilayersingletree/multilayersingletree.insert.search.pane.js new file mode 100644 index 000000000..cc3872191 --- /dev/null +++ b/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); \ No newline at end of file diff --git a/src/widget/multilayersingletree/multilayersingletree.trigger.js b/src/widget/multilayersingletree/multilayersingletree.trigger.js index 6be8ad1cb..5950c5aa8 100644 --- a/src/widget/multilayersingletree/multilayersingletree.trigger.js +++ b/src/widget/multilayersingletree/multilayersingletree.trigger.js @@ -61,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); @@ -69,12 +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) { callback(self._getSearchItems(keyword)); + o.allowInsertValue && self.popup.setKeyword(keyword); } else { callback(); } @@ -209,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); \ No newline at end of file