feat(machine) : single save button + link versioning display

- Replace auto-save-on-blur with single "Enregistrer" button
- Add Cancel button that resets local state
- Expose saveFieldDefinitions via defineExpose on MachineInfoCard
- Remove standalone save button from MachineCustomFieldDefEditor
- Add saveAllMachineCustomFields batch method
- Add submitEdition/cancelEdition/saving/canSubmit to orchestrator
- Show diff summary badges in version list entries
- Show link changes in restore modal description

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-26 16:51:34 +01:00
parent 767c9a7424
commit a7415964a7
8 changed files with 166 additions and 33 deletions

View File

@@ -54,6 +54,7 @@
<!-- Machine Info Card -->
<MachineInfoCard
ref="machineInfoCardRef"
:is-edit-mode="d.isEditMode.value"
:machine-name="d.machineName.value"
:machine-reference="d.machineReference.value"
@@ -71,9 +72,7 @@
@update:machine-reference="d.machineReference.value = $event"
@update:machine-site-id="d.machineSiteId.value = $event"
@update:constructeur-ids="d.handleMachineConstructeurChange"
@blur-field="() => { d.updateMachineInfo(); refreshVersions() }"
@set-custom-field-value="d.setMachineCustomFieldValue"
@update-custom-field="d.updateMachineCustomField"
@custom-fields-saved="() => { d.loadMachineData(); refreshVersions() }"
/>
@@ -97,7 +96,7 @@
:products="d.machineDirectProducts.value"
:is-edit-mode="d.isEditMode.value"
@add-product="openAddModal('product')"
@remove-product="d.removeProductLink"
@remove-product="async (id) => { await d.removeProductLink(id); refreshVersions() }"
/>
<!-- Components Section -->
@@ -112,7 +111,7 @@
@edit-piece="d.updatePieceFromComponent"
@custom-field-update="d.updatePieceCustomField"
@add-component="openAddModal('component')"
@remove-component="d.removeComponentLink"
@remove-component="async (id) => { await d.removeComponentLink(id); refreshVersions() }"
/>
<!-- Machine Pieces Section -->
@@ -126,7 +125,7 @@
@edit-piece="d.editPiece"
@custom-field-update="d.updatePieceCustomField"
@add-piece="openAddModal('piece')"
@remove-piece="d.removePieceLink"
@remove-piece="async (id) => { await d.removePieceLink(id); refreshVersions() }"
@toggle-collapse="d.toggleAllPieces"
/>
@@ -138,6 +137,27 @@
@confirm="handleAddEntity"
/>
<!-- Save / Cancel buttons -->
<div v-if="d.isEditMode.value" class="flex flex-col gap-3 md:flex-row md:justify-end">
<button
type="button"
class="btn btn-ghost"
:class="{ 'btn-disabled': d.saving.value }"
@click="d.cancelEdition()"
>
Annuler
</button>
<button
type="button"
class="btn btn-primary"
:disabled="!d.canSubmit.value"
@click="submitMachineEdition"
>
<span v-if="d.saving.value" class="loading loading-spinner loading-sm mr-2" />
Enregistrer les modifications
</button>
</div>
<!-- Historique -->
<EntityHistorySection
:entries="history"
@@ -224,6 +244,7 @@ if (!machineId) {
}
const d = useMachineDetailData(machineId)
const machineInfoCardRef = ref(null)
const versionRefreshKey = ref(0)
const refreshVersions = () => { versionRefreshKey.value++ }
@@ -240,6 +261,15 @@ const historyFieldLabels = {
prix: 'Prix',
site: 'Site',
constructeurIds: 'Fournisseurs',
addedComponent: 'Composant ajouté',
removedComponent: 'Composant supprimé',
addedPiece: 'Pièce ajoutée',
removedPiece: 'Pièce supprimée',
addedProduct: 'Produit ajouté',
removedProduct: 'Produit supprimé',
componentLinks: 'Composants liés',
pieceLinks: 'Pièces liées',
productLinks: 'Produits liés',
}
const addModalOpen = ref(false)
@@ -258,12 +288,21 @@ const handleAddEntity = async (entityId) => {
} else {
await d.addProductLink(entityId)
}
refreshVersions()
}
const machineViewTitle = computed(() => {
return d.isEditMode.value ? 'Modification de la machine' : 'Détails de la machine'
})
const submitMachineEdition = async () => {
if (machineInfoCardRef.value?.saveFieldDefinitions) {
await machineInfoCardRef.value.saveFieldDefinitions()
}
await d.submitEdition()
refreshVersions()
}
onMounted(() => {
d.loadMachineData()
d.loadInitialData()