From dc5c9f4515ebff247ee1ca4334ec9d68cb49856f Mon Sep 17 00:00:00 2001 From: "vicky.bansal@primathon.in" Date: Tue, 21 Sep 2021 16:06:48 +0530 Subject: [PATCH 1/8] Fix countryCode property --- app/client/src/widgets/InputWidget/widget/index.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/client/src/widgets/InputWidget/widget/index.tsx b/app/client/src/widgets/InputWidget/widget/index.tsx index 0db882802235..fb3b83de0a8c 100644 --- a/app/client/src/widgets/InputWidget/widget/index.tsx +++ b/app/client/src/widgets/InputWidget/widget/index.tsx @@ -167,7 +167,7 @@ class InputWidget extends BaseWidget { }, { helpText: "Changes the type of currency", - propertyName: "currencyCountryCode", + propertyName: "defaultCurrencyCountryCode", label: "Currency", enableSearch: true, dropdownHeight: "195px", @@ -564,6 +564,8 @@ class InputWidget extends BaseWidget { } })() }}`, + countryCode: `{{this.selectedPhoneNumberCountryCode ? this.selectedPhoneNumberCountryCode : this.phoneNumberCountryCode}}`, + currencyCountryCode: `{{this.selectedCurrencyCountryCode ? this.selectedCurrencyCountryCode : this.defaultCurrencyCountryCode}}`, value: `{{this.text}}`, }; } @@ -600,7 +602,10 @@ class InputWidget extends BaseWidget { onCurrencyTypeChange = (code?: string) => { const currencyCountryCode = code; if (this.props.renderMode === RenderModes.CANVAS) { - super.updateWidgetProperty("currencyCountryCode", currencyCountryCode); + super.updateWidgetProperty( + "defaultCurrencyCountryCode", + currencyCountryCode, + ); } else { this.props.updateWidgetMetaProperty( "selectedCurrencyCountryCode", @@ -768,6 +773,8 @@ export interface InputWidgetProps extends WidgetProps { noOfDecimals?: number; allowCurrencyChange?: boolean; phoneNumberCountryCode?: string; + countryCode?: string; + defaultCurrencyCountryCode?: string; decimalsInCurrency?: number; defaultText?: string | number; tooltip?: string; From 5fb19b9cb5ee387c9ee621fd4376125459d63752 Mon Sep 17 00:00:00 2001 From: "vicky.bansal@primathon.in" Date: Thu, 23 Sep 2021 16:53:11 +0530 Subject: [PATCH 2/8] Show dial_code as countryCode and rename currencyCountryCode to currencyCode --- .../utils/autocomplete/EntityDefinitions.ts | 4 +- .../InputWidget/component/ISDCodeDropdown.tsx | 10 ++--- .../src/widgets/InputWidget/widget/index.tsx | 39 ++++--------------- 3 files changed, 14 insertions(+), 39 deletions(-) diff --git a/app/client/src/utils/autocomplete/EntityDefinitions.ts b/app/client/src/utils/autocomplete/EntityDefinitions.ts index aef6dadbd48e..10779df759b9 100644 --- a/app/client/src/utils/autocomplete/EntityDefinitions.ts +++ b/app/client/src/utils/autocomplete/EntityDefinitions.ts @@ -66,9 +66,9 @@ export const entityDefinitions: Record = { "!type": "string", "!doc": "Selected country code for Phone Number type input", }, - currencyCountryCode: { + currencyCode: { "!type": "string", - "!doc": "Selected country code for Currency type input", + "!doc": "Selected currency code for Currency type input", }, }, TABLE_WIDGET: (widget: any) => ({ diff --git a/app/client/src/widgets/InputWidget/component/ISDCodeDropdown.tsx b/app/client/src/widgets/InputWidget/component/ISDCodeDropdown.tsx index cd44c76be956..062fb2aaebb6 100644 --- a/app/client/src/widgets/InputWidget/component/ISDCodeDropdown.tsx +++ b/app/client/src/widgets/InputWidget/component/ISDCodeDropdown.tsx @@ -43,8 +43,8 @@ const getISDCodeOptions = (): Array => { leftElement: countryToFlag(item.code), searchText: item.name, label: `${item.name} (${item.dial_code})`, - value: item.code, - id: item.dial_code, + value: item.dial_code, + id: item.code, }; }); }; @@ -54,7 +54,7 @@ export const ISDCodeDropdownOptions = getISDCodeOptions(); export const getSelectedISDCode = (code?: string): DropdownOption => { let selectedCountry: ISDCodeProps | undefined = code ? ISDCodeOptions.find((item: ISDCodeProps) => { - return item.code === code; + return item.dial_code === code; }) : undefined; if (!selectedCountry) { @@ -67,8 +67,8 @@ export const getSelectedISDCode = (code?: string): DropdownOption => { return { label: `${selectedCountry.name} (${selectedCountry.dial_code})`, searchText: selectedCountry.name, - value: selectedCountry.code, - id: selectedCountry.dial_code, + value: selectedCountry.dial_code, + id: selectedCountry.code, }; }; diff --git a/app/client/src/widgets/InputWidget/widget/index.tsx b/app/client/src/widgets/InputWidget/widget/index.tsx index fb3b83de0a8c..5c3cb00790f7 100644 --- a/app/client/src/widgets/InputWidget/widget/index.tsx +++ b/app/client/src/widgets/InputWidget/widget/index.tsx @@ -167,7 +167,7 @@ class InputWidget extends BaseWidget { }, { helpText: "Changes the type of currency", - propertyName: "defaultCurrencyCountryCode", + propertyName: "currencyCountryCode", label: "Currency", enableSearch: true, dropdownHeight: "195px", @@ -565,7 +565,7 @@ class InputWidget extends BaseWidget { })() }}`, countryCode: `{{this.selectedPhoneNumberCountryCode ? this.selectedPhoneNumberCountryCode : this.phoneNumberCountryCode}}`, - currencyCountryCode: `{{this.selectedCurrencyCountryCode ? this.selectedCurrencyCountryCode : this.defaultCurrencyCountryCode}}`, + currencyCode: `{{this.selectedCurrencyCountryCode ? this.selectedCurrencyCountryCode : this.currencyCountryCode}}`, value: `{{this.text}}`, }; } @@ -600,30 +600,11 @@ class InputWidget extends BaseWidget { }; onCurrencyTypeChange = (code?: string) => { - const currencyCountryCode = code; - if (this.props.renderMode === RenderModes.CANVAS) { - super.updateWidgetProperty( - "defaultCurrencyCountryCode", - currencyCountryCode, - ); - } else { - this.props.updateWidgetMetaProperty( - "selectedCurrencyCountryCode", - currencyCountryCode, - ); - } + this.props.updateWidgetMetaProperty("selectedCurrencyCountryCode", code); }; onISDCodeChange = (code?: string) => { - const countryCode = code; - if (this.props.renderMode === RenderModes.CANVAS) { - super.updateWidgetProperty("phoneNumberCountryCode", countryCode); - } else { - this.props.updateWidgetMetaProperty( - "selectedPhoneNumberCountryCode", - countryCode, - ); - } + this.props.updateWidgetMetaProperty("selectedPhoneNumberCountryCode", code); }; handleFocusChange = (focusState: boolean) => { @@ -677,12 +658,6 @@ class InputWidget extends BaseWidget { const value = this.props.text ?? ""; let isInvalid = "isValid" in this.props && !this.props.isValid && !!this.props.isDirty; - const currencyCountryCode = this.props.selectedCurrencyCountryCode - ? this.props.selectedCurrencyCountryCode - : this.props.currencyCountryCode; - const phoneNumberCountryCode = this.props.selectedPhoneNumberCountryCode - ? this.props.selectedPhoneNumberCountryCode - : this.props.phoneNumberCountryCode; const conditionalProps: Partial = {}; conditionalProps.errorMessage = this.props.errorMessage; if (this.props.isRequired && value.length === 0) { @@ -722,7 +697,7 @@ class InputWidget extends BaseWidget { 1 && this.props.inputType === "TEXT" ) } - currencyCountryCode={currencyCountryCode} + currencyCountryCode={this.props.currencyCode} decimalsInCurrency={this.props.decimalsInCurrency} defaultValue={this.props.defaultText} disableNewLineOnPressEnterKey={!!this.props.onSubmit} @@ -746,7 +721,7 @@ class InputWidget extends BaseWidget { onISDCodeChange={this.onISDCodeChange} onKeyDown={this.handleKeyDown} onValueChange={this.onValueChange} - phoneNumberCountryCode={phoneNumberCountryCode} + phoneNumberCountryCode={this.props.countryCode} placeholder={this.props.placeholderText} showError={!!this.props.isFocused} stepSize={1} @@ -774,7 +749,7 @@ export interface InputWidgetProps extends WidgetProps { allowCurrencyChange?: boolean; phoneNumberCountryCode?: string; countryCode?: string; - defaultCurrencyCountryCode?: string; + currencyCode?: string; decimalsInCurrency?: number; defaultText?: string | number; tooltip?: string; From f11ce7092a84689961a4e7714271825002d54692 Mon Sep 17 00:00:00 2001 From: "vicky.bansal@primathon.in" Date: Thu, 23 Sep 2021 17:19:03 +0530 Subject: [PATCH 3/8] remove unused variable --- app/client/src/widgets/InputWidget/widget/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/src/widgets/InputWidget/widget/index.tsx b/app/client/src/widgets/InputWidget/widget/index.tsx index 5c3cb00790f7..f9a213077e40 100644 --- a/app/client/src/widgets/InputWidget/widget/index.tsx +++ b/app/client/src/widgets/InputWidget/widget/index.tsx @@ -2,7 +2,7 @@ import React from "react"; import BaseWidget, { WidgetProps, WidgetState } from "widgets/BaseWidget"; import { Alignment } from "@blueprintjs/core"; import { IconName } from "@blueprintjs/icons"; -import { WidgetType, RenderModes, TextSize } from "constants/WidgetConstants"; +import { WidgetType, TextSize } from "constants/WidgetConstants"; import InputComponent, { InputComponentProps } from "../component"; import { EventType, From f90d5e97f479b648f002220425b8286744242113 Mon Sep 17 00:00:00 2001 From: "vicky.bansal@primathon.in" Date: Wed, 29 Sep 2021 13:29:14 +0530 Subject: [PATCH 4/8] Add migrations to update selected phone number country code to phone number dial code --- app/client/src/utils/DSLMigrations.ts | 1 + .../src/utils/migrations/InputWidget.test.ts | 124 ++++++++++++++++++ .../src/utils/migrations/InputWidget.ts | 26 ++++ 3 files changed, 151 insertions(+) create mode 100644 app/client/src/utils/migrations/InputWidget.test.ts create mode 100644 app/client/src/utils/migrations/InputWidget.ts diff --git a/app/client/src/utils/DSLMigrations.ts b/app/client/src/utils/DSLMigrations.ts index ed5cc503068a..58d5e9bd2ce1 100644 --- a/app/client/src/utils/DSLMigrations.ts +++ b/app/client/src/utils/DSLMigrations.ts @@ -40,6 +40,7 @@ import { ButtonStyleTypes, ButtonVariantTypes } from "../components/constants"; import { Colors } from "../constants/Colors"; import { migrateResizableModalWidgetProperties } from "./migrations/ModalWidget"; import { migrateMapWidgetIsClickedMarkerCentered } from "./migrations/MapWidget"; +import { migrateInputWidgetDefaultSelectedPhoneNumberCode } from "./migrations/InputWidget"; import { DSLWidget } from "widgets/constants"; /** diff --git a/app/client/src/utils/migrations/InputWidget.test.ts b/app/client/src/utils/migrations/InputWidget.test.ts new file mode 100644 index 000000000000..1fd7e78d75c9 --- /dev/null +++ b/app/client/src/utils/migrations/InputWidget.test.ts @@ -0,0 +1,124 @@ +import { DSLWidget } from "widgets/constants"; +import { migrateInputWidgetDefaultSelectedPhoneNumberCode } from "./InputWidget"; + +describe("Input Widget Property Pane Upgrade", () => { + it("To test phoneNumberCountryCode is having dial code instead of country code", () => { + const inputDsl: DSLWidget = { + widgetName: "MainContainer", + backgroundColor: "none", + rightColumn: 1118, + snapColumns: 64, + detachFromLayout: true, + widgetId: "0", + topRow: 0, + bottomRow: 5016, + containerStyle: "none", + snapRows: 125, + parentRowSpace: 1, + type: "CANVAS_WIDGET", + canExtend: true, + version: 41, + minHeight: 1292, + parentColumnSpace: 1, + dynamicBindingPathList: [], + leftColumn: 0, + renderMode: "CANVAS", + isLoading: false, + children: [ + { + widgetName: "Input1", + displayName: "Input", + iconSVG: "/static/media/icon.e569391a.svg", + topRow: 6, + bottomRow: 10, + parentRowSpace: 10, + autoFocus: false, + type: "INPUT_WIDGET", + phoneNumberCountryCode: "IN", + hideCard: false, + parentColumnSpace: 17.28125, + dynamicTriggerPathList: [], + resetOnSubmit: true, + leftColumn: 14, + dynamicBindingPathList: [], + labelStyle: "BOLD", + inputType: "PHONE_NUMBER", + isDisabled: false, + key: "umf8qep1vn", + isRequired: false, + rightColumn: 34, + widgetId: "wyxyvtpfsw", + isVisible: true, + label: "", + allowCurrencyChange: false, + version: 1, + parentId: "0", + renderMode: "CANVAS", + isLoading: false, + iconAlign: "left", + defaultText: "", + }, + ], + }; + + const outputDsl: DSLWidget = { + widgetName: "MainContainer", + backgroundColor: "none", + rightColumn: 1118, + snapColumns: 64, + detachFromLayout: true, + widgetId: "0", + topRow: 0, + bottomRow: 5016, + containerStyle: "none", + snapRows: 125, + parentRowSpace: 1, + type: "CANVAS_WIDGET", + canExtend: true, + version: 41, + minHeight: 1292, + parentColumnSpace: 1, + dynamicBindingPathList: [], + leftColumn: 0, + renderMode: "CANVAS", + isLoading: false, + children: [ + { + widgetName: "Input1", + displayName: "Input", + iconSVG: "/static/media/icon.e569391a.svg", + topRow: 6, + bottomRow: 10, + parentRowSpace: 10, + autoFocus: false, + type: "INPUT_WIDGET", + phoneNumberCountryCode: "+91", + hideCard: false, + parentColumnSpace: 17.28125, + dynamicTriggerPathList: [], + resetOnSubmit: true, + leftColumn: 14, + dynamicBindingPathList: [], + labelStyle: "BOLD", + inputType: "PHONE_NUMBER", + isDisabled: false, + key: "umf8qep1vn", + isRequired: false, + rightColumn: 34, + widgetId: "wyxyvtpfsw", + isVisible: true, + label: "", + allowCurrencyChange: false, + version: 1, + parentId: "0", + renderMode: "CANVAS", + isLoading: false, + iconAlign: "left", + defaultText: "", + }, + ], + }; + const newDsl = migrateInputWidgetDefaultSelectedPhoneNumberCode(inputDsl); + expect(newDsl).toStrictEqual(outputDsl); + }); +}); diff --git a/app/client/src/utils/migrations/InputWidget.ts b/app/client/src/utils/migrations/InputWidget.ts new file mode 100644 index 000000000000..4683416e3946 --- /dev/null +++ b/app/client/src/utils/migrations/InputWidget.ts @@ -0,0 +1,26 @@ +import { WidgetProps } from "widgets/BaseWidget"; +import { DSLWidget } from "widgets/constants"; +import { ISDCodeProps, ISDCodeOptions } from "constants/ISDCodes"; + +export const migrateInputWidgetDefaultSelectedPhoneNumberCode = ( + currentDSL: DSLWidget, +) => { + currentDSL.children = currentDSL.children?.map((child: WidgetProps) => { + if (child.type === "INPUT_WIDGET") { + if (child.inputType === "PHONE_NUMBER" && child.phoneNumberCountryCode) { + const ISDCodeOption = ISDCodeOptions.find((item: ISDCodeProps) => { + return item.code === child.phoneNumberCountryCode; + }); + // eslint-disable-next-line no-console + console.log({ ISDCodeOption }); + if (ISDCodeOption) { + child.phoneNumberCountryCode = ISDCodeOption.dial_code; + } + } + } else if (child.children && child.children.length > 0) { + child = migrateInputWidgetDefaultSelectedPhoneNumberCode(child); + } + return child; + }); + return currentDSL; +}; From b428d3a7c6bcc8b219fb76dba87eb11d2edb6a1b Mon Sep 17 00:00:00 2001 From: "vicky.bansal@primathon.in" Date: Mon, 4 Oct 2021 11:45:40 +0530 Subject: [PATCH 5/8] remove console.log --- app/client/src/utils/migrations/InputWidget.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/client/src/utils/migrations/InputWidget.ts b/app/client/src/utils/migrations/InputWidget.ts index 4683416e3946..943ce48ddf45 100644 --- a/app/client/src/utils/migrations/InputWidget.ts +++ b/app/client/src/utils/migrations/InputWidget.ts @@ -11,8 +11,6 @@ export const migrateInputWidgetDefaultSelectedPhoneNumberCode = ( const ISDCodeOption = ISDCodeOptions.find((item: ISDCodeProps) => { return item.code === child.phoneNumberCountryCode; }); - // eslint-disable-next-line no-console - console.log({ ISDCodeOption }); if (ISDCodeOption) { child.phoneNumberCountryCode = ISDCodeOption.dial_code; } From e82ee44e9bb59542fabb58bcba74bfdedbb3b832 Mon Sep 17 00:00:00 2001 From: "vicky.bansal@primathon.in" Date: Wed, 6 Oct 2021 15:09:57 +0530 Subject: [PATCH 6/8] Fix cypress test --- .../Smoke_TestSuite/ClientSideTests/FormWidgets/Input_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/Input_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/Input_spec.js index c93a60654acd..1f40d4fb86be 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/Input_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/FormWidgets/Input_spec.js @@ -168,7 +168,7 @@ describe("Input Widget Functionality", function() { cy.get(commonlocators.inputCountryCodeChangeType) .invoke("text") .then((text) => { - expect(text).to.equal("🇺🇸+1"); + expect(text).to.equal("🇨🇦+1"); }); }); From a0f2e035addb7997eb76fce8d01fecf77e77fccf Mon Sep 17 00:00:00 2001 From: Vicky Date: Tue, 26 Oct 2021 13:33:00 +0530 Subject: [PATCH 7/8] Fix: currencyCountryCode to currencyCode binding --- .../src/utils/migrations/InputWidget.test.ts | 179 ++++++++++++++++++ .../src/utils/migrations/InputWidget.ts | 11 ++ 2 files changed, 190 insertions(+) diff --git a/app/client/src/utils/migrations/InputWidget.test.ts b/app/client/src/utils/migrations/InputWidget.test.ts index 1fd7e78d75c9..a23da3d122b4 100644 --- a/app/client/src/utils/migrations/InputWidget.test.ts +++ b/app/client/src/utils/migrations/InputWidget.test.ts @@ -121,4 +121,183 @@ describe("Input Widget Property Pane Upgrade", () => { const newDsl = migrateInputWidgetDefaultSelectedPhoneNumberCode(inputDsl); expect(newDsl).toStrictEqual(outputDsl); }); + + it("To test currencyCountryCode is binded to currencyCode", () => { + const inputDsl: DSLWidget = { + widgetName: "MainContainer", + backgroundColor: "none", + rightColumn: 1118, + snapColumns: 64, + detachFromLayout: true, + widgetId: "0", + topRow: 0, + bottomRow: 5016, + containerStyle: "none", + snapRows: 125, + parentRowSpace: 1, + type: "CANVAS_WIDGET", + canExtend: true, + version: 43, + minHeight: 700, + parentColumnSpace: 1, + dynamicBindingPathList: [], + leftColumn: 0, + children: [ + { + widgetName: "Input1", + displayName: "Input", + iconSVG: "/static/media/icon.9f505595.svg", + topRow: 15, + bottomRow: 19, + parentRowSpace: 10, + autoFocus: false, + type: "INPUT_WIDGET", + hideCard: false, + parentColumnSpace: 17.28125, + dynamicTriggerPathList: [], + resetOnSubmit: true, + leftColumn: 16, + dynamicBindingPathList: [], + labelStyle: "BOLD", + inputType: "CURRENCY", + isDisabled: false, + currencyCountryCode: "AD", + key: "8fnj1syb0s", + isRequired: false, + rightColumn: 36, + widgetId: "l2sm68nyut", + isVisible: true, + label: "", + allowCurrencyChange: true, + version: 1, + parentId: "0", + renderMode: "CANVAS", + isLoading: false, + iconAlign: "left", + defaultText: "", + }, + { + widgetName: "Text1", + displayName: "Text", + iconSVG: "/static/media/icon.e6c93592.svg", + topRow: 24, + bottomRow: 28, + parentRowSpace: 10, + type: "TEXT_WIDGET", + hideCard: false, + parentColumnSpace: 17.28125, + dynamicTriggerPathList: [], + leftColumn: 15, + dynamicBindingPathList: [ + { + key: "text", + }, + ], + text: "{{Input1.currencyCountryCode}}", + key: "2umcw47d8d", + rightColumn: 31, + textAlign: "LEFT", + widgetId: "zp0gap4y1m", + isVisible: true, + fontStyle: "BOLD", + textColor: "#231F20", + version: 1, + parentId: "0", + renderMode: "CANVAS", + isLoading: false, + fontSize: "PARAGRAPH", + }, + ], + }; + + const outputDsl: DSLWidget = { + widgetName: "MainContainer", + backgroundColor: "none", + rightColumn: 1118, + snapColumns: 64, + detachFromLayout: true, + widgetId: "0", + topRow: 0, + bottomRow: 5016, + containerStyle: "none", + snapRows: 125, + parentRowSpace: 1, + type: "CANVAS_WIDGET", + canExtend: true, + version: 43, + minHeight: 700, + parentColumnSpace: 1, + dynamicBindingPathList: [], + leftColumn: 0, + children: [ + { + widgetName: "Input1", + displayName: "Input", + iconSVG: "/static/media/icon.9f505595.svg", + topRow: 15, + bottomRow: 19, + parentRowSpace: 10, + autoFocus: false, + type: "INPUT_WIDGET", + hideCard: false, + parentColumnSpace: 17.28125, + dynamicTriggerPathList: [], + resetOnSubmit: true, + leftColumn: 16, + dynamicBindingPathList: [], + labelStyle: "BOLD", + inputType: "CURRENCY", + isDisabled: false, + currencyCountryCode: "AD", + key: "8fnj1syb0s", + isRequired: false, + rightColumn: 36, + widgetId: "l2sm68nyut", + isVisible: true, + label: "", + allowCurrencyChange: true, + version: 1, + parentId: "0", + renderMode: "CANVAS", + isLoading: false, + iconAlign: "left", + defaultText: "", + }, + { + widgetName: "Text1", + displayName: "Text", + iconSVG: "/static/media/icon.e6c93592.svg", + topRow: 24, + bottomRow: 28, + parentRowSpace: 10, + type: "TEXT_WIDGET", + hideCard: false, + parentColumnSpace: 17.28125, + dynamicTriggerPathList: [], + leftColumn: 15, + dynamicBindingPathList: [ + { + key: "text", + }, + ], + text: "{{Input1.currencyCode}}", + key: "2umcw47d8d", + rightColumn: 31, + textAlign: "LEFT", + widgetId: "zp0gap4y1m", + isVisible: true, + fontStyle: "BOLD", + textColor: "#231F20", + version: 1, + parentId: "0", + renderMode: "CANVAS", + isLoading: false, + fontSize: "PARAGRAPH", + }, + ], + }; + + const newDsl = migrateInputWidgetDefaultSelectedPhoneNumberCode(inputDsl); + expect(newDsl).toStrictEqual(outputDsl); + }); }); diff --git a/app/client/src/utils/migrations/InputWidget.ts b/app/client/src/utils/migrations/InputWidget.ts index 943ce48ddf45..5f8f641527c9 100644 --- a/app/client/src/utils/migrations/InputWidget.ts +++ b/app/client/src/utils/migrations/InputWidget.ts @@ -6,6 +6,16 @@ export const migrateInputWidgetDefaultSelectedPhoneNumberCode = ( currentDSL: DSLWidget, ) => { currentDSL.children = currentDSL.children?.map((child: WidgetProps) => { + for (const key in child) { + if ( + typeof child[key] === "string" && + child[key].includes(".currencyCountryCode") + ) + child[key] = child[key].replace( + ".currencyCountryCode", + ".currencyCode", + ); + } if (child.type === "INPUT_WIDGET") { if (child.inputType === "PHONE_NUMBER" && child.phoneNumberCountryCode) { const ISDCodeOption = ISDCodeOptions.find((item: ISDCodeProps) => { @@ -18,6 +28,7 @@ export const migrateInputWidgetDefaultSelectedPhoneNumberCode = ( } else if (child.children && child.children.length > 0) { child = migrateInputWidgetDefaultSelectedPhoneNumberCode(child); } + return child; }); return currentDSL; From cc7c48b75ffbbe9571a4a95959ab8c9de0b3a23b Mon Sep 17 00:00:00 2001 From: Vicky Date: Thu, 28 Oct 2021 15:09:32 +0530 Subject: [PATCH 8/8] Remove duplicate currencies from currencyOptions and add dialCode and code to currency migrations" --- app/client/src/constants/Currency.tsx | 648 ------------------ app/client/src/constants/WidgetConstants.tsx | 2 +- app/client/src/utils/DSLMigrations.ts | 4 + .../utils/autocomplete/EntityDefinitions.ts | 4 +- .../src/utils/migrations/InputWidget.ts | 19 +- .../src/widgets/InputWidget/widget/index.tsx | 6 +- 6 files changed, 28 insertions(+), 655 deletions(-) diff --git a/app/client/src/constants/Currency.tsx b/app/client/src/constants/Currency.tsx index 04ea4d199cde..db5c8cbc4c3f 100644 --- a/app/client/src/constants/Currency.tsx +++ b/app/client/src/constants/Currency.tsx @@ -66,14 +66,6 @@ export const CurrencyTypeOptions: Array = [ phone: "1-684", symbol_native: "$", }, - { - code: "AT", - currency: "EUR", - currency_name: "Euro", - label: "Austria", - phone: "43", - symbol_native: "€", - }, { code: "AU", currency: "AUD", @@ -82,14 +74,6 @@ export const CurrencyTypeOptions: Array = [ phone: "61", symbol_native: "$", }, - { - code: "AX", - currency: "EUR", - currency_name: "Euro", - label: "Alland Islands", - phone: "358", - symbol_native: "€", - }, { code: "AZ", currency: "AZN", @@ -114,14 +98,6 @@ export const CurrencyTypeOptions: Array = [ phone: "880", symbol_native: "৳", }, - { - code: "BE", - currency: "EUR", - currency_name: "Euro", - label: "Belgium", - phone: "32", - symbol_native: "€", - }, { code: "BF", currency: "XOF", @@ -154,22 +130,6 @@ export const CurrencyTypeOptions: Array = [ phone: "257", symbol_native: "FBu", }, - { - code: "BJ", - currency: "XOF", - currency_name: "CFA Franc BCEAO", - label: "Benin", - phone: "229", - symbol_native: "CFA", - }, - { - code: "BL", - currency: "EUR", - currency_name: "Euro", - label: "Saint Barthelemy", - phone: "590", - symbol_native: "€", - }, { code: "BN", currency: "BND", @@ -234,14 +194,6 @@ export const CurrencyTypeOptions: Array = [ phone: "1", symbol_native: "$", }, - { - code: "CC", - currency: "AUD", - currency_name: "Australian Dollar", - label: "Cocos (Keeling) Islands", - phone: "61", - symbol_native: "$", - }, { code: "CD", currency: "CDF", @@ -258,14 +210,6 @@ export const CurrencyTypeOptions: Array = [ phone: "236", symbol_native: "FCFA", }, - { - code: "CG", - currency: "XAF", - currency_name: "CFA Franc BEAC", - label: "Congo, Republic of the", - phone: "242", - symbol_native: "FCFA", - }, { code: "CH", currency: "CHF", @@ -274,14 +218,6 @@ export const CurrencyTypeOptions: Array = [ phone: "41", symbol_native: "CHF", }, - { - code: "CI", - currency: "XOF", - currency_name: "CFA Franc BCEAO", - label: "Cote d'Ivoire", - phone: "225", - symbol_native: "CFA", - }, { code: "CK", currency: "NZD", @@ -298,14 +234,6 @@ export const CurrencyTypeOptions: Array = [ phone: "56", symbol_native: "$", }, - { - code: "CM", - currency: "XAF", - currency_name: "CFA Franc BEAC", - label: "Cameroon", - phone: "237", - symbol_native: "FCFA", - }, { code: "CN", currency: "CNY", @@ -338,22 +266,6 @@ export const CurrencyTypeOptions: Array = [ phone: "238", symbol_native: "CV$", }, - { - code: "CX", - currency: "AUD", - currency_name: "Australian Dollar", - label: "Christmas Island", - phone: "61", - symbol_native: "$", - }, - { - code: "CY", - currency: "EUR", - currency_name: "Euro", - label: "Cyprus", - phone: "357", - symbol_native: "€", - }, { code: "CZ", currency: "CZK", @@ -362,14 +274,6 @@ export const CurrencyTypeOptions: Array = [ phone: "420", symbol_native: "Kč", }, - { - code: "DE", - currency: "EUR", - currency_name: "Euro", - label: "Germany", - phone: "49", - symbol_native: "€", - }, { code: "DJ", currency: "DJF", @@ -402,22 +306,6 @@ export const CurrencyTypeOptions: Array = [ phone: "213", symbol_native: "د.ج.‏", }, - { - code: "EC", - currency: "USD", - currency_name: "US Dollar", - label: "Ecuador", - phone: "593", - symbol_native: "$", - }, - { - code: "EE", - currency: "EUR", - currency_name: "Euro", - label: "Estonia", - phone: "372", - symbol_native: "€", - }, { code: "EG", currency: "EGP", @@ -442,14 +330,6 @@ export const CurrencyTypeOptions: Array = [ phone: "291", symbol_native: "Nfk", }, - { - code: "ES", - currency: "EUR", - currency_name: "Euro", - label: "Spain", - phone: "34", - symbol_native: "€", - }, { code: "ET", currency: "ETB", @@ -458,46 +338,6 @@ export const CurrencyTypeOptions: Array = [ phone: "251", symbol_native: "Br", }, - { - code: "FI", - currency: "EUR", - currency_name: "Euro", - label: "Finland", - phone: "358", - symbol_native: "€", - }, - { - code: "FM", - currency: "USD", - currency_name: "US Dollar", - label: "Micronesia, Federated States of", - phone: "691", - symbol_native: "$", - }, - { - code: "FO", - currency: "DKK", - currency_name: "Danish Krone", - label: "Faroe Islands", - phone: "298", - symbol_native: "kr", - }, - { - code: "FR", - currency: "EUR", - currency_name: "Euro", - label: "France", - phone: "33", - symbol_native: "€", - }, - { - code: "GA", - currency: "XAF", - currency_name: "CFA Franc BEAC", - label: "Gabon", - phone: "241", - symbol_native: "FCFA", - }, { code: "GB", currency: "GBP", @@ -514,22 +354,6 @@ export const CurrencyTypeOptions: Array = [ phone: "995", symbol_native: "GEL", }, - { - code: "GF", - currency: "EUR", - currency_name: "Euro", - label: "French Guiana", - phone: "594", - symbol_native: "€", - }, - { - code: "GG", - currency: "GBP", - currency_name: "British Pound Sterling", - label: "Guernsey", - phone: "44", - symbol_native: "£", - }, { code: "GH", currency: "GHS", @@ -538,14 +362,6 @@ export const CurrencyTypeOptions: Array = [ phone: "233", symbol_native: "GH₵", }, - { - code: "GL", - currency: "DKK", - currency_name: "Danish Krone", - label: "Greenland", - phone: "299", - symbol_native: "kr", - }, { code: "GN", currency: "GNF", @@ -554,38 +370,6 @@ export const CurrencyTypeOptions: Array = [ phone: "224", symbol_native: "FG", }, - { - code: "GP", - currency: "EUR", - currency_name: "Euro", - label: "Guadeloupe", - phone: "590", - symbol_native: "€", - }, - { - code: "GQ", - currency: "XAF", - currency_name: "CFA Franc BEAC", - label: "Equatorial Guinea", - phone: "240", - symbol_native: "FCFA", - }, - { - code: "GR", - currency: "EUR", - currency_name: "Euro", - label: "Greece", - phone: "30", - symbol_native: "€", - }, - { - code: "GS", - currency: "GBP", - currency_name: "British Pound Sterling", - label: "South Georgia and the South Sandwich Islands", - phone: "500", - symbol_native: "£", - }, { code: "GT", currency: "GTQ", @@ -594,22 +378,6 @@ export const CurrencyTypeOptions: Array = [ phone: "502", symbol_native: "Q", }, - { - code: "GU", - currency: "USD", - currency_name: "US Dollar", - label: "Guam", - phone: "1-671", - symbol_native: "$", - }, - { - code: "GW", - currency: "XOF", - currency_name: "CFA Franc BCEAO", - label: "Guinea-Bissau", - phone: "245", - symbol_native: "CFA", - }, { code: "HK", currency: "HKD", @@ -618,14 +386,6 @@ export const CurrencyTypeOptions: Array = [ phone: "852", symbol_native: "$", }, - { - code: "HM", - currency: "AUD", - currency_name: "Australian Dollar", - label: "Heard Island and McDonald Islands", - phone: "672", - symbol_native: "$", - }, { code: "HN", currency: "HNL", @@ -658,14 +418,6 @@ export const CurrencyTypeOptions: Array = [ phone: "62", symbol_native: "Rp", }, - { - code: "IE", - currency: "EUR", - currency_name: "Euro", - label: "Ireland", - phone: "353", - symbol_native: "€", - }, { code: "IL", currency: "ILS", @@ -674,14 +426,6 @@ export const CurrencyTypeOptions: Array = [ phone: "972", symbol_native: "₪", }, - { - code: "IM", - currency: "GBP", - currency_name: "British Pound Sterling", - label: "Isle of Man", - phone: "44", - symbol_native: "£", - }, { code: "IN", currency: "INR", @@ -690,14 +434,6 @@ export const CurrencyTypeOptions: Array = [ phone: "91", symbol_native: "₹", }, - { - code: "IO", - currency: "USD", - currency_name: "US Dollar", - label: "British Indian Ocean Territory", - phone: "246", - symbol_native: "$", - }, { code: "IQ", currency: "IQD", @@ -722,22 +458,6 @@ export const CurrencyTypeOptions: Array = [ phone: "354", symbol_native: "kr", }, - { - code: "IT", - currency: "EUR", - currency_name: "Euro", - label: "Italy", - phone: "39", - symbol_native: "€", - }, - { - code: "JE", - currency: "GBP", - currency_name: "British Pound Sterling", - label: "Jersey", - phone: "44", - symbol_native: "£", - }, { code: "JM", currency: "JMD", @@ -778,14 +498,6 @@ export const CurrencyTypeOptions: Array = [ phone: "855", symbol_native: "៛", }, - { - code: "KI", - currency: "AUD", - currency_name: "Australian Dollar", - label: "Kiribati", - phone: "686", - symbol_native: "$", - }, { code: "KM", currency: "KMF", @@ -826,14 +538,6 @@ export const CurrencyTypeOptions: Array = [ phone: "961", symbol_native: "ل.ل.‏", }, - { - code: "LI", - currency: "CHF", - currency_name: "Swiss Franc", - label: "Liechtenstein", - phone: "423", - symbol_native: "CHF", - }, { code: "LK", currency: "LKR", @@ -850,22 +554,6 @@ export const CurrencyTypeOptions: Array = [ phone: "370", symbol_native: "Lt", }, - { - code: "LU", - currency: "EUR", - currency_name: "Euro", - label: "Luxembourg", - phone: "352", - symbol_native: "€", - }, - { - code: "LV", - currency: "EUR", - currency_name: "Euro", - label: "Latvia", - phone: "371", - symbol_native: "€", - }, { code: "LY", currency: "LYD", @@ -874,22 +562,6 @@ export const CurrencyTypeOptions: Array = [ phone: "218", symbol_native: "د.ل.‏", }, - { - code: "MA", - currency: "MAD", - currency_name: "Moroccan Dirham", - label: "Morocco", - phone: "212", - symbol_native: "د.م.‏", - }, - { - code: "MC", - currency: "EUR", - currency_name: "Euro", - label: "Monaco", - phone: "377", - symbol_native: "€", - }, { code: "MD", currency: "MDL", @@ -898,22 +570,6 @@ export const CurrencyTypeOptions: Array = [ phone: "373", symbol_native: "MDL", }, - { - code: "ME", - currency: "EUR", - currency_name: "Euro", - label: "Montenegro", - phone: "382", - symbol_native: "€", - }, - { - code: "MF", - currency: "EUR", - currency_name: "Euro", - label: "Saint Martin (French part)", - phone: "590", - symbol_native: "€", - }, { code: "MG", currency: "MGA", @@ -922,14 +578,6 @@ export const CurrencyTypeOptions: Array = [ phone: "261", symbol_native: "MGA", }, - { - code: "MH", - currency: "USD", - currency_name: "US Dollar", - label: "Marshall Islands", - phone: "692", - symbol_native: "$", - }, { code: "MK", currency: "MKD", @@ -938,14 +586,6 @@ export const CurrencyTypeOptions: Array = [ phone: "389", symbol_native: "MKD", }, - { - code: "ML", - currency: "XOF", - currency_name: "CFA Franc BCEAO", - label: "Mali", - phone: "223", - symbol_native: "CFA", - }, { code: "MM", currency: "MMK", @@ -962,30 +602,6 @@ export const CurrencyTypeOptions: Array = [ phone: "853", symbol_native: "MOP$", }, - { - code: "MP", - currency: "USD", - currency_name: "US Dollar", - label: "Northern Mariana Islands", - phone: "1-670", - symbol_native: "$", - }, - { - code: "MQ", - currency: "EUR", - currency_name: "Euro", - label: "Martinique", - phone: "596", - symbol_native: "€", - }, - { - code: "MT", - currency: "EUR", - currency_name: "Euro", - label: "Malta", - phone: "356", - symbol_native: "€", - }, { code: "MU", currency: "MUR", @@ -1026,22 +642,6 @@ export const CurrencyTypeOptions: Array = [ phone: "264", symbol_native: "N$", }, - { - code: "NE", - currency: "XOF", - currency_name: "CFA Franc BCEAO", - label: "Niger", - phone: "227", - symbol_native: "CFA", - }, - { - code: "NF", - currency: "AUD", - currency_name: "Australian Dollar", - label: "Norfolk Island", - phone: "672", - symbol_native: "$", - }, { code: "NG", currency: "NGN", @@ -1058,22 +658,6 @@ export const CurrencyTypeOptions: Array = [ phone: "505", symbol_native: "C$", }, - { - code: "NL", - currency: "EUR", - currency_name: "Euro", - label: "Netherlands", - phone: "31", - symbol_native: "€", - }, - { - code: "NO", - currency: "NOK", - currency_name: "Norwegian Krone", - label: "Norway", - phone: "47", - symbol_native: "kr", - }, { code: "NP", currency: "NPR", @@ -1082,30 +666,6 @@ export const CurrencyTypeOptions: Array = [ phone: "977", symbol_native: "नेरू", }, - { - code: "NR", - currency: "AUD", - currency_name: "Australian Dollar", - label: "Nauru", - phone: "674", - symbol_native: "$", - }, - { - code: "NU", - currency: "NZD", - currency_name: "New Zealand Dollar", - label: "Niue", - phone: "683", - symbol_native: "$", - }, - { - code: "NZ", - currency: "NZD", - currency_name: "New Zealand Dollar", - label: "New Zealand", - phone: "64", - symbol_native: "$", - }, { code: "OM", currency: "OMR", @@ -1154,54 +714,6 @@ export const CurrencyTypeOptions: Array = [ phone: "48", symbol_native: "zł", }, - { - code: "PM", - currency: "EUR", - currency_name: "Euro", - label: "Saint Pierre and Miquelon", - phone: "508", - symbol_native: "€", - }, - { - code: "PN", - currency: "NZD", - currency_name: "New Zealand Dollar", - label: "Pitcairn", - phone: "870", - symbol_native: "$", - }, - { - code: "PR", - currency: "USD", - currency_name: "US Dollar", - label: "Puerto Rico", - phone: "1", - symbol_native: "$", - }, - { - code: "PS", - currency: "ILS", - currency_name: "Israeli New Sheqel", - label: "Palestine, State of", - phone: "970", - symbol_native: "₪", - }, - { - code: "PT", - currency: "EUR", - currency_name: "Euro", - label: "Portugal", - phone: "351", - symbol_native: "€", - }, - { - code: "PW", - currency: "USD", - currency_name: "US Dollar", - label: "Palau", - phone: "680", - symbol_native: "$", - }, { code: "PY", currency: "PYG", @@ -1218,14 +730,6 @@ export const CurrencyTypeOptions: Array = [ phone: "974", symbol_native: "ر.ق.‏", }, - { - code: "RE", - currency: "EUR", - currency_name: "Euro", - label: "Reunion", - phone: "262", - symbol_native: "€", - }, { code: "RO", currency: "RON", @@ -1290,46 +794,6 @@ export const CurrencyTypeOptions: Array = [ phone: "65", symbol_native: "$", }, - { - code: "SI", - currency: "EUR", - currency_name: "Euro", - label: "Slovenia", - phone: "386", - symbol_native: "€", - }, - { - code: "SJ", - currency: "NOK", - currency_name: "Norwegian Krone", - label: "Svalbard and Jan Mayen", - phone: "47", - symbol_native: "kr", - }, - { - code: "SK", - currency: "EUR", - currency_name: "Euro", - label: "Slovakia", - phone: "421", - symbol_native: "€", - }, - { - code: "SM", - currency: "EUR", - currency_name: "Euro", - label: "San Marino", - phone: "378", - symbol_native: "€", - }, - { - code: "SN", - currency: "XOF", - currency_name: "CFA Franc BCEAO", - label: "Senegal", - phone: "221", - symbol_native: "CFA", - }, { code: "SO", currency: "SOS", @@ -1338,14 +802,6 @@ export const CurrencyTypeOptions: Array = [ phone: "252", symbol_native: "Ssh", }, - { - code: "SV", - currency: "USD", - currency_name: "US Dollar", - label: "El Salvador", - phone: "503", - symbol_native: "$", - }, { code: "SY", currency: "SYP", @@ -1354,38 +810,6 @@ export const CurrencyTypeOptions: Array = [ phone: "963", symbol_native: "ل.س.‏", }, - { - code: "TC", - currency: "USD", - currency_name: "US Dollar", - label: "Turks and Caicos Islands", - phone: "1-649", - symbol_native: "$", - }, - { - code: "TD", - currency: "XAF", - currency_name: "CFA Franc BEAC", - label: "Chad", - phone: "235", - symbol_native: "FCFA", - }, - { - code: "TF", - currency: "EUR", - currency_name: "Euro", - label: "French Southern Territories", - phone: "262", - symbol_native: "€", - }, - { - code: "TG", - currency: "XOF", - currency_name: "CFA Franc BCEAO", - label: "Togo", - phone: "228", - symbol_native: "CFA", - }, { code: "TH", currency: "THB", @@ -1394,22 +818,6 @@ export const CurrencyTypeOptions: Array = [ phone: "66", symbol_native: "฿", }, - { - code: "TK", - currency: "NZD", - currency_name: "New Zealand Dollar", - label: "Tokelau", - phone: "690", - symbol_native: "$", - }, - { - code: "TL", - currency: "USD", - currency_name: "US Dollar", - label: "Timor-Leste", - phone: "670", - symbol_native: "$", - }, { code: "TN", currency: "TND", @@ -1442,14 +850,6 @@ export const CurrencyTypeOptions: Array = [ phone: "1-868", symbol_native: "$", }, - { - code: "TV", - currency: "AUD", - currency_name: "Australian Dollar", - label: "Tuvalu", - phone: "688", - symbol_native: "$", - }, { code: "TW", currency: "TWD", @@ -1482,14 +882,6 @@ export const CurrencyTypeOptions: Array = [ phone: "256", symbol_native: "USh", }, - { - code: "US", - currency: "USD", - currency_name: "US Dollar", - label: "United States", - phone: "1", - symbol_native: "$", - }, { code: "UY", currency: "UYU", @@ -1506,14 +898,6 @@ export const CurrencyTypeOptions: Array = [ phone: "998", symbol_native: "UZS", }, - { - code: "VA", - currency: "EUR", - currency_name: "Euro", - label: "Holy See (Vatican City State)", - phone: "379", - symbol_native: "€", - }, { code: "VE", currency: "VEF", @@ -1522,22 +906,6 @@ export const CurrencyTypeOptions: Array = [ phone: "58", symbol_native: "Bs.F.", }, - { - code: "VG", - currency: "USD", - currency_name: "US Dollar", - label: "British Virgin Islands", - phone: "1-284", - symbol_native: "$", - }, - { - code: "VI", - currency: "USD", - currency_name: "US Dollar", - label: "US Virgin Islands", - phone: "1-340", - symbol_native: "$", - }, { code: "VN", currency: "VND", @@ -1546,14 +914,6 @@ export const CurrencyTypeOptions: Array = [ phone: "84", symbol_native: "₫", }, - { - code: "XK", - currency: "EUR", - currency_name: "Euro", - label: "Kosovo", - phone: "383", - symbol_native: "€", - }, { code: "YE", currency: "YER", @@ -1562,14 +922,6 @@ export const CurrencyTypeOptions: Array = [ phone: "967", symbol_native: "ر.ي.‏", }, - { - code: "YT", - currency: "EUR", - currency_name: "Euro", - label: "Mayotte", - phone: "262", - symbol_native: "€", - }, { code: "ZA", currency: "ZAR", diff --git a/app/client/src/constants/WidgetConstants.tsx b/app/client/src/constants/WidgetConstants.tsx index 318af30687c4..9638b9de8a32 100644 --- a/app/client/src/constants/WidgetConstants.tsx +++ b/app/client/src/constants/WidgetConstants.tsx @@ -69,7 +69,7 @@ export const layoutConfigurations: LayoutConfigurations = { FLUID: { minWidth: -1, maxWidth: -1 }, }; -export const LATEST_PAGE_VERSION = 45; +export const LATEST_PAGE_VERSION = 46; export const GridDefaults = { DEFAULT_CELL_SIZE: 1, diff --git a/app/client/src/utils/DSLMigrations.ts b/app/client/src/utils/DSLMigrations.ts index 58d5e9bd2ce1..8ac4d72bd265 100644 --- a/app/client/src/utils/DSLMigrations.ts +++ b/app/client/src/utils/DSLMigrations.ts @@ -979,6 +979,10 @@ export const transformDSL = ( } if (currentDSL.version === 44) { currentDSL = isSortableMigration(currentDSL); + currentDSL.version = 45; + } + if (currentDSL.version === 45) { + currentDSL = migrateInputWidgetDefaultSelectedPhoneNumberCode(currentDSL); currentDSL.version = LATEST_PAGE_VERSION; } diff --git a/app/client/src/utils/autocomplete/EntityDefinitions.ts b/app/client/src/utils/autocomplete/EntityDefinitions.ts index 10779df759b9..e98c84fec114 100644 --- a/app/client/src/utils/autocomplete/EntityDefinitions.ts +++ b/app/client/src/utils/autocomplete/EntityDefinitions.ts @@ -62,9 +62,9 @@ export const entityDefinitions: Record = { isValid: "bool", isVisible: isVisible, isDisabled: "bool", - countryCode: { + dialCode: { "!type": "string", - "!doc": "Selected country code for Phone Number type input", + "!doc": "Selected international dialing code for Phone Number type input", }, currencyCode: { "!type": "string", diff --git a/app/client/src/utils/migrations/InputWidget.ts b/app/client/src/utils/migrations/InputWidget.ts index 5f8f641527c9..2a40cb6e00f2 100644 --- a/app/client/src/utils/migrations/InputWidget.ts +++ b/app/client/src/utils/migrations/InputWidget.ts @@ -1,6 +1,7 @@ import { WidgetProps } from "widgets/BaseWidget"; import { DSLWidget } from "widgets/constants"; import { ISDCodeProps, ISDCodeOptions } from "constants/ISDCodes"; +import { CurrencyOptionProps, CurrencyTypeOptions } from "constants/Currency"; export const migrateInputWidgetDefaultSelectedPhoneNumberCode = ( currentDSL: DSLWidget, @@ -10,11 +11,17 @@ export const migrateInputWidgetDefaultSelectedPhoneNumberCode = ( if ( typeof child[key] === "string" && child[key].includes(".currencyCountryCode") - ) + ) { child[key] = child[key].replace( ".currencyCountryCode", ".currencyCode", ); + } else if ( + typeof child[key] === "string" && + child[key].includes(".countryCode") + ) { + child[key] = child[key].replace(".countryCode", ".dialCode"); + } } if (child.type === "INPUT_WIDGET") { if (child.inputType === "PHONE_NUMBER" && child.phoneNumberCountryCode) { @@ -25,6 +32,16 @@ export const migrateInputWidgetDefaultSelectedPhoneNumberCode = ( child.phoneNumberCountryCode = ISDCodeOption.dial_code; } } + if (child.inputType === "CURRENCY" && child.currencyCode) { + const CurrencyTypeOption = CurrencyTypeOptions.find( + (item: CurrencyOptionProps) => { + return item.code === child.currencyCode; + }, + ); + if (CurrencyTypeOption) { + child.currencyCode = CurrencyTypeOption.currency; + } + } } else if (child.children && child.children.length > 0) { child = migrateInputWidgetDefaultSelectedPhoneNumberCode(child); } diff --git a/app/client/src/widgets/InputWidget/widget/index.tsx b/app/client/src/widgets/InputWidget/widget/index.tsx index f9a213077e40..533a1e6b74c0 100644 --- a/app/client/src/widgets/InputWidget/widget/index.tsx +++ b/app/client/src/widgets/InputWidget/widget/index.tsx @@ -564,7 +564,7 @@ class InputWidget extends BaseWidget { } })() }}`, - countryCode: `{{this.selectedPhoneNumberCountryCode ? this.selectedPhoneNumberCountryCode : this.phoneNumberCountryCode}}`, + dialCode: `{{this.selectedPhoneNumberCountryCode ? this.selectedPhoneNumberCountryCode : this.phoneNumberCountryCode}}`, currencyCode: `{{this.selectedCurrencyCountryCode ? this.selectedCurrencyCountryCode : this.currencyCountryCode}}`, value: `{{this.text}}`, }; @@ -721,7 +721,7 @@ class InputWidget extends BaseWidget { onISDCodeChange={this.onISDCodeChange} onKeyDown={this.handleKeyDown} onValueChange={this.onValueChange} - phoneNumberCountryCode={this.props.countryCode} + phoneNumberCountryCode={this.props.dialCode} placeholder={this.props.placeholderText} showError={!!this.props.isFocused} stepSize={1} @@ -748,7 +748,7 @@ export interface InputWidgetProps extends WidgetProps { noOfDecimals?: number; allowCurrencyChange?: boolean; phoneNumberCountryCode?: string; - countryCode?: string; + dialCode?: string; currencyCode?: string; decimalsInCurrency?: number; defaultText?: string | number;