feat(machine) : add entity history section to machine detail page
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,7 @@ export type EntityHistoryEntry = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ENTITY_ENDPOINTS: Record<string, string> = {
|
const ENTITY_ENDPOINTS: Record<string, string> = {
|
||||||
|
machine: '/machines',
|
||||||
composant: '/composants',
|
composant: '/composants',
|
||||||
piece: '/pieces',
|
piece: '/pieces',
|
||||||
product: '/products',
|
product: '/products',
|
||||||
@@ -35,7 +36,7 @@ const extractItems = (payload: any): EntityHistoryEntry[] => {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useEntityHistory(entityType: 'composant' | 'piece' | 'product') {
|
export function useEntityHistory(entityType: 'machine' | 'composant' | 'piece' | 'product') {
|
||||||
const { get } = useApi()
|
const { get } = useApi()
|
||||||
const basePath = ENTITY_ENDPOINTS[entityType]
|
const basePath = ENTITY_ENDPOINTS[entityType]
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,14 @@
|
|||||||
@confirm="handleAddEntity"
|
@confirm="handleAddEntity"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- Historique -->
|
||||||
|
<EntityHistorySection
|
||||||
|
:entries="history"
|
||||||
|
:loading="historyLoading"
|
||||||
|
:error="historyError"
|
||||||
|
:field-labels="historyFieldLabels"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- Comments -->
|
<!-- Comments -->
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<CommentSection
|
<CommentSection
|
||||||
@@ -181,6 +189,7 @@
|
|||||||
import { computed, ref, onMounted } from 'vue'
|
import { computed, ref, onMounted } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { useMachineDetailData } from '~/composables/useMachineDetailData'
|
import { useMachineDetailData } from '~/composables/useMachineDetailData'
|
||||||
|
import { useEntityHistory } from '~/composables/useEntityHistory'
|
||||||
import DocumentPreviewModal from '~/components/DocumentPreviewModal.vue'
|
import DocumentPreviewModal from '~/components/DocumentPreviewModal.vue'
|
||||||
import PageHero from '~/components/PageHero.vue'
|
import PageHero from '~/components/PageHero.vue'
|
||||||
import MachinePrintSelectionModal from '~/components/MachinePrintSelectionModal.vue'
|
import MachinePrintSelectionModal from '~/components/MachinePrintSelectionModal.vue'
|
||||||
@@ -191,6 +200,7 @@ import MachineProductsCard from '~/components/machine/MachineProductsCard.vue'
|
|||||||
import MachineComponentsCard from '~/components/machine/MachineComponentsCard.vue'
|
import MachineComponentsCard from '~/components/machine/MachineComponentsCard.vue'
|
||||||
import MachinePiecesCard from '~/components/machine/MachinePiecesCard.vue'
|
import MachinePiecesCard from '~/components/machine/MachinePiecesCard.vue'
|
||||||
import AddEntityToMachineModal from '~/components/machine/AddEntityToMachineModal.vue'
|
import AddEntityToMachineModal from '~/components/machine/AddEntityToMachineModal.vue'
|
||||||
|
import EntityHistorySection from '~/components/common/EntityHistorySection.vue'
|
||||||
import IconLucideAlertTriangle from '~icons/lucide/alert-triangle'
|
import IconLucideAlertTriangle from '~icons/lucide/alert-triangle'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@@ -203,6 +213,21 @@ if (!machineId) {
|
|||||||
|
|
||||||
const d = useMachineDetailData(machineId)
|
const d = useMachineDetailData(machineId)
|
||||||
|
|
||||||
|
const {
|
||||||
|
history,
|
||||||
|
loading: historyLoading,
|
||||||
|
error: historyError,
|
||||||
|
loadHistory,
|
||||||
|
} = useEntityHistory('machine')
|
||||||
|
|
||||||
|
const historyFieldLabels = {
|
||||||
|
name: 'Nom',
|
||||||
|
reference: 'Référence',
|
||||||
|
prix: 'Prix',
|
||||||
|
site: 'Site',
|
||||||
|
constructeurIds: 'Fournisseurs',
|
||||||
|
}
|
||||||
|
|
||||||
const addModalOpen = ref(false)
|
const addModalOpen = ref(false)
|
||||||
const addModalKind = ref('component')
|
const addModalKind = ref('component')
|
||||||
|
|
||||||
@@ -228,6 +253,7 @@ const machineViewTitle = computed(() => {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
d.loadMachineData()
|
d.loadMachineData()
|
||||||
d.loadInitialData()
|
d.loadInitialData()
|
||||||
|
loadHistory(String(machineId)).catch(() => {})
|
||||||
|
|
||||||
if (route.query.edit === 'true' && canEdit.value) {
|
if (route.query.edit === 'true' && canEdit.value) {
|
||||||
d.isEditMode.value = true
|
d.isEditMode.value = true
|
||||||
|
|||||||
Reference in New Issue
Block a user