From 22ccfcbbee60ecb6726543c351e833b22b8322d1 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 13 Aug 2020 17:36:39 +0800 Subject: [PATCH] BI-70667 fix: --- changelog.md | 1 + src/widget/multiselect/multiselect.combo.js | 2 +- .../multiselect/multiselect.combo.nobar.js | 6 +++--- .../multiselect/multiselect.insert.combo.js | 6 +++--- .../multiselect.insert.combo.nobar.js | 6 +++--- .../search/multiselect.search.insert.pane.js | 16 +++++++++++++++- .../search/multiselect.search.pane.js | 16 +++++++++++++++- .../trigger/searcher.multiselect.insert.js | 4 ++++ .../multiselect/trigger/searcher.multiselect.js | 4 ++++ .../search/singleselect.search.pane.insert.js | 16 +++++++++++++++- .../search/singleselect.search.pane.js | 16 +++++++++++++++- src/widget/singleselect/singleselect.combo.js | 2 +- .../singleselect/singleselect.insert.combo.js | 2 +- .../trigger/searcher.singleselect.js | 4 ++++ 14 files changed, 85 insertions(+), 16 deletions(-) diff --git a/changelog.md b/changelog.md index 6ec4a48f8..fd2f41750 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-08) +- 修复了复选下拉系列'点按空格添加完全匹配项'添加的是显示值而非实际值的问题 - search_text_value_combo支持水印 - BI.makeObject 方法支持传入iteratee diff --git a/src/widget/multiselect/multiselect.combo.js b/src/widget/multiselect/multiselect.combo.js index e73d36e1c..4880c5df7 100644 --- a/src/widget/multiselect/multiselect.combo.js +++ b/src/widget/multiselect/multiselect.combo.js @@ -80,7 +80,7 @@ BI.MultiSelectCombo = BI.inherit(BI.Single, { }); this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { if (this.getSearcher().hasMatched()) { - var keyword = this.getSearcher().getKeyword(); + var keyword = this.getSearcher().getMatchedItemValue(); self._join({ type: BI.Selection.Multi, value: [keyword] diff --git a/src/widget/multiselect/multiselect.combo.nobar.js b/src/widget/multiselect/multiselect.combo.nobar.js index 10faf902c..81045f049 100644 --- a/src/widget/multiselect/multiselect.combo.nobar.js +++ b/src/widget/multiselect/multiselect.combo.nobar.js @@ -80,7 +80,7 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, { }); this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { if (this.getSearcher().hasMatched()) { - self._addItem(assertShowValue); + self._addItem(assertShowValue, true); } }); @@ -277,9 +277,9 @@ BI.MultiSelectNoBarCombo = BI.inherit(BI.Single, { }); }, - _addItem: function (assertShowValue) { + _addItem: function (assertShowValue, matched) { var self = this; - var keyword = this.trigger.getSearcher().getKeyword(); + var keyword = matched ? this.trigger.getSearcher().getMatchedItemValue() : this.trigger.getSearcher().getKeyword(); this._join({ type: BI.Selection.Multi, value: [keyword] diff --git a/src/widget/multiselect/multiselect.insert.combo.js b/src/widget/multiselect/multiselect.insert.combo.js index bbc9a61d8..a9e56c9c1 100644 --- a/src/widget/multiselect/multiselect.insert.combo.js +++ b/src/widget/multiselect/multiselect.insert.combo.js @@ -77,7 +77,7 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, { }); this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_PAUSE, function () { if (this.getSearcher().hasMatched()) { - self._addItem(assertShowValue); + self._addItem(assertShowValue, true); } }); this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM, function () { @@ -289,9 +289,9 @@ BI.MultiSelectInsertCombo = BI.inherit(BI.Single, { }); }, - _addItem: function (assertShowValue) { + _addItem: function (assertShowValue, matched) { var self = this; - var keyword = this.trigger.getSearcher().getKeyword(); + var keyword = matched ? this.trigger.getSearcher().getMatchedItemValue() : this.trigger.getSearcher().getKeyword(); this._join({ type: BI.Selection.Multi, value: [keyword] diff --git a/src/widget/multiselect/multiselect.insert.combo.nobar.js b/src/widget/multiselect/multiselect.insert.combo.nobar.js index daf32aa20..70e1ab405 100644 --- a/src/widget/multiselect/multiselect.insert.combo.nobar.js +++ b/src/widget/multiselect/multiselect.insert.combo.nobar.js @@ -72,7 +72,7 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, { }); this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_PAUSE, function () { if (this.getSearcher().hasMatched()) { - self._addItem(assertShowValue); + self._addItem(assertShowValue, true); } }); this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM, function () { @@ -285,9 +285,9 @@ BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, { }); }, - _addItem: function (assertShowValue) { + _addItem: function (assertShowValue, matched) { var self = this; - var keyword = this.trigger.getSearcher().getKeyword(); + var keyword = matched ? this.trigger.getSearcher().getMatchedItemValue() : this.trigger.getSearcher().getKeyword(); this._join({ type: BI.Selection.Multi, value: [keyword] diff --git a/src/widget/multiselect/search/multiselect.search.insert.pane.js b/src/widget/multiselect/search/multiselect.search.insert.pane.js index c3228e886..f09c8cf86 100644 --- a/src/widget/multiselect/search/multiselect.search.insert.pane.js +++ b/src/widget/multiselect/search/multiselect.search.insert.pane.js @@ -78,7 +78,7 @@ BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, { setKeyword: function (keyword) { var o = this.options; var hasSameValue = BI.some(this.loader.getAllButtons(), function (idx, btn) { - return keyword === btn.getValue(); + return keyword === (o.valueFormatter(btn.getValue()) || btn.getValue()); }); var isMatchTipVisible = this.loader.getAllButtons().length > 0 && hasSameValue; this.tooltipClick.setVisible(isMatchTipVisible); @@ -86,6 +86,20 @@ BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, { !isMatchTipVisible && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword)); }, + getMatchedItemValue: function () { + var value; + var o = this.options; + BI.some(this.loader.getAllButtons(), function (idx, btn) { + var v = btn.getValue(); + if (o.keywordGetter() === (o.valueFormatter(v) || v)) { + value = v; + return true; + } + }); + + return value; + }, + isAllSelected: function () { return this.loader.isAllSelected(); }, diff --git a/src/widget/multiselect/search/multiselect.search.pane.js b/src/widget/multiselect/search/multiselect.search.pane.js index d79502f94..1d4db7385 100644 --- a/src/widget/multiselect/search/multiselect.search.pane.js +++ b/src/widget/multiselect/search/multiselect.search.pane.js @@ -65,7 +65,7 @@ BI.MultiSelectSearchPane = BI.inherit(BI.Widget, { setKeyword: function (keyword) { var btn, o = this.options; - var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && keyword === btn.getValue(); + var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === (o.valueFormatter(btn.getValue()) || btn.getValue())); if (isVisible !== this.tooltipClick.isVisible()) { this.tooltipClick.setVisible(isVisible); this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0); @@ -73,6 +73,20 @@ BI.MultiSelectSearchPane = BI.inherit(BI.Widget, { } }, + getMatchedItemValue: function () { + var value; + var o = this.options; + BI.some(this.loader.getAllButtons(), function (idx, btn) { + var v = btn.getValue(); + if (o.keywordGetter() === (o.valueFormatter(v) || v)) { + value = v; + return true; + } + }); + + return value; + }, + isAllSelected: function () { return this.loader.isAllSelected(); }, diff --git a/src/widget/multiselect/trigger/searcher.multiselect.insert.js b/src/widget/multiselect/trigger/searcher.multiselect.insert.js index 4dacd5091..9cf47dea9 100644 --- a/src/widget/multiselect/trigger/searcher.multiselect.insert.js +++ b/src/widget/multiselect/trigger/searcher.multiselect.insert.js @@ -167,6 +167,10 @@ BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, { } }, + getMatchedItemValue: function() { + return this.searcher.getView().getMatchedItemValue(); + }, + getState: function() { return this.editor.getState(); }, diff --git a/src/widget/multiselect/trigger/searcher.multiselect.js b/src/widget/multiselect/trigger/searcher.multiselect.js index dbcfabdc2..60ba6990f 100644 --- a/src/widget/multiselect/trigger/searcher.multiselect.js +++ b/src/widget/multiselect/trigger/searcher.multiselect.js @@ -94,6 +94,10 @@ BI.MultiSelectSearcher = BI.inherit(BI.Widget, { } }, + getMatchedItemValue: function() { + return this.searcher.getView().getMatchedItemValue(); + }, + adjustView: function () { this.searcher.adjustView(); }, diff --git a/src/widget/singleselect/search/singleselect.search.pane.insert.js b/src/widget/singleselect/search/singleselect.search.pane.insert.js index 5945801df..4d80b649d 100644 --- a/src/widget/singleselect/search/singleselect.search.pane.insert.js +++ b/src/widget/singleselect/search/singleselect.search.pane.insert.js @@ -80,7 +80,7 @@ BI.SingleSelectSearchInsertPane = BI.inherit(BI.Widget, { setKeyword: function (keyword) { var o = this.options; var hasSameValue = BI.some(this.loader.getAllButtons(), function (idx, btn) { - return keyword === btn.getValue(); + return keyword === (o.valueFormatter(btn.getValue()) || btn.getValue()); }); var isMatchTipVisible = this.loader.getAllButtons().length > 0 && hasSameValue; this.tooltipClick.setVisible(isMatchTipVisible); @@ -88,6 +88,20 @@ BI.SingleSelectSearchInsertPane = BI.inherit(BI.Widget, { !isMatchTipVisible && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword)); }, + getMatchedItemValue: function () { + var value; + var o = this.options; + BI.some(this.loader.getAllButtons(), function (idx, btn) { + var v = btn.getValue(); + if (o.keywordGetter() === (o.valueFormatter(v) || v)) { + value = v; + return true; + } + }); + + return value; + }, + hasMatched: function () { return this.tooltipClick.isVisible(); }, diff --git a/src/widget/singleselect/search/singleselect.search.pane.js b/src/widget/singleselect/search/singleselect.search.pane.js index dbdf670bc..236b58cf5 100644 --- a/src/widget/singleselect/search/singleselect.search.pane.js +++ b/src/widget/singleselect/search/singleselect.search.pane.js @@ -67,7 +67,7 @@ BI.SingleSelectSearchPane = BI.inherit(BI.Widget, { setKeyword: function (keyword) { var btn, o = this.options; - var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && keyword === btn.getValue(); + var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === (o.valueFormatter(btn.getValue()) || btn.getValue())); if (isVisible !== this.tooltipClick.isVisible()) { this.tooltipClick.setVisible(isVisible); this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0); @@ -75,6 +75,20 @@ BI.SingleSelectSearchPane = BI.inherit(BI.Widget, { } }, + getMatchedItemValue: function () { + var value; + var o = this.options; + BI.some(this.loader.getAllButtons(), function (idx, btn) { + var v = btn.getValue(); + if (o.keywordGetter() === (o.valueFormatter(v) || v)) { + value = v; + return true; + } + }); + + return value; + }, + hasMatched: function () { return this.tooltipClick.isVisible(); }, diff --git a/src/widget/singleselect/singleselect.combo.js b/src/widget/singleselect/singleselect.combo.js index b786eee8c..d90a588eb 100644 --- a/src/widget/singleselect/singleselect.combo.js +++ b/src/widget/singleselect/singleselect.combo.js @@ -68,7 +68,7 @@ BI.SingleSelectCombo = BI.inherit(BI.Single, { }); this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () { if (this.getSearcher().hasMatched()) { - var keyword = this.getSearcher().getKeyword(); + var keyword = this.getSearcher().getMatchedItemValue(); self.combo.setValue(self.storeValue); self._setStartValue(keyword); assertShowValue(); diff --git a/src/widget/singleselect/singleselect.insert.combo.js b/src/widget/singleselect/singleselect.insert.combo.js index c6a808d6c..d02ecce5d 100644 --- a/src/widget/singleselect/singleselect.insert.combo.js +++ b/src/widget/singleselect/singleselect.insert.combo.js @@ -83,7 +83,7 @@ BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { }); this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () { if (this.getSearcher().hasMatched()) { - var keyword = this.getSearcher().getKeyword(); + var keyword = this.getSearcher().getMatchedItemValue(); self.storeValue = keyword; self.combo.setValue(self.storeValue); self._setStartValue(keyword); diff --git a/src/widget/singleselect/trigger/searcher.singleselect.js b/src/widget/singleselect/trigger/searcher.singleselect.js index 39c81602f..1eefcd485 100644 --- a/src/widget/singleselect/trigger/searcher.singleselect.js +++ b/src/widget/singleselect/trigger/searcher.singleselect.js @@ -95,6 +95,10 @@ BI.SingleSelectSearcher = BI.inherit(BI.Widget, { } }, + getMatchedItemValue: function() { + return this.searcher.getView().getMatchedItemValue(); + }, + adjustView: function () { this.searcher.adjustView(); },