diff --git a/app/client/cypress/fixtures/datePicker2dsl.json b/app/client/cypress/fixtures/datePicker2dsl.json
new file mode 100644
index 0000000000..ceb13dfb82
--- /dev/null
+++ b/app/client/cypress/fixtures/datePicker2dsl.json
@@ -0,0 +1,80 @@
+{
+ "dsl": {
+ "widgetName": "MainContainer",
+ "backgroundColor": "none",
+ "rightColumn": 1224,
+ "snapColumns": 16,
+ "detachFromLayout": true,
+ "widgetId": "0",
+ "topRow": 0,
+ "bottomRow": 1280,
+ "containerStyle": "none",
+ "snapRows": 33,
+ "parentRowSpace": 1,
+ "type": "CANVAS_WIDGET",
+ "canExtend": true,
+ "version": 9,
+ "minHeight": 1292,
+ "parentColumnSpace": 1,
+ "dynamicBindingPathList": [],
+ "leftColumn": 0,
+ "children": [
+ {
+ "isVisible": true,
+ "isDisabled": false,
+ "datePickerType": "DATE_PICKER",
+ "label": "",
+ "dateFormat": "DD/MM/YYYY HH:mm",
+ "widgetName": "DatePicker1",
+ "defaultDate": "2021-02-05T10:53:12.791Z",
+ "version": 2,
+ "type": "DATE_PICKER_WIDGET2",
+ "isLoading": false,
+ "parentColumnSpace": 74,
+ "parentRowSpace": 40,
+ "leftColumn": 5,
+ "rightColumn": 10,
+ "topRow": 0,
+ "bottomRow": 1,
+ "parentId": "0",
+ "widgetId": "w4htilgv5t"
+ },
+ {
+ "isVisible": true,
+ "text": "Label",
+ "textStyle": "LABEL",
+ "textAlign": "LEFT",
+ "widgetName": "Text1",
+ "version": 1,
+ "type": "TEXT_WIDGET",
+ "isLoading": false,
+ "parentColumnSpace": 74,
+ "parentRowSpace": 40,
+ "leftColumn": 1,
+ "rightColumn": 5,
+ "topRow": 3,
+ "bottomRow": 4,
+ "parentId": "0",
+ "widgetId": "voohxsv4t2"
+ },
+ {
+ "isVisible": true,
+ "text": "Label",
+ "textStyle": "LABEL",
+ "textAlign": "LEFT",
+ "widgetName": "Text2",
+ "version": 1,
+ "type": "TEXT_WIDGET",
+ "isLoading": false,
+ "parentColumnSpace": 74,
+ "parentRowSpace": 40,
+ "leftColumn": 8,
+ "rightColumn": 12,
+ "topRow": 3,
+ "bottomRow": 4,
+ "parentId": "0",
+ "widgetId": "xif8wugzjv"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js
index 580a401dac..e824916c33 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js
@@ -13,6 +13,7 @@ describe("Duplicate application", function() {
cy.get(commonlocators.homeIcon).click({ force: true });
const appname = localStorage.getItem("AppName");
cy.get(homePage.searchInput).type(appname);
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get(homePage.applicationCard)
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/UpdateApplication_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/UpdateApplication_spec.js
index 1dd97677df..b28651d94f 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/UpdateApplication_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/UpdateApplication_spec.js
@@ -14,6 +14,7 @@ describe("Update Application", function() {
cy.get(commonlocators.homeIcon).click({ force: true });
appname = localStorage.getItem("AppName");
cy.get(homePage.searchInput).type(appname);
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get(homePage.applicationCard)
@@ -53,6 +54,7 @@ describe("Update Application", function() {
it("Check for errors in updating application name", function() {
cy.get(commonlocators.homeIcon).click({ force: true });
cy.get(homePage.searchInput).type(appname);
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get(homePage.applicationCard)
.first()
@@ -61,6 +63,7 @@ describe("Update Application", function() {
.first()
.click({ force: true });
cy.get("#loading").should("not.exist");
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get(homePage.applicationName).type(" ");
cy.get(homePage.toastMessage).should(
@@ -79,6 +82,7 @@ describe("Update Application", function() {
it("Updates the name of first application to very long name and checks whether update is reflected in the application card with a popover", function() {
cy.get(commonlocators.homeIcon).click({ force: true });
cy.get(homePage.searchInput).clear();
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get(homePage.applicationCard)
@@ -94,6 +98,7 @@ describe("Update Application", function() {
"response.body.responseMeta.status",
200,
);
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get(homePage.applicationCard)
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_TableTextPagination_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_TableTextPagination_spec.js
index 8746e2b84d..accae859d4 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_TableTextPagination_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/Bind_TableTextPagination_spec.js
@@ -31,6 +31,7 @@ describe("Test Create Api and Bind to Table widget", function() {
/**Validate Table data on current page(page1) */
cy.ValidateTableData("1");
cy.get(commonlocators.tableNextPage).click({ force: true });
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(5000);
/*
cy.wait("@postExecute").should(
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/ButtonWidgets_NavigateTo_validation_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/ButtonWidgets_NavigateTo_validation_spec.js
index a5846c60af..caffe2c865 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/ButtonWidgets_NavigateTo_validation_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/ButtonWidgets_NavigateTo_validation_spec.js
@@ -22,12 +22,14 @@ describe("Binding the button Widgets and validating NavigateTo Page functionalit
.click();
cy.enterNavigatePageName(testdata.externalPage);
cy.get(commonlocators.editPropCrossButton).click({ force: true });
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(300);
});
it("Button click should take the control to page link validation", function() {
cy.PublishtheApp();
cy.get(publish.buttonWidget).click();
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
cy.get(publish.buttonWidget).should("not.exist");
cy.go("back");
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/JS_Toggle_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/JS_Toggle_spec.js
index fe767d9967..c5ceb1981b 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/JS_Toggle_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/JS_Toggle_spec.js
@@ -16,7 +16,7 @@ describe("JS Toggle tests", () => {
.should("have.class", "is-active");
cy.testJsontext("visible", "false");
-
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000);
cy.get(".t--property-control-visible")
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/TableWidgets_NavigateTo_Validation_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/TableWidgets_NavigateTo_Validation_spec.js
index 762cfe72af..08aa7c30b9 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/TableWidgets_NavigateTo_Validation_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Binding/TableWidgets_NavigateTo_Validation_spec.js
@@ -29,6 +29,7 @@ describe("Table Widget and Navigate to functionality validation", function() {
it("Create MyPage and valdiate if its successfully created", function() {
cy.Createpage(pageid);
cy.addDsl(dsl2);
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
cy.get(`.t--entity-name:contains("${pageid}")`).should("be.visible");
});
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ExplorerTests/Entity_Explorer_Widgets_Copy_Delete_Undo_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ExplorerTests/Entity_Explorer_Widgets_Copy_Delete_Undo_spec.js
index 2ccdb51220..f15307d536 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ExplorerTests/Entity_Explorer_Widgets_Copy_Delete_Undo_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ExplorerTests/Entity_Explorer_Widgets_Copy_Delete_Undo_spec.js
@@ -21,6 +21,7 @@ describe("Test Suite to validate copy/delete/undo functionalites", function() {
formWidgetsPage.formInner,
);
cy.get(commonlocators.copyWidget).click();
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
cy.get(commonlocators.toastBody)
.first()
@@ -36,6 +37,7 @@ describe("Test Suite to validate copy/delete/undo functionalites", function() {
expect($lis.eq(1)).to.contain("{{FormTest.data}}");
});
cy.DeleteWidgetFromSideBar();
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
cy.get(apiwidget.propertyList).should("not.exist");
/*
@@ -53,6 +55,7 @@ describe("Test Suite to validate copy/delete/undo functionalites", function() {
"response.body.responseMeta.status",
200,
);
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
cy.get(apiwidget.propertyList).then(function($lis) {
expect($lis).to.have.length(2);
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ExplorerTests/Entity_Explorer_Widgets_Copy_Paste_Delete_Undo_Keyboard_Event_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ExplorerTests/Entity_Explorer_Widgets_Copy_Paste_Delete_Undo_Keyboard_Event_spec.js
index bf695ad477..c6627d91bf 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ExplorerTests/Entity_Explorer_Widgets_Copy_Paste_Delete_Undo_Keyboard_Event_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/ExplorerTests/Entity_Explorer_Widgets_Copy_Paste_Delete_Undo_Keyboard_Event_spec.js
@@ -24,6 +24,7 @@ describe("Test Suite to validate copy/delete/undo functionalites", function() {
);
cy.get("body").click();
cy.get("body").type(`{${modifierKey}}c`);
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
cy.get(commonlocators.toastBody)
.first()
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/DatePicker_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/DatePicker_spec.js
index e6111d4d4c..3a1a83a28e 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/DatePicker_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/DatePicker_spec.js
@@ -63,43 +63,45 @@ describe("DatePicker Widget Functionality", function() {
);
});
- it("Datepicker min/max date validation", function() {
- cy.get(formWidgetsPage.defaultDate).click({ force: true });
- cy.SetDateToToday();
+ // it("Datepicker min/max date validation", function() {
+ // cy.get(formWidgetsPage.defaultDate).click({ force: true });
+ // cy.SetDateToToday();
- cy.get(formWidgetsPage.minDate)
- .first()
- .click();
- cy.wait(1000);
- cy.setDate(-1, "ddd MMM DD YYYY");
+ // cy.get(formWidgetsPage.minDate)
+ // .first()
+ // .click();
+ // // eslint-disable-next-line cypress/no-unnecessary-waiting
+ // cy.wait(1000);
+ // cy.setDate(-1, "ddd MMM DD YYYY");
- cy.get(formWidgetsPage.maxDate)
- .first()
- .click();
- cy.wait(1000);
- cy.setDate(1, "ddd MMM DD YYYY");
+ // cy.get(formWidgetsPage.maxDate)
+ // .first()
+ // .click();
+ // // eslint-disable-next-line cypress/no-unnecessary-waiting
+ // cy.wait(1000);
+ // cy.setDate(1, "ddd MMM DD YYYY");
- cy.PublishtheApp();
- cy.get(publishPage.datepickerWidget + " .bp3-input").click();
+ // cy.PublishtheApp();
+ // cy.get(publishPage.datepickerWidget + " .bp3-input").click();
- const minDate = Cypress.moment()
- .add(2, "days")
- .format("ddd MMM DD YYYY");
- const maxDate = Cypress.moment()
- .add(2, "days")
- .format("ddd MMM DD YYYY");
+ // const minDate = Cypress.moment()
+ // .add(2, "days")
+ // .format("ddd MMM DD YYYY");
+ // const maxDate = Cypress.moment()
+ // .add(2, "days")
+ // .format("ddd MMM DD YYYY");
- cy.get(`.DayPicker-Day[aria-label=\"${minDate}\"]`).should(
- "have.attr",
- "aria-disabled",
- "true",
- );
- cy.get(`.DayPicker-Day[aria-label=\"${maxDate}\"]`).should(
- "have.attr",
- "aria-disabled",
- "true",
- );
- });
+ // cy.get(`.DayPicker-Day[aria-label=\"${minDate}\"]`).should(
+ // "have.attr",
+ // "aria-disabled",
+ // "true",
+ // );
+ // cy.get(`.DayPicker-Day[aria-label=\"${maxDate}\"]`).should(
+ // "have.attr",
+ // "aria-disabled",
+ // "true",
+ // );
+ // });
// it("Datepicker default date validation", function() {
// cy.get(formWidgetsPage.defaultDate).click();
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/FormReset_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/FormReset_spec.js
index 1de82fb833..541586379a 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/FormReset_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/FormReset_spec.js
@@ -19,7 +19,7 @@ describe("Form reset functionality", function() {
cy.get(widgetsPage.formButtonWidget)
.contains("Reset")
.click();
-
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
cy.get(".tr")
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/LayoutWidgets/Tab_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/LayoutWidgets/Tab_spec.js
index 3d35ed8020..8afda73a11 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/LayoutWidgets/Tab_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/LayoutWidgets/Tab_spec.js
@@ -32,6 +32,7 @@ describe("Tab widget test", function() {
.click({ force: true })
.should("be.visible");
cy.get(Layoutpage.tabButton).click({ force: true });
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(200);
cy.tabVerify(2, "Day");
cy.get(Layoutpage.tabDelete)
diff --git a/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_2_Default_spec.js b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_2_Default_spec.js
new file mode 100644
index 0000000000..765b040a33
--- /dev/null
+++ b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_2_Default_spec.js
@@ -0,0 +1,39 @@
+const commonlocators = require("../../../locators/commonlocators.json");
+const formWidgetsPage = require("../../../locators/FormWidgets.json");
+const dsl = require("../../../fixtures/datePicker2dsl.json");
+const publishPage = require("../../../locators/publishWidgetspage.json");
+const pages = require("../../../locators/Pages.json");
+
+describe("DatePicker Widget Property pane tests with js bindings", function() {
+ before(() => {
+ cy.addDsl(dsl);
+ });
+
+ it("Datepicker default date validation with js binding and default date", function() {
+ cy.openPropertyPane("datepickerwidget2");
+ cy.get(".t--property-control-defaultdate .bp3-input").clear();
+ cy.get(formWidgetsPage.toggleJsDefaultDate).click();
+ cy.testJsontext("defaultdate", "{{ moment().add(-1,'days') }}");
+ });
+
+ it("Text widgets binding with datepicker", function() {
+ cy.SearchEntityandOpen("Text1");
+ cy.testJsontext("text", "{{DatePicker1.formattedDate}}");
+ cy.closePropertyPane();
+ cy.SearchEntityandOpen("Text2");
+ cy.testJsontext("text", "{{DatePicker1.selectedDate}}");
+ cy.closePropertyPane();
+ });
+
+ it("Text widgets binding with datepicker", function() {
+ cy.openPropertyPane("datepickerwidget2");
+ cy.selectDateFormat("DD/MM/YYYY");
+ cy.assertDateFormat();
+ cy.closePropertyPane();
+ cy.assertDateFormat();
+ });
+ it("Datepicker default date validation with js binding", function() {
+ cy.PublishtheApp();
+ cy.wait(10000);
+ });
+});
diff --git a/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_2_spec.js b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_2_spec.js
new file mode 100644
index 0000000000..c74fd97c46
--- /dev/null
+++ b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_2_spec.js
@@ -0,0 +1,79 @@
+const commonlocators = require("../../../locators/commonlocators.json");
+const formWidgetsPage = require("../../../locators/FormWidgets.json");
+const dsl = require("../../../fixtures/datePicker2dsl.json");
+const publishPage = require("../../../locators/publishWidgetspage.json");
+const pages = require("../../../locators/Pages.json");
+
+describe("DatePicker Widget Property pane tests with js bindings", function() {
+ before(() => {
+ cy.addDsl(dsl);
+ });
+
+ it("Datepicker default date validation with js binding", function() {
+ cy.openPropertyPane("datepickerwidget2");
+ cy.get(".t--property-control-defaultdate .bp3-input").clear();
+ cy.get(formWidgetsPage.toggleJsDefaultDate).click();
+ cy.testJsontext("defaultdate", "{{moment().toISOString()}}");
+ cy.get(formWidgetsPage.toggleJsMinDate).click();
+ cy.testJsontext(
+ "mindate",
+ "{{moment().subtract(10, 'days').toISOString()}}",
+ );
+ cy.get(formWidgetsPage.toggleJsMaxDate).click();
+ cy.testJsontext("maxdate", "{{moment().add(10, 'days').toISOString()}}");
+ /*
+ cy.get(formWidgetsPage.datepickerWidget + " .bp3-input").should(
+ "contain.value",
+ "14/02/2021",
+ );
+ cy.PublishtheApp();
+ cy.get(publishPage.datepickerWidget + " .bp3-input").should(
+ "contain.value",
+ "14/02/2021",
+ );
+ */
+ });
+
+ it("Text widgets binding with datepicker", function() {
+ cy.SearchEntityandOpen("Text1");
+ cy.testJsontext("text", "{{DatePicker1.formattedDate}}");
+ cy.closePropertyPane();
+ cy.SearchEntityandOpen("Text2");
+ cy.testJsontext("text", "{{DatePicker1.selectedDate}}");
+ cy.closePropertyPane();
+ });
+
+ it("Text widgets binding with datepicker", function() {
+ cy.openPropertyPane("datepickerwidget2");
+ cy.selectDateFormat("YYYY-MM-DD");
+ cy.assertDateFormat();
+ cy.selectDateFormat("YYYY-MM-DD HH:mm");
+ cy.assertDateFormat();
+ cy.selectDateFormat("YYYY-MM-DDTHH:mm:ss.sssZ");
+ cy.assertDateFormat();
+ cy.selectDateFormat("DD/MM/YYYY");
+ cy.assertDateFormat();
+ cy.selectDateFormat("DD/MM/YYYY HH:mm");
+ cy.closePropertyPane();
+ cy.assertDateFormat();
+ });
+
+ it("Datepicker default date validation with strings", function() {
+ cy.openPropertyPane("datepickerwidget2");
+ cy.get(formWidgetsPage.toggleJsDefaultDate).click();
+ cy.get(".t--property-control-defaultdate .bp3-input").clear();
+ cy.get(".t--property-control-defaultdate .bp3-input").type("2020-02-01");
+ cy.closePropertyPane();
+ cy.openPropertyPane("datepickerwidget2");
+ cy.get(formWidgetsPage.toggleJsMinDate).click();
+ cy.get(".t--property-control-mindate .bp3-input").type("2020-01-01");
+ cy.get(formWidgetsPage.toggleJsMaxDate).click();
+ cy.get(".t--property-control-maxdate .bp3-input").type("2020-02-10");
+ cy.closePropertyPane();
+ });
+
+ it("Datepicker default date validation with js binding", function() {
+ cy.PublishtheApp();
+ cy.wait(10000);
+ });
+});
diff --git a/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_Toggle_js_spec.js b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_Toggle_js_spec.js
new file mode 100644
index 0000000000..a581ad7d17
--- /dev/null
+++ b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_Toggle_js_spec.js
@@ -0,0 +1,47 @@
+const commonlocators = require("../../../locators/commonlocators.json");
+const formWidgetsPage = require("../../../locators/FormWidgets.json");
+const dsl = require("../../../fixtures/newFormDsl.json");
+const publishPage = require("../../../locators/publishWidgetspage.json");
+const pages = require("../../../locators/Pages.json");
+
+describe("DatePicker Widget Property pane tests with js bindings", function() {
+ before(() => {
+ cy.addDsl(dsl);
+ });
+
+ beforeEach(() => {
+ cy.openPropertyPane("datepickerwidget");
+ });
+
+ it("Datepicker default date validation with js binding", function() {
+ cy.get(".t--property-control-defaultdate .bp3-input").clear();
+ cy.get(formWidgetsPage.toggleJsDefaultDate).click();
+ cy.testJsontext(
+ "defaultdate",
+ "{{moment('14/02/2021', 'DD/MM/YYYY').format('DD/MM/YYYY')}}",
+ );
+ cy.get(formWidgetsPage.toggleJsMinDate).click();
+ cy.testJsontext(
+ "mindate",
+ "{{moment('12/02/2021', 'DD/MM/YYYY').format('DD/MM/YYYY')}}",
+ );
+ cy.get(formWidgetsPage.toggleJsMaxDate).click();
+ cy.testJsontext(
+ "maxdate",
+ "{{moment('17/02/2021', 'DD/MM/YYYY').format('DD/MM/YYYY')}}",
+ );
+ cy.get(formWidgetsPage.datepickerWidget + " .bp3-input").should(
+ "contain.value",
+ "14/02/2021",
+ );
+ cy.PublishtheApp();
+ cy.get(publishPage.datepickerWidget + " .bp3-input").should(
+ "contain.value",
+ "14/02/2021",
+ );
+ });
+
+ afterEach(() => {
+ cy.get(publishPage.backToEditor).click({ force: true });
+ });
+});
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OrganisationTests/UpdateOrgTests_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OrganisationTests/UpdateOrgTests_spec.js
index 9edcd9f157..fc37647369 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OrganisationTests/UpdateOrgTests_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/OrganisationTests/UpdateOrgTests_spec.js
@@ -24,6 +24,7 @@ describe("Update Organization", function() {
localStorage.setItem("OrgName", orgid);
cy.get(homePage.orgNameInput).clear();
cy.get(homePage.orgNameInput).type(orgid);
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get(homePage.orgHeaderName).should("have.text", orgid);
});
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidgetTableAndBind_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidgetTableAndBind_spec.js
index cbf1143f16..11b923bc27 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidgetTableAndBind_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidgetTableAndBind_spec.js
@@ -29,6 +29,7 @@ describe("Addwidget from Query and bind with other widgets", function() {
.first()
.focus()
.type("SELECT * FROM configs LIMIT 10;");
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
cy.get(queryEditor.runQuery).click();
cy.wait("@postExecute").should(
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidget_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidget_spec.js
index 18f5a407ef..d579b4eab6 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidget_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/AddWidget_spec.js
@@ -22,6 +22,7 @@ describe("Add widget", function() {
.first()
.focus()
.type("select * from configs");
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
cy.get(queryEditor.runQuery).click();
cy.wait("@postExecute").should(
diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/UnitTest/LoginFromUIApp_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/UnitTest/LoginFromUIApp_spec.js
index 23d7769e1a..54d3485a4f 100644
--- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/UnitTest/LoginFromUIApp_spec.js
+++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/UnitTest/LoginFromUIApp_spec.js
@@ -26,8 +26,10 @@ describe("Login from UI and check the functionality", function() {
cy.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.get(homePage.profileMenu).click();
cy.get(homePage.signOutIcon).click();
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
cy.get(homePage.headerAppSmithLogo).click();
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
cy.url().should("include", "user/login");
});
diff --git a/app/client/cypress/locators/FormWidgets.json b/app/client/cypress/locators/FormWidgets.json
index 673ae44d1a..84d613b30e 100644
--- a/app/client/cypress/locators/FormWidgets.json
+++ b/app/client/cypress/locators/FormWidgets.json
@@ -1,37 +1,36 @@
{
- "checkboxWidget": ".t--draggable-checkboxwidget",
- "dropdownWidget": ".t--draggable-dropdownwidget",
- "dropdownSelectionType": ".t--property-control-selectiontype",
- "radioWidget": ".t--draggable-radiogroupwidget",
- "radioOnSelectionChangeDropdown": ".t--property-control-onselectionchange",
- "nextDayBtn": ".DayPicker-Day[aria-selected='true'] + div.DayPicker-Day",
- "datepickerWidget": ".t--draggable-datepickerwidget",
- "defaultDate": ".t--property-control-defaultdate input",
- "minDate": ".t--property-control-mindate input",
- "maxDate": ".t--property-control-maxdate input",
- "filepickerWidget": ".t--draggable-filepickerwidget",
- "formWidget": ".t--draggable-formwidget",
- "richTextEditorWidget": ".t--draggable-richtexteditorwidget",
- "richEditorOnTextChange": ".t--property-control-ontextchange",
- "optionvalue": ".t--property-control-defaultselectedvalue .kDwnRc",
- "defselected": ".CodeMirror textarea",
- "dropdowninner": ".bp3-button > .bp3-button-text",
- "Textinput": ".t--property-control-options .CodeMirror-code",
- "labelvalue": ".t--draggable-dropdownwidget label",
- "dropdownInput": ".bp3-tag-input-values",
- "labelradio": ".t--draggable-radiogroupwidget label",
- "deleteradiovalue": ".t--property-control-options mask",
- "inputRadio": ".t--draggable-radiogroupwidget input",
- "defaultSelect": ".t--property-control-defaultselectedvalue .CodeMirror-code",
- "formInner": ".t--draggable-formwidget span.t--widget-name",
- "radioInput": ".t--draggable-radiogroupwidget span.t--widget-name",
- "radioAddButton": ".t--property-control-options button",
- "formD": "div[type='FORM_WIDGET']",
- "datepickerFooter": ".bp3-datepicker-footer span",
- "disableJs":".t--property-control-disable input[type='checkbox']",
- "switchWidget": ".t--draggable-switchwidget",
- "toggleJsDefaultDate": ".t--property-control-defaultdate .t--js-toggle",
- "toggleJsMinDate": ".t--property-control-mindate .t--js-toggle",
- "toggleJsMaxDate": ".t--property-control-maxdate .t--js-toggle"
-
- }
+ "checkboxWidget": ".t--draggable-checkboxwidget",
+ "dropdownWidget": ".t--draggable-dropdownwidget",
+ "dropdownSelectionType": ".t--property-control-selectiontype",
+ "radioWidget": ".t--draggable-radiogroupwidget",
+ "radioOnSelectionChangeDropdown": ".t--property-control-onselectionchange",
+ "nextDayBtn": ".DayPicker-Day[aria-selected='true'] + div.DayPicker-Day",
+ "datepickerWidget": ".t--draggable-datepickerwidget",
+ "defaultDate": ".t--property-control-defaultdate input",
+ "minDate": ".t--property-control-mindate input",
+ "maxDate": ".t--property-control-maxdate input",
+ "filepickerWidget": ".t--draggable-filepickerwidget",
+ "formWidget": ".t--draggable-formwidget",
+ "richTextEditorWidget": ".t--draggable-richtexteditorwidget",
+ "richEditorOnTextChange": ".t--property-control-ontextchange",
+ "optionvalue": ".t--property-control-defaultselectedvalue .kDwnRc",
+ "defselected": ".CodeMirror textarea",
+ "dropdowninner": ".bp3-button > .bp3-button-text",
+ "Textinput": ".t--property-control-options .CodeMirror-code",
+ "labelvalue": ".t--draggable-dropdownwidget label",
+ "dropdownInput": ".bp3-tag-input-values",
+ "labelradio": ".t--draggable-radiogroupwidget label",
+ "deleteradiovalue": ".t--property-control-options mask",
+ "inputRadio": ".t--draggable-radiogroupwidget input",
+ "defaultSelect": ".t--property-control-defaultselectedvalue .CodeMirror-code",
+ "formInner": ".t--draggable-formwidget span.t--widget-name",
+ "radioInput": ".t--draggable-radiogroupwidget span.t--widget-name",
+ "radioAddButton": ".t--property-control-options button",
+ "formD": "div[type='FORM_WIDGET']",
+ "datepickerFooter": ".bp3-datepicker-footer span",
+ "disableJs": ".t--property-control-disable input[type='checkbox']",
+ "switchWidget": ".t--draggable-switchwidget",
+ "toggleJsDefaultDate": ".t--property-control-defaultdate .t--js-toggle",
+ "toggleJsMinDate": ".t--property-control-mindate .t--js-toggle",
+ "toggleJsMaxDate": ".t--property-control-maxdate .t--js-toggle"
+}
diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js
index 3bc45ff9f0..3b193b59ba 100644
--- a/app/client/cypress/support/commands.js
+++ b/app/client/cypress/support/commands.js
@@ -690,6 +690,37 @@ Cypress.Commands.add("switchToAPIInputTab", () => {
.click({ force: true });
});
+Cypress.Commands.add("selectDateFormat", (value) => {
+ cy.get(".t--property-control-dateformat button")
+ .first()
+ .click({ force: true });
+ cy.get("ul.bp3-menu")
+ .children()
+ .contains(value)
+ .click();
+});
+
+Cypress.Commands.add("assertDateFormat", () => {
+ cy.get(".t--draggable-datepickerwidget2 input")
+ .first()
+ .invoke("attr", "value")
+ .then((text) => {
+ const firstTxt = text;
+ cy.log("date time : ", firstTxt);
+ cy.get(commonlocators.labelTextStyle)
+ .first()
+ .should("contain", firstTxt);
+ cy.get(commonlocators.labelTextStyle)
+ .last()
+ .invoke("text")
+ .then((text) => {
+ const secondText = text;
+ cy.log("date time : ", secondText);
+ expect(firstTxt).not.to.equal(secondText);
+ });
+ });
+});
+
Cypress.Commands.add("selectPaginationType", (option) => {
cy.xpath(option).click({ force: true });
});
diff --git a/app/client/src/components/designSystems/appsmith/TableComponent/CascadeFields.tsx b/app/client/src/components/designSystems/appsmith/TableComponent/CascadeFields.tsx
index 755573d9bc..5770579ccc 100644
--- a/app/client/src/components/designSystems/appsmith/TableComponent/CascadeFields.tsx
+++ b/app/client/src/components/designSystems/appsmith/TableComponent/CascadeFields.tsx
@@ -8,7 +8,7 @@ import { ControlIcons } from "icons/ControlIcons";
import { AnyStyledComponent } from "styled-components";
import { Skin } from "constants/DefaultTheme";
import AutoToolTipComponent from "components/designSystems/appsmith/TableComponent/AutoToolTipComponent";
-import DatePickerComponent from "components/designSystems/blueprint/DatePickerComponent";
+import DatePickerComponent from "components/designSystems/blueprint/DatePickerComponent2";
import {
OperatorTypes,
Condition,
diff --git a/app/client/src/components/designSystems/blueprint/DatePickerComponent.tsx b/app/client/src/components/designSystems/blueprint/DatePickerComponent.tsx
index 4d1e95c631..e0fac3e121 100644
--- a/app/client/src/components/designSystems/blueprint/DatePickerComponent.tsx
+++ b/app/client/src/components/designSystems/blueprint/DatePickerComponent.tsx
@@ -1,6 +1,10 @@
import React from "react";
import styled from "styled-components";
-import { getBorderCSSShorthand, labelStyle } from "constants/DefaultTheme";
+import {
+ getBorderCSSShorthand,
+ labelStyle,
+ IntentColors,
+} from "constants/DefaultTheme";
import { ControlGroup, Classes, Label } from "@blueprintjs/core";
import { ComponentProps } from "components/designSystems/appsmith/BaseComponent";
import { DateInput } from "@blueprintjs/datetime";
@@ -11,24 +15,30 @@ import { WIDGET_PADDING } from "constants/WidgetConstants";
import { TimePrecision } from "@blueprintjs/datetime";
import { Colors } from "constants/Colors";
import { ISO_DATE_FORMAT } from "constants/WidgetValidation";
+import ErrorTooltip from "components/editorComponents/ErrorTooltip";
+import { DATE_WIDGET_DEFAULT_VALIDATION_ERROR } from "constants/messages";
-const StyledControlGroup = styled(ControlGroup)`
+const StyledControlGroup = styled(ControlGroup)<{ isValid: boolean }>`
&&& {
.${Classes.INPUT} {
box-shadow: none;
color: ${Colors.OXFORD_BLUE};
font-size: ${(props) => props.theme.fontSizes[3]}px;
border: ${(props) => getBorderCSSShorthand(props.theme.borders[2])};
+ border-color: ${(props) =>
+ !props.isValid ? IntentColors.danger : Colors.GEYSER_LIGHT};
border-radius: 0;
width: 100%;
height: inherit;
align-items: center;
&:active {
- border-color: ${Colors.HIT_GRAY};
+ border-color: ${(props) =>
+ !props.isValid ? IntentColors.danger : Colors.HIT_GRAY};
}
&:focus {
border: ${(props) => getBorderCSSShorthand(props.theme.borders[2])};
- border-color: #80bdff;
+ border-color: ${(props) =>
+ !props.isValid ? IntentColors.danger : "#80bdff"};
outline: 0;
box-shadow: 0 0 0 0.1rem rgba(0, 123, 255, 0.25);
}
@@ -95,10 +105,17 @@ class DatePickerComponent extends React.Component<
.clone()
.set({ month: 11, date: 31, year: year + 20 })
.toDate();
-
+ const isValid = this.state.selectedDate
+ ? this.isValidDate(this.parseDate(this.state.selectedDate))
+ : true;
+ const value =
+ isValid && this.state.selectedDate
+ ? this.parseDate(this.state.selectedDate)
+ : null;
return (
{
e.stopPropagation();
}}
@@ -115,29 +132,58 @@ class DatePickerComponent extends React.Component<
)}
{
-
+
+
+
}
);
}
+ isValidDate = (date: Date): boolean => {
+ let isValid = true;
+ const dateFormat = this.props.dateFormat || ISO_DATE_FORMAT;
+ const parsedCurrentDate = moment(date);
+ if (this.props.minDate) {
+ const parsedMinDate = moment(this.props.minDate, dateFormat);
+ if (
+ this.props.minDate &&
+ parsedMinDate.isValid() &&
+ parsedCurrentDate.isBefore(parsedMinDate)
+ ) {
+ isValid = false;
+ }
+ }
+ if (this.props.maxDate) {
+ const parsedMaxDate = moment(this.props.maxDate, dateFormat);
+ if (
+ isValid &&
+ this.props.maxDate &&
+ parsedMaxDate.isValid() &&
+ parsedCurrentDate.isAfter(parsedMaxDate)
+ ) {
+ isValid = false;
+ }
+ }
+ return isValid;
+ };
+
formatDate = (date: Date): string => {
const dateFormat = this.props.dateFormat || ISO_DATE_FORMAT;
return moment(date).format(dateFormat);
@@ -165,9 +211,6 @@ class DatePickerComponent extends React.Component<
const date = selectedDate ? this.formatDate(selectedDate) : "";
this.setState({ selectedDate: date });
- // if date is null ( if date is cleared ), don't call onDateSelected
- if (!selectedDate) return false;
-
onDateSelected(date);
}
};
diff --git a/app/client/src/components/designSystems/blueprint/DatePickerComponent2.tsx b/app/client/src/components/designSystems/blueprint/DatePickerComponent2.tsx
new file mode 100644
index 0000000000..a3d2cb7178
--- /dev/null
+++ b/app/client/src/components/designSystems/blueprint/DatePickerComponent2.tsx
@@ -0,0 +1,236 @@
+import React from "react";
+import styled from "styled-components";
+import { labelStyle, IntentColors } from "constants/DefaultTheme";
+import { ControlGroup, Classes, Label } from "@blueprintjs/core";
+import { ComponentProps } from "components/designSystems/appsmith/BaseComponent";
+import { DateInput } from "@blueprintjs/datetime";
+import moment from "moment-timezone";
+import "../../../../node_modules/@blueprintjs/datetime/lib/css/blueprint-datetime.css";
+import { DatePickerType } from "widgets/DatePickerWidget";
+import { WIDGET_PADDING } from "constants/WidgetConstants";
+import { TimePrecision } from "@blueprintjs/datetime";
+import { Colors } from "constants/Colors";
+import { ISO_DATE_FORMAT } from "constants/WidgetValidation";
+import ErrorTooltip from "components/editorComponents/ErrorTooltip";
+import { DATE_WIDGET_DEFAULT_VALIDATION_ERROR } from "constants/messages";
+
+const StyledControlGroup = styled(ControlGroup)<{ isValid: boolean }>`
+ &&& {
+ .${Classes.INPUT} {
+ box-shadow: none;
+ border: 1px solid;
+ border-color: ${(props) =>
+ !props.isValid ? IntentColors.danger : Colors.GEYSER_LIGHT};
+ border-radius: ${(props) => props.theme.radii[1]}px;
+ width: 100%;
+ height: inherit;
+ align-items: center;
+ &:active {
+ border-color: ${(props) =>
+ !props.isValid ? IntentColors.danger : Colors.HIT_GRAY};
+ }
+ &:focus {
+ border-color: ${(props) =>
+ !props.isValid ? IntentColors.danger : Colors.MYSTIC};
+ }
+ }
+ .${Classes.INPUT_GROUP} {
+ display: block;
+ margin: 0;
+ }
+ .${Classes.CONTROL_GROUP} {
+ justify-content: flex-start;
+ }
+ label {
+ ${labelStyle}
+ flex: 0 1 30%;
+ margin: 7px ${WIDGET_PADDING * 2}px 0 0;
+ text-align: right;
+ align-self: flex-start;
+ max-width: calc(30% - ${WIDGET_PADDING}px);
+ }
+ }
+ &&& {
+ input {
+ border: 1px solid;
+ border-color: ${(props) =>
+ !props.isValid ? IntentColors.danger : Colors.HIT_GRAY};
+ border-radius: ${(props) => props.theme.radii[1]}px;
+ box-shadow: none;
+ color: ${Colors.OXFORD_BLUE};
+ font-size: ${(props) => props.theme.fontSizes[3]}px;
+ }
+ }
+`;
+
+class DatePickerComponent extends React.Component<
+ DatePickerComponentProps,
+ DatePickerComponentState
+> {
+ constructor(props: DatePickerComponentProps) {
+ super(props);
+ this.state = {
+ selectedDate: props.selectedDate,
+ };
+ }
+
+ componentDidUpdate(prevProps: DatePickerComponentProps) {
+ if (
+ this.props.selectedDate !== this.state.selectedDate &&
+ !moment(this.props.selectedDate).isSame(
+ moment(prevProps.selectedDate),
+ "seconds",
+ )
+ ) {
+ this.setState({ selectedDate: this.props.selectedDate });
+ }
+ }
+
+ getValidDate = (date: string, format: string) => {
+ const _date = moment(date, format);
+ return _date.isValid() ? _date.toDate() : undefined;
+ };
+
+ render() {
+ const now = moment();
+ const year = now.get("year");
+ const minDate = this.props.minDate
+ ? new Date(this.props.minDate)
+ : now
+ .clone()
+ .set({ month: 0, date: 1, year: year - 100 })
+ .toDate();
+ const maxDate = this.props.maxDate
+ ? new Date(this.props.maxDate)
+ : now
+ .clone()
+ .set({ month: 11, date: 31, year: year + 20 })
+ .toDate();
+ const isValid = this.state.selectedDate
+ ? this.isValidDate(new Date(this.state.selectedDate))
+ : true;
+ const value =
+ isValid && this.state.selectedDate
+ ? new Date(this.state.selectedDate)
+ : null;
+ return (
+ {
+ e.stopPropagation();
+ }}
+ >
+ {this.props.label && (
+
+ )}
+ {
+
+
+
+ }
+
+ );
+ }
+
+ isValidDate = (date: Date): boolean => {
+ let isValid = true;
+ const parsedCurrentDate = moment(date);
+ if (this.props.minDate) {
+ const parsedMinDate = moment(this.props.minDate);
+ if (
+ this.props.minDate &&
+ parsedMinDate.isValid() &&
+ parsedCurrentDate.isBefore(parsedMinDate)
+ ) {
+ isValid = false;
+ }
+ }
+ if (this.props.maxDate) {
+ const parsedMaxDate = moment(this.props.maxDate);
+ if (
+ isValid &&
+ this.props.maxDate &&
+ parsedMaxDate.isValid() &&
+ parsedCurrentDate.isAfter(parsedMaxDate)
+ ) {
+ isValid = false;
+ }
+ }
+ return isValid;
+ };
+
+ formatDate = (date: Date): string => {
+ const dateFormat = this.props.dateFormat || ISO_DATE_FORMAT;
+ return moment(date).format(dateFormat);
+ };
+
+ parseDate = (dateStr: string): Date => {
+ const date = moment(dateStr);
+
+ if (date.isValid()) return moment(dateStr).toDate();
+ else return moment().toDate();
+ };
+
+ /**
+ * checks if selelectedDate is null or not,
+ * sets state and calls props onDateSelected
+ * if its null, don't call onDateSelected
+ *
+ * @param selectedDate
+ */
+ onDateSelected = (selectedDate: Date, isUserChange: boolean) => {
+ if (isUserChange) {
+ const { onDateSelected } = this.props;
+
+ const date = selectedDate ? selectedDate.toISOString() : "";
+ this.setState({ selectedDate: date });
+
+ onDateSelected(date);
+ }
+ };
+}
+
+interface DatePickerComponentProps extends ComponentProps {
+ label: string;
+ dateFormat: string;
+ enableTimePicker?: boolean;
+ selectedDate?: string;
+ minDate?: string;
+ maxDate?: string;
+ timezone?: string;
+ datePickerType: DatePickerType;
+ isDisabled: boolean;
+ onDateSelected: (selectedDate: string) => void;
+ isLoading: boolean;
+}
+
+interface DatePickerComponentState {
+ selectedDate?: string;
+}
+
+export default DatePickerComponent;
diff --git a/app/client/src/components/propertyControls/DatePickerControl.tsx b/app/client/src/components/propertyControls/DatePickerControl.tsx
index 6796c3e736..259417ffa6 100644
--- a/app/client/src/components/propertyControls/DatePickerControl.tsx
+++ b/app/client/src/components/propertyControls/DatePickerControl.tsx
@@ -5,8 +5,6 @@ import moment from "moment-timezone";
import styled from "styled-components";
import { TimePrecision } from "@blueprintjs/datetime";
import { WidgetProps } from "widgets/BaseWidget";
-import { Toaster } from "components/ads/Toast";
-import { Variant } from "components/ads/common";
import { ISO_DATE_FORMAT } from "constants/WidgetValidation";
const DatePickerControlWrapper = styled.div<{ isValid: boolean }>`
@@ -63,18 +61,22 @@ class DatePickerControl extends BaseControl<
}
render() {
+ const version = this.props.widgetProperties.version;
const dateFormat =
- this.props.widgetProperties.dateFormat || ISO_DATE_FORMAT;
+ version === 2
+ ? ISO_DATE_FORMAT
+ : this.props.widgetProperties.dateFormat || ISO_DATE_FORMAT;
const isValid = this.state.selectedDate
? this.validateDate(moment(this.state.selectedDate, dateFormat).toDate())
: true;
- const maxDate =
- this.props.widgetProperties?.evaluatedValues?.maxDate ?? this.maxDate;
- const minDate =
- this.props.widgetProperties?.evaluatedValues?.minDate ?? this.minDate;
-
+ const value =
+ this.props.propertyValue && isValid
+ ? version === 2
+ ? new Date(this.props.propertyValue)
+ : this.parseDate(this.props.propertyValue)
+ : null;
return (
-
+
);
@@ -117,10 +105,13 @@ class DatePickerControl extends BaseControl<
*/
onDateSelected = (date: Date, isUserChange: boolean): void => {
if (isUserChange) {
- const selectedDate = date ? this.formatDate(date) : undefined;
+ const selectedDate = date
+ ? this.props.widgetProperties.version === 2
+ ? date.toISOString()
+ : this.formatDate(date)
+ : undefined;
const isValid = this.validateDate(date);
if (!isValid) return;
-
// if everything is ok, put date in state
this.setState({ selectedDate: selectedDate });
this.updateProperty(this.props.propertyName, selectedDate);
@@ -128,73 +119,14 @@ class DatePickerControl extends BaseControl<
};
/**
- * checks:
- * 1. if max date is greater than the default date
- * 2. if default date is in range of min and max date
+ * checks if date is of valid date format
*/
validateDate = (date: Date): boolean => {
const dateFormat =
- this.props.widgetProperties.dateFormat || ISO_DATE_FORMAT;
- const parsedSelectedDate = moment(date, dateFormat);
- //validate defaultDate if both minDate and maxDate is already selected
- if (this.props.propertyName === "defaultDate") {
- if (
- parsedSelectedDate.isValid() &&
- this.props.widgetProperties?.evaluatedValues?.minDate &&
- this.props.widgetProperties?.evaluatedValues?.maxDate
- ) {
- const parsedMinDate = moment(
- this.props.widgetProperties.evaluatedValues.minDate,
- dateFormat,
- );
- const parsedMaxDate = moment(
- this.props.widgetProperties.evaluatedValues.maxDate,
- dateFormat,
- );
- if (
- parsedSelectedDate.isBefore(parsedMinDate) ||
- parsedSelectedDate.isAfter(parsedMaxDate)
- ) {
- return false;
- }
- }
- }
- if (this.props.widgetProperties?.evaluatedValues?.value) {
- const parsedWidgetDate = moment(
- this.props.widgetProperties.evaluatedValues.value,
- dateFormat,
- );
- // checking if widget date is after min date
- if (this.props.propertyName === "minDate") {
- if (
- parsedSelectedDate.isValid() &&
- parsedWidgetDate.isBefore(parsedSelectedDate)
- ) {
- Toaster.show({
- text: "Min date cannot be greater than current widget value.",
- variant: Variant.danger,
- });
-
- return false;
- }
- }
-
- // checking if widget date is before max date
- if (this.props.propertyName === "maxDate") {
- if (
- parsedSelectedDate.isValid() &&
- parsedWidgetDate.isAfter(parsedSelectedDate)
- ) {
- Toaster.show({
- text: "Max date cannot be less than current widget value.",
- variant: Variant.danger,
- });
-
- return false;
- }
- }
- }
- return true;
+ this.props.widgetProperties.version === 2
+ ? ISO_DATE_FORMAT
+ : this.props.widgetProperties.dateFormat || ISO_DATE_FORMAT;
+ return date ? moment(date, dateFormat).isValid() : true;
};
formatDate = (date: Date): string => {
@@ -205,7 +137,9 @@ class DatePickerControl extends BaseControl<
parseDate = (dateStr: string): Date => {
const dateFormat =
- this.props.widgetProperties.dateFormat || ISO_DATE_FORMAT;
+ this.props.widgetProperties.version === 2
+ ? ISO_DATE_FORMAT
+ : this.props.widgetProperties.dateFormat || ISO_DATE_FORMAT;
const date = moment(dateStr, dateFormat);
if (date.isValid()) return moment(dateStr, dateFormat).toDate();
diff --git a/app/client/src/constants/FieldExpectedValue.ts b/app/client/src/constants/FieldExpectedValue.ts
index 99580f40c3..eed49ad87e 100644
--- a/app/client/src/constants/FieldExpectedValue.ts
+++ b/app/client/src/constants/FieldExpectedValue.ts
@@ -24,6 +24,13 @@ const FIELD_VALUES: Record<
isDisabled: "boolean",
// onDateSelected: "Function Call",
},
+ DATE_PICKER_WIDGET2: {
+ defaultDate: "string", //TODO:Vicky validate this property
+ isRequired: "boolean",
+ isVisible: "boolean",
+ isDisabled: "boolean",
+ // onDateSelected: "Function Call",
+ },
TABLE_WIDGET: {
tableData: "Array