From bdc125a16f6cae9a1daeb2f13d59b6802e8299c2 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 13 Apr 2020 15:54:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?BI-61182=20test:=20=E5=8D=95=E6=B5=8B=20&&?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8Dvirtual=5Flist=20populate=E6=97=A0?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 2 + src/base/list/virtuallist.js | 2 +- .../__test__/timeinterval.test.js | 102 ++++++++++++++++-- .../__test__/yearmonthinterval.test.js | 44 +++++++- 4 files changed, 139 insertions(+), 11 deletions(-) diff --git a/changelog.md b/changelog.md index fe1e30a8a..10554c938 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ # 更新日志 2.0(2020-04) +- 修复了复选下拉列表初始化的时候发送执行两次itemsCreator的问题 +- 修复了virtual_list重新populate无效的问题 - 复选下拉框新增值的时候外抛事件 - 空格不再编码成  - 支持文本区域水印可滚动 diff --git a/src/base/list/virtuallist.js b/src/base/list/virtuallist.js index e5d996bcd..3eb51ab64 100644 --- a/src/base/list/virtuallist.js +++ b/src/base/list/virtuallist.js @@ -171,7 +171,7 @@ BI.VirtualList = BI.inherit(BI.Widget, { if (items && this.options.items !== items) { this.restore(); } - this._populate(); + this._populate(items); }, destroyed: function () { diff --git a/src/widget/timeinterval/__test__/timeinterval.test.js b/src/widget/timeinterval/__test__/timeinterval.test.js index 4ab9225a1..808c14547 100644 --- a/src/widget/timeinterval/__test__/timeinterval.test.js +++ b/src/widget/timeinterval/__test__/timeinterval.test.js @@ -10,28 +10,70 @@ describe("DateInterval", function () { * test_author_windy */ it("DateInterval_defaultValue", function () { + var dateInterval = BI.Test.createWidget({ + type: "bi.date_interval" + }); + dateInterval.setValue({ + start: { + type: 1, + value: { + year: 2018, + month: 1, + day: 12 + } + }, + end: { + type: 2, + value: { + year: -1, + position: 2 + } + } + }); + expect(dateInterval.element.find(".bi-date-trigger .bi-label").text()).to.equal("2018-01-122019-01-01"); + dateInterval.destroy(); + }); + + /** + * test_author_windy + */ + it("DateInterval_测试报错", function (done) { + var testText; var dateInterval = BI.Test.createWidget({ type: "bi.date_interval", value: { start: { - type: 1, + type: 2, value: { - year: 2018, - month: 1, - day: 12 + year: -1, + position: 2 } }, end: { - type: 2, + type: 1, value: { - year: -1, - position: 2 + year: 2018, + month: 1, + day: 12 } } }, + listeners: [{ + eventName: "EVENT_ERROR", + action: function () { + testText = "ERROR"; + } + }] }); - expect(dateInterval.element.find(".bi-date-trigger .bi-label").text()).to.equal("2018-01-122019-01-01"); - dateInterval.destroy(); + BI.nextTick(function () { + dateInterval.element.find(".first-element .bi-date-trigger .bi-basic-button").click(); + BI.delay(function () { + dateInterval.element.find(".first-element .bi-text-button:contains(确定)").click(); + expect(testText).to.equal("ERROR"); + dateInterval.destroy(); + done(); + }, 300); + }) }); /** @@ -98,4 +140,46 @@ describe("DateInterval", function () { }); dateInterval.destroy(); }); + + /** + * test_author_windy + */ + it("TimeInterval_测试报错", function (done) { + var testText; + var dateInterval = BI.Test.createWidget({ + type: "bi.time_interval", + value: { + start: { + type: 2, + value: { + year: -1, + position: 2 + } + }, + end: { + type: 1, + value: { + year: 2018, + month: 1, + day: 12 + } + } + }, + listeners: [{ + eventName: "EVENT_ERROR", + action: function () { + testText = "ERROR"; + } + }] + }); + BI.nextTick(function () { + dateInterval.element.find(".first-element .bi-date-time-trigger .bi-basic-button").click(); + BI.delay(function () { + dateInterval.element.find(".first-element .bi-text-button:contains(确定)").click(); + expect(testText).to.equal("ERROR"); + dateInterval.destroy(); + done(); + }, 300); + }) + }); }); \ No newline at end of file diff --git a/src/widget/yearmonthinterval/__test__/yearmonthinterval.test.js b/src/widget/yearmonthinterval/__test__/yearmonthinterval.test.js index 7e116f3af..fd8092caf 100644 --- a/src/widget/yearmonthinterval/__test__/yearmonthinterval.test.js +++ b/src/widget/yearmonthinterval/__test__/yearmonthinterval.test.js @@ -60,7 +60,7 @@ describe("YearMonthInterval", function () { */ it("setValue", function () { var dateCombo = BI.Test.createWidget({ - type: "bi.dynamic_year_month_combo", + type: "bi.year_month_interval", width: 220, height: 30 }); @@ -99,4 +99,46 @@ describe("YearMonthInterval", function () { dateCombo.destroy(); }); + + /** + * test_author_windy + */ + it("错误提示", function (done) { + var testText; + var dateCombo = BI.Test.createWidget({ + type: "bi.year_month_interval", + width: 220, + height: 30, + value: { + start: { + type: 2, + value: { + year: -1, + month: 1 + } + }, + end: { + type: 1, + value: { + year: 2018, + month: 1 + } + } + }, + listeners: [{ + eventName: "EVENT_ERROR", + action: function () { + testText = "ERROR" + } + }] + }); + dateCombo.element.find(".first-element .pull-down-font").click(); + BI.delay(function () { + dateCombo.element.find(".bi-text-button:contains(确定)").click(); + expect(testText).to.equal("ERROR"); + dateCombo.destroy(); + done(); + }, 300); + + }); }); \ No newline at end of file From 007b00c2c6d0b0afefd1a436b8858bc800e47b70 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Mon, 13 Apr 2020 15:55:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?BI-63192=20fix:=20=E4=BF=AE=E5=A4=8Dmulti?= =?UTF-8?q?=5Fselect=5Flist=E5=88=9D=E5=A7=8B=E5=8C=96=E4=B8=A4=E6=AC=A1it?= =?UTF-8?q?emsCreator=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widget/multiselectlist/multiselectlist.insert.js | 9 ++++++--- .../multiselectlist/multiselectlist.insert.nobar.js | 9 ++++++--- src/widget/multiselectlist/multiselectlist.js | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/widget/multiselectlist/multiselectlist.insert.js b/src/widget/multiselectlist/multiselectlist.insert.js index ea51fbf92..2c56a3ac2 100644 --- a/src/widget/multiselectlist/multiselectlist.insert.js +++ b/src/widget/multiselectlist/multiselectlist.insert.js @@ -46,9 +46,12 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, { return self.trigger.getKeyword(); }, itemsCreator: function (op, callback) { - op.keywords = [self.trigger.getKeyword()]; - this.setKeyword(op.keywords[0]); - o.itemsCreator(op, callback); + var keyword = self.trigger.getKeyword(); + if (BI.isNotEmptyString(keyword)) { + op.keywords = [keyword]; + this.setKeyword(op.keywords[0]); + o.itemsCreator(op, callback); + } }, listeners: [{ eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM, diff --git a/src/widget/multiselectlist/multiselectlist.insert.nobar.js b/src/widget/multiselectlist/multiselectlist.insert.nobar.js index 136aa51c5..04b29e09b 100644 --- a/src/widget/multiselectlist/multiselectlist.insert.nobar.js +++ b/src/widget/multiselectlist/multiselectlist.insert.nobar.js @@ -52,9 +52,12 @@ BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, { return self.trigger.getKeyword(); }, itemsCreator: function (op, callback) { - op.keywords = [self.trigger.getKeyword()]; - this.setKeyword(op.keywords[0]); - o.itemsCreator(op, callback); + var keyword = self.trigger.getKeyword(); + if (BI.isNotEmptyString(keyword)) { + op.keywords = [keyword]; + this.setKeyword(op.keywords[0]); + o.itemsCreator(op, callback); + } }, listeners: [{ eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM, diff --git a/src/widget/multiselectlist/multiselectlist.js b/src/widget/multiselectlist/multiselectlist.js index d364b6336..b0085f5d6 100644 --- a/src/widget/multiselectlist/multiselectlist.js +++ b/src/widget/multiselectlist/multiselectlist.js @@ -50,9 +50,12 @@ BI.MultiSelectList = BI.inherit(BI.Widget, { return self.trigger.getKeyword(); }, itemsCreator: function (op, callback) { - op.keywords = [self.trigger.getKeyword()]; - this.setKeyword(op.keywords[0]); - o.itemsCreator(op, callback); + var keyword = self.trigger.getKeyword(); + if (BI.isNotEmptyString(keyword)) { + op.keywords = [keyword]; + this.setKeyword(op.keywords[0]); + o.itemsCreator(op, callback); + } } }); this.searcherPane.setVisible(false);