-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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(relation-widget): Allow the relation widget to target file collections #3717
Conversation
I fleshed this out a bit more today, adding support for targeting list being nested inside an object! I'm rather fond of overloading I also added a category field to the demo site to test this out visually, and found an issue where loaded options are not being persisted. I think it may have to do with the fact that in a folder-targeting relation widget, the options loaded via In my custom widget, I persist loaded options in the widget's local state, but it doesn't seem to work here. It's also likely something to do with my code, will look more into it. |
Hhhm I'm a bit stuck here. Intuitively I think it's best to replicate the same structure from folder relation, but even if I want to do so, the function Another approach I can think of, is to do |
Hi @d4rekanguok, was meaning to comment on this soon (haven't had the time to test my thoughts yet), but I think you can dump if (field.has('file')) {
hits = hits.filter(hit => hit.slug === field.get('file'));
} Disadvantage it that the CMS will still retrieve all files in the referenced collection, but I think it is a minor issue considering the alternative. I would actually not overload the |
Thanks @erezrokah, that makes sense! I'll explore the approach you mentioned. |
Replaced by #3754 |
Summary
Hello everyone! This PR is a WIP and is meant to facilitate discussion, no hurt feeling if it's rejected.
A few challenges when targeting a file collection:
For the first two, I think we could use dot notation in collection name:
If
collection
contains dots, usequery
as usual; otherwise useloadEntry
. Later on, when a user want to target a list widget in the same entry as the relation widget, I think it should be smart and use the newentry
props.Also, I found that query's results are stored in
queryHits
. I wonder ifloadEntry
results should be stored in a similar manner?Please let me know if this is a valid approach!
Test plan
I've written 2 basic tests that covers a simple list & a list of items with the same object shape. Will need a few more.
closes #800