Compare commits
1 Commits
main
...
modifyVehi
Author | SHA1 | Date |
---|---|---|
soukainna | e8e7fb4849 |
|
@ -3,23 +3,26 @@
|
|||
{{ if eq (index .ViewState.vehicle.Administrators 0) .Group.ID }}
|
||||
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 md:px-8">
|
||||
<h1 class="text-2xl font-semibold text-gray-900">Modifier un véhicule</h1>
|
||||
<h1 class="text-2xl font-semibold text-gray-900">Modifier le véhicule</h1>
|
||||
</div>
|
||||
|
||||
<div class="max-w-7xl mx-auto px-4 sm:px-6 md:px-8 mt-8" x-data="{
|
||||
fields: {
|
||||
licence_plate: '{{ .ViewState.vehicle.Data.licence_plate }}',
|
||||
name: '{{ .ViewState.vehicle.Data.name }}',
|
||||
type: '{{ .ViewState.vehicle.Type }}',
|
||||
},
|
||||
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}$'
|
||||
name: ['required'],
|
||||
type: ['required'],
|
||||
},
|
||||
formValidation: {
|
||||
valid: false,
|
||||
fields: {
|
||||
name: {valid: null},
|
||||
licence_plate: {valid: null},
|
||||
type: {valid: null},
|
||||
}
|
||||
},
|
||||
isFormValid: true,
|
||||
|
@ -36,6 +39,10 @@
|
|||
event.preventDefault()
|
||||
}
|
||||
return this.formValidation.valid
|
||||
},
|
||||
|
||||
displayAutomatic(type) {
|
||||
return type == 'Voiture'
|
||||
}
|
||||
}">
|
||||
<form class="space-y-6" method="POST" @submit="submit">
|
||||
|
@ -48,19 +55,44 @@
|
|||
<div class="mt-5 md:mt-0 md:col-span-2">
|
||||
<div class="grid grid-cols-3 md:grid-cols-6 gap-6">
|
||||
<div class="col-span-5">
|
||||
<label for="name" class="block text-sm font-medium text-gray-700">Modèle (ou nom donné au
|
||||
véhicule)</label>
|
||||
<label for="name" class="block text-sm font-medium text-gray-700">Modèle (ou nom donné au véhicule)</label>
|
||||
<input type="text" name="name" id="name"
|
||||
class="mt-1 focus:ring-co-blue focus:border-co-blue block w-full shadow-sm sm:text-sm rounded-2xl"
|
||||
x-model="fields.name" @blur="validateField('name')"
|
||||
:class="formValidation.fields.name.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
|
||||
</div>
|
||||
<div class="col-span-3">
|
||||
{{template "vehicle_type_select" .}}
|
||||
<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">
|
||||
{{if .ViewState.vehicle.Data.automatic}}
|
||||
<input id="automatic" aria-describedby="automatic-description" name="automatic" type="checkbox" checked class="h-4 w-4 rounded border-gray-300 text-co-blue focus:ring-co-blue">
|
||||
{{else}}
|
||||
<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">
|
||||
{{end}}
|
||||
</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 class="col-span-3">
|
||||
<label for="licence_plate"
|
||||
class="block text-sm font-medium text-gray-700">Immatriculation</label>
|
||||
class="block text-sm font-medium text-gray-700">Numéro (Immat, Bicycode, ...)</label>
|
||||
<input type="text" name="licence_plate" id="licence_plate" placeholder="XX-123-YY"
|
||||
class="mt-1 focus:ring-co-blue focus:border-co-blue block w-full shadow-sm sm:text-sm rounded-2xl"
|
||||
x-model="fields.licence_plate"
|
||||
|
@ -85,11 +117,12 @@
|
|||
{{else}}
|
||||
{{ template "address_autocomplete" dict "FieldName" $fieldName}}
|
||||
{{end}}
|
||||
|
||||
<div class="mt-5">
|
||||
<label for="informations" class="block text-sm font-medium text-gray-700">Informations pratiques pour le bénéficiaire</label>
|
||||
<label for="informations" class="block text-sm font-medium text-gray-700">Informations pratiques</label>
|
||||
<div class="mt-1">
|
||||
<textarea rows="4" name="informations" id="informations" value="{{.ViewState.vehicle.Data.informations}}"
|
||||
class="shadow-sm focus:ring-co-blue focus:border-co-blue block w-full sm:text-sm border-gray-300 rounded-2xl">{{ if .ViewState.vehicle.Data.informations}} {{.ViewState.vehicle.Data.informations}} {{end}}</textarea>
|
||||
class="shadow-sm focus:ring-co-blue focus:border-co-blue block w-full sm:text-sm border-gray-300 rounded-2xl">{{ if .ViewState.vehicle.Data.informations}}{{.ViewState.vehicle.Data.informations}}{{end}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -108,7 +141,6 @@
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{{else}}
|
||||
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"></div>
|
||||
|
||||
|
@ -125,9 +157,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="flex justify-center items-center mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense ">
|
||||
<!-- class="flex justify-center items-center py-2 px-3 border-t dark:border-gray-600 -->
|
||||
<a href="/app/vehicles-management/fleet/{{.ViewState.vehicle.ID}}" class="rounded-2xl mt-3 inline-flex w-full justify-center rounded-l-2xl border border-gray-300 bg-white px-4 py-2 text-base font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-co-blue focus:ring-offset-2 sm:col-start-1 sm:mt-0 sm:text-sm">Annuler</a>
|
||||
<!-- <button type="submit" class="inline-flex w-full justify-center rounded-r-2xl border border-transparent bg-co-blue px-4 py-2 text-base font-medium text-white shadow-sm hover:bg-co-blue focus:outline-none focus:ring-2 focus:ring-co-blue focus:ring-offset-2 sm:col-start-2 sm:text-sm">Confirmation</button> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue