Possibility to overwrite form to add row
Closed this issue · 2 comments
It's possible to overwrite the form to edit a row using a column in the table.tsv to pass the name of the new template, as shown in this block:
nanobot.rs/src/resources/table.html
Lines 291 to 294 in 057adbd
Could this be extended to adding a row? The href would be similar to the edit part. We could use another column in table.tsv or the same as in the edit.
nanobot.rs/src/resources/table.html
Lines 259 to 261 in 057adbd
This is a good feature. I'll think about how I want to support this in general. I just checked that it's already possible to make this work for your own project:
- add an "edit_view" column to the "table" table
- add a corresponding entry to the "column" table
- change the
table.html
template to use "edit_view":<a class="btn btn-outline-success" href="{{ table.table }}?view={{ table.edit_view or 'form' }}">Add row</a>
- set "edit_view" to 'foo' for a table "bar"
When viewing the page for the "bar" table, clicking "Format" > "JSON (page, pretty)" shows you all the information that is fed into the template, including a top-level "table" key with all the values from the "bar" row of the "table" table.
In short: You can add any columns you want to the "table" table, they will appear under the "table" key, and you can use them in your template. You don't need to change Nanobot's Rust code to do any of this.
Yes, I did precisely this. I just wanted to suggest the change in the source instead of overwriting the table template only for changing the href address 😄