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

Move and remove elements from JSON arrays in form #4347

Draft
wants to merge 16 commits into
base: 2.x
Choose a base branch
from

Conversation

dafeder
Copy link
Member

@dafeder dafeder commented Nov 22, 2024

Fixes #4335

Describe your changes

Fairly extensive changes to how array properties are handled in JSON Form Widget. Arrays, whether "simple" (an array of strings or numbers) or "complex" (arrays of objects) will contain one more level of nested fieldsets. This is because each array item now has its own action buttons, so that array items can be removed or moved in the order. Previously we only had action buttons at the end of the array, allowing us to "add one" or "remove one".

Because the autoselect widgets expect a built array fieldset and then rewrite it, there are also a number of changes to that logic. A risk - we do not really have full functional test coverage for these elements. Also, now that I understand the code flow a bit better, it does make me wonder if there's a better approach that avoids building all these nested fieldsets on the first pass only to flatten and replace them on the second pass with WidgetRouter.

QA Steps

  • Create a new Dataset
  • Add several distributions
  • Re-order them, remove distributions from the beginning or middle of the list
  • Do the same for "References"
  • Confirm that the keyword and topic fields continue to work as expected
  • Save the dataset, and view the JSON in the API to confirm all works as expected
  • Edit an existing dataset, and try similar tests

You may want to remove some fields from the distribution schema to make that form element shorter - Keep it to just title, description and downloadURL for instance.

Note on codeclimate failure - ArrayHelper is pretty big now but I don't see an obvious way to split it up that would make the code much more readable. Open to suggestions but IMO let's just let it slide for now and revisit if the method count gets any higher.

Checklist before requesting review

If any of these are left unchecked, please provide an explanation

  • I have updated or added tests to cover my code
  • I have updated or added documentation

@dafeder dafeder marked this pull request as draft December 2, 2024 21:43
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.

Remove or Reorder Objects in An Array
1 participant