github.com/benoitkugler/goacve@v0.0.0-20201217100549-151ce6e55dc8/server/frontend/bv/src/pages/espace_perso/components/general/messages/BaseAttestation.vue (about) 1 <template> 2 <div> 3 <span v-if="contenu.distribution == Distribution.DEspacePerso" 4 >{{ label }} téléchargée depuis cet espace.</span 5 > 6 <div v-else-if="contenu.distribution == Distribution.DMail"> 7 <b-row> 8 <b-col cols="auto"> {{ label }} disponible. </b-col> 9 <b-col class="align-self-center" style="max-width: 120px;"> 10 <b-badge class="d-block" :href="urlDownload" @click="afterDownload" 11 >Télécharger</b-badge 12 > 13 </b-col> 14 </b-row> 15 </div> 16 <span v-else-if="contenu.distribution == Distribution.DMailAndDownload"> 17 {{ label }} 18 <span class="text-muted" 19 >téléchargée depuis cet espace le {{ time(message.modified) }}</span 20 > 21 </span> 22 </div> 23 </template> 24 25 <script lang="ts"> 26 import Vue from "vue"; 27 import Component from "vue-class-component"; 28 import { 29 PseudoMessage, 30 MessageKind, 31 ContenuAttestation, 32 Distribution 33 } from "@/shared/logic/types"; 34 import { C } from "../../../logic/controller"; 35 import { formatDateTime } from "@/shared/logic/utils"; 36 37 export type Mode = "facture" | "presence"; 38 39 const BaseAttestationProps = Vue.extend({ 40 props: { 41 contenu: Object as () => ContenuAttestation, 42 message: Object as () => PseudoMessage, 43 mode: String as () => Mode 44 } 45 }); 46 47 @Component({}) 48 export default class BaseAttestation extends BaseAttestationProps { 49 Distribution = Distribution; 50 time = formatDateTime; 51 52 get label() { 53 if (this.mode == "facture") return "Facture acquittée"; 54 if (this.mode == "presence") return "Attestation de présence"; 55 return ""; 56 } 57 58 get urlDownload() { 59 if (this.mode == "facture") return C.data.urlFacture; 60 if (this.mode == "presence") return C.data.urlAttestationPresence; 61 return ""; 62 } 63 afterDownload() { 64 // le téléchargement d'une facture modifie les messages 65 window.setTimeout(() => C.data.loadData(), 1000); 66 } 67 } 68 </script> 69 70 <style scoped></style>