Skip to content

Commit 67362ff

Browse files
Merge remote-tracking branch 'upstream/master' into GH-5074-4
2 parents 1508a1b + 8bced18 commit 67362ff

24 files changed

+512
-474
lines changed
Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
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"
@@ -18,9 +22,25 @@
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"
3252
import BaseSelect from "../basecomponents/BaseSelect.vue"
3353
import { useCidReq } from "../../composables/cidReq"
3454
import { useNotification } from "../../composables/notification"
35-
import glossaryService from "../../services/glossaryService"
3655
3756
const { t } = useI18n()
3857
const { sid, cid } = useCidReq()
@@ -47,28 +66,7 @@ const formats = [
4766
]
4867
const 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>

assets/vue/services/glossaryService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default {
4444
*/
4545
export: async (formData) => {
4646
const endpoint = `${ENTRYPOINT}glossaries/export`
47-
const response = await axios.post(endpoint, formData, { responsetype: "blob " })
47+
const response = await axios.post(endpoint, formData, { responsetype: "blob" })
4848

4949
return response.data
5050
},

0 commit comments

Comments
 (0)