Compare commits

...

7 Commits

5 changed files with 262 additions and 36 deletions

View File

@ -100,10 +100,12 @@ views:
files:
- web/layouts/agenda/_partials/subscribers-table.html
- web/layouts/agenda/display-event.html
- web/layouts/agenda/_partials/event-files.html
create_event:
files:
- web/layouts/_partials/address_autocomplete.html
- web/layouts/agenda/create-event.html
- web/layouts/agenda/_partials/event-files.html
delete_subscriber:
files:
- web/layouts/agenda/delete-subscriber.html

View File

@ -0,0 +1,134 @@
{{define "event_files"}}
<div class="px-4 py-6 sm:px-6"
x-data="{
fields: {
name: null,
type: null,
file: null,
},
rules: {
name: ['required'],
type: ['required'],
file: ['required'],
},
formValidation: {
valid: false,
fields: {
name: {valid: null},
type: {valid: null},
file: {valid: null},
}
},
isFormValid: true,
validate() {
this.formValidation = Iodine.assert(this.fields, this.rules)
},
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
}
}">
{{if eq (len .ViewState.documents) 0}}
<p class="p-12 text-gray-500 text-center text-md">Aucun document</p>
{{end}}
{{if gt (len .ViewState.documents) 0}}
<div class="-mx-4 mb-10 ring-1 ring-gray-300 sm:-mx-6 md:mx-0 md:rounded-lg">
<table class="min-w-full divide-y divide-gray-300">
<thead>
<tr>
<th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Type</th>
<th scope="col" class="hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 lg:table-cell">Nom du document</th>
<th scope="col" class="hidden px-3 py-3.5 text-left text-sm font-semibold text-gray-900 lg:table-cell">Ajouté le</th>
<th scope="col" class="relative py-3.5 pl-3 pr-4 sm:pr-6">
<span class="sr-only">Actions</span>
</th>
</tr>
</thead>
<tbody>
{{range .ViewState.documents}}
<tr>
<td class="relative py-4 pl-4 sm:pl-6 pr-3 text-sm">
<div class="font-medium text-gray-900">
<span class="bg-co-blue text-xs text-white rounded-xl p-1 mr-2">{{index $.ViewState.file_types_map .Metadata.Type}}</span>
</div>
</td>
<td class="px-3 py-3.5 text-sm text-gray-900 lg:table-cell">{{.Metadata.Name}}</td>
<td class="px-3 py-3.5 text-sm text-gray-500 lg:table-cell">{{.LastModified.Format "02/01/2006"}}</td>
<td class="relative py-3.5 pl-3 pr-4 sm:pr-6 text-right text-sm font-medium">
<a href="/app/agenda/{{$.ViewState.event.ID}}/documents/{{.FileName}}" target="_blank">
<button type="button" class="inline-flex items-center rounded-md border border-gray-300 bg-white px-3 py-2 text-sm font-medium leading-4 text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-co-blue focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-30">Voir<span class="sr-only"> le document</span></button>
</a>
</td>
</tr>
{{end}}
<!-- More plans... -->
</tbody>
</table>
</div>
{{end}}
{{ if eq (index .ViewState.event.Owners 0) .Group.ID }}
<h3 class="text-lg">Ajouter un document</h3>
<form method="POST" action="/app/agenda/{{.ViewState.event.ID}}/documents" @submit="submit" enctype="multipart/form-data">
<div class="md:grid md:grid-cols-6 p-2">
<div class="sm:col-span-2">
<label for="type" class="block text-sm font-medium text-gray-700">Type</label>
<select id="type" name="type" class="mt-1 block w-full rounded-l-2xl border-gray-300 py-2 pl-3 pr-10 text-base focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm"
x-model="fields.type" @blur="validateField('type')"
:class="formValidation.fields.type.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
<option value="" selected>Sélectionner un type</option>
{{range .ViewState.events_file_types}}
<option value="{{.}}">{{index $.ViewState.file_types_map .}}</option>
{{end}}
</select>
</div>
<div class="sm:col-span-4">
<label for="name" class="block text-sm font-medium text-gray-700">Nom</label>
<input type="text" name="name" id="name"
placeholder="Nom du fichier"
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.name" @blur="validateField('name')"
:class="formValidation.fields.name.valid == false ? 'border-co-red border-2' : 'border-gray-300'" />
</div>
<div class="sm:col-span-6 mt-4">
<label for="cover-photo" class="block text-sm font-medium text-gray-700">Téléchargement</label>
<div class="mt-1 flex justify-center rounded-md border-2 border-dashed px-6 pt-5 pb-6"
x-on:drop="console.log('toto')"
:class="formValidation.fields.file.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
<div class="space-y-1 text-center">
{{.IconSet.Icon "hero:outline/folder-plus" "mx-auto h-12 w-12 text-gray-400"}}
<div class="flex text-sm text-gray-600">
<label for="file-upload" class="relative cursor-pointer rounded-md bg-white font-medium text-co-blue focus-within:outline-none focus-within:ring-2 focus-within:ring-co-blue focus-within:ring-offset-2 hover:text-co-blue">
<span>Sélectionnez un fichier </span>
<input id="file-upload" name="file-upload" type="file" class="sr-only"
x-model="fields.file" @blur="validateField('file')">
</label>
<!-- <p class="pl-1">ou glissez-déposez</p> -->
</div>
<p class="text-xs text-gray-500">Jusqu'à 10MB</p>
<p class="text-co-blue p-2" x-text="fields.file" x-if="fields.file"></p>
</div>
</div>
</div>
</div>
<button type="submit"
class="rounded-2xl border border-transparent bg-co-blue px-4 py-2 my-4 mt-8 w-full text-sm font-medium text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-co-blue focus:ring-offset-2 sm:w-auto">
Ajouter le document
</button>
</form>
{{end}}
</div>
{{end}}

View File

@ -4,8 +4,7 @@
<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="{
<div class="max-w-7xl mx-auto px-4 sm:px-6 md:px-8 mt-8" x-data="{
fields: {
name: null,
type: null,
@ -16,6 +15,9 @@
starttime: null,
endtime: null,
max_subscribers: 0,
file_name: null,
file_type: null,
file: null,
},
rules: {
name: ['required'],
@ -25,7 +27,10 @@
starttime: ['optional'],
endtime: ['optional'],
description: ['optional'],
max_subscribers: ['required', 'min:0']
max_subscribers: ['required', 'min:0'],
file_name: ['optional'],
file_type: ['optional'],
file: ['optional'],
},
formValidation: {
valid: false,
@ -39,6 +44,9 @@
endtime: {valid: null},
allday: {valid: null},
max_subscribers: {valid: null},
file_name: {valid: null},
file_type: {valid: null},
file: {valid: null},
}
},
isFormValid: true,
@ -62,12 +70,14 @@
return this.formValidation.valid
}
}">
<form class="space-y-6" method="POST" @submit="submit">
<form id="eventForm" 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>
<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">
@ -80,8 +90,7 @@
</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')"
<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>
@ -94,8 +103,8 @@
<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')"
<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>
@ -119,12 +128,14 @@
<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'"
<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"
<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">
@ -134,14 +145,16 @@
<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>
<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>
<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')"
@ -155,14 +168,16 @@
<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>
<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>
<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')"
@ -184,12 +199,14 @@
<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>
<p class="mt-1 text-sm text-gray-500">Paramètres du dispositif (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>
<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')"
@ -199,8 +216,54 @@
</div>
</div>
</div>
<!-- <div class="bg-white shadow px-4 py-5 sm:rounded-lg sm:p-6 mt-8">
<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">Ajouter un document</h3>
<p class="mt-1 text-sm text-gray-500">Téléchargez un document lié à cet événement</p>
</div>
<div class="md:grid md:grid-cols-6 p-2">
<div class="sm:col-span-2">
<label for="file_type" class="block text-sm font-medium text-gray-700">Type</label>
<select id="file_type" name="file_type" class="mt-1 block w-full rounded-l-2xl border-gray-300 py-2 pl-3 pr-10 text-base focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm"
x-model="fields.file_type" @blur="validateField('file_type')"
:class="formValidation.fields.file_type.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
<option value="" selected>Sélectionner un type</option>
{{range .ViewState.events_file_types}}
<option value="{{.}}">{{index $.ViewState.file_types_map .}}</option>
{{end}}
</select>
</div>
<div class="sm:col-span-4">
<label for="file_name" class="block text-sm font-medium text-gray-700">Nom</label>
<input type="text" name="file_name" id="file_name"
placeholder="Nom du fichier"
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.file_name" @blur="validateField('file_name')"
:class="formValidation.fields.file_name.valid == false ? 'border-co-red border-2' : 'border-gray-300'" />
</div>
<div class="sm:col-span-6 mt-4">
<label for="cover-photo" class="block text-sm font-medium text-gray-700">Téléchargement</label>
<div class="mt-1 flex justify-center rounded-md border-2 border-dashed px-6 pt-5 pb-6"
x-on:drop="console.log('toto')"
:class="formValidation.fields.file.valid == false ? 'border-co-red border-2' : 'border-gray-300'">
<div class="space-y-1 text-center">
{{.IconSet.Icon "hero:outline/folder-plus" "mx-auto h-12 w-12 text-gray-400"}}
<div class="flex text-sm text-gray-600">
<label for="file-upload" class="relative cursor-pointer rounded-md bg-white font-medium text-co-blue focus-within:outline-none focus-within:ring-2 focus-within:ring-co-blue focus-within:ring-offset-2 hover:text-co-blue">
<span>Sélectionnez un fichier </span>
<input id="file-upload" name="file-upload" type="file" class="sr-only"
x-model="fields.file" @blur="validateField('file')">
</label>
</div>
<p class="text-xs text-gray-500">Jusqu'à 10MB</p>
<p class="text-co-blue p-2" x-text="fields.file" x-if="fields.file"></p>
</div>
</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>

View File

@ -85,6 +85,7 @@
</div>
</div>
</section>
{{ if eq (index .ViewState.event.Owners 0) .Group.ID }}
<section aria-labelledby="subscribers-table"></section>
<div class="bg-white shadow sm:rounded-lg">
@ -205,5 +206,17 @@
</div>
</section>
</div>
<div class="mt-8 max-w-3xl mx-auto grid grid-cols-1 gap-6 sm:px-6 lg:max-w-7xl lg:grid-flow-col-dense lg:grid-cols-3">
<div class="space-y-6 lg:col-start-1 lg:col-span-2">
<section aria-labelledby="event-documents">
<div class="bg-white mt-4 px-4 py-5 shadow sm:rounded-lg sm:px-6">
<h2 id="documents-title" class="text-lg font-medium text-gray-900">Documents</h2>
<div class="flex justify-between items-center">
<div>{{template "event_files" .}}</div>
</div>
</div>
</section>
</div>
</div>
</main>
{{ end }}

View File

@ -147,6 +147,20 @@
<div class="lg:col-start-2 lg:col-span-2">
{{if .ViewState.searched}}
<div class="bg-white px-4 py-5 shadow sm:rounded-2xl sm:px-6">
<h2 id="timeline-title" class="text-lg font-medium text-gray-900">Documents demandés</h2>
<table>
<tbody>
{{range .ViewState.search.mandatory_documents}}
<tr>
<td class="whitespace-nowrap py-4 px-3 text-sm text-gray-500">
{{index $.ViewState.search.file_types_map .}}
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
<div class="bg-white mt-8 px-4 py-5 shadow sm:rounded-2xl sm:px-6">
<h2 id="timeline-title" class="text-lg font-medium text-gray-900">Véhicules disponibles</h2>
<div class="mt-8 flex flex-col">
<div class="-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8">