diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/module/button_download/index.ts b/src/Bundle/ChillDocStoreBundle/Resources/public/module/button_download/index.ts new file mode 100644 index 000000000..9ffe696c7 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/module/button_download/index.ts @@ -0,0 +1,27 @@ +import {_createI18n} from "../../../../../ChillMainBundle/Resources/public/vuejs/_js/i18n"; +import {createApp} from "vue"; +import DocumentActionButtonsGroup from "../../vuejs/DocumentActionButtonsGroup.vue"; +import {StoredObject, StoredObjectStatusChange} from "../../types"; +import {defineComponent} from "vue"; +import DownloadButton from "../../vuejs/StoredObjectButton/DownloadButton.vue"; +import ToastPlugin from "vue-toast-notification"; + + + +const i18n = _createI18n({}); + +window.addEventListener('DOMContentLoaded', function (e) { + document.querySelectorAll('div[data-download-button-single]').forEach((el) => { + const storedObject = JSON.parse(el.dataset.storedObject as string) as StoredObject; + const title = el.dataset.title as string; + const app = createApp({ + components: {DownloadButton}, + data() { + return {storedObject, title, classes: {btn: true, "btn-outline-primary": true}}; + }, + template: '', + }); + + app.use(i18n).use(ToastPlugin).mount(el); + }); +}); diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/types.ts b/src/Bundle/ChillDocStoreBundle/Resources/public/types.ts index f93e9c5b7..2a998fb63 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/types.ts +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/types.ts @@ -2,6 +2,7 @@ import { DateTime, User, } from "../../../ChillMainBundle/Resources/public/types"; +import {SignedUrlGet} from "./vuejs/StoredObjectButton/helpers"; export type StoredObjectStatus = "empty" | "ready" | "failure" | "pending"; @@ -30,6 +31,7 @@ export interface StoredObject { href: string; expiration: number; }; + downloadLink?: SignedUrlGet; }; } diff --git a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue index d1efabcee..ecf9055af 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue +++ b/src/Bundle/ChillDocStoreBundle/Resources/public/vuejs/StoredObjectButton/DownloadButton.vue @@ -1,5 +1,5 @@