Add a confirmation message for delete actions, except for session

I do not like confirmation messages: they question user’s actions, and
in general it is better to offer an undo option afterward. However, undo
is harder to implement, and currently i do not have time to do this.

The delete for the session is different because the only repercussion
would be to log in again; the user is not in danger of losing any data
whatsoever.
This commit is contained in:
jordi fita mas 2023-09-26 17:00:22 +02:00
parent d4cabce7f5
commit 650d3bff7b
4 changed files with 54 additions and 27 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: camper\n" "Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2023-09-26 16:50+0200\n" "POT-Creation-Date: 2023-09-26 16:55+0200\n"
"PO-Revision-Date: 2023-07-22 23:45+0200\n" "PO-Revision-Date: 2023-07-22 23:45+0200\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n" "Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Catalan <ca@dodds.net>\n" "Language-Team: Catalan <ca@dodds.net>\n"
@ -20,7 +20,7 @@ msgstr ""
#: web/templates/public/services.gohtml:6 #: web/templates/public/services.gohtml:6
#: web/templates/public/services.gohtml:15 #: web/templates/public/services.gohtml:15
#: web/templates/admin/services/index.gohtml:50 #: web/templates/admin/services/index.gohtml:53
msgctxt "title" msgctxt "title"
msgid "Services" msgid "Services"
msgstr "Serveis" msgstr "Serveis"
@ -338,7 +338,7 @@ msgstr "Nom"
#: web/templates/admin/campsite/type/index.gohtml:18 #: web/templates/admin/campsite/type/index.gohtml:18
#: web/templates/admin/services/index.gohtml:19 #: web/templates/admin/services/index.gohtml:19
#: web/templates/admin/services/index.gohtml:57 #: web/templates/admin/services/index.gohtml:60
#: web/templates/admin/home/index.gohtml:19 #: web/templates/admin/home/index.gohtml:19
msgctxt "campsite type" msgctxt "campsite type"
msgid "Translations" msgid "Translations"
@ -473,35 +473,44 @@ msgid "Caption"
msgstr "Llegenda" msgstr "Llegenda"
#: web/templates/admin/services/index.gohtml:20 #: web/templates/admin/services/index.gohtml:20
#: web/templates/admin/services/index.gohtml:58 #: web/templates/admin/services/index.gohtml:61
#: web/templates/admin/home/index.gohtml:20 #: web/templates/admin/home/index.gohtml:20
msgctxt "campsite type" msgctxt "campsite type"
msgid "Actions" msgid "Actions"
msgstr "Accions" msgstr "Accions"
#: web/templates/admin/services/index.gohtml:39 #: web/templates/admin/services/index.gohtml:24
#: web/templates/admin/services/index.gohtml:74 #: web/templates/admin/home/index.gohtml:24
#: web/templates/admin/home/index.gohtml:39 msgid "Are you sure you wish to delete this slide?"
msgstr "Esteu segur de voler esborrar aquesta diapositiva?"
#: web/templates/admin/services/index.gohtml:42
#: web/templates/admin/services/index.gohtml:80
#: web/templates/admin/home/index.gohtml:42
msgctxt "action" msgctxt "action"
msgid "Delete" msgid "Delete"
msgstr "Esborra" msgstr "Esborra"
#: web/templates/admin/services/index.gohtml:47 #: web/templates/admin/services/index.gohtml:50
#: web/templates/admin/home/index.gohtml:47 #: web/templates/admin/home/index.gohtml:50
msgid "No slides added yet." msgid "No slides added yet."
msgstr "No sha afegit cap diapositiva encara." msgstr "No sha afegit cap diapositiva encara."
#: web/templates/admin/services/index.gohtml:51 #: web/templates/admin/services/index.gohtml:54
msgctxt "action" msgctxt "action"
msgid "Add service" msgid "Add service"
msgstr "Afegeix servei" msgstr "Afegeix servei"
#: web/templates/admin/services/index.gohtml:56 #: web/templates/admin/services/index.gohtml:59
msgctxt "header" msgctxt "header"
msgid "Service" msgid "Service"
msgstr "Servei" msgstr "Servei"
#: web/templates/admin/services/index.gohtml:82 #: web/templates/admin/services/index.gohtml:65
msgid "Are you sure you wish to delete this service?"
msgstr "Esteu segur de voler esborrar aquest servei?"
#: web/templates/admin/services/index.gohtml:88
msgid "No services added yet." msgid "No services added yet."
msgstr "No sha afegit cap servei encara." msgstr "No sha afegit cap servei encara."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: camper\n" "Project-Id-Version: camper\n"
"Report-Msgid-Bugs-To: jordi@tandem.blog\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n"
"POT-Creation-Date: 2023-09-26 16:50+0200\n" "POT-Creation-Date: 2023-09-26 16:55+0200\n"
"PO-Revision-Date: 2023-07-22 23:46+0200\n" "PO-Revision-Date: 2023-07-22 23:46+0200\n"
"Last-Translator: jordi fita mas <jordi@tandem.blog>\n" "Last-Translator: jordi fita mas <jordi@tandem.blog>\n"
"Language-Team: Spanish <es@tp.org.es>\n" "Language-Team: Spanish <es@tp.org.es>\n"
@ -20,7 +20,7 @@ msgstr ""
#: web/templates/public/services.gohtml:6 #: web/templates/public/services.gohtml:6
#: web/templates/public/services.gohtml:15 #: web/templates/public/services.gohtml:15
#: web/templates/admin/services/index.gohtml:50 #: web/templates/admin/services/index.gohtml:53
msgctxt "title" msgctxt "title"
msgid "Services" msgid "Services"
msgstr "Servicios" msgstr "Servicios"
@ -338,7 +338,7 @@ msgstr "Nombre"
#: web/templates/admin/campsite/type/index.gohtml:18 #: web/templates/admin/campsite/type/index.gohtml:18
#: web/templates/admin/services/index.gohtml:19 #: web/templates/admin/services/index.gohtml:19
#: web/templates/admin/services/index.gohtml:57 #: web/templates/admin/services/index.gohtml:60
#: web/templates/admin/home/index.gohtml:19 #: web/templates/admin/home/index.gohtml:19
msgctxt "campsite type" msgctxt "campsite type"
msgid "Translations" msgid "Translations"
@ -473,35 +473,44 @@ msgid "Caption"
msgstr "Leyenda" msgstr "Leyenda"
#: web/templates/admin/services/index.gohtml:20 #: web/templates/admin/services/index.gohtml:20
#: web/templates/admin/services/index.gohtml:58 #: web/templates/admin/services/index.gohtml:61
#: web/templates/admin/home/index.gohtml:20 #: web/templates/admin/home/index.gohtml:20
msgctxt "campsite type" msgctxt "campsite type"
msgid "Actions" msgid "Actions"
msgstr "Acciones" msgstr "Acciones"
#: web/templates/admin/services/index.gohtml:39 #: web/templates/admin/services/index.gohtml:24
#: web/templates/admin/services/index.gohtml:74 #: web/templates/admin/home/index.gohtml:24
#: web/templates/admin/home/index.gohtml:39 msgid "Are you sure you wish to delete this slide?"
msgstr "¿Estáis seguro de querer borrar esta diapositiva?"
#: web/templates/admin/services/index.gohtml:42
#: web/templates/admin/services/index.gohtml:80
#: web/templates/admin/home/index.gohtml:42
msgctxt "action" msgctxt "action"
msgid "Delete" msgid "Delete"
msgstr "Borrar" msgstr "Borrar"
#: web/templates/admin/services/index.gohtml:47 #: web/templates/admin/services/index.gohtml:50
#: web/templates/admin/home/index.gohtml:47 #: web/templates/admin/home/index.gohtml:50
msgid "No slides added yet." msgid "No slides added yet."
msgstr "No se ha añadido ninguna diapositiva todavía." msgstr "No se ha añadido ninguna diapositiva todavía."
#: web/templates/admin/services/index.gohtml:51 #: web/templates/admin/services/index.gohtml:54
msgctxt "action" msgctxt "action"
msgid "Add service" msgid "Add service"
msgstr "Añadir servicio" msgstr "Añadir servicio"
#: web/templates/admin/services/index.gohtml:56 #: web/templates/admin/services/index.gohtml:59
msgctxt "header" msgctxt "header"
msgid "Service" msgid "Service"
msgstr "Servicio" msgstr "Servicio"
#: web/templates/admin/services/index.gohtml:82 #: web/templates/admin/services/index.gohtml:65
msgid "Are you sure you wish to delete this service?"
msgstr "¿Estáis seguro de querer borrar este servicio?"
#: web/templates/admin/services/index.gohtml:88
msgid "No services added yet." msgid "No services added yet."
msgstr "No se ha añadido ningún servicio todavía." msgstr "No se ha añadido ningún servicio todavía."

View File

@ -21,6 +21,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{ $confirm := (gettext "Are you sure you wish to delete this slide?")}}
{{ range $slide := .Slides -}} {{ range $slide := .Slides -}}
<tr> <tr>
<td><a href="/admin/home/slides/{{ .ID }}"><img src="{{ .Media }}" alt=""></a></td> <td><a href="/admin/home/slides/{{ .ID }}"><img src="{{ .Media }}" alt=""></a></td>
@ -35,7 +36,9 @@
{{ end }} {{ end }}
</td> </td>
<td> <td>
<form data-hx-delete="/admin/home/slides/{{ .ID }}" data-hx-headers='{ {{ CSRFHeader }} }'> <form data-hx-delete="/admin/home/slides/{{ .ID }}"
data-hx-confirm="{{ $confirm }}"
data-hx-headers='{ {{ CSRFHeader }} }'>
<button type="submit">{{( pgettext "Delete" "action" )}}</button> <button type="submit">{{( pgettext "Delete" "action" )}}</button>
</form> </form>
</td> </td>

View File

@ -21,6 +21,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{ $confirm := ( gettext "Are you sure you wish to delete this slide?" )}}
{{ range $slide := .Slides -}} {{ range $slide := .Slides -}}
<tr> <tr>
<td><a href="/admin/services/slides/{{ .ID }}"><img src="{{ .Media }}" alt=""></a></td> <td><a href="/admin/services/slides/{{ .ID }}"><img src="{{ .Media }}" alt=""></a></td>
@ -35,7 +36,9 @@
{{ end }} {{ end }}
</td> </td>
<td> <td>
<form data-hx-delete="/admin/services/slides/{{ .ID }}" data-hx-headers='{ {{ CSRFHeader }} }'> <form data-hx-delete="/admin/services/slides/{{ .ID }}"
data-hx-confirm="{{ $confirm }}"
data-hx-headers='{ {{ CSRFHeader }} }'>
<button type="submit">{{( pgettext "Delete" "action" )}}</button> <button type="submit">{{( pgettext "Delete" "action" )}}</button>
</form> </form>
</td> </td>
@ -59,6 +62,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{ $confirm := ( gettext "Are you sure you wish to delete this service?" )}}
{{ range .Services -}} {{ range .Services -}}
<tr> <tr>
<td class="icon_{{ .Icon }}"><a href="{{ .URL }}">{{ .Name }}</a></td> <td class="icon_{{ .Icon }}"><a href="{{ .URL }}">{{ .Name }}</a></td>
@ -70,7 +74,9 @@
{{ end }} {{ end }}
</td> </td>
<td> <td>
<form data-hx-delete="{{ .URL }}" data-hx-headers='{ {{ CSRFHeader }} }'> <form data-hx-delete="{{ .URL }}"
data-hx-confirm="{{ $confirm }}"
data-hx-headers='{ {{ CSRFHeader }} }'>
<button type="submit">{{( pgettext "Delete" "action" )}}</button> <button type="submit">{{( pgettext "Delete" "action" )}}</button>
</form> </form>
</td> </td>