Changeset 35787
- Timestamp:
- 2021-12-10T10:41:08+13:00 (2 years ago)
- Location:
- main/trunk/model-interfaces-dev/atea/macron-restoration/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-interfaces-dev/atea/macron-restoration/src/components/FileInput.vue
r35781 r35787 1 <script> 2 import { mapState } from "vuex"; 3 import MacronRestorationService from "../js/MacronRestorationModule" 4 import FileUpload from "./FileUpload.vue" 5 6 const macronRestorer = new MacronRestorationService(); 7 8 export default { 9 name: "FileInput", 10 components: { 11 FileUpload 12 }, 13 computed: { 14 ...mapState({ 15 translations: state => state.translations, 16 fileInfos: state => state.macronisedFileInfos 17 }) 18 }, 19 methods: { 20 buildDownloadUrl(fileInfo) { 21 return macronRestorer.buildDownloadUrl(fileInfo.filePath, fileInfo.fileName); 22 } 23 } 24 } 25 </script> 26 1 27 <template> 2 28 <file-upload /> … … 12 38 {{ fileInfo.fileName }} 13 39 14 < button @click="download(fileInfo)" type="button" class="btn-primary theme-flat">40 <a class="btn-primary theme-flat" :href="buildDownloadUrl(fileInfo)" download> 15 41 <span class="material-icons">download</span> 16 42 <span>{{ translations.get("FileInput_Download") }}</span> 17 </ button>43 </a> 18 44 </div> 19 45 … … 21 47 </div> 22 48 </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 49 29 50 </template> … … 59 80 } 60 81 </style> 61 62 <script>63 import { mapState } from "vuex";64 import MacronRestorationService from "../js/MacronRestorationModule"65 import FileUpload from "./FileUpload.vue"66 67 const macronRestorer = new MacronRestorationService();68 69 export default {70 name: "FileInput",71 components: {72 FileUpload73 },74 computed: {75 ...mapState({76 translations: state => state.translations,77 fileInfos: state => state.macronisedFileInfos78 })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> -
main/trunk/model-interfaces-dev/atea/macron-restoration/src/js/MacronRestorationModule.js
r35772 r35787 111 111 } 112 112 } 113 114 /** 115 * Builds a URL used to retrieve a file. 116 * @param {String} filePath The path of the file to download. 117 * @param {String} fileName The name to display in the download response. 118 */ 119 buildDownloadUrl(filePath, fileName) { 120 return `${this.rootQueryUrl}download?filepath=${filePath}&filename=${fileName}`; 121 } 113 122 }
Note:
See TracChangeset
for help on using the changeset viewer.