feat(ui) : add confirmation dialogs on all delete and unlink actions

This commit is contained in:
2026-04-04 16:41:35 +02:00
parent 239f417a35
commit a610284325
2 changed files with 37 additions and 4 deletions

View File

@@ -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)

View File

@@ -90,7 +90,7 @@
@files-added="d.handleMachineFilesAdded"
@preview="d.openPreview"
@download="d.downloadDocument"
@remove="d.removeMachineDocument"
@remove="confirmRemoveDocument"
/>
<!-- Produits associés -->
@@ -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()