diff --git a/app/components/ComposantSelect.vue b/app/components/ComposantSelect.vue index 480de19..0ae7947 100644 --- a/app/components/ComposantSelect.vue +++ b/app/components/ComposantSelect.vue @@ -8,7 +8,7 @@ :empty-text="emptyText" size="sm" option-value="id" - option-label="name" + :option-label="formatLabel" :disabled="disabled" server-search @update:modelValue="updateValue" @@ -104,6 +104,12 @@ const updateValue = (value: string | number | null | undefined) => { emit('update:modelValue', String(value)) } +const formatLabel = (option: any) => { + if (!option) return '' + const name = option.name || 'Composant' + return option.reference ? `${name} — ${option.reference}` : name +} + const formatDescription = (option: any) => { const parts: string[] = [] const typeName = option?.typeComposant?.name diff --git a/app/components/PieceSelect.vue b/app/components/PieceSelect.vue index 2227945..ba19d56 100644 --- a/app/components/PieceSelect.vue +++ b/app/components/PieceSelect.vue @@ -8,7 +8,7 @@ :empty-text="emptyText" size="sm" option-value="id" - option-label="name" + :option-label="formatLabel" :disabled="disabled" server-search @update:modelValue="updateValue" @@ -104,6 +104,12 @@ const updateValue = (value: string | number | null | undefined) => { emit('update:modelValue', String(value)) } +const formatLabel = (option: any) => { + if (!option) return '' + const name = option.name || 'Pièce' + return option.reference ? `${name} — ${option.reference}` : name +} + const formatDescription = (option: any) => { const parts: string[] = [] const typeName = option?.typePiece?.name diff --git a/app/components/ProductSelect.vue b/app/components/ProductSelect.vue index 3b3261e..0e2496b 100644 --- a/app/components/ProductSelect.vue +++ b/app/components/ProductSelect.vue @@ -8,7 +8,7 @@ :empty-text="emptyText" size="sm" option-value="id" - option-label="name" + :option-label="formatLabel" :disabled="disabled" server-search @update:modelValue="updateValue" @@ -104,6 +104,12 @@ const updateValue = (value: string | number | null | undefined) => { emit('update:modelValue', String(value)) } +const formatLabel = (option: any) => { + if (!option) return '' + const name = option.name || 'Produit' + return option.reference ? `${name} — ${option.reference}` : name +} + const formatDescription = (option: any) => { const parts: string[] = [] const typeName = option?.typeProduct?.name diff --git a/app/components/machine/AddEntityToMachineModal.vue b/app/components/machine/AddEntityToMachineModal.vue index 3cf8529..f6459ed 100644 --- a/app/components/machine/AddEntityToMachineModal.vue +++ b/app/components/machine/AddEntityToMachineModal.vue @@ -147,7 +147,10 @@ const selectedTypeName = computed(() => { return found?.name || '' }) -const entityOptionLabel = (e: any) => e.name || '(sans nom)' +const entityOptionLabel = (e: any) => { + const name = e.name || '(sans nom)' + return e.reference ? `${name} — ${e.reference}` : name +} const entityOptionDescription = (e: any) => e.reference || '' const selectedEntitySummary = computed(() => { diff --git a/app/shared/utils/structureAssignmentLabels.ts b/app/shared/utils/structureAssignmentLabels.ts index 35c2caf..499e4ac 100644 --- a/app/shared/utils/structureAssignmentLabels.ts +++ b/app/shared/utils/structureAssignmentLabels.ts @@ -85,7 +85,8 @@ export const componentOptionLabel = (component?: ComponentOption | null): string if (!component) { return 'Composant sans nom' } - return component.name || 'Composant sans nom' + const name = component.name || 'Composant sans nom' + return component.reference ? `${name} — ${component.reference}` : name } export const componentOptionDescription = (component?: ComponentOption | null): string => { @@ -110,9 +111,10 @@ export const componentOptionDescription = (component?: ComponentOption | null): export const pieceOptionLabel = (piece?: PieceOption | null): string => { if (!piece) { - return 'Pi\u00e8ce' + return 'Pièce' } - return piece.name || 'Pi\u00e8ce' + const name = piece.name || 'Pièce' + return piece.reference ? `${name} — ${piece.reference}` : name } export const pieceOptionDescription = (piece?: PieceOption | null): string => { @@ -139,7 +141,8 @@ export const productOptionLabel = (product?: ProductOption | null): string => { if (!product) { return 'Produit' } - return product.name || product.reference || 'Produit' + const name = product.name || 'Produit' + return product.reference ? `${name} — ${product.reference}` : name } export const productOptionDescription = (product?: ProductOption | null): string => {