cldellow / datasette-ui-extras

Add editing UI and other power-user features to Datasette.
Apache License 2.0
12 stars 1 forks source link

ability to insert row #72

Closed cldellow closed 1 year ago

cldellow commented 1 year ago

The response from the insert endpoint looks like:

{"ok": true, "rows": [{"id": null, "user_id": 5428, "name": "Autobiographer", "date": "2023-02-16 22:17:00.000"}]}

...so we'll have to know what the pkey columns are. Maybe we can dump those into a JS variable on the page.

cldellow commented 1 year ago

Hmm. I tried adding a new route at /db/table/-/dux-insert. It seems kinda fiddly - if I want to re-use the row template, I need to make sure I have the right context object.

Then I'll still need to invoke the render_cell / edit_control hooks myself.

I think I might try this from a different, more disgusting angle: respond on /db/table/dux-insert.

We'll monkey patch Datasette.resolve_row to return a candidate row.