github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/server/frontend/directeurs/src/views/inscrits_complets.ts (about) 1 import TooltipBtn from "@/components/TooltipBtn.vue"; 2 import { C, DossierMessages, OptionsExportInscrit } from "@/logic/controller"; 3 import { BaseInscrits, matchesBus } from "@/views/inscrits"; 4 import Component from "vue-class-component"; 5 import FichesSanitaires from "../components/inscrits/FichesSanitaires.vue"; 6 import FormExport from "../components/inscrits/FormExport.vue"; 7 import FormInscrit from "../components/inscrits/FormInscrit.vue"; 8 import GroupeChip from "../components/inscrits/GroupeChip.vue"; 9 import { Attribution } from "../components/inscrits/ListeGroupes"; 10 import ListeGroupes from "../components/inscrits/ListeGroupes.vue"; 11 import PanelContraintes from "../components/inscrits/PanelContraintes.vue"; 12 import PanelInfosParticulieres from "../components/inscrits/PanelInfosParticulieres.vue"; 13 import PanelMessages from "../components/inscrits/PanelMessages.vue"; 14 import ToolbarSwitch from "../components/ToolbarSwitch.vue"; 15 import { EditFields } from "../logic/formatter"; 16 import { 17 Bus, 18 Date_, 19 Groupe, 20 Inscrit, 21 OptionnalId, 22 Responsable, 23 ResumeMessage 24 } from "../logic/types"; 25 26 @Component({ 27 components: { 28 FormInscrit, 29 ToolbarSwitch, 30 FormExport, 31 FichesSanitaires, 32 ListeGroupes, 33 PanelContraintes, 34 TooltipBtn, 35 PanelMessages, 36 PanelInfosParticulieres, 37 GroupeChip 38 } 39 }) 40 export default class Inscrits extends BaseInscrits { 41 showExportDialog = false; 42 showGroupesDialog = false; 43 showEditDialog = false; 44 showListeFicheSanitaire = false; 45 showContraintesDialog = false; 46 47 messages: ResumeMessage[] = []; 48 showMessagesDialog = false; 49 50 infosParticulieres: DossierMessages[] = []; 51 showInfosParticulieresDialog = false; 52 53 get camp() { 54 return C.camp; 55 } 56 57 editedInscrit: Inscrit | null = null; 58 59 showAttente = false; 60 filterBus: Bus = Bus.BAucun; 61 62 header = [ 63 { 64 text: "", 65 value: "has_info", 66 sortable: false, 67 width: "30px" 68 }, 69 { 70 text: "Réglement", 71 value: "paiement_complet", 72 sortable: false, 73 align: "center" 74 }, 75 { text: "Nom", value: "nom", align: "center", sortable: true }, 76 { 77 text: "Prénom", 78 value: "prenom", 79 align: "center", 80 sortable: true 81 }, 82 { 83 text: "Sexe", 84 value: "sexe", 85 sortable: true 86 }, 87 { 88 text: "Age", 89 value: "age_debut_camp", 90 sortable: true, 91 align: "center", 92 width: "10%" 93 }, 94 { 95 text: "Date de naissance", 96 value: "date_naissance", 97 sortable: true, 98 align: "center", 99 width: "120px", 100 sort: (a: Date_, b: Date_) => 101 new Date(a).valueOf() - new Date(b).valueOf() 102 }, 103 { 104 text: "Groupe", 105 value: "id_groupe", 106 sortable: true, 107 align: "center", 108 sort: (a: OptionnalId, b: OptionnalId) => a.Int64 - b.Int64 109 }, 110 { 111 text: "Bus", 112 value: "options.bus", 113 sortable: true, 114 align: "center", 115 sort: (a: Bus, b: Bus) => a.localeCompare(b) 116 } 117 ]; 118 119 busItems = EditFields.bus; 120 121 get groupes() { 122 return C.groupes; 123 } 124 125 get items() { 126 return C.inscrits.filter( 127 item => 128 (!item.responsable.valide || item.responsable.inscription_valide) && 129 (this.showAttente ? true : !item.is_attente) && 130 (this.filterBus == "" 131 ? true 132 : matchesBus(this.filterBus, item.options.bus)) 133 ); 134 } 135 136 get attributions(): Attribution[] { 137 return C.inscrits.map(r => ({ 138 dateNaissance: r.date_naissance, 139 idGroupe: r.id_groupe, 140 isAttente: r.is_attente, 141 isValidated: !r.responsable.valide || r.responsable.inscription_valide 142 })); 143 } 144 145 created() { 146 this.refresh(true); 147 } 148 149 async refresh(notifie: boolean) { 150 await C.getGroupes(false); 151 const ok = await C.getInscrits(); 152 if (!ok) return; 153 if (notifie) { 154 C.notifications.success = "Liste des inscrits chargée."; 155 } 156 } 157 158 showMessages(item: Inscrit) { 159 this.messages = item.responsable.messages || []; 160 this.showMessagesDialog = true; 161 } 162 163 showInfosParticulieres() { 164 this.infosParticulieres = C.infosParticulieres(); 165 this.showInfosParticulieresDialog = true; 166 } 167 168 getGroupe(item: Inscrit): Groupe | null { 169 // sur une suppression, le dictionnaire des groupes 170 // peut être temporairement incomplet 171 if (item.id_groupe.Valid) { 172 return C.groupes[item.id_groupe.Int64] || null; 173 } 174 return null; 175 } 176 177 colorPaiement(item: Inscrit) { 178 switch (item.responsable.paiement_complet) { 179 case 1: 180 return "red"; 181 case 2: 182 return "orange"; 183 case 3: 184 return "green"; 185 default: 186 return ""; 187 } 188 } 189 tooltipPaiement(item: Inscrit) { 190 switch (item.responsable.paiement_complet) { 191 case 1: 192 return "Aucun paiement reçu. Méfiance !"; 193 case 2: 194 return "Paiement en cours"; 195 case 3: 196 return "Paiement complet"; 197 default: 198 return "Aucune information n'est disponible"; 199 } 200 } 201 202 renderResponsableHtml(respo: Responsable) { 203 if (!respo.valide) return "<h3>Sans responsable</h3>"; 204 return `${respo.prenom} ${respo.nom} <i>${respo.mail}</i> <br/> 205 Tels: ${respo.tels} <br/> 206 Adresse: ${respo.adresse} ${respo.code_postal} ${respo.ville}`; 207 } 208 209 async downloadListe( 210 mode: "inscrits" | "finances", 211 options: OptionsExportInscrit 212 ) { 213 this.showExportDialog = false; 214 const name = await C.export(mode, options); 215 if (name !== undefined) { 216 C.notifications.success = "Liste téléchargée avec succès."; 217 } 218 } 219 220 async saveRemoteChange(item: Inscrit) { 221 this.showEditDialog = false; 222 const ok = await C.updateInscrit({ id: item.id, modifications: item }); 223 if (ok) { 224 C.notifications.success = "Le participant a bien été mis à jour."; 225 } 226 } 227 }