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: add support for scalar array #389

Merged
merged 6 commits into from
Sep 5, 2024
Merged

feat: add support for scalar array #389

merged 6 commits into from
Sep 5, 2024

Conversation

foyarash
Copy link
Collaborator

@foyarash foyarash commented Sep 2, 2024

Title

Add support for Prisma scalar array

Type of Change

  • New feature
  • Bug fix
  • Documentation update
  • Example update
  • Refactoring
  • Hotfix
  • Security patch
  • UI/UX improvement

Issue

#322

Description

Add support for Prisma scalar arrays. Currently supported scalar types are strings and numbers.

In the list, the array is displayed as a count. The PR also includes support search inside the array (case sensitive & exact content as its the only supported way on Prisma)

Screenshots

image

image

@foyarash foyarash requested review from baptadn and cregourd September 2, 2024 15:09
Copy link

changeset-bot bot commented Sep 2, 2024

🦋 Changeset detected

Latest commit: 7384ece

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@premieroctet/next-admin Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@FacundoSpira
Copy link
Contributor

FacundoSpira commented Sep 2, 2024

Hey @foyarash, first of all thanks for the quick response to the issue and for this PR. It's looking really good. I tried some things last Friday, and did a similar approach than what you did here with the separation of different cases in the ArrayField component, but I had some problems with the @rjsf that I'm not that familiar with.

One thing that I was noticing that it can be added (maybe you prefer to do it in another PR with a separate issue, or I can even help you adding it) is the support for array of enums. What I saw is that we can add it as well to the ArrayField component by doing

if (dmmfField?.kind === "enum" && dmmfField?.isList)

Then, what we really need is a select with the possible enum values. We can even get those enums from the schema by doing schema.enum, which returns an array of objects with a label and value. So we can even use this info to render a multi-select with a fixed number of options. What do you think?

Thanks again! :)

@foyarash
Copy link
Collaborator Author

foyarash commented Sep 3, 2024

Hello @FacundoSpira

Interesting, i actually didnt think about the use case with enums ! This can be part of another PR when this one will be merged. This will require to use the same logic we do in MultiSelectWidget

Let me know if you want to work on this stuff !

@FacundoSpira
Copy link
Contributor

Hello @FacundoSpira

Interesting, i actually didnt think about the use case with enums ! This can be part of another PR when this one will be merged. This will require to use the same logic we do in MultiSelectWidget

Let me know if you want to work on this stuff !

Sure, I'll do it! I'll raise a PR pointing to this one shortly :)

Copy link
Collaborator

@cregourd cregourd left a comment

Choose a reason for hiding this comment

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

Perfect, just one thing, in demo example on Post entity, the tags fields is required, but there is no error when I submit without any tags

@foyarash foyarash merged commit b013f25 into main Sep 5, 2024
3 checks passed
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.

3 participants