diff --git a/changelog.md b/changelog.md index 6ec4a48f80..fd2f417506 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 e73d36e1cc..4880c5df7e 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 10faf902ce..81045f049a 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 bbc9a61d82..a9e56c9c1d 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 daf32aa20a..70e1ab405a 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 c3228e886a..f09c8cf86d 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 d79502f941..1d4db73858 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 4dacd5091d..9cf47dea9f 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 dbcfabdc2f..60ba6990f7 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 5945801df8..4d80b649d5 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 dbdf670bcd..236b58cf56 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 b786eee8ca..d90a588eb8 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 c6a808d6c2..d02ecce5d6 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 39c81602f0..1eefcd4854 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(); },