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(api-refactor): implement specific reorder field api #1726

Merged
merged 14 commits into from
Apr 27, 2021

Conversation

karrui
Copy link
Contributor

@karrui karrui commented Apr 26, 2021

Integration tests will be added to a separate PR to prevent PR size from becoming too big

This PR cannot be rolled back after release due to the invocation of the new endpoint on the client side.

Problem

This PR adds a specific endpoint to reorder form fields in the form, and updates the frontend client to use that endpoint when reordering fields. There is also a feature to undo the field reordering if the reorder network request fails for one reason or another.

Closes #1482

Solution

Backend Features:

  • feat: add ExtractTypeFromArray type
  • feat(FormModel): add reorderFormFieldById instance method
  • feat(AdminFormSvc): add reorderFormField service function
  • feat(AdminFormCtl): add handleReorderFormField controller handler fn
  • feat(AdminFormRoutes): add route for reordering form field

Client Features

  • feat(client): add reorderSingleFormField client service fn
  • feat(client): call new reorder field endpoint

Improvements:

  • ref: move immutable-array-fns to /shared directory

Bug Fixes:

  • feat: rollback form fields if reordering encounters error

Tests

  • test(FormModel): add tests for reorderFormFieldById
  • test(AdminFormSvc): add unit tests for reorderFormField
  • test(AdminFormCtl): add unit tests for _handleReorderFormField

Manual tests

  • Turn off network (from chrome devtools) and attempt to reorder a field. An error toast should occur and the form field ordering should revert to initial ordering
  • Reorder a field. The returned form_fields shape should be the new ordering.
  • Open two builder tabs in your browser for the same form (with at least 2 initial fields). Add a field on the second tab (should now have +1 fields). Go back to the first tab (with the initial field count) and reorder the fields. 3 fields should show up but correctly ordered.

src/app/models/form.server.model.ts Outdated Show resolved Hide resolved
@mantariksh mantariksh merged commit 443a12e into develop Apr 27, 2021
@karrui karrui deleted the feat/reorder-field-api branch April 27, 2021 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API] Extract form field reorder endpoint from PUT /:formId/adminform
2 participants