diff --git a/app/composables/useDocuments.ts b/app/composables/useDocuments.ts index 842a68a..5078c5a 100644 --- a/app/composables/useDocuments.ts +++ b/app/composables/useDocuments.ts @@ -49,6 +49,7 @@ interface LoadDocumentsOptions { orderBy?: string orderDir?: 'asc' | 'desc' attachmentFilter?: string + type?: string force?: boolean } @@ -105,10 +106,11 @@ export function useDocuments() { orderBy = 'createdAt', orderDir = 'desc', attachmentFilter = 'all', + type = 'all', force = false, } = options - if (!force && loaded.value && !search && page === 1 && attachmentFilter === 'all') { + if (!force && loaded.value && !search && page === 1 && attachmentFilter === 'all' && type === 'all') { return { success: true, data: documents.value } } @@ -130,6 +132,10 @@ export function useDocuments() { params.set(`exists[${attachmentFilter}]`, 'true') } + if (type && type !== 'all') { + params.set('type', type) + } + params.set(`order[${orderBy}]`, orderDir) const result = await get(`/documents?${params.toString()}`) diff --git a/app/pages/documents.vue b/app/pages/documents.vue index 7bfd658..031a336 100644 --- a/app/pages/documents.vue +++ b/app/pages/documents.vue @@ -7,6 +7,13 @@ @close="closePreview" /> + + Produits + + + + Type + + + Tous + + {{ t.label }} + + + @@ -77,6 +104,10 @@ {{ row.mimeType || 'Inconnu' }} + + {{ getDocumentTypeLabel(row.type || 'documentation') }} + + {{ formatSize(row.size) }} @@ -98,6 +129,14 @@ + + Modifier + +const typeFilter = table.filters.typeFilter as Ref const previewDocument = ref(null) const previewVisible = ref(false) +const editingDocument = ref(null) +const editModalVisible = ref(false) const documentsOnPage = computed(() => documents.value.length) const paginationState = table.pagination(total, documentsOnPage) const columns = [ { key: 'name', label: 'Nom', sortable: true, sortKey: 'name' }, - { key: 'mimeType', label: 'Type' }, + { key: 'mimeType', label: 'Type MIME' }, + { key: 'type', label: 'Type' }, { key: 'size', label: 'Taille', sortable: true, sortKey: 'size' }, { key: 'attachment', label: 'Rattaché à' }, { key: 'createdAt', label: 'Date', sortable: true, sortKey: 'createdAt' }, @@ -168,6 +215,7 @@ async function fetchDocuments() { orderBy: table.sortField.value, orderDir: table.sortDirection.value as 'asc' | 'desc', attachmentFilter: attachmentFilter.value, + type: typeFilter.value, force: true, }) } @@ -198,6 +246,25 @@ const closePreview = () => { previewDocument.value = null } +const openEditModal = (doc: any) => { + editingDocument.value = doc + editModalVisible.value = true +} + +const handleDocumentUpdated = async (data: { name: string; type: string }) => { + if (!editingDocument.value?.id) return + const result = await updateDocument(editingDocument.value.id, data) + if (result.success) { + const doc = documents.value.find((d) => d.id === editingDocument.value.id) + if (doc) { + doc.name = data.name + doc.type = data.type + } + } + editModalVisible.value = false + editingDocument.value = null +} + onMounted(() => { fetchDocuments() })