From d69064aecc92c42829c56587aefba1835c43e24f Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 20 Mar 2020 17:55:36 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-28558=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BA=86=E8=BF=9E=E7=BB=AD=E5=A4=9A=E6=AC=A1=E8=B0=83=E7=94=A8?= =?UTF-8?q?BI.Msg.alert=E5=90=8E=E5=8F=AA=E6=9C=89=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E5=BC=B9=E5=87=BA=E7=9A=84=E5=8F=AF=E4=BB=A5=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20&&=20=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 1 + src/base/foundation/message.js | 18 +++++--- src/base/grid/__test__/grid.test.js | 41 +++++++++++++++++++ .../farbtastic/__test__/farbtastic.test.js | 21 ++++++++++ src/case/pager/__test__/pager.test.js | 16 ++++++++ 5 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 src/base/grid/__test__/grid.test.js create mode 100644 src/case/colorchooser/farbtastic/__test__/farbtastic.test.js diff --git a/changelog.md b/changelog.md index 5f35acd189..0116c51ab2 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,6 @@ # 更新日志 2.0(2020-03) +- 修复了连续多次调用BI.Msg.alert后只有最后弹出的可以关闭的问题 - 修复了time_combo设置格式为%M:%S后value设置大于30分钟的值时标红的问题 - 复选下拉树系列展开节点性能优化 diff --git a/src/base/foundation/message.js b/src/base/foundation/message.js index 8dbbca146e..c2a96e0ccd 100644 --- a/src/base/foundation/message.js +++ b/src/base/foundation/message.js @@ -5,7 +5,9 @@ */ BI.Msg = function () { - var messageShow, $mask, $pop; + var $mask, $pop; + + var messageShows = []; var toastStack = []; @@ -67,7 +69,7 @@ BI.Msg = function () { }, 5000); }, _show: function (hasCancel, title, message, callback) { - $mask = BI.Widget._renderEngine.createElement("
").css({ + BI.isNull($mask) && ($mask = BI.Widget._renderEngine.createElement("
").css({ position: "absolute", zIndex: BI.zIndex_tip - 2, top: 0, @@ -75,7 +77,7 @@ BI.Msg = function () { right: 0, bottom: 0, opacity: 0.5 - }).appendTo("body"); + }).appendTo("body")); $pop = BI.Widget._renderEngine.createElement("
").css({ position: "absolute", zIndex: BI.zIndex_tip - 1, @@ -85,8 +87,12 @@ BI.Msg = function () { bottom: 0 }).appendTo("body"); var close = function () { - messageShow.destroy(); - $mask.remove(); + messageShows[messageShows.length - 1].destroy(); + messageShows.pop(); + if (messageShows.length === 0) { + $mask.remove(); + $mask = null; + } }; var controlItems = []; if (hasCancel === true) { @@ -191,7 +197,7 @@ BI.Msg = function () { ] }; - messageShow = BI.createWidget(conf); + messageShows[messageShows.length] = BI.createWidget(conf); } }; }(); \ No newline at end of file diff --git a/src/base/grid/__test__/grid.test.js b/src/base/grid/__test__/grid.test.js new file mode 100644 index 0000000000..d65c3d24cd --- /dev/null +++ b/src/base/grid/__test__/grid.test.js @@ -0,0 +1,41 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/20 + */ +describe("GridTest", function () { + + /** + * test_author_windy + */ + it("grid", function () { + var items = []; + var rowCount = 1000, columnCount = 100; + for (var i = 0; i < rowCount; i++) { + items[i] = []; + for (var j = 0; j < columnCount; j++) { + items[i][j] = { + type: "bi.label", + text: i + "-" + j + }; + } + } + var grid = BI.createWidget({ + type: "bi.grid_view", + width: 400, + height: 300, + estimatedRowSize: 30, + estimatedColumnSize: 100, + items: items, + scrollTop: 100, + rowHeightGetter: function () { + return 30; + }, + columnWidthGetter: function () { + return 100; + } + }); + // TODO 性能展示类控件,不知道要测啥,标记一下 + grid.destroy(); + }); +}); \ No newline at end of file diff --git a/src/case/colorchooser/farbtastic/__test__/farbtastic.test.js b/src/case/colorchooser/farbtastic/__test__/farbtastic.test.js new file mode 100644 index 0000000000..b3703d908c --- /dev/null +++ b/src/case/colorchooser/farbtastic/__test__/farbtastic.test.js @@ -0,0 +1,21 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/3/20 + */ +describe("FarbtasticTest", function () { + + /** + * test_author_windy + */ + it("Farbtastic", function () { + var a = BI.Test.createWidget({ + type: "bi.farbtastic", + height: 200, + width: 200 + }); + a.setValue("#d56c6c"); + expect(a.getValue()).to.equal("#d56c6c"); + a.destroy(); + }); +}); \ No newline at end of file diff --git a/src/case/pager/__test__/pager.test.js b/src/case/pager/__test__/pager.test.js index 257e79272e..a0904109e2 100644 --- a/src/case/pager/__test__/pager.test.js +++ b/src/case/pager/__test__/pager.test.js @@ -78,4 +78,20 @@ describe("PagerTest", function () { a.clear(); a.destroy(); }); + + /** + * test_author_windy + */ + it("detail_Pager", function () { + var a = BI.Test.createWidget({ + type: "bi.detail_pager", + pages: 100 + }); + a.setAllPages(200); + a.populate(); + a.setValue(200); + expect(a.hasPrev(200)).to.equal(true); + expect(a.hasNext(200)).to.equal(false); + a.destroy(); + }); }); \ No newline at end of file