I’m trying to implement an admin interface for phoenix (like ExAdmin) based on having VueJS forms on the frontend which communicate with the backend using JSON. It would be an npm package with primitive VueJS components + some mix generators to generate forms made out of those components (and possibly controllers to receive the JSON, if it can’t be handled by a generic function). VueJS might seem a little overkill, but I have my reasons.
It’s supposed to be simple CRUD, but it’ll have forms with nested insets. This will require processing nested JSON maps on the backend. Ultimately, those maps will be converted into an Ecto Schema to be sent to the database.
My question is: what would be the simplest way of handling this on the server? Is there any ready-to-use library to convert the (nested) JSON into structures I can
insert into the Repo (without DDOSing the BEAM with new atoms)?
I can implement it myself, of course, by introspecting the Ecto schemas and by using something like
string_to_existing_atom recursively on the map keys, but if there is a library for already, I could focus on working on the client and generators.
PS: Some justification for the weird design decisions:
- I want the forms to reflect changes elsewhere in real time using Phoenix Channels
- I want ot make it very easy to edit assocs using insets, select widgets, radio buttons and checkboxes.
- I’m using VueJS because it makes the above points very easy, not because I’m a masochist who likes to write JS. Other solutions I’ve seen that use “less JS” end up using JQuery hacks soread around the forms, something I don’t particularly enjoy. Also, well designed VueJS components encapsulate the necessary JS and feel like writinh native HTML widgets.
- I want to use generators because I want VueJS components I can edit and customize (change styles, add client side validation, add text in the middle of the form, etc)
- Using VueJS single-file components requires Webpack. I don’t really like webpck, but I don’t like Brunch either, so it’s not a great loss…