numerus/web/template/invoices
jordi fita mas d20573aa99 Allow editing invoice tags inline from the index table
I use the same pattern as HTMx’s “Click to Edit” example[0], except that
my edit form is triggered by submit and by focus out of the tags input.

I could not, however, use the standard focus out event because it would
also trigger when removing a tag with the mouse, as for a moment the
remove button has the focus and the search input dispatches a bubbling
focusout.  I had to resort to a custom event for that, but i am not
happy with it.

The autofocus attribute seems to do nothing in this case, so i need to
manually change the focus to the new input with JavaScript.  However,
this means that i can not use the same input ID for all the forms
because getElementById would always return the first in document order,
changing the focus to that same element and automatically submit the
form due to focus out.  That’s why in this form i append the invoice’s
slug to the input’s ID.

Finally, this is the first time i am using an HTMx-only solution and i
needed a way to return back just the HTML for the <td>, without <title>,
breadcrumbs, or <dialog>.  In principle, the template would be the
“layout”, but then i would need to modify everything to check whether
the template file is empty, or something to that effect, so instead i
created a “standalone” template for these cases.

[0]: https://htmx.org/examples/click-to-edit/
2023-04-11 10:46:27 +02:00
..
edit.gohtml Show the duplicate invoice form in a dialog 2023-04-04 14:39:55 +02:00
index.gohtml Allow editing invoice tags inline from the index table 2023-04-11 10:46:27 +02:00
new.gohtml Show the duplicate invoice form in a dialog 2023-04-04 14:39:55 +02:00
products.gohtml Show the duplicate invoice form in a dialog 2023-04-04 14:39:55 +02:00
view.gohtml Use HX-Location instead of HX-Refresh when editing invoices 2023-04-05 10:29:03 +02:00