github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/server/frontend/directeurs/src/components/equipiers/Formulaires.vue (about) 1 <template> 2 <v-card> 3 <v-toolbar> 4 <v-toolbar-title>Accès aux formulaires des équipiers</v-toolbar-title> 5 <v-spacer></v-spacer> 6 <v-toolbar-items> 7 <v-menu left> 8 <template v-slot:activator="{ on: menu }"> 9 <v-tooltip bottom> 10 <template v-slot:activator="{ on: tooltip }"> 11 <v-btn icon v-on="{ ...tooltip, ...menu }"> 12 <v-icon>{{ $icons["mdi-send"] }}</v-icon> 13 </v-btn> 14 </template> 15 Inviter plusieurs équipiers... 16 </v-tooltip> 17 </template> 18 <v-list> 19 <v-list-item 20 @click="inviteAll(true)" 21 :disabled="notInvited.length == 0" 22 > 23 Ne pas ré-inviter les équipiers déjà contactés 24 </v-list-item> 25 <v-list-item 26 @click="inviteAll(false)" 27 :disabled="notAnswered.length == 0" 28 > 29 Inviter les équipiers n'ayant pas répondu 30 </v-list-item> 31 </v-list> 32 </v-menu> 33 </v-toolbar-items> 34 </v-toolbar> 35 <v-data-table 36 :items="value" 37 :headers="headers" 38 hide-default-footer 39 dense 40 :items-per-page="9999" 41 fixed-header 42 height="75vh" 43 > 44 <template #item.nom_prenom="{item}"> 45 {{ fmt.nomPrenom(item) }} 46 </template> 47 <template #item.invitation_equipier="{item}"> 48 <span :style="{ color: renderInvitationColor(item) }"> 49 {{ renderInvitation(item) }} 50 </span> 51 </template> 52 <template #item.charte="{item}"> 53 <span :style="{ color: renderCharteColor(item) }"> 54 {{ renderCharte(item) }} 55 </span> 56 </template> 57 <template #item.invite="{item}"> 58 <tooltip-btn 59 :tooltip="`Envoyer un <b>mail d'invitation</b> à` + item.prenom" 60 v-if="isEmailValid(item.mail) === true" 61 icon 62 small 63 @click="invite(item)" 64 > 65 <v-icon>{{ $icons["mdi-email"] }}</v-icon> 66 </tooltip-btn> 67 <v-menu :close-on-content-click="false"> 68 <template v-slot:activator="{ on: menu }"> 69 <v-tooltip bottom> 70 <template v-slot:activator="{ on: tooltip }"> 71 <v-btn 72 width="30px" 73 height="30px" 74 v-on="{ ...menu, ...tooltip }" 75 icon 76 small 77 > 78 <v-icon>{{ $icons["mdi-link"] }}</v-icon> 79 </v-btn> 80 </template> 81 Afficher le lien vers le formulaire de {{ item.prenom }} 82 </v-tooltip> 83 </template> 84 <v-card max-width="400px"> 85 <v-card-title>Lien</v-card-title> 86 <v-card-text> 87 <a :href="item.lien_formulaire" target="_blank">{{ 88 item.lien_formulaire 89 }}</a> 90 </v-card-text> 91 </v-card> 92 </v-menu> 93 </template> 94 </v-data-table> 95 </v-card> 96 </template> 97 98 <script lang="ts"> 99 import Vue from "vue"; 100 import Component from "vue-class-component"; 101 import { EquipierDirecteur, OptionnalBool } from "../../logic/types"; 102 import { C } from "../../logic/controller"; 103 import { Formatter, isEmailValid } from "@/logic/formatter"; 104 import TooltipBtn from "@/components/TooltipBtn.vue"; 105 106 const FormulairesProps = Vue.extend({ 107 props: { 108 value: Array as () => EquipierDirecteur[] 109 } 110 }); 111 112 @Component({ 113 components: { TooltipBtn } 114 }) 115 export default class Formulaires extends FormulairesProps { 116 headers = [ 117 { text: "Equipier", value: "nom_prenom", sortable: false }, 118 { text: "Invitation", value: "invitation_equipier", align: "center" }, 119 { text: "Charte", value: "charte", align: "center" }, 120 { text: "", value: "invite", align: "center" } 121 ]; 122 123 fmt = Formatter; 124 isEmailValid = isEmailValid; 125 126 get notInvited() { 127 return this.value.filter(item => item.invitation_equipier == 0); 128 } 129 get notAnswered() { 130 return this.value.filter(item => item.invitation_equipier <= 1); 131 } 132 133 renderInvitation(item: EquipierDirecteur) { 134 switch (item.invitation_equipier) { 135 case 1: 136 return "En attente de réponse"; 137 case 2: 138 return "Formulaire rempli"; 139 default: 140 return "Non envoyée"; 141 } 142 } 143 renderInvitationColor(item: EquipierDirecteur) { 144 switch (item.invitation_equipier) { 145 case 1: 146 return "orange"; 147 case 2: 148 return "green"; 149 default: 150 return ""; 151 } 152 } 153 154 renderCharte(item: EquipierDirecteur) { 155 switch (item.charte as OptionnalBool) { 156 case OptionnalBool.OBOui: 157 return "Acceptée"; 158 case OptionnalBool.OBNon: 159 return "Refusée"; 160 default: 161 return "Non vue"; 162 } 163 } 164 renderCharteColor(item: EquipierDirecteur) { 165 switch (item.charte as OptionnalBool) { 166 case OptionnalBool.OBOui: 167 return "green"; 168 case OptionnalBool.OBNon: 169 return "red"; 170 default: 171 return ""; 172 } 173 } 174 175 async invite(item: EquipierDirecteur) { 176 const data = await C.inviteFormulaireEquipier("one", item.id); 177 if (data === undefined) return; 178 this.$emit("input", data.equipe); 179 C.notifications.success = "Un mail d'invitation a bien été envoyé."; 180 } 181 182 async inviteAll(onlyNew: boolean) { 183 const data = await C.inviteFormulaireEquipier(onlyNew ? "new" : "all", -1); 184 if (data === undefined) return; 185 this.$emit("input", data.equipe); 186 C.notifications.success = "Les invitations ont bien été envoyées."; 187 } 188 } 189 </script> 190 191 <style scoped></style>