diff --git a/frontend/app/components/CommentSection.vue b/frontend/app/components/CommentSection.vue index 7c483a4..17e81c2 100644 --- a/frontend/app/components/CommentSection.vue +++ b/frontend/app/components/CommentSection.vue @@ -255,7 +255,16 @@ const handleResolve = async (commentId: string) => { } } +const { confirm } = useConfirm() + const handleDelete = async (commentId: string) => { + const ok = await confirm({ + title: 'Supprimer ce commentaire ?', + message: 'Cette action est irréversible.', + confirmText: 'Supprimer', + dangerous: true, + }) + if (!ok) return const result = await deleteComment(commentId) if (result.success) { comments.value = comments.value.filter(c => c.id !== commentId) diff --git a/frontend/app/pages/machine/[id].vue b/frontend/app/pages/machine/[id].vue index b92c4d5..306c98e 100644 --- a/frontend/app/pages/machine/[id].vue +++ b/frontend/app/pages/machine/[id].vue @@ -90,7 +90,7 @@ @files-added="d.handleMachineFilesAdded" @preview="d.openPreview" @download="d.downloadDocument" - @remove="d.removeMachineDocument" + @remove="confirmRemoveDocument" /> @@ -99,7 +99,7 @@ :products="d.machineDirectProducts.value" :is-edit-mode="d.isEditMode.value" @add-product="openAddModal('product')" - @remove-product="async (id) => { await d.removeProductLink(id); refreshVersions() }" + @remove-product="confirmRemoveProduct" @fill-entity="(linkId, typeId) => handleFillEntity(linkId, 'product', typeId)" /> @@ -115,7 +115,7 @@ @edit-piece="d.updatePieceFromComponent" @custom-field-update="d.handleCustomFieldUpdate" @add-component="openAddModal('component')" - @remove-component="async (id) => { await d.removeComponentLink(id); refreshVersions() }" + @remove-component="confirmRemoveComponent" @fill-entity="(linkId, typeId) => handleFillEntity(linkId, 'component', typeId)" /> @@ -130,7 +130,7 @@ @edit-piece="d.editPiece" @custom-field-update="d.handleCustomFieldUpdate" @add-piece="openAddModal('piece')" - @remove-piece="async (id) => { await d.removePieceLink(id); refreshVersions() }" + @remove-piece="confirmRemovePiece" @fill-entity="(linkId, typeId) => handleFillEntity(linkId, 'piece', typeId)" @toggle-collapse="d.toggleAllPieces" /> @@ -254,6 +254,7 @@ const d = useMachineDetailData(machineId) const machineInfoCardRef = ref(null) const versionRefreshKey = ref(0) const refreshVersions = () => { versionRefreshKey.value++ } +const { confirm: confirmDialog } = useConfirm() const { history, @@ -340,6 +341,29 @@ const submitMachineEdition = async () => { refreshVersions() } +const confirmRemoveProduct = async (id) => { + if (!await confirmDialog({ title: 'Retirer ce produit ?', message: 'Le produit sera dissocié de la machine.', confirmText: 'Retirer', dangerous: true })) return + await d.removeProductLink(id) + refreshVersions() +} + +const confirmRemoveComponent = async (id) => { + if (!await confirmDialog({ title: 'Retirer ce composant ?', message: 'Le composant sera dissocié de la machine.', confirmText: 'Retirer', dangerous: true })) return + await d.removeComponentLink(id) + refreshVersions() +} + +const confirmRemovePiece = async (id) => { + if (!await confirmDialog({ title: 'Retirer cette pièce ?', message: 'La pièce sera dissociée de la machine.', confirmText: 'Retirer', dangerous: true })) return + await d.removePieceLink(id) + refreshVersions() +} + +const confirmRemoveDocument = async (id) => { + if (!await confirmDialog({ title: 'Supprimer ce document ?', message: 'Le fichier sera supprimé définitivement.', confirmText: 'Supprimer', dangerous: true })) return + d.removeMachineDocument(id) +} + onMounted(() => { d.loadMachineData() d.loadInitialData()