xpbytes / administrate-serialized_fields Goto Github PK
View Code? Open in Web Editor NEW:ab: Automatically deserialize administrate fields on form submit.
License: MIT License
:ab: Automatically deserialize administrate fields on form submit.
License: MIT License
This gem looks helpful to solve the issue described in codica2/administrate-field-jsonb#1, thanks!
However it does not seem to support nested fields. I have a Post dashboard configured as follows (schema was configured by globalize):
# app/dashboards/post_dashboard.rb
class PostDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
translations: NestedHasMany.with_options(class_name: "Post::Translation"),
...
}.freeze
...
end
# app/dashboards/post/translation_dashboard.rb
class Post::TranslationDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
tags: Field::JSONB,
...
}.freeze
...
end
The aim is to apply deserialize_json_fields
to the tags
field of the post translation.
NB: NestedHasMany
is a modification of Field::NestedHasMany
to support namespaced models, as shown here.
There are two problems:
deserialize_json_fields
on the controller, but both Admin::Post::TranslationsController
and Admin::PostsController
will potentially need to handle the submission of tags
(respectively either being a direct property of the resource associated to the controller, or as a property of the nested sub-resource through the has-many relation)tags
, but on the form's translations_attributes
value which looks like this:{
"0"=>{"id"=>"19", "_destroy"=>"false", "locale"=>"en", "tags"=>"[\"in english\"]", ...},
"1"=>{"id"=>"20", "_destroy"=>"false", "locale"=>"fr", "tags"=>"[\"en français\"]", ...}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.