diff --git a/frontend/src/components/JsonViewer.vue b/frontend/src/components/JsonViewer.vue index 01f5aaf..615954c 100644 --- a/frontend/src/components/JsonViewer.vue +++ b/frontend/src/components/JsonViewer.vue @@ -116,6 +116,7 @@ :locataire="loc" :index="idx" :highlighted="highlightedLocataireIndex === idx" + :changed="changedLocataireSet.has(idx)" @update:locataire="updateLocataire(idx, $event)" @remove="removeLocataire(idx)" /> @@ -147,6 +148,7 @@ :categorie="group.categorie" :operations="group.operations" :highlightIndex="group.categorie === highlightOperationCategorie ? highlightOperationIndex : -1" + :changedIndices="changedOpByCategorie[group.categorie] || []" @update:operations="updateOperationsGroup(group.categorie, $event)" /> @@ -187,6 +189,10 @@ const props = defineProps({ highlight: { type: Object, default: null + }, + diff: { + type: Object, + default: null } }) @@ -213,6 +219,30 @@ const operationsGroupedByCategory = computed(() => { return groups }) +// Indices de locataires modifiés par la re-extraction (anneau « modifié »). +const changedLocataireSet = computed( + () => new Set(props.diff?.changedLocataireIndices || []) +) + +// Indices d'opérations modifiées, ramenés au repère (catégorie, index dans le groupe). +const changedOpByCategorie = computed(() => { + const result = {} + const operations = props.data?.data?.recapitulatif_operations + const changed = new Set(props.diff?.changedOperationIndices || []) + if (!operations || !changed.size) return result + const counters = {} + operations.forEach((op, absIdx) => { + const cat = op.categorie || 'AUTRES' + if (!(cat in counters)) counters[cat] = 0 + if (changed.has(absIdx)) { + if (!result[cat]) result[cat] = [] + result[cat].push(counters[cat]) + } + counters[cat]++ + }) + return result +}) + const copyLabel = ref('Copier') const expandedSections = reactive({ metadata: true, @@ -269,6 +299,17 @@ watch( { immediate: true } ) +// Déplier automatiquement les sections qui contiennent des différences. +watch( + () => props.diff, + (diff) => { + if (!diff) return + if (diff.summary?.metadata) expandedSections.metadata = true + if (diff.summary?.locataires) expandedSections.locataires = true + if (diff.summary?.operations) expandedSections.operations = true + } +) + function toggleSection(section) { expandedSections[section] = !expandedSections[section] } diff --git a/frontend/src/components/LocataireCard.vue b/frontend/src/components/LocataireCard.vue index 8759117..e6d923c 100644 --- a/frontend/src/components/LocataireCard.vue +++ b/frontend/src/components/LocataireCard.vue @@ -1,5 +1,5 @@