github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/server/frontend/directeurs/src/components/home/DetailsI.vue (about) 1 <template> 2 <v-card flat v-if="details != null"> 3 <v-form ref="form"> 4 <v-card-text> 5 <v-row dense> 6 <v-col xs="12" md="3"> 7 <v-text-field v-model="details.nom" label="Nom"></v-text-field> 8 </v-col> 9 <v-col xs="12" md="3"> 10 <v-text-field v-model="details.lieu" label="Lieu"></v-text-field> 11 </v-col> 12 <v-col xs="12" md="2"> 13 <v-text-field 14 :value="date(details.date_debut)" 15 label="Date de début" 16 readonly 17 ></v-text-field> 18 </v-col> 19 <v-col xs="12" md="2"> 20 <v-text-field 21 :value="date(details.date_fin)" 22 label="Date de fin" 23 readonly 24 ></v-text-field> 25 </v-col> 26 <v-col xs="12" md="2"> 27 <v-text-field 28 v-model.number="details.nb_places" 29 type="number" 30 label="Nombre de places" 31 ></v-text-field> 32 </v-col> 33 </v-row> 34 <v-row dense> 35 <v-col xs="12" sm="6"> 36 <v-tooltip bottom :disabled="!details.bus.actif"> 37 <template v-slot:activator="{ on }"> 38 <v-text-field 39 v-on="on" 40 :value="resumeBus" 41 label="Navette proposée" 42 placeholder="Aucune navette" 43 readonly 44 ></v-text-field> 45 </template> 46 Une option 47 <i>Navette</i> est proposée sur le formulaire d'inscription. 48 </v-tooltip> 49 </v-col> 50 </v-row> 51 <v-row dense> 52 <v-col xs="12" md="3"> 53 <v-tooltip bottom> 54 <template v-slot:activator="{ on }"> 55 <div v-on="on"> 56 <v-checkbox 57 v-if="details != null" 58 label="Matériel de ski proposé" 59 v-model="details.materiel_ski.actif" 60 ></v-checkbox> 61 </div> 62 </template> 63 En cas de sélection, une option 64 <i>Prêt de matériel</i> est proposée sur le formulaire 65 d'inscription. 66 </v-tooltip> 67 </v-col> 68 <v-col xs="12" md="3"> 69 <v-text-field 70 :disabled="!details.materiel_ski.actif" 71 suffix="€" 72 type="number" 73 label="Prix demandé par le loueur" 74 :rules="details.materiel_ski.actif ? [isNonEmpty] : []" 75 v-model.number="details.materiel_ski.prix_loueur" 76 hint="Prix indicatif de la location pour un participant, chez un loueur professionnel." 77 ></v-text-field> 78 </v-col> 79 <v-col xs="12" md="3"> 80 <v-text-field 81 :disabled="!details.materiel_ski.actif" 82 suffix="€" 83 type="number" 84 label="Prix du matériel ACVE" 85 :rules="details.materiel_ski.actif ? [isNonEmpty] : []" 86 v-model.number="details.materiel_ski.prix_acve" 87 hint="Participation à l'entretion du matériel prété par l'ACVE." 88 ></v-text-field> 89 </v-col> 90 </v-row> 91 <v-row dense> 92 <v-col xs="12" md="6"> 93 <v-tooltip bottom> 94 <template v-slot:activator="{ on }"> 95 <div v-on="on"> 96 <v-checkbox 97 v-if="details != null" 98 v-model="details.need_equilibre_gf" 99 label="Equilibre garçons/fille souhaité" 100 ></v-checkbox> 101 </div> 102 </template> 103 En cas de sélection, le centre d'inscription sera averti. 104 <br />Ce n'est pas une garantie d'un équilibre effectif. 105 </v-tooltip> 106 </v-col> 107 </v-row> 108 </v-card-text> 109 <v-card-actions> 110 <v-spacer></v-spacer> 111 <v-btn @click="saveDetails" class="success">Sauvegarder</v-btn> 112 </v-card-actions> 113 </v-form> 114 </v-card> 115 </template> 116 117 <script lang="ts"> 118 import Vue from "vue"; 119 import Component from "vue-class-component"; 120 import { Details } from "@/logic/types"; 121 import { Formatter } from "@/logic/formatter"; 122 import { C } from "../../logic/controller"; 123 124 const DetailsIProps = Vue.extend({ 125 props: {} 126 }); 127 128 @Component({}) 129 export default class DetailsI extends DetailsIProps { 130 details: Details | null = null; 131 132 date = Formatter.date; 133 134 $refs!: { 135 form: HTMLFormElement; 136 }; 137 get resumeBus() { 138 if (this.details == null || !this.details.bus.actif) return ""; 139 return ( 140 `Aller : ${this.details.bus.aller.rendez_vous} (${this.details.bus.aller.prix} €) ; ` + 141 `Retour : ${this.details.bus.retour.rendez_vous} (${this.details.bus.retour.prix} €)` 142 ); 143 } 144 145 isNonEmpty = (value: number) => !!value || "Requis !"; 146 147 async created() { 148 const r = await C.getDetails("details"); 149 if (r != undefined) { 150 this.details = r.details; 151 C.notifications.success = "Données chargées"; 152 } 153 } 154 155 async saveDetails() { 156 if (!this.$refs.form.validate()) { 157 return; 158 } 159 if (this.details == null) return; 160 const r = await C.updateDetails("details", this.details); 161 if (r != undefined) { 162 this.details = r.details; 163 C.notifications.success = "Détails du camp bien modifiés."; 164 } 165 } 166 } 167 </script> 168 169 <style scoped></style>