-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Ordered relationship select #7352
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
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/keystonejs/keystone-next-docs/3drRmbNj8LW8puvxu1kmo18xG7um |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
|
Hi @skeary , This is nice to have functionality! If you want to try and do that, awesome! Otherwise we'll try and expand on this pull request when we have time 👍 |
|
Hi @dcousens, I think the following might be a reasonable configuration approach but just wanted to checked what you thought before I go ahead: With examples of use in schema.ts: I've tried to make the configuration align with the GraphQL orderBy query clauses. In terms the different configuration of specifying the sort order on the label field vs named fields, I wanted to choose an approach where the TypeScript IDE help guides you on how to sort on label field. In the future I think this could be expanded to allow custom/different sorts, since you could just union more choices onto 'asc' | 'desc'. What do you think? |
|
Note this changeset now (I think) includes a working fix for #6112. This issue was that the ui.labelField option under the relationship field config wasn't having any affect. I noticed this problem while testing my changes and have now hopefully fixed the issue. Unless I'm missing something, the support for this feature wasn't really there rather than a logic bug or similar. So I've now implemented support for this. |
1f1bb48 to
d7e5cbb
Compare
|
Hi @dcousens, To me, this seems a reasonably simple way to configure the ordering and should hopefully cover the significant number of use cases. If someone doesn't want ordering they can turn off the ordering which will revert to the current behaviour. By default the ordering is still based on label field (ascending) and I think that is what is useful for most people? I've updated the documentation to describe the new configuration options. See https://keystone-next-docs-ahungkcd8-keystonejs.vercel.app/docs/apis/fields#relationship for a rendered version. As part of doing this changeset, I also think I've addressed #6112. It would be great if you could review my overall approach and implementation and let me know what you think. I'm happy to tweak as needed. Cheers, |
|
Nice work @skeary ; let's hope this can be merged soon! |
26e4ead to
f2ca4d1
Compare
|
Would love the ability to sort relationship select and cards. Excited to see this feature merged! |
|
Replaced by #9648 |
Updates the admin UI for the relation type fields so that the values in the select are ordered (ascending) by the label field. This makes it easier to find an option when dealing with larger select lists.
The behavior could be made configurable within
schema.tsso that ordering could be done on another field or descending rather than ascending order. I wasn't sure of the value of this so I've not made it configurable but explore this if felt useful.