diff --git a/frontend/app/components/model-types/ModelTypeForm.vue b/frontend/app/components/model-types/ModelTypeForm.vue index 83c365c..25987ab 100644 --- a/frontend/app/components/model-types/ModelTypeForm.vue +++ b/frontend/app/components/model-types/ModelTypeForm.vue @@ -194,15 +194,16 @@ const form = reactive({ }) const formulaBuilderCustomFields = computed(() => { + let fields: any[] = [] if (form.category === 'PIECE') { - const fields = pieceStructure.value?.customFields - return Array.isArray(fields) ? fields : [] + const raw = pieceStructure.value?.customFields + fields = Array.isArray(raw) ? raw : [] } - if (form.category === 'COMPONENT') { - const fields = componentStructure.value?.customFields - return Array.isArray(fields) ? fields : [] + else if (form.category === 'COMPONENT') { + const raw = componentStructure.value?.customFields + fields = Array.isArray(raw) ? raw : [] } - return [] + return fields.filter((f: any) => !f.machineContextOnly) }) const extractFormulaFields = (formula: string | null | undefined): string[] => { diff --git a/frontend/app/composables/useComponentCreate.ts b/frontend/app/composables/useComponentCreate.ts index cfd3d92..499c2fe 100644 --- a/frontend/app/composables/useComponentCreate.ts +++ b/frontend/app/composables/useComponentCreate.ts @@ -151,6 +151,7 @@ export function useComponentCreate() { values: computed(() => []), entityType: 'composant', entityId: createdComponentId, + context: 'standalone', }) const structureHasRequirements = computed(() => diff --git a/frontend/app/composables/useComponentEdit.ts b/frontend/app/composables/useComponentEdit.ts index f24db16..104d4f8 100644 --- a/frontend/app/composables/useComponentEdit.ts +++ b/frontend/app/composables/useComponentEdit.ts @@ -209,6 +209,7 @@ export function useComponentEdit(componentId: string) { values: computed(() => component.value?.customFieldValues ?? []), entityType: 'composant', entityId: computed(() => component.value?.id ?? null), + context: 'standalone', onValueCreated: (newValue) => { if (component.value && Array.isArray(component.value.customFieldValues)) { component.value.customFieldValues.push(newValue) @@ -556,6 +557,7 @@ export function useComponentEdit(componentId: string) { originalConstructeurLinks, constructeurIdsFromForm, customFieldInputs, + requiredCustomFieldsFilled, historyFieldLabels, // Computed diff --git a/frontend/app/composables/usePieceEdit.ts b/frontend/app/composables/usePieceEdit.ts index b5ad95b..5b49d1c 100644 --- a/frontend/app/composables/usePieceEdit.ts +++ b/frontend/app/composables/usePieceEdit.ts @@ -99,6 +99,7 @@ export function usePieceEdit(pieceId: string) { values: computed(() => piece.value?.customFieldValues ?? []), entityType: 'piece', entityId: computed(() => piece.value?.id ?? null), + context: 'standalone', onValueCreated: (newValue) => { if (piece.value && Array.isArray(piece.value.customFieldValues)) { piece.value.customFieldValues.push(newValue) @@ -435,6 +436,7 @@ export function usePieceEdit(pieceId: string) { constructeurIdsFromForm, productSelections, customFieldInputs, + requiredCustomFieldsFilled, canEdit, // Computed diff --git a/frontend/app/pages/pieces/create.vue b/frontend/app/pages/pieces/create.vue index 9013a2d..c0780f8 100644 --- a/frontend/app/pages/pieces/create.vue +++ b/frontend/app/pages/pieces/create.vue @@ -218,6 +218,9 @@

+

+ Certains champs personnalisés sont obligatoires. Veuillez les renseigner avant de valider. +

+

+ Merci de renseigner tous les champs personnalisés obligatoires avant de créer la pièce. +

@@ -311,7 +317,9 @@ const { fields: customFieldInputs, requiredFilled: requiredCustomFieldsFilled, s values: [] as any[], entityType: 'piece' as CustomFieldEntityType, entityId: createdEntityId, + context: 'standalone', }) +const hasRequiredCustomFields = computed(() => customFieldInputs.value.some(f => f.required)) const selectedDocuments = ref([]) const uploadingDocuments = ref(false) diff --git a/frontend/app/pages/product/[id]/index.vue b/frontend/app/pages/product/[id]/index.vue index 2099ae1..1ba844c 100644 --- a/frontend/app/pages/product/[id]/index.vue +++ b/frontend/app/pages/product/[id]/index.vue @@ -274,6 +274,9 @@