From 2f6a3685232c1484ab2b3421a01b65f43cb306c2 Mon Sep 17 00:00:00 2001 From: Arnaud Delcasse Date: Thu, 26 Feb 2026 17:50:36 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20mutualiser=20les=20templates=20book?= =?UTF-8?q?ing-display=20en=203=20partials=20partag=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yaml | 6 + .../vehicles/_partials/booking_documents.html | 51 +++++++++ .../_partials/booking_status_badge.html | 16 +++ .../_partials/booking_status_history.html | 43 ++++++++ web/layouts/vehicles/booking-display.html | 60 ++-------- .../vehicles_management/booking-display.html | 103 +++++++++--------- 6 files changed, 173 insertions(+), 106 deletions(-) create mode 100644 web/layouts/vehicles/_partials/booking_documents.html create mode 100644 web/layouts/vehicles/_partials/booking_status_badge.html create mode 100644 web/layouts/vehicles/_partials/booking_status_history.html diff --git a/config.yaml b/config.yaml index 53e2a50..b7c13bb 100644 --- a/config.yaml +++ b/config.yaml @@ -137,6 +137,9 @@ views: - web/layouts/vehicles/search.html booking_display: files: + - web/layouts/vehicles/_partials/booking_status_badge.html + - web/layouts/vehicles/_partials/booking_documents.html + - web/layouts/vehicles/_partials/booking_status_history.html - web/layouts/vehicles/booking-display.html bookings_list: files: @@ -170,6 +173,9 @@ views: - web/layouts/vehicles_management/fleet-update.html booking_display: files: + - web/layouts/vehicles/_partials/booking_status_badge.html + - web/layouts/vehicles/_partials/booking_documents.html + - web/layouts/vehicles/_partials/booking_status_history.html - web/layouts/vehicles_management/booking-display.html delete_booking: files: diff --git a/web/layouts/vehicles/_partials/booking_documents.html b/web/layouts/vehicles/_partials/booking_documents.html new file mode 100644 index 0000000..0fa6dbd --- /dev/null +++ b/web/layouts/vehicles/_partials/booking_documents.html @@ -0,0 +1,51 @@ +{{define "booking_documents"}} +
+

Documents

+ {{if eq (len .ViewState.documents) 0}} +

Aucun document

+ {{end}} + + + {{if gt (len .ViewState.documents) 0}} + +
+ + + + + + + + + + + {{range .ViewState.documents}} + + + + + + + {{end}} + + + + +
Type + Actions +
+
+ {{index $.ViewState.file_types_map .Metadata.Type}} +
+
+

{{.Metadata.Name}}

+
{{.LastModified.Format "02/01/2006"}} + + + +
+
+ + {{end}} +
+{{end}} \ No newline at end of file diff --git a/web/layouts/vehicles/_partials/booking_status_badge.html b/web/layouts/vehicles/_partials/booking_status_badge.html new file mode 100644 index 0000000..16f653d --- /dev/null +++ b/web/layouts/vehicles/_partials/booking_status_badge.html @@ -0,0 +1,16 @@ +{{define "booking_status_badge"}} +{{if eq .ViewState.status_management "manual"}} + {{$currentStatus := .ViewState.booking.ManualStatus}} + {{range .ViewState.status_options}} + {{if eq (index . "name") $currentStatus}} + {{if eq (index . "meta_status") "open"}} + {{index . "label"}} + {{else if eq (index . "meta_status") "active"}} + {{index . "label"}} + {{else if eq (index . "meta_status") "closed"}} + {{index . "label"}} + {{end}} + {{end}} + {{end}} +{{end}} +{{end}} \ No newline at end of file diff --git a/web/layouts/vehicles/_partials/booking_status_history.html b/web/layouts/vehicles/_partials/booking_status_history.html new file mode 100644 index 0000000..32c506d --- /dev/null +++ b/web/layouts/vehicles/_partials/booking_status_history.html @@ -0,0 +1,43 @@ +{{define "booking_status_history"}} +{{if eq .ViewState.status_management "manual"}} +{{if .ViewState.booking.StatusHistory}} +
+

Historique des statuts

+
+
    + {{range .ViewState.booking.StatusHistory}} +
  • +
    +
    +
    + + + + + +
    +
    +
    +

    + {{if .FromStatus}}{{$from := .FromStatus}}{{range $.ViewState.status_options}}{{if eq (index . "name") $from}}{{index . "label"}}{{end}}{{end}} → {{end}}{{$to := .ToStatus}}{{range $.ViewState.status_options}}{{if eq (index . "name") $to}}{{index . "label"}}{{end}}{{end}} + par {{.UserName}} + ({{.GroupName}}) +

    + {{if .Comment}} +

    {{.Comment}}

    + {{end}} +
    +
    + {{.Date.Format "02/01/2006 15:04"}} +
    +
    +
    +
    +
  • + {{end}} +
+
+
+{{end}} +{{end}} +{{end}} \ No newline at end of file diff --git a/web/layouts/vehicles/booking-display.html b/web/layouts/vehicles/booking-display.html index 096e14b..79a153e 100644 --- a/web/layouts/vehicles/booking-display.html +++ b/web/layouts/vehicles/booking-display.html @@ -72,7 +72,10 @@
-

Réservation

+

+ Réservation + {{template "booking_status_badge" .}} +

Informations utiles sur la réservation.

@@ -101,9 +104,7 @@
Réservé par
{{if .ViewState.booking.Data.booked_by.user}} - - + {{.ViewState.booking.Data.booked_by.user.display_name}} {{end}} @@ -141,55 +142,8 @@
{{(timeFrom .ViewState.booking.Enddate).Format "02/01/2006 à 15:04"}}
-
-

Documents

- {{if eq (len .ViewState.documents) 0}} -

Aucun document

- {{end}} - - - {{if gt (len .ViewState.documents) 0}} - -
- - - - - - - - - - - {{range .ViewState.documents}} - - - - - - - {{end}} - - - - -
Type - Actions -
-
- {{index $.ViewState.file_types_map .Metadata.Type}} -
-
-

{{.Metadata.Name}}

-
{{.LastModified.Format "02/01/2006"}} - - - -
-
- - {{end}} -
+ {{template "booking_documents" .}} + {{template "booking_status_history" .}}
diff --git a/web/layouts/vehicles_management/booking-display.html b/web/layouts/vehicles_management/booking-display.html index 4b15d35..88352df 100644 --- a/web/layouts/vehicles_management/booking-display.html +++ b/web/layouts/vehicles_management/booking-display.html @@ -9,6 +9,7 @@
{{if and (ne .ViewState.booking.Status -1) (not .ViewState.booking.Deleted)}} + {{if eq .ViewState.status_management "manual"}} + + {{end}}
+ + {{if eq .ViewState.status_management "manual"}} + + {{end}}
@@ -151,7 +194,10 @@

Motif : {{.ViewState.booking.Data.motif}}

{{end}} {{else}} -

Réservation

+

+ Réservation + {{template "booking_status_badge" .}} +

Informations utiles sur la réservation.

{{end}}
@@ -181,9 +227,7 @@
Prescripteur
{{if .ViewState.booking.Data.booked_by.user}} - - + {{.ViewState.booking.Data.booked_by.user.display_name}} {{end}} @@ -308,55 +352,8 @@
-
-

Documents

- {{if eq (len .ViewState.documents) 0}} -

Aucun document

- {{end}} - - - {{if gt (len .ViewState.documents) 0}} - -
- - - - - - - - - - - {{range .ViewState.documents}} - - - - - - - {{end}} - - - - -
Type - Actions -
-
- {{index $.ViewState.file_types_map .Metadata.Type}} -
-
-

{{.Metadata.Name}}

-
{{.LastModified.Format "02/01/2006"}} - - - -
-
- - {{end}} -
+ {{template "booking_documents" .}} + {{template "booking_status_history" .}}