-
-
Notifications
You must be signed in to change notification settings - Fork 238
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
Reorder key-value fields #1029
Comments
That sounds like a good idea. It shouldn't be that difficult to implement. Maybe someone can pick it up.
|
Hey @adrianthedev I can get it if it's still available 🙏 |
Yes, you can! |
And, thank you! |
@adrianthedev you mean something like this 🤭 Screen.Recording.2024-10-01.at.18.02.24.mov |
Screen.Recording.2024-10-01.at.20.20.06.moveven it works in front-end well, it cannot be updated on DB. I checked what I sent to controller
I am pretty new in AVO codebase. Where or what should I check? |
Hey @enderahmetyurt, looking great already, thank you! I would start by debugging it here https://github.com/avo-hq/avo/blob/main/lib/avo/fields/key_value_field.rb#L86. The |
Thank you man. I'll look at it 🙏 |
Let me know how it goes |
I debugged it and I noticed that but if I changed the begin
new_value = JSON.parse(value)
rescue StandardError
new_value = {}
end
record.update(meta: {}) if key == 'meta'
record.send(:"#{key}=", new_value)
record Screen.Recording.2024-10-02.at.09.28.42.movit looks good but I don't like the solution. I'd like to hear your ideas 🙏 |
We can't do a direct I suspected that this could be the issue, thanks for debugging it! I'll do some research, meanwhile, let me know if you find anything. While writing this, an idea just came to mind. What if we mark the key as dirty on the |
def fill_field(record, key, value, _params)
begin
new_value = JSON.parse(value)
rescue StandardError
new_value = {}
end
record.send(:"#{key}_will_change!")
record.send(:"#{key}=", new_value)
record
end it works fine like above :) |
Cool! Looking good! |
Feature
It would be helpful to reorder key-value fields. At the moment when you enter key values the only way to reorder them is to delete and re-add, which is difficult if you have many entries.
Current workarounds
Delete and re-add those entries. Alternatively, when you display them to the user (outside of avo) you could apply a sort, but only very simple sorting would be possible (like alphabetical ordering).
Screenshots
Additional context
You can see this in the avo demo app
The text was updated successfully, but these errors were encountered: