215 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			HTML
		
	
	
	
			
		
		
	
	
			215 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			HTML
		
	
	
	
{{ define "content" }}
 | 
						|
 | 
						|
<div class="max-w-7xl mx-auto px-4 sm:px-6 md:px-8">
 | 
						|
    <h1 class="text-2xl font-semibold text-gray-900">Ajouter à l'agenda</h1>
 | 
						|
</div>
 | 
						|
 | 
						|
<div class="max-w-7xl mx-auto px-4 sm:px-6 md:px-8 mt-8"
 | 
						|
    x-data="{
 | 
						|
        fields: {
 | 
						|
            name: null,
 | 
						|
            type: null,
 | 
						|
            description: null,
 | 
						|
            allday: false,
 | 
						|
            startdate: null,
 | 
						|
            enddate: null,
 | 
						|
            starttime: null,
 | 
						|
            endtime: null,
 | 
						|
            max_subscribers: 0,
 | 
						|
        },
 | 
						|
        rules: {
 | 
						|
            name: ['required'],
 | 
						|
            type: ['required'],
 | 
						|
            startdate: ['required'],
 | 
						|
            enddate: ['required'],
 | 
						|
            starttime: ['optional'],
 | 
						|
            endtime: ['optional'],
 | 
						|
            description: ['optional'],
 | 
						|
            max_subscribers: ['required', 'min:0']
 | 
						|
        },
 | 
						|
        formValidation: {
 | 
						|
            valid: false,
 | 
						|
            fields: {
 | 
						|
                name: {valid: null},
 | 
						|
                type: {valid: null},
 | 
						|
                description: {valid: null},
 | 
						|
                startdate: {valid: null},
 | 
						|
                enddate: {valid: null},
 | 
						|
                starttime: {valid: null},
 | 
						|
                endtime: {valid: null},
 | 
						|
                allday: {valid: null},
 | 
						|
                max_subscribers: {valid: null},
 | 
						|
            }
 | 
						|
        },
 | 
						|
        isFormValid: true,
 | 
						|
        validate() {
 | 
						|
            this.formValidation = Iodine.assert(this.fields, this.rules)
 | 
						|
 | 
						|
            if(!Iodine.assertAfterOrEqual(new Date(this.fields.enddate), new Date(this.fields.startdate))) {
 | 
						|
                this.formValidation.fields.enddate.valid = false
 | 
						|
                this.formValidation.valid = false
 | 
						|
            }
 | 
						|
        },
 | 
						|
        validateField(field) {
 | 
						|
            this.formValidation.fields[field] = Iodine.assert(this.fields[field], this.rules[field])
 | 
						|
        },
 | 
						|
        submit(event) {
 | 
						|
            this.validate()
 | 
						|
            if(!this.formValidation.valid) {
 | 
						|
                this.isFormValid = false
 | 
						|
                event.preventDefault()
 | 
						|
            }
 | 
						|
            return this.formValidation.valid
 | 
						|
        }
 | 
						|
    }">
 | 
						|
    <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="md:grid md:grid-cols-3 md:gap-6">
 | 
						|
                <div class="md:col-span-1">
 | 
						|
                    <h3 class="text-lg font-medium leading-6 text-gray-900">Informations sur le dispositif</h3>
 | 
						|
                    <p class="mt-1 text-sm text-gray-500">Informations générales sur le dispositif d'accompagnement à ajouter à l'agenda</p>
 | 
						|
                </div>
 | 
						|
                <div class="mt-5 md:mt-0 md:col-span-2">
 | 
						|
                    <div class="grid grid-cols-6 gap-6">
 | 
						|
                        <div class="col-span-6 sm:col-span-3">
 | 
						|
                            <label for="name" class="block text-sm font-medium text-gray-700">Nom</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="sm:col-span-3">
 | 
						|
                            <label for="type" class="block text-sm font-medium text-gray-700">Type de dispositif</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></option>
 | 
						|
                                <option value="Permis accéléré">Permis accéléré</option>
 | 
						|
                                <option value="Auto-école sociale (classique)">Auto-école sociale (classique)</option>
 | 
						|
                                <option value="Information collective">Information collective</option>
 | 
						|
                                <option value="Autres">Autres</option>
 | 
						|
                            </select>
 | 
						|
                        </div>
 | 
						|
                        <div class="col-span-6">
 | 
						|
                            <label for="description" class="block text-sm font-medium text-gray-700">Description</label>
 | 
						|
                            <div class="mt-1">
 | 
						|
                                <textarea rows="4" name="description" id="descrpition" 
 | 
						|
                                    x-model="fields.description" @blur="validateField('description')"
 | 
						|
                                    :class="formValidation.fields.description.valid == false ? 'border-co-red border-2' : 'border-gray-300'"
 | 
						|
                                    class="shadow-sm focus:ring-co-blue focus:border-co-blue block w-full sm:text-sm border-gray-300 rounded-2xl"></textarea>
 | 
						|
                            </div>
 | 
						|
                        </div>
 | 
						|
 | 
						|
                        {{ $fieldName := "address" }}
 | 
						|
                        {{ template "address_autocomplete" dict "FieldName" $fieldName }}
 | 
						|
                    </div>
 | 
						|
                </div>
 | 
						|
            </div>
 | 
						|
        </div>
 | 
						|
 | 
						|
        <div class="bg-white shadow px-4 py-5 sm:rounded-lg sm:p-6">
 | 
						|
            <div class="md:grid md:grid-cols-3 md:gap-6">
 | 
						|
                <div class="md:col-span-1">
 | 
						|
                    <h3 class="text-lg font-medium leading-6 text-gray-900">Planification</h3>
 | 
						|
                    <p class="mt-1 text-sm text-gray-500">Dates et horaires de l'événement</p>
 | 
						|
                </div>
 | 
						|
                <div class="mt-5 space-y-6 md:mt-0 md:col-span-2 align-middle">
 | 
						|
                    <div class="grid grid-cols-6 gap-6">
 | 
						|
 | 
						|
                        <div class="col-span-6">
 | 
						|
 | 
						|
                            <button type="button" class="relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-co-blue focus:ring-offset-2" role="switch" aria-checked="false"
 | 
						|
                                :class="fields.allday ? 'bg-co-blue' : 'bg-gray-200'"
 | 
						|
                                @click="fields.allday = ! fields.allday">
 | 
						|
                                <span class="sr-only">Use setting</span>
 | 
						|
                                <!-- Enabled: "translate-x-5", Not Enabled: "translate-x-0" -->
 | 
						|
                                <span aria-hidden="true" class="pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"
 | 
						|
                                    :class="fields.allday ? 'translate-x-5' : 'translate-x-0'"></span>
 | 
						|
                            </button> <span class="text-md font-medium text-gray-700 ml-2">Toute la journée</span>
 | 
						|
                            <input type="hidden" name="allday" x-model="fields.allday">
 | 
						|
 | 
						|
                        </div>
 | 
						|
 | 
						|
                        <div class="sm:col-span-6">
 | 
						|
                            <div class="inline-flex w-full">
 | 
						|
                                <div class="flex-1">
 | 
						|
                                    <label for="startdate" class="block text-sm font-medium text-gray-700">Date de début</label>
 | 
						|
                                    <input type="date" name="startdate" id="startdate" placeholder="JJ/MM/AAAA"
 | 
						|
                                            class="mt-1 focus:ring-co-blue focus:border-co-blue block w-full shadow-sm sm:text-sm rounded-l-2xl"
 | 
						|
                                            x-model="fields.startdate" @blur="validateField('startdate')"
 | 
						|
                                            :class="formValidation.fields.startdate.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
 | 
						|
                                </div>
 | 
						|
                                <div class="flex-1">
 | 
						|
                                    <label for="enddate" class="block text-sm font-medium text-gray-700">Date de fin</label>
 | 
						|
                                    <input type="date" name="enddate" id="enddate" placeholder="JJ/MM/AAAA"
 | 
						|
                                            class="mt-1 focus:ring-co-blue focus:border-co-blue block w-full shadow-sm sm:text-sm rounded-r-2xl"
 | 
						|
                                            x-model="fields.enddate" @blur="validateField('enddate')"
 | 
						|
                                            :class="formValidation.fields.enddate.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
 | 
						|
                                </div>
 | 
						|
                                
 | 
						|
                                
 | 
						|
                            </div>
 | 
						|
                        </div>
 | 
						|
 | 
						|
                        <div class="sm:col-span-6" x-show="!fields.allday">
 | 
						|
                            <div class="inline-flex w-full">
 | 
						|
                                <div class="flex-1">
 | 
						|
                                    <label for="startdate" class="block text-sm font-medium text-gray-700">Horaire de début</label>
 | 
						|
                                    <input type="time" name="starttime" id="starttime" placeholder="00:00"
 | 
						|
                                            class="mt-1 focus:ring-co-blue focus:border-co-blue block w-full shadow-sm sm:text-sm rounded-l-2xl"
 | 
						|
                                            x-model="fields.starttime" @blur="validateField('starttime')"
 | 
						|
                                            :class="formValidation.fields.starttime.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
 | 
						|
                                </div>
 | 
						|
                                <div class="flex-1">
 | 
						|
                                    <label for="endtime" class="block text-sm font-medium text-gray-700">Horaire de fin</label>
 | 
						|
                                    <input type="time" name="endtime" id="endtime" placeholder="00:00"
 | 
						|
                                            class="mt-1 focus:ring-co-blue focus:border-co-blue block w-full shadow-sm sm:text-sm rounded-r-2xl"
 | 
						|
                                            x-model="fields.endtime" @blur="validateField('endtime')"
 | 
						|
                                            :class="formValidation.fields.endtime.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
 | 
						|
                                </div>
 | 
						|
                                
 | 
						|
                                
 | 
						|
                            </div>
 | 
						|
                        </div>
 | 
						|
 | 
						|
 | 
						|
                    </div>
 | 
						|
 | 
						|
                </div>
 | 
						|
            </div>
 | 
						|
        </div>
 | 
						|
 | 
						|
        <div class="bg-white shadow px-4 py-5 sm:rounded-lg sm:p-6">
 | 
						|
            <div class="md:grid md:grid-cols-3 md:gap-6">
 | 
						|
                <div class="md:col-span-1">
 | 
						|
                    <h3 class="text-lg font-medium leading-6 text-gray-900">Paramètres</h3>
 | 
						|
                    <p class="mt-1 text-sm text-gray-500">Paramètres du dispositift (nombre de places disponibles, etc...)</p>
 | 
						|
                </div>
 | 
						|
                <div class="mt-5 space-y-6 md:mt-0 md:col-span-2 align-middle">
 | 
						|
                    <div class="grid grid-cols-6 gap-6">
 | 
						|
                        <div class="col-span-6 sm:col-span-3">
 | 
						|
                            <label for="max_subscribers" class="block text-sm font-medium text-gray-700">Places disponibles (0 = illimité)</label>
 | 
						|
                            <input type="number" name="max_subscribers" id="max_subscribers"
 | 
						|
                                class="mt-1 focus:ring-co-blue focus:border-co-blue block w-full shadow-sm sm:text-sm  rounded-2xl"
 | 
						|
                                x-model="fields.max_subscribers" @blur="validateField('max_subscribers')"
 | 
						|
                                :class="formValidation.fields.max_subscribers.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
 | 
						|
                        </div>
 | 
						|
                    </div>
 | 
						|
                </div>
 | 
						|
            </div>
 | 
						|
        </div>
 | 
						|
 | 
						|
        <div class="flex justify-end">
 | 
						|
            <p x-show="! isFormValid" class="px-4 py-2 text-sm text-co-red">Certains champs de sont pas valides.</p>
 | 
						|
            <a href="/app/agenda/">
 | 
						|
                <button type="button"
 | 
						|
                    class="bg-white py-2 px-4 border border-gray-300 rounded-2xl shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-co-blue">Annuler</button>
 | 
						|
            </a>
 | 
						|
            <button type="submit"
 | 
						|
                class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-2xl text-white bg-co-blue hover:bg-co-blue focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-co-blue">Ajouter</button>
 | 
						|
        </div>
 | 
						|
    </form>
 | 
						|
</div>
 | 
						|
 | 
						|
{{end}} |