From d161133498a13eaaf615aa49c0a5c32ce03eb462 Mon Sep 17 00:00:00 2001 From: "Jimmy.Chai" Date: Mon, 29 Jul 2024 20:44:30 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-18940=20refactor:=20=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=92=8C=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../multiselect/multiselect.insert.combo.js | 13 ++++++++++++- .../multiselect/multiselect.insert.trigger.js | 2 +- .../widget/multiselect/multiselect.trigger.js | 2 +- .../trigger/searcher.multiselect.insert.js | 4 ++++ .../src/widget/multitree/multi.tree.combo.js | 18 +++++++++++++++--- .../multitree/trigger/searcher.multi.tree.js | 4 ++++ .../singleselect/singleselect.insert.combo.js | 18 ++++++++++++++++-- .../trigger/searcher.singleselect.js | 4 ++++ 8 files changed, 57 insertions(+), 8 deletions(-) diff --git a/packages/fineui/src/widget/multiselect/multiselect.insert.combo.js b/packages/fineui/src/widget/multiselect/multiselect.insert.combo.js index 0e41b1b10..4cf2d8dfd 100644 --- a/packages/fineui/src/widget/multiselect/multiselect.insert.combo.js +++ b/packages/fineui/src/widget/multiselect/multiselect.insert.combo.js @@ -47,6 +47,7 @@ export class MultiSelectInsertCombo extends Single { static REQ_GET_ALL_DATA = "-1"; static EVENT_FOCUS = "EVENT_FOCUS"; static EVENT_BLUR = "EVENT_BLUR"; + static EVENT_START = "EVENT_START"; static EVENT_STOP = "EVENT_STOP"; static EVENT_SEARCHING = "EVENT_SEARCHING"; static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM"; @@ -64,6 +65,8 @@ export class MultiSelectInsertCombo extends Single { height: 24, itemHeight: SIZE_CONSANTS.LIST_ITEM_HEIGHT, allowEdit: true, + popup: {}, + masker: {}, }); } @@ -99,6 +102,8 @@ export class MultiSelectInsertCombo extends Single { this.trigger = createWidget({ type: MultiSelectInsertTrigger.xtype, + popup: o.popup, + masker: o.masker, allowEdit: o.allowEdit, height: toPix(o.height, o.simple ? 1 : 2), text: o.text, @@ -124,6 +129,7 @@ export class MultiSelectInsertCombo extends Single { this.trigger.on(MultiSelectInsertTrigger.EVENT_START, function() { self._setStartValue(""); this.getSearcher().setValue(self.storeValue); + self.fireEvent(MultiSelectInsertCombo.EVENT_START); }); this.trigger.on(MultiSelectInsertTrigger.EVENT_STOP, () => { self._setStartValue(""); @@ -249,7 +255,8 @@ export class MultiSelectInsertCombo extends Single { hideChecker(e) { return ( triggerBtn.element.find(e.target).length === 0 && - size(self.numberCounter.getView()?.element.find(e.target)) === 0 + size(self.numberCounter.getView()?.element.find(e.target)) === 0 && + size(self.trigger.getSearcher().getSearcher().getView()?.element.find(e.target)) === 0 ); }, }); @@ -570,4 +577,8 @@ export class MultiSelectInsertCombo extends Single { getNumberCounter() { return this.numberCounter; } + + getTrigger() { + return this.trigger; + } } diff --git a/packages/fineui/src/widget/multiselect/multiselect.insert.trigger.js b/packages/fineui/src/widget/multiselect/multiselect.insert.trigger.js index b7be3abf6..d292971c0 100644 --- a/packages/fineui/src/widget/multiselect/multiselect.insert.trigger.js +++ b/packages/fineui/src/widget/multiselect/multiselect.insert.trigger.js @@ -50,7 +50,7 @@ export class MultiSelectInsertTrigger extends Trigger { itemFormatter: o.itemFormatter, itemHeight: o.itemHeight, watermark: o.watermark, - popup: {}, + popup: o.popup, adapter: o.adapter, masker: o.masker, value: o.value, diff --git a/packages/fineui/src/widget/multiselect/multiselect.trigger.js b/packages/fineui/src/widget/multiselect/multiselect.trigger.js index d0666731d..8bfcfb6f7 100644 --- a/packages/fineui/src/widget/multiselect/multiselect.trigger.js +++ b/packages/fineui/src/widget/multiselect/multiselect.trigger.js @@ -50,7 +50,7 @@ export class MultiSelectTrigger extends Trigger { valueFormatter: o.valueFormatter, itemFormatter: o.itemFormatter, watermark: o.watermark, - popup: {}, + popup: o.popup, adapter: o.adapter, masker: o.masker, value: o.value, diff --git a/packages/fineui/src/widget/multiselect/trigger/searcher.multiselect.insert.js b/packages/fineui/src/widget/multiselect/trigger/searcher.multiselect.insert.js index 36d2cf184..cb948a7ac 100644 --- a/packages/fineui/src/widget/multiselect/trigger/searcher.multiselect.insert.js +++ b/packages/fineui/src/widget/multiselect/trigger/searcher.multiselect.insert.js @@ -132,6 +132,10 @@ export class MultiSelectInsertSearcher extends Widget { } } + getSearcher() { + return this.searcher; + } + adjustView() { this.searcher.adjustView(); } diff --git a/packages/fineui/src/widget/multitree/multi.tree.combo.js b/packages/fineui/src/widget/multitree/multi.tree.combo.js index cc8ab0e60..8edab4f41 100644 --- a/packages/fineui/src/widget/multitree/multi.tree.combo.js +++ b/packages/fineui/src/widget/multitree/multi.tree.combo.js @@ -27,6 +27,7 @@ export class MultiTreeCombo extends Single { static EVENT_FOCUS = "EVENT_FOCUS"; static EVENT_BLUR = "EVENT_BLUR"; + static EVENT_START = "EVENT_START"; static EVENT_STOP = "EVENT_STOP"; static EVENT_SEARCHING = "EVENT_SEARCHING"; static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM"; @@ -43,6 +44,8 @@ export class MultiTreeCombo extends Single { height: 24, allowEdit: true, isNeedAdjustWidth: true, + popup: {}, + masker: {}, }); } @@ -64,7 +67,9 @@ export class MultiTreeCombo extends Single { this.storeValue = { value: o.value || {} }; this.trigger = createWidget({ - type: "bi.multi_select_trigger", + type: MultiSelectTrigger.xtype, + popup: o.popup, + masker: o.masker, allowEdit: o.allowEdit, height: toPix(o.height, o.simple ? 1 : 2), valueFormatter: o.valueFormatter, @@ -75,7 +80,7 @@ export class MultiTreeCombo extends Single { return this.popup.getView(); }, searcher: { - type: "bi.multi_tree_searcher", + type: MultiTreeSearcher.xtype, itemsCreator: o.itemsCreator, listeners: [ { @@ -161,7 +166,9 @@ export class MultiTreeCombo extends Single { hideChecker(e) { return ( triggerBtn.element.find(e.target).length === 0 && - size(self.numberCounter.getView()?.element.find(e.target)) === 0 + size(self.numberCounter.getView()?.element.find(e.target)) === 0 && + size(self.trigger.getSearcher().getSearcher().getView()?.element.find(e.target)) === 0 && + self.trigger.getSearcher().getSearcher().getView()?.element[0] !== e.target ); }, }); @@ -188,6 +195,7 @@ export class MultiTreeCombo extends Single { self.storeValue = { value: self.combo.getValue() }; this.setValue(self.storeValue); self.numberCounter.setValue(self.storeValue); + self.fireEvent(MultiTreeCombo.EVENT_START); }); this.trigger.on(MultiSelectTrigger.EVENT_STOP, function () { self.storeValue = { value: this.getValue() }; @@ -442,4 +450,8 @@ export class MultiTreeCombo extends Single { getNumberCounter() { return this.numberCounter; } + + getTrigger() { + return this.trigger; + } } diff --git a/packages/fineui/src/widget/multitree/trigger/searcher.multi.tree.js b/packages/fineui/src/widget/multitree/trigger/searcher.multi.tree.js index 518dff408..972f8ac15 100644 --- a/packages/fineui/src/widget/multitree/trigger/searcher.multi.tree.js +++ b/packages/fineui/src/widget/multitree/trigger/searcher.multi.tree.js @@ -220,6 +220,10 @@ export class MultiTreeSearcher extends Widget { return this.editor.getState(); } + getSearcher() { + return this.searcher; + } + setValue(ob) { this.setState(ob); this.searcher.setValue(ob); diff --git a/packages/fineui/src/widget/singleselect/singleselect.insert.combo.js b/packages/fineui/src/widget/singleselect/singleselect.insert.combo.js index 5bf6dc855..8b07ee6ec 100644 --- a/packages/fineui/src/widget/singleselect/singleselect.insert.combo.js +++ b/packages/fineui/src/widget/singleselect/singleselect.insert.combo.js @@ -10,7 +10,8 @@ import { isNotNull, nextTick, AbsoluteLayout, - makeObject + makeObject, + size } from "@/core"; import { Single, Combo } from "@/base"; import { SingleSelectTrigger } from "./singleselect.trigger"; @@ -25,6 +26,7 @@ export class SingleSelectInsertCombo extends Single { static REQ_GET_ALL_DATA = -1; static EVENT_FOCUS = "EVENT_FOCUS"; static EVENT_BLUR = "EVENT_BLUR"; + static EVENT_START = "EVENT_START"; static EVENT_STOP = "EVENT_STOP"; static EVENT_SEARCHING = "EVENT_SEARCHING"; static EVENT_CLICK_ITEM = "EVENT_CLICK_ITEM"; @@ -41,6 +43,8 @@ export class SingleSelectInsertCombo extends Single { height: 24, allowEdit: true, watermark: i18nText("BI-Basic_Search_And_Patch_Paste"), + popup: {}, + masker: {}, }); } @@ -58,6 +62,7 @@ export class SingleSelectInsertCombo extends Single { this.trigger = createWidget({ type: SingleSelectTrigger.xtype, + masker: o.masker, watermark: o.watermark, height: toPix(o.height, o.simple ? 1 : 2), allowNoSelect: o.allowNoSelect, @@ -78,6 +83,7 @@ export class SingleSelectInsertCombo extends Single { searcher: { popup: { type: SingleSelectSearchInsertPane.xtype, + ...o.popup, }, }, }); @@ -92,6 +98,7 @@ export class SingleSelectInsertCombo extends Single { this.trigger.on(SingleSelectTrigger.EVENT_START, function () { self._setStartValue(); this.getSearcher().setValue(self.storeValue); + self.fireEvent(SingleSelectInsertCombo.EVENT_START); }); this.trigger.on(SingleSelectTrigger.EVENT_STOP, () => { self._setStartValue(); @@ -160,7 +167,10 @@ export class SingleSelectInsertCombo extends Single { ...o.popup, }, hideChecker(e) { - return triggerBtn.element.find(e.target).length === 0; + return ( + triggerBtn.element.find(e.target).length === 0 && + size(self.trigger.getSearcher().getSearcher().getView()?.element.find(e.target)) === 0 + ); }, value: o.value, }); @@ -268,4 +278,8 @@ export class SingleSelectInsertCombo extends Single { getPopup() { return this.popup; } + + getTrigger() { + return this.trigger; + } } diff --git a/packages/fineui/src/widget/singleselect/trigger/searcher.singleselect.js b/packages/fineui/src/widget/singleselect/trigger/searcher.singleselect.js index 31ebc6f67..c9df1bde1 100644 --- a/packages/fineui/src/widget/singleselect/trigger/searcher.singleselect.js +++ b/packages/fineui/src/widget/singleselect/trigger/searcher.singleselect.js @@ -131,6 +131,10 @@ export class SingleSelectSearcher extends Widget { return this.searcher.getView() && this.searcher.getView().hasChecked(); } + getSearcher() { + return this.searcher; + } + setAdapter(adapter) { this.searcher.setAdapter(adapter); }