source: main/trunk/model-interfaces-dev/atea/macron-restoration/src/components/FileInput.vue@ 35781

Last change on this file since 35781 was 35781, checked in by cstephen, 2 years ago

Update Office icons

File size: 2.4 KB
Line 
1<template>
2<file-upload />
3
4<div class="file-info-list">
5 <div v-for="(fileInfo, index) in fileInfos" :key="fileInfo.id">
6 <div class="info-container">
7 <img class="icon-l" src="../assets/word_icon.webp" v-if="fileInfo.fileType === '.docx'" />
8 <img class="icon-l" src="../assets/powerpoint_icon.webp" v-else-if="fileInfo.fileType === '.pptx'" />
9 <img class="icon-l" src="../assets/excel_icon.webp" v-else-if="fileInfo.fileType === '.xlsx'" />
10 <span class="material-icons mdi-override" v-else>description</span>
11
12 {{ fileInfo.fileName }}
13
14 <button @click="download(fileInfo)" type="button" class="btn-primary theme-flat">
15 <span class="material-icons">download</span>
16 <span>{{ translations.get("FileInput_Download") }}</span>
17 </button>
18 </div>
19
20 <hr class="divider-s" v-if="index !== fileInfos.length - 1" />
21 </div>
22</div>
23
24<form ref="formDownload" method="post" target="_blank">
25 <input ref="inputFilePath" type="hidden" name="filepath" />
26 <input ref="inputFileName" type="hidden" name="filename" />
27</form>
28
29</template>
30
31<style scoped lang="scss">
32.info-container {
33 display: grid;
34 grid-template-columns: auto 1fr auto;
35 align-items: center;
36
37 gap: 0.5em;
38 padding: 0.5em;
39 transition-duration: var(--transition-duration);
40
41 &:hover {
42 background-color: #DDD;
43 }
44}
45
46.file-info-list {
47 border: 1px solid #BBB;
48 margin-top: 1em;
49}
50
51.mdi-override {
52 @extend .mdi-l;
53
54 color: var(--bg-color);
55}
56
57.icon-l {
58 height: 36px;
59}
60</style>
61
62<script>
63import { mapState } from "vuex";
64import MacronRestorationService from "../js/MacronRestorationModule"
65import FileUpload from "./FileUpload.vue"
66
67const macronRestorer = new MacronRestorationService();
68
69export default {
70 name: "FileInput",
71 components: {
72 FileUpload
73 },
74 computed: {
75 ...mapState({
76 translations: state => state.translations,
77 fileInfos: state => state.macronisedFileInfos
78 })
79 },
80 methods: {
81 download(fileInfo) {
82 this.$refs.inputFilePath.value = fileInfo.filePath;
83 this.$refs.inputFileName.value = fileInfo.fileName;
84 this.$refs.formDownload.submit();
85 }
86 },
87 mounted() {
88 this.$refs.formDownload.setAttribute("action", macronRestorer.rootQueryUrl + "download");
89 }
90}
91</script>
Note: See TracBrowser for help on using the repository browser.