diff --git a/demo/js/config/widget.js b/demo/js/config/widget.js index 0b6ddc771..c419b7ee8 100644 --- a/demo/js/config/widget.js +++ b/demo/js/config/widget.js @@ -142,14 +142,6 @@ Demo.WIDGET_CONFIG = [{ pId: 412, text: "bi.year_combo", value: "demo.year" -}, { - pId: 412, - text: "bi.month_combo", - value: "demo.month" -}, { - pId: 412, - text: "bi.quarter_combo", - value: "demo.quarter" }, { pId: 412, text: "bi.year_month_combo", diff --git a/demo/js/widget/month/demo.month.js b/demo/js/widget/month/demo.month.js deleted file mode 100644 index 0ab9551a0..000000000 --- a/demo/js/widget/month/demo.month.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Created by Dailer on 2017/7/11. - */ -Demo.Month = BI.inherit(BI.Widget, { - props: { - baseCls: "demo-exceltable" - }, - render: function () { - var self = this; - return { - type: "bi.horizontal_auto", - items: [{ - type: "bi.month_combo", - width: 300, - ref: function () { - self.monthcombo = this; - }, - value: 11 - }, { - type: "bi.button", - text: "getValue", - handler: function () { - BI.Msg.toast(JSON.stringify(self.monthcombo.getValue())); - }, - width: 300 - }, { - type: "bi.button", - text: "setValue : 11", - handler: function () { - self.monthcombo.setValue(11); - }, - width: 300 - }, { - type: "bi.label", - text: "月份value 范围为0-11,显示范围为1-12", - width: 300 - }], - vgap: 10 - }; - } -}); - -BI.shortcut("demo.month", Demo.Month); \ No newline at end of file diff --git a/demo/js/widget/quarter/demo.quarter.js b/demo/js/widget/quarter/demo.quarter.js deleted file mode 100644 index 49d02fe63..000000000 --- a/demo/js/widget/quarter/demo.quarter.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Created by Dailer on 2017/7/11. - */ -Demo.Quarter = BI.inherit(BI.Widget, { - props: { - baseCls: "demo-exceltable" - }, - render: function () { - var self = this; - return { - type: "bi.horizontal_auto", - items: [{ - type: "bi.quarter_combo", - width: 300, - ref: function () { - self.quartercombo = this; - }, - value: 3 - }, { - type: "bi.button", - text: "getValue", - handler: function () { - BI.Msg.toast(JSON.stringify(self.quartercombo.getValue())); - }, - width: 300 - }, { - type: "bi.button", - text: "setValue : 3", - handler: function () { - self.quartercombo.setValue(3); - }, - width: 300 - }], - vgap: 10 - }; - } -}); - -BI.shortcut("demo.quarter", Demo.Quarter); \ No newline at end of file diff --git a/src/widget/intervalslider/__test__/intervalslider.test.js b/src/widget/intervalslider/__test__/intervalslider.test.js index 1555af80a..3b7b3618d 100644 --- a/src/widget/intervalslider/__test__/intervalslider.test.js +++ b/src/widget/intervalslider/__test__/intervalslider.test.js @@ -33,4 +33,32 @@ describe("intervalSlider", function () { }); }); + + /** + * test_author_windy + */ + it("reset", function () { + var intervalSliderLabel = BI.Test.createWidget({ + type: "bi.interval_slider", + width: 300, + unit: "px", + cls: "layout-bg-white" + }); + intervalSliderLabel.setMinAndMax({ + min: 0, + max: 120 + }); + intervalSliderLabel.setValue({ + min: 10, + max: 120 + }); + intervalSliderLabel.reset(); + intervalSliderLabel.populate(); + expect(intervalSliderLabel.getValue()).eql({ + min: "", + max: "" + }); + intervalSliderLabel.destroy(); + }); + }); \ No newline at end of file diff --git a/src/widget/intervalslider/intervalslider.js b/src/widget/intervalslider/intervalslider.js index 71b9c95d4..7b7e197ac 100644 --- a/src/widget/intervalslider/intervalslider.js +++ b/src/widget/intervalslider/intervalslider.js @@ -298,7 +298,9 @@ BI.IntervalSlider = BI.inherit(BI.Single, { if (BI.isEmptyString(dotText)) { }else{ if (BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max)) { - if(o.digit === false) { + // 虽然规定了所填写的小数位数,但是我们认为所有的整数都是满足设置的小数位数的 + // 100等价于100.0 100.00 100.000 + if(o.digit === false || BI.isInteger(v)) { valid = true; }else{ dotText = dotText || ""; diff --git a/src/widget/year/__test__/combo.year.test.js b/src/widget/year/__test__/combo.year.test.js new file mode 100644 index 000000000..d04051890 --- /dev/null +++ b/src/widget/year/__test__/combo.year.test.js @@ -0,0 +1,246 @@ +/** + * @author windy + * @version 2.0 + * Created by windy on 2020/1/14 + */ + +describe("YearCombo", function () { + + before(function () { + BI.holidays = { + "2010-02-28": true, + "2010-02-27": true + }; + }); + + /** + * test_author_windy + */ + it("defaultValue", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_year_combo", + value: { + type: 1, + value: { + year: 2018 + } + } + }); + BI.nextTick(function () { + expect(dateCombo.element.find(".bi-year-trigger .bi-label").text()).to.equal("2018年"); + dateCombo.destroy(); + done(); + }); + + }); + + /** + * test_author_windy + */ + it("测试输入值收起下拉清空值下拉出现", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_year_combo", + width: 220, + height: 30 + }); + BI.nextTick(function () { + dateCombo.element.find(".bi-year-trigger .bi-basic-button").click(); + // 输入8, 检查popup是否收起 + BI.Test.triggerKeyDown(dateCombo.element.find(".bi-year-trigger .bi-input"), "2", 50, function () { + BI.nextTick(function () { + expect(dateCombo.element.find(".bi-year-trigger + .bi-popup-view").css("display")).to.equal("none"); + // 清空输入, 检查popup是否弹出 + BI.Test.triggerKeyDown(dateCombo.element.find(".bi-year-trigger .bi-input"), "", BI.KeyCode.BACKSPACE, function () { + BI.nextTick(function () { + expect(dateCombo.element.find(".bi-year-trigger + .bi-popup-view").css("display")).to.equal("block"); + dateCombo.destroy(); + done(); + }); + }); + }); + }); + }); + + }); + + /** + * test_author_windy + */ + it("trigger的confirm-下拉面板选值confirm", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_year_combo", + width: 220, + height: 30 + }); + // 点击日期,是否收起下拉 + dateCombo.element.find(".bi-year-trigger .bi-basic-button").click(); + BI.nextTick(function () { + dateCombo.element.find(".bi-year-card .bi-list-item-select:first-child").click(); + expect(dateCombo.element.find(".bi-year-trigger + .bi-popup-view").css("display")).to.equal("none"); + dateCombo.destroy(); + done(); + }) + + }); + + /** + * test_author_windy + */ + it("下拉后直接点击外部的触发的confirm", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_year_combo", + width: 220, + height: 30, + }); + BI.nextTick(function () { + dateCombo.element.find(".bi-year-trigger .bi-basic-button").click(); + BI.nextTick(function () { + var input = dateCombo.element.find(".bi-year-trigger .bi-input"); + BI.Test.triggerKeyDown(input, null, BI.KeyCode.ENTER, function () { + BI.delay(function () { + expect(dateCombo.element.find(".bi-year-trigger + .bi-popup-view").css("display")).to.equal("none"); + dateCombo.destroy(); + done(); + }, 300); + }); + }) + }); + }); + + + /** + * test_author_windy + */ + it("点击清空", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_year_combo", + width: 220, + height: 30, + value: { + type: 1, + value: { + year: 2018, + month: 1 + } + } + }); + dateCombo.element.find(".bi-year-trigger .bi-basic-button").click(); + BI.nextTick(function () { + dateCombo.element.find(".bi-year-popup .bi-text:contains(清除)").parent().click(); + expect(BI.isNull(dateCombo.getValue())).to.equal(true); + dateCombo.destroy(); + done(); + }) + }); + + /** + * test_author_windy + */ + it("点击本年", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_year_combo", + width: 220, + height: 30 + }); + dateCombo.element.find(".bi-year-trigger .bi-basic-button").click(); + BI.nextTick(function () { + dateCombo.element.find(".bi-year-popup .bi-text:contains(今年)").parent().click(); + var date = BI.getDate(); + expect(dateCombo.getValue()).to.deep.equal({ + type: 1, + value: { + year: date.getFullYear() + } + }); + dateCombo.destroy(); + done(); + }) + }); + + + /** + * test_author_windy + */ + it("点击确定", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_year_combo", + width: 220, + height: 30, + value: { + type: 1, + value: { + year: 2018 + } + } + }); + dateCombo.element.find(".bi-year-trigger .bi-basic-button").click(); + BI.nextTick(function () { + dateCombo.element.find(".bi-year-popup .bi-text:contains(确定)").parent().click(); + expect(dateCombo.getValue()).to.deep.equal({ + type: 1, + value: { + year: 2018 + } + }); + dateCombo.destroy(); + done(); + }) + }); + + /** + * test_author_windy + */ + it("测试动态默认值", function () { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_year_combo", + width: 220, + height: 30, + value: { + type: 2, + value: { + year: -1 + } + } + }); + expect(dateCombo.getValue()).to.deep.equal({ + type: 2, + value: { + year: -1 + } + }); + dateCombo.destroy(); + }); + + + /** + * test_author_windy + */ + it("trigger的输入日期后confirm", function (done) { + var dateCombo = BI.Test.createWidget({ + type: "bi.dynamic_year_combo", + width: 220, + height: 30, + value: { + type: 1, + value: { + year: 2018 + } + } + }); + BI.nextTick(function () { + dateCombo.element.find(".bi-year-trigger .bi-basic-button").click(); + BI.nextTick(function () { + var input = dateCombo.element.find(".bi-year-trigger .bi-input"); + input.val("2017"); + BI.Test.triggerKeyDown(dateCombo.element.find(".bi-year-trigger .bi-input"), null, BI.KeyCode.ENTER, function () { + BI.delay(function () { + expect(dateCombo.element.find(".bi-year-trigger .bi-text-button").text()).to.equal("2017"); + dateCombo.destroy(); + done(); + }, 300); + }); + }); + }) + + }); +}); \ No newline at end of file diff --git a/src/widget/year/combo.year.js b/src/widget/year/combo.year.js index a60bef760..a22ee77a0 100644 --- a/src/widget/year/combo.year.js +++ b/src/widget/year/combo.year.js @@ -19,6 +19,11 @@ BI.DynamicYearCombo = BI.inherit(BI.Widget, { height: o.height, value: o.value || "" }); + this.trigger.on(BI.DynamicYearTrigger.EVENT_KEY_DOWN, function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } + }); this.trigger.on(BI.DynamicYearTrigger.EVENT_FOCUS, function () { self.storeTriggerValue = this.getKey(); }); diff --git a/src/widget/year/trigger.year.js b/src/widget/year/trigger.year.js index 13d54bd59..84237e41e 100644 --- a/src/widget/year/trigger.year.js +++ b/src/widget/year/trigger.year.js @@ -39,6 +39,9 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { return BI.i18nText("BI-Year_Trigger_Invalid_Text"); } }); + this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { + self.fireEvent(BI.DynamicYearTrigger.EVENT_KEY_DOWN, arguments); + }); this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { self.fireEvent(BI.DynamicYearTrigger.EVENT_FOCUS); }); @@ -162,6 +165,7 @@ BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { return this.editor.getValue() | 0; } }); +BI.DynamicYearTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; BI.DynamicYearTrigger.EVENT_FOCUS = "EVENT_FOCUS"; BI.DynamicYearTrigger.EVENT_ERROR = "EVENT_ERROR"; BI.DynamicYearTrigger.EVENT_START = "EVENT_START";