numerus/pkg
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
..
company.go Create constants for the HTMX request and response headers used 2023-04-06 12:07:20 +02:00
contacts.go Replace tag relations with array attributes 2023-04-07 21:31:35 +02:00
db.go Properly register array and composite PostgreSQL types with pgtype 2023-02-20 11:42:21 +01:00
form.go Add filters form for invoices 2023-03-29 16:16:31 +02:00
htmx.go Create constants for the HTMX request and response headers used 2023-04-06 12:07:20 +02:00
invoices.go Allow editing invoice tags inline from the index table 2023-04-11 10:46:27 +02:00
locale.go Add currency_pattern to language relation 2023-02-23 12:12:33 +01:00
logger.go Move source file to the root of pkg 2023-01-17 10:40:22 +01:00
login.go Replace default router with github.com/julienschmidt/httprouter 2023-02-03 12:30:56 +01:00
pgtypes.go Replace tag relations with array attributes 2023-04-07 21:31:35 +02:00
products.go Replace tag relations with array attributes 2023-04-07 21:31:35 +02:00
profile.go Create constants for the HTMX request and response headers used 2023-04-06 12:07:20 +02:00
recover.go Gofmt recover.go 2023-01-22 20:37:34 +01:00
router.go Allow editing invoice tags inline from the index table 2023-04-11 10:46:27 +02:00
template.go Allow editing invoice tags inline from the index table 2023-04-11 10:46:27 +02:00