11<template >
2- <form >
2+ <form
3+ action =" /api/glossaries/export"
4+ method =" post"
5+ @submit =" submitForm"
6+ >
37 <BaseSelect
48 id =" format"
59 v-model =" selectedFormat"
1822 :label =" t('Export')"
1923 icon =" file-export"
2024 type =" secondary"
21- @click = " submitForm "
25+ is-submit
2226 />
2327 </LayoutFormButtons >
28+ 29+ <input
30+ name =" cid"
31+ type =" hidden"
32+ :value =" cid"
33+ />
34+ <input
35+ name =" sid"
36+ type =" hidden"
37+ :value =" sid"
38+ />
39+ <input
40+ name =" format"
41+ type =" hidden"
42+ :value =" selectedFormat"
43+ />
2444 </form >
2545</template >
2646
@@ -32,7 +52,6 @@ import BaseButton from "../basecomponents/BaseButton.vue"
3252import BaseSelect from " ../basecomponents/BaseSelect.vue"
3353import { useCidReq } from " ../../composables/cidReq"
3454import { useNotification } from " ../../composables/notification"
35- import glossaryService from " ../../services/glossaryService"
3655
3756const { t } = useI18n ()
3857const { sid , cid } = useCidReq ()
@@ -47,28 +66,7 @@ const formats = [
4766]
4867const selectedFormat = ref (" csv" )
4968
50- const submitForm = async () => {
51- const format = selectedFormat .value
52-
53- const formData = new FormData ()
54- formData .append (" format" , format)
55- formData .append (" sid" , sid)
56- formData .append (" cid" , cid)
57-
58- try {
59- const data = await glossaryService .export (formData)
60- const fileUrl = window .URL .createObjectURL (new Blob ([data]))
61- const link = document .createElement (" a" )
62- link .href = fileUrl
63- link .setAttribute (" download" , ` glossary.${ format} ` )
64- document .body .appendChild (link)
65- link .click ()
66- document .body .removeChild (link)
67-
68- notification .showSuccessNotification (t (" Glossary exported" ))
69- } catch (error) {
70- console .error (" Error exporting glossary:" , error)
71- notification .showErrorNotification (t (" Could not export glossary" ))
72- }
69+ const submitForm = () => {
70+ notification .showSuccessNotification (t (" Glossary exported" ))
7371}
7472</script >
0 commit comments