From e297d1bb3964847309c258350bd32a5bba5325e0 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Mon, 13 Oct 2025 17:03:06 +0200 Subject: [PATCH] feat(frontend): add reusable search select and wire it into machine creation fix(frontend): guard custom field persistence against non-string values --- app/components/common/SearchSelect.vue | 335 +++++++++++++++++++++++++ app/pages/component-catalog.vue | 48 +++- app/pages/component/[id]/edit.vue | 19 +- app/pages/component/create.vue | 19 +- app/pages/machines/new.vue | 111 ++++---- app/pages/pieces-catalog.vue | 47 +++- app/pages/pieces/[id]/edit.vue | 19 +- app/pages/pieces/create.vue | 19 +- 8 files changed, 544 insertions(+), 73 deletions(-) create mode 100644 app/components/common/SearchSelect.vue diff --git a/app/components/common/SearchSelect.vue b/app/components/common/SearchSelect.vue new file mode 100644 index 0000000..31c7716 --- /dev/null +++ b/app/components/common/SearchSelect.vue @@ -0,0 +1,335 @@ + + + + + diff --git a/app/pages/component-catalog.vue b/app/pages/component-catalog.vue index 76b9b44..11f7b62 100644 --- a/app/pages/component-catalog.vue +++ b/app/pages/component-catalog.vue @@ -50,12 +50,22 @@ {{ component.typeComposant?.name || '—' }} {{ component.reference || '—' }} - - Modifier - +
+ + Modifier + + +
@@ -70,9 +80,33 @@ diff --git a/app/pages/machines/new.vue b/app/pages/machines/new.vue index 2613f7a..9b2dec3 100644 --- a/app/pages/machines/new.vue +++ b/app/pages/machines/new.vue @@ -53,14 +53,15 @@ - +
@@ -164,22 +165,17 @@ - +

Pièce existante - +

{ return machineTypes.value.find(type => type.id === newMachine.typeMachineId) || null }) +const machineTypeLabel = (type) => { + if (!type) { + return '' + } + return type.name || 'Type de machine' +} + +const machineTypeDescription = (type) => { + if (!type) { + return '' + } + const parts = [] + if (type.category) { + parts.push(`Catégorie : ${type.category}`) + } + const componentCount = type.componentRequirements?.length ?? 0 + const pieceCount = type.pieceRequirements?.length ?? 0 + parts.push(`${componentCount} composant(s)`, `${pieceCount} pièce(s)`) + return parts.join(' • ') +} + const componentById = computed(() => { const map = new Map() ;(composants.value || []).forEach((component) => { @@ -891,11 +904,13 @@ const getPieceOptions = (requirement, currentEntry) => { }) } -const formatComponentOption = (component) => { +const componentOptionLabel = (component) => component?.name || 'Composant' + +const componentOptionDescription = (component) => { if (!component) { return '' } - const parts = [component.name || 'Composant'] + const parts = [] if (component.reference) { parts.push(`Réf. ${component.reference}`) } @@ -910,11 +925,13 @@ const formatComponentOption = (component) => { return parts.join(' • ') } -const formatPieceOption = (piece) => { +const pieceOptionLabel = (piece) => piece?.name || 'Pièce' + +const pieceOptionDescription = (piece) => { if (!piece) { return '' } - const parts = [piece.name || 'Pièce'] + const parts = [] if (piece.reference) { parts.push(`Réf. ${piece.reference}`) } diff --git a/app/pages/pieces-catalog.vue b/app/pages/pieces-catalog.vue index 94988de..39edebb 100644 --- a/app/pages/pieces-catalog.vue +++ b/app/pages/pieces-catalog.vue @@ -49,12 +49,22 @@ {{ piece.typePiece?.name || '—' }} {{ piece.reference || '—' }} - - Modifier - +

+ + Modifier + + +
@@ -69,10 +79,33 @@