escape json

This commit is contained in:
Arnaud Delcasse 2025-10-08 23:54:53 +02:00
parent 878200058b
commit 80c40759bb
3 changed files with 17 additions and 17 deletions

View File

@ -9,13 +9,13 @@
{{range $index, $booking := .ViewState.bookings}}{{if $index}},{{end}}{ {{range $index, $booking := .ViewState.bookings}}{{if $index}},{{end}}{
id: '{{$booking.Id}}', id: '{{$booking.Id}}',
driverId: '{{$booking.Driver.Id}}', driverId: '{{$booking.Driver.Id}}',
driverFirstName: '{{ (index $.ViewState.drivers_map $booking.Driver.Id).Data.first_name }}', driverFirstName: '{{ jsEscape (index $.ViewState.drivers_map $booking.Driver.Id).Data.first_name }}',
driverLastName: '{{ (index $.ViewState.drivers_map $booking.Driver.Id).Data.last_name }}', driverLastName: '{{ jsEscape (index $.ViewState.drivers_map $booking.Driver.Id).Data.last_name }}',
passengerId: '{{$booking.Passenger.Id}}', passengerId: '{{$booking.Passenger.Id}}',
passengerFirstName: '{{ (index $.ViewState.passengers_map $booking.Passenger.Id).Data.first_name }}', passengerFirstName: '{{ jsEscape (index $.ViewState.passengers_map $booking.Passenger.Id).Data.first_name }}',
passengerLastName: '{{ (index $.ViewState.passengers_map $booking.Passenger.Id).Data.last_name }}', passengerLastName: '{{ jsEscape (index $.ViewState.passengers_map $booking.Passenger.Id).Data.last_name }}',
pickupAddress: '{{$booking.PassengerPickupAddress}}', pickupAddress: '{{ jsEscape $booking.PassengerPickupAddress }}',
dropAddress: '{{$booking.PassengerDropAddress}}', dropAddress: '{{ jsEscape $booking.PassengerDropAddress }}',
pickupDate: '{{ timeFormat $booking.PassengerPickupDate.AsTime "02/01/2006 15:04" }}', pickupDate: '{{ timeFormat $booking.PassengerPickupDate.AsTime "02/01/2006 15:04" }}',
status: '{{$booking.Status.String}}', status: '{{$booking.Status.String}}',
price: '{{if $booking.Price}}{{ printf "%.2f" (round2 $booking.Price.Amount) }}{{else}}N/A{{end}}', price: '{{if $booking.Price}}{{ printf "%.2f" (round2 $booking.Price.Amount) }}{{else}}N/A{{end}}',

View File

@ -32,11 +32,11 @@
drivers: [ drivers: [
{{range $index, $driver := .ViewState.drivers}}{{if $index}},{{end}}{ {{range $index, $driver := .ViewState.drivers}}{{if $index}},{{end}}{
id: '{{$driver.ID}}', id: '{{$driver.ID}}',
firstName: '{{$driver.Data.first_name}}', firstName: '{{ jsEscape $driver.Data.first_name }}',
lastName: '{{$driver.Data.last_name}}', lastName: '{{ jsEscape $driver.Data.last_name }}',
address: '{{if $driver.Data.address}}{{$driver.Data.address.properties.label}}{{end}}', address: '{{if $driver.Data.address}}{{ jsEscape $driver.Data.address.properties.label }}{{end}}',
addressDestination: '{{if $driver.Data.address_destination}}{{$driver.Data.address_destination.properties.label}}{{end}}', addressDestination: '{{if $driver.Data.address_destination}}{{ jsEscape $driver.Data.address_destination.properties.label }}{{end}}',
phoneNumber: '{{$driver.Data.phone_number}}', phoneNumber: '{{ jsEscape $driver.Data.phone_number }}',
validated: {{if carpoolDriverValidatedProfile $driver (carpoolDocuments $driver.ID)}}true{{else}}false{{end}} validated: {{if carpoolDriverValidatedProfile $driver (carpoolDocuments $driver.ID)}}true{{else}}false{{end}}
}{{end}} }{{end}}
], ],
@ -94,8 +94,8 @@
<template x-for="driver in paginatedDrivers" :key="driver.id"> <template x-for="driver in paginatedDrivers" :key="driver.id">
<tr> <tr>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6" x-text="driver.firstName + ' ' + driver.lastName"></td> <td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6" x-text="driver.firstName + ' ' + driver.lastName"></td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6" x-text="driver.address"></td> <td class="py-4 pl-4 pr-3 text-sm sm:pl-6" x-text="driver.address"></td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6" x-text="driver.addressDestination"></td> <td class="py-4 pl-4 pr-3 text-sm sm:pl-6" x-text="driver.addressDestination"></td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6" x-text="driver.phoneNumber"></td> <td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6" x-text="driver.phoneNumber"></td>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6"> <td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm sm:pl-6">
<span x-show="driver.validated" class="p-1 px-2 text-xs bg-co-green rounded-2xl">Oui</span> <span x-show="driver.validated" class="p-1 px-2 text-xs bg-co-green rounded-2xl">Oui</span>

View File

@ -31,10 +31,10 @@
drivers: [ drivers: [
{{range $index, $driver := .ViewState.drivers}}{{if $index}},{{end}}{ {{range $index, $driver := .ViewState.drivers}}{{if $index}},{{end}}{
id: '{{$driver.ID}}', id: '{{$driver.ID}}',
firstName: '{{$driver.Data.first_name}}', firstName: '{{ jsEscape $driver.Data.first_name }}',
lastName: '{{$driver.Data.last_name}}', lastName: '{{ jsEscape $driver.Data.last_name }}',
address: '{{if $driver.Data.address}}{{$driver.Data.address.properties.label}}{{end}}', address: '{{if $driver.Data.address}}{{ jsEscape $driver.Data.address.properties.label }}{{end}}',
phoneNumber: '{{$driver.Data.phone_number}}', phoneNumber: '{{ jsEscape $driver.Data.phone_number }}',
validated: {{if solidarityDriverValidatedProfile $driver (solidarityDocuments $driver.ID)}}true{{else}}false{{end}} validated: {{if solidarityDriverValidatedProfile $driver (solidarityDocuments $driver.ID)}}true{{else}}false{{end}}
}{{end}} }{{end}}
], ],