add feedback when moving reservation slot

This commit is contained in:
imperosol
2025-06-30 22:50:44 +02:00
parent f9fa4c0643
commit dfb545b15e
4 changed files with 33 additions and 7 deletions

View File

@ -7,7 +7,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-04-22 17:07+0200\n" "POT-Creation-Date: 2025-06-30 22:48+0200\n"
"PO-Revision-Date: 2024-09-17 11:54+0200\n" "PO-Revision-Date: 2024-09-17 11:54+0200\n"
"Last-Translator: Sli <antoine@bartuccio.fr>\n" "Last-Translator: Sli <antoine@bartuccio.fr>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n" "Language-Team: AE info <ae.info@utbm.fr>\n"
@ -193,7 +193,7 @@ msgstr "Montrer moins"
msgid "Show more" msgid "Show more"
msgstr "Montrer plus" msgstr "Montrer plus"
#: core/static/bundled/user/family-graph-index.js #: core/static/bundled/user/family-graph-index.ts
msgid "family_tree.%(extension)s" msgid "family_tree.%(extension)s"
msgstr "arbre_genealogique.%(extension)s" msgstr "arbre_genealogique.%(extension)s"
@ -255,6 +255,10 @@ msgstr "La réorganisation des types de produit a échoué avec le code : %d"
msgid "Rooms" msgid "Rooms"
msgstr "Salles" msgstr "Salles"
#: reservation/static/bundled/reservation/slot-reservation-index.ts
msgid "This slot has been successfully moved"
msgstr "Ce créneau a été bougé avec succès"
#: sas/static/bundled/sas/pictures-download-index.ts #: sas/static/bundled/sas/pictures-download-index.ts
msgid "pictures.%(extension)s" msgid "pictures.%(extension)s"
msgstr "photos.%(extension)s" msgstr "photos.%(extension)s"

View File

@ -76,16 +76,14 @@ export class RoomScheduler extends inheritHtmlElement("div") {
* the start and the duration of a reservation slot * the start and the duration of a reservation slot
*/ */
async changeReservation(args: EventDropArg) { async changeReservation(args: EventDropArg) {
const duration = new Date(args.event.end.getTime() - args.event.start.getTime());
const response = await reservationslotUpdateSlot({ const response = await reservationslotUpdateSlot({
// biome-ignore lint/style/useNamingConvention: api is snake_case // biome-ignore lint/style/useNamingConvention: api is snake_case
path: { slot_id: Number.parseInt(args.event.id) }, path: { slot_id: Number.parseInt(args.event.id) },
body: { // biome-ignore lint/style/useNamingConvention: api is snake_case
start_at: args.event.startStr, body: { start_at: args.event.startStr, end_at: args.event.endStr },
end_at: args.event.endStr,
},
}); });
if (response.response.ok) { if (response.response.ok) {
document.dispatchEvent(new CustomEvent("reservationSlotChanged"));
this.scheduler.refetchEvents(); this.scheduler.refetchEvents();
} }
} }

View File

@ -1,3 +1,4 @@
import { AlertMessage } from "#core:utils/alert-message";
import type { SlotSelectedEventArg } from "#reservation:reservation/types"; import type { SlotSelectedEventArg } from "#reservation:reservation/types";
document.addEventListener("alpine:init", () => { document.addEventListener("alpine:init", () => {
@ -20,4 +21,19 @@ document.addEventListener("alpine:init", () => {
); );
}, },
})); }));
/**
* Component that will catch events sent from the scheduler
* to display success messages accordingly.
*/
Alpine.data("scheduleMessages", () => ({
alertMessage: new AlertMessage({ defaultDuration: 2000 }),
init() {
document.addEventListener("reservationSlotChanged", (_event: CustomEvent) => {
this.alertMessage.display(gettext("This slot has been successfully moved"), {
success: true,
});
});
},
}));
}); });

View File

@ -13,6 +13,14 @@
{% block content %} {% block content %}
<h2 class="margin-bottom">{% trans %}Room reservation{% endtrans %}</h2> <h2 class="margin-bottom">{% trans %}Room reservation{% endtrans %}</h2>
<p
x-data="scheduleMessages"
class="alert snackbar"
:class="alertMessage.success ? 'alert-green' : 'alert-red'"
x-show="alertMessage.open"
x-transition.duration.500ms
x-text="alertMessage.content"
></p>
<room-scheduler <room-scheduler
locale="{{ LANGUAGE_CODE }}" locale="{{ LANGUAGE_CODE }}"
can_edit_slot="{{ user.has_perm("reservation.change_reservationslot") }}" can_edit_slot="{{ user.has_perm("reservation.change_reservationslot") }}"