From 92a71257d3c77845175d2b7e3888ac776747e1f5 Mon Sep 17 00:00:00 2001 From: zsmj Date: Thu, 23 Jun 2022 17:02:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?KERNEL-11647=20feat:=20=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86trigger=E6=8C=89=E9=92=AE=E4=BA=A4=E4=BA=92=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA=E7=9A=84=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/combination/combo.js | 3 ++ src/case/combo/bubblecombo/combo.bubble.js | 1 + src/core/constant/events.js | 8 ++- src/widget/multiselect/multiselect.combo.js | 22 +------- .../multiselect/multiselect.combo.nobar.js | 23 +-------- src/widget/multiselect/multiselect.trigger.js | 14 +++-- src/widget/multitree/multi.tree.combo.js | 51 ++++++------------- .../multitree/multi.tree.insert.combo.js | 49 +++++------------- src/widget/multitree/multi.tree.list.combo.js | 49 +++++------------- 9 files changed, 67 insertions(+), 153 deletions(-) diff --git a/src/base/combination/combo.js b/src/base/combination/combo.js index 604e2cac9..27d00fc6a 100644 --- a/src/base/combination/combo.js +++ b/src/base/combination/combo.js @@ -55,6 +55,9 @@ }); this.combo.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { if (self.isEnabled() && self.isValid()) { + if (type === BI.Events.TOGGLE) { + self._toggle(); + } if (type === BI.Events.EXPAND) { self._popupView(); } diff --git a/src/case/combo/bubblecombo/combo.bubble.js b/src/case/combo/bubblecombo/combo.bubble.js index 2709295d9..5f0a4c720 100644 --- a/src/case/combo/bubblecombo/combo.bubble.js +++ b/src/case/combo/bubblecombo/combo.bubble.js @@ -52,6 +52,7 @@ BI.BubbleCombo = BI.inherit(BI.Widget, { hideChecker: o.hideChecker, offsetStyle: o.offsetStyle, showArrow: true, + comboClass: o.comboClass, el: o.el, popup: () => BI.extend({ type: "bi.bubble_popup_view", diff --git a/src/core/constant/events.js b/src/core/constant/events.js index 2faa2593b..5e1abba85 100644 --- a/src/core/constant/events.js +++ b/src/core/constant/events.js @@ -143,6 +143,12 @@ _.extend(BI, { */ COLLAPSE: "_COLLAPSE", + /** + * @static + * @property 下拉菜单切换展开收起事件 + */ + TOGGLE: "_TOGGLE", + /** * @static * @property 回调事件 @@ -435,4 +441,4 @@ _.extend(BI, { */ AEMAIL: "afteremail" } -}); \ No newline at end of file +}); diff --git a/src/widget/multiselect/multiselect.combo.js b/src/widget/multiselect/multiselect.combo.js index 23d5385b8..2e71071b8 100644 --- a/src/widget/multiselect/multiselect.combo.js +++ b/src/widget/multiselect/multiselect.combo.js @@ -173,7 +173,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { }, value: o.value, hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0 && self.numberCounter.element.find(e.target).length === 0; + return self.numberCounter.element.find(e.target).length === 0; }, }); @@ -198,21 +198,6 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { } }); - var triggerBtn = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.height, - height: o.height, - cls: "multi-select-trigger-icon-button", - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - self.numberCounter.hideView(); - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - this.numberCounter = BI.createWidget({ type: "bi.multi_select_check_selected_switcher", masker: { @@ -263,11 +248,6 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { right: 0, top: 0, bottom: 0, - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0, }, { el: { type: "bi.vertical_adapt", diff --git a/src/widget/multiselect/multiselect.combo.nobar.js b/src/widget/multiselect/multiselect.combo.nobar.js index ff4cc5d34..a72519750 100644 --- a/src/widget/multiselect/multiselect.combo.nobar.js +++ b/src/widget/multiselect/multiselect.combo.nobar.js @@ -174,8 +174,7 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, { value: o.value }, hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0 && - self.numberCounter.element.find(e.target).length === 0; + return self.numberCounter.element.find(e.target).length === 0; } }); @@ -200,21 +199,6 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, { } }); - var triggerBtn = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.height, - height: o.height, - cls: "multi-select-trigger-icon-button" - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - self.numberCounter.hideView(); - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - this.numberCounter = BI.createWidget({ type: "bi.multi_select_check_selected_switcher", masker: { @@ -268,11 +252,6 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, { right: 0, top: 0, bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 }, { el: { type: "bi.vertical_adapt", diff --git a/src/widget/multiselect/multiselect.trigger.js b/src/widget/multiselect/multiselect.trigger.js index 5b39b84dc..4f75b38cb 100644 --- a/src/widget/multiselect/multiselect.trigger.js +++ b/src/widget/multiselect/multiselect.trigger.js @@ -83,7 +83,15 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, { el: this.wrapNumberCounter, width: 0 }, { - el: BI.createWidget(), + el: { + type: "bi.trigger_icon_button", + height: o.height, + stopPropagation: true, + cls: "multi-select-trigger-icon-button", + handler: function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.TOGGLE); + } + }, width: 24 }] }); @@ -114,7 +122,7 @@ BI.MultiSelectTrigger = BI.inherit(BI.Trigger, { /** * 重新调整numberCounter的空白占位符 */ - refreshPlaceHolderWidth: function(width) { + refreshPlaceHolderWidth: function (width) { this.wrapper.attr("items")[1].width = width; this.wrapper.resize(); }, @@ -167,4 +175,4 @@ BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POP BI.MultiSelectTrigger.EVENT_BLUR = "EVENT_BLUR"; BI.MultiSelectTrigger.EVENT_FOCUS = "EVENT_FOCUS"; -BI.shortcut("bi.multi_select_trigger", BI.MultiSelectTrigger); \ No newline at end of file +BI.shortcut("bi.multi_select_trigger", BI.MultiSelectTrigger); diff --git a/src/widget/multitree/multi.tree.combo.js b/src/widget/multitree/multi.tree.combo.js index 4e42df154..ec94374d8 100644 --- a/src/widget/multitree/multi.tree.combo.js +++ b/src/widget/multitree/multi.tree.combo.js @@ -22,7 +22,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { var isInit = false; var want2showCounter = false; - this.storeValue = {value: o.value || {}}; + this.storeValue = { value: o.value || {} }; this.trigger = BI.createWidget({ type: "bi.multi_select_trigger", @@ -44,7 +44,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { type: "bi.multi_tree_searcher", itemsCreator: o.itemsCreator }, - value: {value: o.value || {}} + value: { value: o.value || {} } }); this.combo = BI.createWidget({ @@ -105,10 +105,9 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { maxWidth: o.isNeedAdjustWidth ? "auto" : 500, }, isNeedAdjustWidth: o.isNeedAdjustWidth, - value: {value: o.value || {}}, + value: { value: o.value || {} }, hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0 && - self.numberCounter.element.find(e.target).length === 0; + return self.numberCounter.element.find(e.target).length === 0; } }); @@ -131,12 +130,12 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { }); this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { - self.storeValue = {value: self.combo.getValue()}; + self.storeValue = { value: self.combo.getValue() }; this.setValue(self.storeValue); self.numberCounter.setValue(self.storeValue); }); this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { - self.storeValue = {value: this.getValue()}; + self.storeValue = { value: this.getValue() }; self.combo.setValue(self.storeValue); self.numberCounter.setValue(self.storeValue); BI.nextTick(function () { @@ -151,11 +150,11 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { self.fireEvent(BI.MultiTreeCombo.EVENT_SEARCHING); }); - function showCounter () { + function showCounter() { if (isSearching()) { - self.storeValue = {value: self.trigger.getValue()}; + self.storeValue = { value: self.trigger.getValue() }; } else if (isPopupView()) { - self.storeValue = {value: self.combo.getValue()}; + self.storeValue = { value: self.combo.getValue() }; } self.trigger.setValue(self.storeValue); self.numberCounter.setValue(self.storeValue); @@ -174,7 +173,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { var checked = this.getSearcher().hasChecked(); var val = { type: BI.Selection.Multi, - value: checked ? {1: 1} : {} + value: checked ? { 1: 1 } : {} }; this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None); self.numberCounter.setButtonChecked(val); @@ -186,7 +185,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { return; } if (change === true) { - self.storeValue = {value: self.combo.getValue()}; + self.storeValue = { value: self.combo.getValue() }; change = false; } self.combo.setValue(self.storeValue); @@ -201,9 +200,9 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { } else { if (isPopupView()) { self._stopEditing(); - self.storeValue = {value: self.combo.getValue()}; + self.storeValue = { value: self.combo.getValue() }; if (clear === true) { - self.storeValue = {value: {}}; + self.storeValue = { value: {} }; } self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM); } @@ -212,21 +211,6 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { change = false; }); - var triggerBtn = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.height, - height: o.height, - cls: "multi-select-trigger-icon-button" - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - self.numberCounter.hideView(); - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - this.numberCounter = BI.createWidget({ type: "bi.multi_select_check_selected_switcher", el: { @@ -245,7 +229,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { }, itemsCreator: o.itemsCreator, valueFormatter: o.valueFormatter, - value: {value: o.value || {}} + value: { value: o.value || {} } }); this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () { if (!self.combo.isViewVisible()) { @@ -289,11 +273,6 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { right: 0, top: 0, bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 }, { el: { type: "bi.vertical_adapt", @@ -306,7 +285,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, { }); }, - _stopEditing: function() { + _stopEditing: function () { this.trigger.stopEditing(); this.numberCounter.hideView(); }, diff --git a/src/widget/multitree/multi.tree.insert.combo.js b/src/widget/multitree/multi.tree.insert.combo.js index 9694b3556..9823b37a7 100644 --- a/src/widget/multitree/multi.tree.insert.combo.js +++ b/src/widget/multitree/multi.tree.insert.combo.js @@ -23,7 +23,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { var isInit = false; var want2showCounter = false; - this.storeValue = {value: o.value || {}}; + this.storeValue = { value: o.value || {} }; this.trigger = BI.createWidget({ type: "bi.multi_select_trigger", @@ -59,7 +59,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { }] } }, - value: {value: o.value || {}} + value: { value: o.value || {} } }); @@ -121,10 +121,9 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { maxWidth: o.isNeedAdjustWidth ? "auto" : 500, }, isNeedAdjustWidth: o.isNeedAdjustWidth, - value: {value: o.value || {}}, + value: { value: o.value || {} }, hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0 && - self.numberCounter.element.find(e.target).length === 0; + return self.numberCounter.element.find(e.target).length === 0; } }); @@ -147,12 +146,12 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { }); this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { - self.storeValue = {value: self.combo.getValue()}; + self.storeValue = { value: self.combo.getValue() }; this.setValue(self.storeValue); self.numberCounter.setValue(self.storeValue); }); this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { - self.storeValue = {value: this.getValue()}; + self.storeValue = { value: this.getValue() }; self.combo.setValue(self.storeValue); self.numberCounter.setValue(self.storeValue); BI.nextTick(function () { @@ -167,11 +166,11 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { self.fireEvent(BI.MultiTreeInsertCombo.EVENT_SEARCHING); }); - function showCounter () { + function showCounter() { if (isSearching()) { - self.storeValue = {value: self.trigger.getValue()}; + self.storeValue = { value: self.trigger.getValue() }; } else if (isPopupView()) { - self.storeValue = {value: self.combo.getValue()}; + self.storeValue = { value: self.combo.getValue() }; } self.trigger.setValue(self.storeValue); self.numberCounter.setValue(self.storeValue); @@ -185,7 +184,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { var checked = this.getSearcher().hasChecked(); var val = { type: BI.Selection.Multi, - value: checked ? {1: 1} : {} + value: checked ? { 1: 1 } : {} }; this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None); self.numberCounter.setButtonChecked(val); @@ -197,7 +196,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { return; } if (change === true) { - self.storeValue = {value: self.combo.getValue()}; + self.storeValue = { value: self.combo.getValue() }; change = false; } self.combo.setValue(self.storeValue); @@ -212,9 +211,9 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { } else { if (isPopupView()) { self._stopEditing(); - self.storeValue = {value: self.combo.getValue()}; + self.storeValue = { value: self.combo.getValue() }; if (clear === true) { - self.storeValue = {value: {}}; + self.storeValue = { value: {} }; } self.fireEvent(BI.MultiTreeInsertCombo.EVENT_CONFIRM); } @@ -223,21 +222,6 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { change = false; }); - var triggerBtn = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.height, - height: o.height, - cls: "multi-select-trigger-icon-button" - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - self.numberCounter.hideView(); - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - this.numberCounter = BI.createWidget({ type: "bi.multi_select_check_selected_switcher", el: { @@ -300,11 +284,6 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { right: 0, top: 0, bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 }, { el: { type: "bi.vertical_adapt", @@ -322,7 +301,7 @@ BI.MultiTreeInsertCombo = BI.inherit(BI.Single, { this.numberCounter.setButtonChecked(this.storeValue); }, - _stopEditing: function() { + _stopEditing: function () { this.trigger.stopEditing(); this.numberCounter.hideView(); }, diff --git a/src/widget/multitree/multi.tree.list.combo.js b/src/widget/multitree/multi.tree.list.combo.js index ff5a2864a..2a378b1ae 100644 --- a/src/widget/multitree/multi.tree.list.combo.js +++ b/src/widget/multitree/multi.tree.list.combo.js @@ -23,7 +23,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { var isInit = false; var want2showCounter = false; - this.storeValue = {value: o.value || []}; + this.storeValue = { value: o.value || [] }; this.trigger = BI.createWidget({ type: "bi.multi_select_trigger", @@ -74,7 +74,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { itemsCreator: o.itemsCreator } }, - value: {value: o.value || {}} + value: { value: o.value || {} } }); @@ -139,10 +139,9 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { maxWidth: o.isNeedAdjustWidth ? "auto" : 500, }, isNeedAdjustWidth: o.isNeedAdjustWidth, - value: {value: o.value || {}}, + value: { value: o.value || {} }, hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0 && - self.numberCounter.element.find(e.target).length === 0; + return self.numberCounter.element.find(e.target).length === 0; } }); @@ -165,12 +164,12 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { }); this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { - self.storeValue = {value: self.combo.getValue()}; + self.storeValue = { value: self.combo.getValue() }; this.setValue(self.storeValue); self.numberCounter.setValue(self.storeValue); }); this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { - self.storeValue = {value: this.getValue()}; + self.storeValue = { value: this.getValue() }; self.combo.setValue(self.storeValue); self.numberCounter.setValue(self.storeValue); BI.nextTick(function () { @@ -185,11 +184,11 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { self.fireEvent(BI.MultiTreeListCombo.EVENT_SEARCHING); }); - function showCounter () { + function showCounter() { if (isSearching()) { - self.storeValue = {value: self.trigger.getValue()}; + self.storeValue = { value: self.trigger.getValue() }; } else if (isPopupView()) { - self.storeValue = {value: self.combo.getValue()}; + self.storeValue = { value: self.combo.getValue() }; } self.trigger.setValue(self.storeValue); self.numberCounter.setValue(self.storeValue); @@ -203,7 +202,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { var checked = this.getSearcher().hasChecked(); var val = { type: BI.Selection.Multi, - value: checked ? {1: 1} : {} + value: checked ? { 1: 1 } : {} }; this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None); self.numberCounter.setButtonChecked(val); @@ -215,7 +214,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { return; } if (change === true) { - self.storeValue = {value: self.combo.getValue()}; + self.storeValue = { value: self.combo.getValue() }; change = false; } self.combo.setValue(self.storeValue); @@ -230,9 +229,9 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { } else { if (isPopupView()) { self._stopEditing(); - self.storeValue = {value: self.combo.getValue()}; + self.storeValue = { value: self.combo.getValue() }; if (clear === true) { - self.storeValue = {value: []}; + self.storeValue = { value: [] }; } self.fireEvent(BI.MultiTreeListCombo.EVENT_CONFIRM); } @@ -241,21 +240,6 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { change = false; }); - var triggerBtn = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.height, - height: o.height, - cls: "multi-select-trigger-icon-button" - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - self.numberCounter.hideView(); - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - this.numberCounter = BI.createWidget({ type: "bi.multi_select_check_selected_switcher", el: { @@ -318,11 +302,6 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { right: 0, top: 0, bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 }, { el: { type: "bi.vertical_adapt", @@ -340,7 +319,7 @@ BI.MultiTreeListCombo = BI.inherit(BI.Single, { this.numberCounter.setButtonChecked(this.storeValue); }, - _stopEditing: function() { + _stopEditing: function () { this.trigger.stopEditing(); this.numberCounter.hideView(); }, From fe3c4c5697ef6d18b2df6e7854e4fb94678ccb29 Mon Sep 17 00:00:00 2001 From: zsmj Date: Thu, 23 Jun 2022 17:23:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?KERNEL-11647=20feat:=20=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86trigger=E6=8C=89=E9=92=AE=E4=BA=A4=E4=BA=92=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA=E7=9A=84=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../combo/searchtextvaluecombo/trigger.searchtextvalue.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js b/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js index 3344d1804..c61093b35 100644 --- a/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js +++ b/src/case/combo/searchtextvaluecombo/trigger.searchtextvalue.js @@ -24,7 +24,10 @@ BI.SearchTextValueTrigger = BI.inherit(BI.Trigger, { }, width: o.height, height: o.height, - width: 24, + stopPropagation: true, + handler: function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.TOGGLE); + } }; var stateText = this._digest(o.value, o.items) || o.text;