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

Multiple dynamic fields - Create Dataset Form #395

Merged

Conversation

g-saracca
Copy link
Contributor

@g-saracca g-saracca commented May 13, 2024

What this PR does / why we need it:
Adds the ability to add multiple values to a field.

Which issue(s) this PR closes:

Closes #376

Special notes for your reviewer:

  • New Select Multiple component integrated in the form to replace the multiple checkbox.
  • FormGroupWithMultipleFields is no longer responsible for adding or removing elements, that is taken care of by the consumer logic (SPA).
  • I need to remove Form Group required and withinMultipleFields props being cloned to all childrens inside because did not work correctly when we had nested elements to clone within the Forms Group (e.g. adding props to all elements unnecessarily).
  • I removed withinMultipleFields props from form elements and with it the <FormElementLayout/>, so now the design system is not responsible for rendering the form group as a column or as a row.
    In some cases within the Create Dataset form when working on this issue I found some complications when working with so many dynamic fields.

I think it's pretty useful to just pass a prop to render the form group one way or another, but I think the use of react.cloneElement was being counter-intuitive in this case.
Perhaps we could see in a separate issue a way to accomplish the same thing but without the use of cloneElement.

Suggestions on how to test this:

Step 1: Run the Development Environment

  1. Execute npm i.
  2. Navigate with cd packages/design-system && npm run build.
  3. Return with cd ../../.
  4. Ensure you have a .env file similar to .env.example, with the variable VITE_DATAVERSE_BACKEND_URL=http://localhost:8000.
  5. Navigate with cd dev-env.
  6. Start the environment using ./run-env.sh unstable.
  7. To verify the environment, visit http://localhost:8000 and check your local Dataverse installation.

Step 2: Test the Create Dataset Form

  • Log in, click the create dataset button and the form fields should be displayed successfully.
  • Add or remove a field by clicking the buttons to the right of it.
  • Complete all required fields and save the form, everything should keep working as usual.
  • Try closing the accordion and clicking the Save button without filling any field, the accordion with errors should open and scroll and focus to the first field with errors.

Is there a release notes update needed for this change?:

**Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Yes.
DynamicMultipleFields

Additional documentation:
No.

@coveralls
Copy link

coveralls commented May 13, 2024

Coverage Status

coverage: 97.829% (+0.4%) from 97.426%
when pulling 0046b6a on feature/376-add-dynamic-field-types-to-create-dataset-form
into df24105 on develop.

@g-saracca g-saracca added Size: 3 A percentage of a sprint. 2.1 hours. pm.GREI-d-2.7.1 NIH, yr2, aim7, task1: R&D UI modules for creating datasets and supporting publishing workflows pm.GREI-d-2.7.2 NIH, yr2, aim7, task2: Implement UI modules for creating datasets and publishing workflows SPA: Create Dataset Form labels May 13, 2024
@g-saracca g-saracca marked this pull request as ready for review May 13, 2024 19:59
@g-saracca g-saracca changed the title Feature/376 add dynamic field types to create dataset form Multiple dynamic fields - Create Dataset Form May 14, 2024
@ekraffmiller ekraffmiller self-assigned this May 14, 2024
Copy link
Contributor

@ekraffmiller ekraffmiller left a comment

Choose a reason for hiding this comment

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

This looks good and works very well!
A general comment I have is, could we MetadataBlockFormFields and the components within it to a shared folder? I think that code will end up being used in the Edit Dataset action, and also it seems like code that other UIs would want to reuse. Also creating stories and tests for these components I think would help with re-use. What do you think?

@g-saracca
Copy link
Contributor Author

This looks good and works very well! A general comment I have is, could we MetadataBlockFormFields and the components within it to a shared folder? I think that code will end up being used in the Edit Dataset action, and also it seems like code that other UIs would want to reuse. Also creating stories and tests for these components I think would help with re-use. What do you think?

Hi @ekraffmiller I thought the same thing at the time, but I think it is not yet ready to be in a shared component, it will have to be more generic yet, but indeed that should be the direction we have to follow, maybe when the time comes to make the edit form we could simply make the necessary changes to make it fully functional for both create and edit and then put it in shared folder, what do you think?

@ekraffmiller
Copy link
Contributor

This looks good and works very well! A general comment I have is, could we MetadataBlockFormFields and the components within it to a shared folder? I think that code will end up being used in the Edit Dataset action, and also it seems like code that other UIs would want to reuse. Also creating stories and tests for these components I think would help with re-use. What do you think?

Hi @ekraffmiller I thought the same thing at the time, but I think it is not yet ready to be in a shared component, it will have to be more generic yet, but indeed that should be the direction we have to follow, maybe when the time comes to make the edit form we could simply make the necessary changes to make it fully functional for both create and edit and then put it in shared folder, what do you think?

Ok, That makes sense! We will have a better idea how to refactor it when we do the edit page.

@ekraffmiller
Copy link
Contributor

I noticed the e2e tests are failing, maybe we can merge the latest from develop when the race condition PR is merged, to make sure the tests are ok.

@g-saracca
Copy link
Contributor Author

I noticed the e2e tests are failing, maybe we can merge the latest from develop when the race condition PR is merged, to make sure the tests are ok.

Yes, I think that will be the safest thing to do.

@g-saracca g-saracca assigned g-saracca and ekraffmiller and unassigned g-saracca May 16, 2024
@g-saracca
Copy link
Contributor Author

@ekraffmiller all e2e tests are passing, I only update the test for the create dataset form to select an option from the select multiple field.

Copy link
Contributor

@ekraffmiller ekraffmiller left a comment

Choose a reason for hiding this comment

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

Looks good. approved!

@ekraffmiller ekraffmiller removed their assignment May 20, 2024
@GPortas GPortas self-assigned this May 20, 2024
Copy link
Contributor

@GPortas GPortas left a comment

Choose a reason for hiding this comment

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

Looks and works great!

qa_multiple_dynamic_fields.mov

@GPortas GPortas merged commit 2ace63e into develop May 20, 2024
14 checks passed
@GPortas GPortas deleted the feature/376-add-dynamic-field-types-to-create-dataset-form branch May 20, 2024 14:24
jayanthkomarraju pushed a commit to jayanthkomarraju/dataverse-frontend that referenced this pull request May 31, 2024
…ypes-to-create-dataset-form

Multiple dynamic fields - Create Dataset Form
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pm.GREI-d-2.7.1 NIH, yr2, aim7, task1: R&D UI modules for creating datasets and supporting publishing workflows pm.GREI-d-2.7.2 NIH, yr2, aim7, task2: Implement UI modules for creating datasets and publishing workflows Size: 3 A percentage of a sprint. 2.1 hours. SPA: Create Dataset Form
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add dynamic multiple field types to Create Dataset Form
4 participants