-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix default values from permission's field presets #10576
Conversation
You're absolutely right about this. The presets aren't a filter object, and shouldn't be parsed as such 👍🏻 |
What about if I want to use $CURRENT_USER in presets? it doesn't work anymore. Thanks. |
@HeshamAlassaf Would you mind creating an issue to track that? Thanks! |
Right now preset on a string field will show up as "eq": "text here" instead of just text here |
@brandnewx By "right now", would you mind to clarify what version of Directus are you on? This fix should be available since v9.4.1. However if you have a minimal reproducible bug report on this presets issue again, and if it's not related to #10782, it'll be very helpful if you can make a new issue for it 👍 |
Running v9.4.3 docker image using Field Presets on Create role permission. The field shows up text here just fine but after saving, it will be saved as {"_eq":"text here"} I think you believe it was fixed because it shows up in the editor just fine but the bug is still there. After you save the item and opening it, you'll see the wrong value. This bug is still reproducible after modifying the field presets and saving it again, to make sure the old saved field presets are replaced by the ones in the new version. |
Thanks for clarifying! That should indeed be the same root cause as #10782. |
Fixes #10535
Bug
After adding field presets to a particular role to set a default value on create, the default value ended up showing
[object Object]
instead oftesting
in this case:Investigation
Seems like it's because the parseFilter here:
directus/app/src/stores/permissions.ts
Lines 29 to 31 in 4ba3ef4
And when it gets set as the default value here:
directus/app/src/composables/use-permissions.ts
Line 75 in 4ba3ef4
It resulted in
{ _eq: "test" }
(hence the [object Object]) instead of"test"
:Solution
Opted to remove the parsing on Presets since I believe they don't need to be parsed? unless there's some misunderstanding on my part. It's also odd how this wasn't brought up before, but it might be some form of unintended regression from the more recent parseFilter change.
After fix applied