fix some error on web/layouts/vehicles_management/fleet-update.html

This commit is contained in:
Nicolas CARON 2024-10-29 14:07:08 +01:00
parent 3526ee8700
commit c6f40f2aa2
1 changed files with 30 additions and 1 deletions

View File

@ -9,6 +9,7 @@
fields: { fields: {
licence_plate: '{{ .ViewState.vehicle.Data.licence_plate }}', licence_plate: '{{ .ViewState.vehicle.Data.licence_plate }}',
name: '{{ .ViewState.vehicle.Data.name }}', name: '{{ .ViewState.vehicle.Data.name }}',
kilometers: '{{ .ViewState.vehicle.Data.kilometers }}',
}, },
rules: { rules: {
licence_plate: ['required', 'regexMatch:^[A-Z]{1,2}-[0-9]{1,3}-[A-Z]{1,2}$'], licence_plate: ['required', 'regexMatch:^[A-Z]{1,2}-[0-9]{1,3}-[A-Z]{1,2}$'],
@ -35,7 +36,12 @@
event.preventDefault() event.preventDefault()
} }
return this.formValidation.valid return this.formValidation.valid
},
displayAutomatic(type) {
return type == 'Voiture'
} }
}"> }">
<form class="space-y-6" method="POST" @submit="submit"> <form class="space-y-6" method="POST" @submit="submit">
<div class="bg-white shadow px-4 py-5 sm:rounded-lg sm:p-6"> <div class="bg-white shadow px-4 py-5 sm:rounded-lg sm:p-6">
@ -55,7 +61,30 @@
:class="formValidation.fields.name.valid == false ? 'border-co-red border-2' : 'border-gray-300'"> :class="formValidation.fields.name.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
</div> </div>
<div class="col-span-3"> <div class="col-span-3">
{{template "vehicle_type_select" .}} <div class="col-span-3">
<label for="type" class="block text-sm font-medium text-gray-700">Type de véhicule</label>
<select id="type" name="type"
x-model="fields.type" @blur="validateField('type')"
class="max-w-lg mt-1 block focus:ring-co-blue focus:border-co-blue w-full shadow-sm sm:max-w-xs sm:text-sm rounded-2xl"
:class="formValidation.fields.type.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
<option value="" selected></option>
{{range .ViewState.vehicle_types}}
<option value="{{.}}">{{.}}</option>
{{end}}
</select>
<div class="m-4" x-show="displayAutomatic(fields.type)">
<legend class="sr-only">Automatique</legend>
<div class="relative flex items-start">
<div class="flex h-5 items-center">
<input id="automatic" aria-describedby="automatic-description" name="automatic" type="checkbox" class="h-4 w-4 rounded border-gray-300 text-co-blue focus:ring-co-blue">
</div>
<div class="ml-3 text-sm">
<label for="automatic" class="font-medium text-gray-700">Automatique</label>
<p id="automatic-description" class="text-gray-500">Ce véhicule a une boite automatique.</p>
</div>
</div>
</div>
</div>
</div> </div>
<div class="col-span-3"> <div class="col-span-3">
<label for="licence_plate" <label for="licence_plate"