<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';

import VnDmsList from 'src/components/common/VnDmsList.vue';
import TicketDmsImportForm from 'src/pages/Ticket/Card/TicketDmsImportForm.vue';

const { t } = useI18n();

const dmsListRef = ref(null);
const showImportDialog = ref(false);

const onDataSaved = () => dmsListRef.value.dmsRef.fetch();
</script>
<template>
    <VnDmsList
        ref="dmsListRef"
        model="TicketDms"
        update-model="tickets"
        delete-model="TicketDms"
        download-model="dms"
        default-dms-code="ticket"
        filter="ticketFk"
        allow-import
    />
    <QDialog v-model="showImportDialog">
        <TicketDmsImportForm @on-data-saved="onDataSaved()" />
    </QDialog>
    <QPageSticky position="bottom-right" :offset="[25, 90]">
        <QBtn
            fab
            color="primary"
            icon="file_copy"
            @click="showImportDialog = true"
            class="fill-icon"
        >
            <QTooltip>
                {{ t('Import from existing') }}
            </QTooltip>
        </QBtn>
    </QPageSticky>
</template>

<i18n>
es:
    Import from existing: Importar desde existente
</i18n>
