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

Custom Fields: Local editing handling #13898

Closed

Conversation

hafizrahman
Copy link
Contributor

@hafizrahman hafizrahman commented Sep 9, 2024

Part of: #13493

Please do not merge until target is trunk

Description

The flow for editing/adding/deleting custom fields can be described as follows:

  1. Each item in the Custom Fields List screen can open the Custom Field Editor screen. In the editor, merchants can change things and then tap "Done" when they're done editing. Doing so will return them to the list screen and the change will be shown.
  2. Merchant can also delete a field from its Custom Field Editor screen. This removes the field from the list screen.
  3. Custom Fields List also has an add button that opens the editor, then merchant can also tap "Done" to keep the change. This adds a field to the list screen.
  4. All changes from edit/delete/add actions above are still pending. The Custom Fields List has a "Save" button, which acts as the only way to do remote API call to save. It will save all existing changes at once, matching the behavior in core.

This PR handles the local editing behavior, by adding these:

  1. CustomFieldsListViewModel which handles the business logic.
  2. The viewmodel contains editedFields and addedFields to store the pending edit and addition. It also has combinedList which is an array of the latest combined changes. Depending on the remote call design, any of these can be used to do the call.
  3. The viewmodel has editField() and addField() functions that can later be used when editing or adding a field.
  4. Unit tests for the viewmodel.

Not in this PR and will be added separately:

  1. Handling for deletion.
  2. UI functionality for editing or adding field.
  3. UI functionality for remote saving

Steps to reproduce

The handling is not used anywhere in the app yet, so for now just check the code and ensure the unit tests also passes.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on all devices (phone/tablet) and no regressions are added.

@hafizrahman hafizrahman changed the base branch from trunk to feat/13493-custom-fields-edit-ui September 9, 2024 13:40
@dangermattic
Copy link
Collaborator

dangermattic commented Sep 9, 2024

1 Warning
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.

Generated by 🚫 Danger

This includes support for cases like:
- Editing a field, then editing it again
- Adding new field, then editing that new field

The bulk of the logic is to ensure the content of `pendingChanges` to remain accurate during those cases.
Also removes the struct for PendingChanges to simplify code.
@hafizrahman hafizrahman added the type: task An internally driven task. label Sep 10, 2024
@hafizrahman hafizrahman added this to the 20.4 milestone Sep 10, 2024
@hafizrahman hafizrahman marked this pull request as ready for review September 11, 2024 14:01
@wpmobilebot wpmobilebot modified the milestones: 20.4, 20.5 Sep 13, 2024
@wpmobilebot
Copy link
Collaborator

Version 20.4 has now entered code-freeze, so the milestone of this PR has been updated to 20.5.

Base automatically changed from feat/13493-custom-fields-edit-ui to trunk September 19, 2024 14:59
@wpmobilebot wpmobilebot modified the milestones: 20.5, 20.6 Sep 20, 2024
@wpmobilebot
Copy link
Collaborator

Version 20.5 has now entered code-freeze, so the milestone of this PR has been updated to 20.6.

@hafizrahman
Copy link
Contributor Author

Closing this in favor of #14029

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants