From 3169fa9e8714ce0a098b4f174be9f103ea41d4d3 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 4 Jun 2020 18:24:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?BI-66372=20fix:=20=E5=8D=95=E9=80=89?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=94=AF=E6=8C=81=E6=96=B0=E5=A2=9E=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + .../singleselect/singleselectlist.insert.js | 40 ++++++++++++++----- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/changelog.md b/changelog.md index 8e588c8e5..570603d63 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-06) +- 单选列表支持新增选项 - 增加组件shortcut未定义的错误提示 2.0(2020-05) diff --git a/src/widget/singleselect/singleselectlist.insert.js b/src/widget/singleselect/singleselectlist.insert.js index 6b580d1e6..e1e046954 100644 --- a/src/widget/singleselect/singleselectlist.insert.js +++ b/src/widget/singleselect/singleselectlist.insert.js @@ -43,7 +43,7 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { }); this.searcherPane = BI.createWidget({ - type: "bi.single_select_search_pane", + type: "bi.single_select_search_insert_pane", allowNoSelect: o.allowNoSelect, cls: "bi-border-left bi-border-right bi-border-bottom", valueFormatter: o.valueFormatter, @@ -54,7 +54,22 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { op.keywords = [self.trigger.getKeyword()]; this.setKeyword(op.keywords[0]); o.itemsCreator(op, callback); - } + }, + listeners: [{ + eventName: BI.SingleSelectSearchInsertPane.EVENT_ADD_ITEM, + action: function () { + var keyword = self.trigger.getKeyword(); + if (!self.trigger.hasMatched()) { + self.storeValue = keyword; + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self.adapter.populate(); + if (self.storeValue.type === BI.Selection.Multi) { + self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); + } + } + } + }] }); this.searcherPane.setVisible(false); @@ -91,14 +106,19 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { eventName: BI.Searcher.EVENT_PAUSE, action: function () { var keyword = this.getKeyword(); - self.storeValue = keyword; - self._showAdapter(); - self.adapter.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(); - self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); + if (this.hasMatched()) { + self.storeValue = keyword; + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(); + self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); + } else { + self._showAdapter(); + } + } }, { eventName: BI.Searcher.EVENT_SEARCHING, From 0f70b1c9f7d638036ccec692d839768b87ffc5a2 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Thu, 4 Jun 2020 18:26:19 +0800 Subject: [PATCH 2/2] update --- src/widget/singleselect/singleselectlist.insert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget/singleselect/singleselectlist.insert.js b/src/widget/singleselect/singleselectlist.insert.js index e1e046954..b588aec7b 100644 --- a/src/widget/singleselect/singleselectlist.insert.js +++ b/src/widget/singleselect/singleselectlist.insert.js @@ -65,7 +65,7 @@ BI.SingleSelectInsertList = BI.inherit(BI.Single, { self.adapter.setValue(self.storeValue); self.adapter.populate(); if (self.storeValue.type === BI.Selection.Multi) { - self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); + self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); } } }