Skip to content
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

JS-Table-Editor to go together with json2html #15

Open
muellermichel opened this issue Mar 4, 2016 · 2 comments
Open

JS-Table-Editor to go together with json2html #15

muellermichel opened this issue Mar 4, 2016 · 2 comments

Comments

@muellermichel
Copy link
Contributor

I've had this idea on how to extend the simplicity of json2html for both read and write operations on the client side.

How about we'd build a JS based on jquery that

(a) runs over a json2html generated table (passing in a jquery selector) and wraps all text nodes except those that have been generated from a json dict key in input text elements. So the whole table becomes a form.

(b) adds a way to add new rows / subtables by allowing to copy a whole json2html generated structure and replace the text content with empty strings. This could be a rightclick-action on the background of the selected structure or some button inserted in a good place.

(c) adds a submit button at the end.

(d) when clicking submit it parses the table and basically does the reverse operation (html2json), so the server can get back a json. The whole implementation should work such that if the user doesn't edit anything, the posted json should be exactly the same as the one that was used to generate the html in the first place.

Now this would be quite a project, but imagine how cool it would be if you could have a configuration editor in your browser for any kind of JSON file and you wouldn't have to lift a finger other than installing json2html on the server and adding this Javascript to the response. It would be trivial to provide that json2html tooling as a Flask plugin as well at that point.

@akhiljay
Copy link

I quite like this idea, has there be any progress on this request?

@p-doyle
Copy link

p-doyle commented Feb 7, 2020

I may have a similar solution that does what you describe with the exception of adding new rows/columns.. I am currently using it to allow values to be changed in the generated html table and then submitted. I can add some more detail if anyone is interested but basically you need to add contenteditable="true" to all of the table cells you want to be able to edit(requires manually editing jsonconv.py) and then create a js or jquery function that grabs the table html and posts it somewhere when a button is clicked. The last part is the html2json part that I had to make a custom function for. There is a html2json package on pip but if iirc it didn't seem to be working as intended with the html generated by json2html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants