From a3fde7a1915d6e019b9aa69fe2608d850f15892b Mon Sep 17 00:00:00 2001 From: matthieu Date: Sun, 8 Mar 2026 14:37:43 +0100 Subject: [PATCH] refactor(frontend) : extract CustomFieldDisplay shared component Co-Authored-By: Claude Opus 4.6 --- app/components/ComponentItem.vue | 88 +--------- app/components/PieceItem.vue | 157 ++--------------- app/components/common/CustomFieldDisplay.vue | 173 +++++++++++++++++++ 3 files changed, 189 insertions(+), 229 deletions(-) create mode 100644 app/components/common/CustomFieldDisplay.vue diff --git a/app/components/ComponentItem.vue b/app/components/ComponentItem.vue index e394962..cb3a06b 100644 --- a/app/components/ComponentItem.vue +++ b/app/components/ComponentItem.vue @@ -213,79 +213,12 @@ -
-

- Champs personnalisés -

-
-
- - - -
-
-
+
@@ -381,15 +314,6 @@ import { documentIcon, downloadDocument, } from '~/shared/utils/documentDisplayUtils' -import { - resolveFieldKey, - resolveFieldName, - resolveFieldType, - resolveFieldOptions, - resolveFieldRequired, - resolveFieldReadOnly, - formatFieldDisplayValue, -} from '~/shared/utils/entityCustomFieldLogic' import { useEntityDocuments } from '~/composables/useEntityDocuments' import { useEntityProductDisplay } from '~/composables/useEntityProductDisplay' import { useEntityCustomFields } from '~/composables/useEntityCustomFields' diff --git a/app/components/PieceItem.vue b/app/components/PieceItem.vue index 6586452..acc5260 100644 --- a/app/components/PieceItem.vue +++ b/app/components/PieceItem.vue @@ -234,143 +234,12 @@
-
-
- Champs personnalisés -
-
-
- - - - - - - -
-
-
+
@@ -434,14 +303,8 @@ import { downloadDocument, } from '~/shared/utils/documentDisplayUtils' import { - resolveFieldKey, resolveFieldId, - resolveFieldName, - resolveFieldType, - resolveFieldOptions, - resolveFieldRequired, resolveFieldReadOnly, - formatFieldDisplayValue, } from '~/shared/utils/entityCustomFieldLogic' import { useEntityDocuments } from '~/composables/useEntityDocuments' import { useEntityProductDisplay } from '~/composables/useEntityProductDisplay' @@ -595,16 +458,16 @@ const handleProductChange = async (value) => { updatePiece() } -// --- Custom field local helpers --- -const setCustomFieldValue = (fieldValueId, value, field) => { +// --- Custom field event handlers --- +const handleCustomFieldInput = (field, value) => { if (resolveFieldReadOnly(field)) return - if (field && typeof field === 'object') field.value = value + const fieldValueId = resolveFieldId(field) if (!fieldValueId) return const fieldValue = props.piece.customFieldValues?.find((fv) => fv.id === fieldValueId) if (fieldValue) fieldValue.value = value } -const updateCustomFieldValue = async (_fieldValueId, field) => { +const handleCustomFieldBlur = async (field) => { await updateCustomField(field) const cfId = field?.customFieldId || field?.customField?.id || null if (cfId || field?.customFieldValueId) { diff --git a/app/components/common/CustomFieldDisplay.vue b/app/components/common/CustomFieldDisplay.vue new file mode 100644 index 0000000..5e70315 --- /dev/null +++ b/app/components/common/CustomFieldDisplay.vue @@ -0,0 +1,173 @@ +