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

Dynamically render form field in Create Dataset Form + Fields Validations #369

Merged
merged 67 commits into from
Apr 17, 2024

Conversation

g-saracca
Copy link
Contributor

@g-saracca g-saracca commented Apr 11, 2024

What this PR does / why we need it:

Dynamically renders all fields of each metadatablock in the dataset creation form and adds their respective validations.

This sub branch is a combination of two issues that are tightly related.

Both issues have their own pr's merged to this sub branch:

Which issue(s) this PR closes:

Special notes for your reviewer:

Create Dataset Form Storybook

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.
  • Submit the form without filling any required field, every required field should show te required error feedback, and the form should focus and scroll to the first input with an error.
  • Fill a date field with the wrong format, respective feedback error should be visible.
  • Fill an integer field with the wrong format (e.g.: 23.5), respective feedback error should be visible.
  • Fill a float field with the wrong format (e.g.: 'hi'), respective feedback error should be visible.
  • Fill an email field with a wrong format (e.g.: 'test@'), respective feedback error should be visible.
  • Fill a URL field with a wrong format (e.g.: 'bad://something'), respective feedback error should be visible.
  • Submit the form filling al required fields with the correct format, a new dataset should be created.

Run unit and e2e tests and check they are all passing.

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

Yes.
spa_datasets_create(Desktop 1366)

Also I modified at spa level not design system level the styles for the checkbox group, I think if it is successful we could apply it to the design system directly in the future.
This checkbox group that allows to select multiple values is a temporary replacement of the select multiple not yet done.
Examples below: 👇👇
Screenshot 2024-04-11 at 14 01 29
Screenshot 2024-04-11 at 14 01 42
Screenshot 2024-04-11 at 14 01 51

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

Additional documentation:

I have refactor some design system components:

  • Accordion: refactor of props using already existen props from react-bootstrap.
  • AccordionBody: able to receive bsPrefix and as props and extend html props attributes.
  • AccordionHeader: able to receive onClick, bsPrefix and as props and extend html props attributes.
  • AccordionItem: able to receive bsPrefix and as props and extend html props attributes.
  • FormGroup: able to clone children but wrapped through fragments also.
  • Some form elements so that they can forward a react ref and pass it to the input itself. This was necessary so that the form validation library could focus and scroll to the first item encountered with a validation error.

All tests were ok and add one more test to test the cloning through childrens wrapped in fragments.

g-saracca and others added 30 commits March 20, 2024 17:08
…-fields

Feature/336 dynamically render form fields
@g-saracca g-saracca marked this pull request as ready for review April 11, 2024 19:49
@g-saracca g-saracca changed the title Feature/sub branch/dynamic fields and validation Dynamically render form field in Create Dataset Form + Fields Validations Apr 11, 2024
@MellyGray MellyGray self-assigned this Apr 15, 2024
Copy link
Contributor

@MellyGray MellyGray left a comment

Choose a reason for hiding this comment

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

Works great! 🎉

I left some comments for minor improvements. Also can you solve the merge conflicts?

src/metadata-block-info/domain/models/MetadataBlockInfo.ts Outdated Show resolved Hide resolved
src/metadata-block-info/domain/models/fieldValidations.ts Outdated Show resolved Hide resolved
src/sections/create-dataset/utils.ts Outdated Show resolved Hide resolved
Comment on lines +23 to +25
cy.findByText('Author')
.closest('.row')
.within(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using floating labels to look for the inputs by their labels

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only for composed fields, where for example in this case, 'Author' is the root 'label' lets say but is not actually a label.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I understand. That's why I was suggesting the use of Floating Labels because each input needs to have its own label. "Author" cannot be the label for four different inputs.

We can use floating labels to provide each input with its own label "Author name", "Author Affiliation", without significantly altering the UI, as these labels are floating.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I understand now what you mean, labels from composed fields groups may not be unique. Let discuss it with the team, great!

Copy link
Contributor

Choose a reason for hiding this comment

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

@GermanSaracca I think that change doesn't need to block this PR. I'll approve the PR, and you can discuss it with the team. If there is an action item, you can create an issue. Thanks!

@MellyGray MellyGray assigned g-saracca and unassigned MellyGray Apr 15, 2024
Copy link
Contributor

@MellyGray MellyGray left a comment

Choose a reason for hiding this comment

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

All requested changes addressed except for the multiple fields labels. Take a look at my comment #369 (comment)

We can discuss this decision with the team

Copy link
Contributor

@MellyGray MellyGray left a comment

Choose a reason for hiding this comment

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

LGTM!

@ekraffmiller ekraffmiller added 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 and removed pm.GREI-d-2.6.1 NIH, yr2, aim6, task1: Test differentially private releases with NIH-funded datasets pm.GREI-d-2.6.2 NIH, yr2, aim6, task2: Design and implement MVP for DataTags levels labels Apr 17, 2024
@ekraffmiller ekraffmiller self-assigned this Apr 17, 2024
@ekraffmiller
Copy link
Contributor

Looks good, merging!

@ekraffmiller ekraffmiller merged commit 24b8ff0 into develop Apr 17, 2024
10 of 14 checks passed
jayanthkomarraju pushed a commit to jayanthkomarraju/dataverse-frontend that referenced this pull request May 31, 2024
…ds-and-validation

Dynamically render form field in Create Dataset Form + Fields Validations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D: Design System Deliverable: Design System 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: 10 A percentage of a sprint. 7 hours. SPA: Create Dataset Form
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants