Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add country field backend #3770

Merged
merged 5 commits into from
Jun 22, 2022

Conversation

jia1
Copy link
Member

@jia1 jia1 commented Apr 19, 2022

Problem

  • Create country field backend

Partially solves #481

Solution

Breaking Changes

  • Yes - this PR contains breaking changes
    • Details ...
  • No - this PR is backwards compatible

Features:

  • This PR is largely a copy of !3015
  • There is a TODO in src/public/modules/forms/services/form-fields.client.service.js which says Unhide Country field once the frontend for Country field is done.

Before & After Screenshots

N/A

Tests

src/app/utils/field-validation/validators/__tests__/country-validation.spec.ts

@jia1 jia1 requested a review from karrui April 19, 2022 09:29
@jia1 jia1 self-assigned this Apr 19, 2022
@jia1 jia1 added the contribute free for contributors to pick up label Apr 19, 2022
Copy link
Contributor

@karrui karrui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waiting on build fixes before reviewing

Copy link
Contributor

@karrui karrui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but let's refrain from merging yet, since this will be going into the react branch. can continue to react implementation for prefilling of fields!

@jia1 jia1 force-pushed the form-v2/add-country-field-backend branch from f93611f to 869dcee Compare June 15, 2022 08:52
@jia1 jia1 force-pushed the form-v2/add-country-field-backend branch from 869dcee to 2313c23 Compare June 21, 2022 12:19
@karrui karrui changed the base branch from form-v2/develop to form-v2/jia1-country-field June 22, 2022 09:35
@karrui
Copy link
Contributor

karrui commented Jun 22, 2022

updated your base branch to another one so you can squash and continue with other PRs without this dangling!

@jia1 jia1 merged commit 199bc04 into form-v2/jia1-country-field Jun 22, 2022
@jia1 jia1 deleted the form-v2/add-country-field-backend branch June 22, 2022 10:11
jia1 added a commit that referenced this pull request Aug 31, 2022
* feat: add country field backend

* fix: Fix Property 'country' is missing

* fix: replace BasicField.Dropdown in CountryField story

* fix: import CountryField into FieldFactory

* fix: fix type errors due to lack of handling for new country field

Co-authored-by: Kar Rui <[email protected]>
jia1 added a commit that referenced this pull request Aug 31, 2022
* feat: add country field backend

* fix: Fix Property 'country' is missing

* fix: replace BasicField.Dropdown in CountryField story

* fix: import CountryField into FieldFactory

* fix: fix type errors due to lack of handling for new country field

Co-authored-by: Kar Rui <[email protected]>
jia1 added a commit that referenced this pull request Oct 12, 2022
* feat: add country field backend (#3770)

* feat: add country field backend

* fix: Fix Property 'country' is missing

* fix: replace BasicField.Dropdown in CountryField story

* fix: import CountryField into FieldFactory

* fix: fix type errors due to lack of handling for new country field

Co-authored-by: Kar Rui <[email protected]>

* feat: add Country field to frontend

* feat: move Singapore up to the first value in the Country enum

* test: add tests for CountryField

* fix: update the typed characters in the partial typing test case

* test: adjust test case for partial typing in Country field

* refactor: rename Country enum to CountryRegion

* refactor: rename BasicField.Country to BasicField.CountryRegion

* refactor: rename CountryField to CountryRegionField

* fix: commit renaming changes for tests/

* refactor: rename *Country* to *CountryRegion* in frontend edit field folder

* feat: sort CountryRegion enums inside CountryRegionField

* fix: remove removed isSaveEnabled prop

* fix: inline sort country options constant

* test: update CountryRegionField tests

* fix(CountryRegionField): correctly set singapore as the first option

also update tests to use the options that the field uses

* style: use flag icon and fix capitalisation for CountryRegion

* feat: allow validation rule overriding for DropdownField

* fix: update error message for invalid Country/Region

* test: fix country/region capitalisation in test

Co-authored-by: Kar Rui <[email protected]>
jia1 added a commit that referenced this pull request Jun 13, 2023
* feat: add country field backend

* fix: Fix Property 'country' is missing

* fix: replace BasicField.Dropdown in CountryField story

* fix: import CountryField into FieldFactory

* fix: fix type errors due to lack of handling for new country field

Co-authored-by: Kar Rui <[email protected]>
jia1 added a commit that referenced this pull request Jun 13, 2023
* feat: add country field backend (#3770)

* feat: add country field backend

* fix: Fix Property 'country' is missing

* fix: replace BasicField.Dropdown in CountryField story

* fix: import CountryField into FieldFactory

* fix: fix type errors due to lack of handling for new country field

Co-authored-by: Kar Rui <[email protected]>

* feat: add Country field to frontend

* feat: move Singapore up to the first value in the Country enum

* test: add tests for CountryField

* fix: update the typed characters in the partial typing test case

* test: adjust test case for partial typing in Country field

* refactor: rename Country enum to CountryRegion

* refactor: rename BasicField.Country to BasicField.CountryRegion

* refactor: rename CountryField to CountryRegionField

* fix: commit renaming changes for tests/

* refactor: rename *Country* to *CountryRegion* in frontend edit field folder

* feat: sort CountryRegion enums inside CountryRegionField

* fix: remove removed isSaveEnabled prop

* fix: inline sort country options constant

* test: update CountryRegionField tests

* fix(CountryRegionField): correctly set singapore as the first option

also update tests to use the options that the field uses

* style: use flag icon and fix capitalisation for CountryRegion

* feat: allow validation rule overriding for DropdownField

* fix: update error message for invalid Country/Region

* test: fix country/region capitalisation in test

Co-authored-by: Kar Rui <[email protected]>
tshuli added a commit that referenced this pull request Aug 2, 2023
* feat: add country field backend (#3770)

* feat: add country field backend

* fix: Fix Property 'country' is missing

* fix: replace BasicField.Dropdown in CountryField story

* fix: import CountryField into FieldFactory

* fix: fix type errors due to lack of handling for new country field

Co-authored-by: Kar Rui <[email protected]>

* feat: add CountryRegion field to frontend (#4112)

* feat: add country field backend (#3770)

* feat: add country field backend

* fix: Fix Property 'country' is missing

* fix: replace BasicField.Dropdown in CountryField story

* fix: import CountryField into FieldFactory

* fix: fix type errors due to lack of handling for new country field

Co-authored-by: Kar Rui <[email protected]>

* feat: add Country field to frontend

* feat: move Singapore up to the first value in the Country enum

* test: add tests for CountryField

* fix: update the typed characters in the partial typing test case

* test: adjust test case for partial typing in Country field

* refactor: rename Country enum to CountryRegion

* refactor: rename BasicField.Country to BasicField.CountryRegion

* refactor: rename CountryField to CountryRegionField

* fix: commit renaming changes for tests/

* refactor: rename *Country* to *CountryRegion* in frontend edit field folder

* feat: sort CountryRegion enums inside CountryRegionField

* fix: remove removed isSaveEnabled prop

* fix: inline sort country options constant

* test: update CountryRegionField tests

* fix(CountryRegionField): correctly set singapore as the first option

also update tests to use the options that the field uses

* style: use flag icon and fix capitalisation for CountryRegion

* feat: allow validation rule overriding for DropdownField

* fix: update error message for invalid Country/Region

* test: fix country/region capitalisation in test

Co-authored-by: Kar Rui <[email protected]>

* fix: remove duplicate country files

* fix: remove duplicate country field files and restore TODO

* chore: rename test file

* fix: add missing imports

* fix: use new CreatePageDrawerContentContainer component

* fix: dropdown now uses requiredSingleAnswerValidationFn for validation

* fix: add validation and processing of CountryRegion fields on client

* refactor: implement specific CRField instead of using DropdownField

* fix: remove unused field schema regression

* feat: make CountryRegion values uppercase when sent to the server

* Revert "feat: make CountryRegion values uppercase when sent to the server"

This reverts commit be8a9d3.

* fix: use title-case country/region only in render

* Revert "fix: use title-case country/region only in render"

This reverts commit 589af79.

* feat: transform Country/Region form inputs to upper-case on submit

* fix: validate against upper-case country/region, add comments on why this is done, and remove reference to any

* fix: remove reference to toString()

* fix: simulate transformations from handleSubmitForm in country-region-validation.spec.ts

* fix: resolve rebase and use === instead of ==

* fix: remove duplicate import

* chore: fix prettier violations

* fix: update generate-form-data import path

* fix: follow DropdownField's way of querying input element and casting options

* fix: update INVALID_COUNTRY_REGION_OPTION_ERROR

* fix: linting

* fix: use uppercased countryregion for non-fetch submission

---------

Co-authored-by: Kar Rui <[email protected]>
Co-authored-by: Jiayee Lim <[email protected]>
Co-authored-by: Jiayee <[email protected]>
Co-authored-by: tshuli <[email protected]>
LeonardYam pushed a commit to LeonardYam/FormSG that referenced this pull request Aug 3, 2023
* feat: add country field backend (opengovsg#3770)

* feat: add country field backend

* fix: Fix Property 'country' is missing

* fix: replace BasicField.Dropdown in CountryField story

* fix: import CountryField into FieldFactory

* fix: fix type errors due to lack of handling for new country field

Co-authored-by: Kar Rui <[email protected]>

* feat: add CountryRegion field to frontend (opengovsg#4112)

* feat: add country field backend (opengovsg#3770)

* feat: add country field backend

* fix: Fix Property 'country' is missing

* fix: replace BasicField.Dropdown in CountryField story

* fix: import CountryField into FieldFactory

* fix: fix type errors due to lack of handling for new country field

Co-authored-by: Kar Rui <[email protected]>

* feat: add Country field to frontend

* feat: move Singapore up to the first value in the Country enum

* test: add tests for CountryField

* fix: update the typed characters in the partial typing test case

* test: adjust test case for partial typing in Country field

* refactor: rename Country enum to CountryRegion

* refactor: rename BasicField.Country to BasicField.CountryRegion

* refactor: rename CountryField to CountryRegionField

* fix: commit renaming changes for tests/

* refactor: rename *Country* to *CountryRegion* in frontend edit field folder

* feat: sort CountryRegion enums inside CountryRegionField

* fix: remove removed isSaveEnabled prop

* fix: inline sort country options constant

* test: update CountryRegionField tests

* fix(CountryRegionField): correctly set singapore as the first option

also update tests to use the options that the field uses

* style: use flag icon and fix capitalisation for CountryRegion

* feat: allow validation rule overriding for DropdownField

* fix: update error message for invalid Country/Region

* test: fix country/region capitalisation in test

Co-authored-by: Kar Rui <[email protected]>

* fix: remove duplicate country files

* fix: remove duplicate country field files and restore TODO

* chore: rename test file

* fix: add missing imports

* fix: use new CreatePageDrawerContentContainer component

* fix: dropdown now uses requiredSingleAnswerValidationFn for validation

* fix: add validation and processing of CountryRegion fields on client

* refactor: implement specific CRField instead of using DropdownField

* fix: remove unused field schema regression

* feat: make CountryRegion values uppercase when sent to the server

* Revert "feat: make CountryRegion values uppercase when sent to the server"

This reverts commit be8a9d3.

* fix: use title-case country/region only in render

* Revert "fix: use title-case country/region only in render"

This reverts commit 589af79.

* feat: transform Country/Region form inputs to upper-case on submit

* fix: validate against upper-case country/region, add comments on why this is done, and remove reference to any

* fix: remove reference to toString()

* fix: simulate transformations from handleSubmitForm in country-region-validation.spec.ts

* fix: resolve rebase and use === instead of ==

* fix: remove duplicate import

* chore: fix prettier violations

* fix: update generate-form-data import path

* fix: follow DropdownField's way of querying input element and casting options

* fix: update INVALID_COUNTRY_REGION_OPTION_ERROR

* fix: linting

* fix: use uppercased countryregion for non-fetch submission

---------

Co-authored-by: Kar Rui <[email protected]>
Co-authored-by: Jiayee Lim <[email protected]>
Co-authored-by: Jiayee <[email protected]>
Co-authored-by: tshuli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribute free for contributors to pick up
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants