fix(custom-fields) : masquer les champs machineContextOnly hors vue machine
Ajoute context: 'standalone' aux appels useCustomFieldInputs dans les vues composant, pièce et produit (création et édition) pour filtrer les champs perso réservés au contexte machine. Exclut également ces champs de la formule de référence automatique dans le ReferenceFormulaBuilder des catégories. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -194,15 +194,16 @@ const form = reactive<ModelTypePayload & { referenceFormula?: string | null }>({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const formulaBuilderCustomFields = computed(() => {
|
const formulaBuilderCustomFields = computed(() => {
|
||||||
|
let fields: any[] = []
|
||||||
if (form.category === 'PIECE') {
|
if (form.category === 'PIECE') {
|
||||||
const fields = pieceStructure.value?.customFields
|
const raw = pieceStructure.value?.customFields
|
||||||
return Array.isArray(fields) ? fields : []
|
fields = Array.isArray(raw) ? raw : []
|
||||||
}
|
}
|
||||||
if (form.category === 'COMPONENT') {
|
else if (form.category === 'COMPONENT') {
|
||||||
const fields = componentStructure.value?.customFields
|
const raw = componentStructure.value?.customFields
|
||||||
return Array.isArray(fields) ? fields : []
|
fields = Array.isArray(raw) ? raw : []
|
||||||
}
|
}
|
||||||
return []
|
return fields.filter((f: any) => !f.machineContextOnly)
|
||||||
})
|
})
|
||||||
|
|
||||||
const extractFormulaFields = (formula: string | null | undefined): string[] => {
|
const extractFormulaFields = (formula: string | null | undefined): string[] => {
|
||||||
|
|||||||
@@ -151,6 +151,7 @@ export function useComponentCreate() {
|
|||||||
values: computed(() => []),
|
values: computed(() => []),
|
||||||
entityType: 'composant',
|
entityType: 'composant',
|
||||||
entityId: createdComponentId,
|
entityId: createdComponentId,
|
||||||
|
context: 'standalone',
|
||||||
})
|
})
|
||||||
|
|
||||||
const structureHasRequirements = computed(() =>
|
const structureHasRequirements = computed(() =>
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ export function useComponentEdit(componentId: string) {
|
|||||||
values: computed(() => component.value?.customFieldValues ?? []),
|
values: computed(() => component.value?.customFieldValues ?? []),
|
||||||
entityType: 'composant',
|
entityType: 'composant',
|
||||||
entityId: computed(() => component.value?.id ?? null),
|
entityId: computed(() => component.value?.id ?? null),
|
||||||
|
context: 'standalone',
|
||||||
onValueCreated: (newValue) => {
|
onValueCreated: (newValue) => {
|
||||||
if (component.value && Array.isArray(component.value.customFieldValues)) {
|
if (component.value && Array.isArray(component.value.customFieldValues)) {
|
||||||
component.value.customFieldValues.push(newValue)
|
component.value.customFieldValues.push(newValue)
|
||||||
@@ -556,6 +557,7 @@ export function useComponentEdit(componentId: string) {
|
|||||||
originalConstructeurLinks,
|
originalConstructeurLinks,
|
||||||
constructeurIdsFromForm,
|
constructeurIdsFromForm,
|
||||||
customFieldInputs,
|
customFieldInputs,
|
||||||
|
requiredCustomFieldsFilled,
|
||||||
historyFieldLabels,
|
historyFieldLabels,
|
||||||
|
|
||||||
// Computed
|
// Computed
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ export function usePieceEdit(pieceId: string) {
|
|||||||
values: computed(() => piece.value?.customFieldValues ?? []),
|
values: computed(() => piece.value?.customFieldValues ?? []),
|
||||||
entityType: 'piece',
|
entityType: 'piece',
|
||||||
entityId: computed(() => piece.value?.id ?? null),
|
entityId: computed(() => piece.value?.id ?? null),
|
||||||
|
context: 'standalone',
|
||||||
onValueCreated: (newValue) => {
|
onValueCreated: (newValue) => {
|
||||||
if (piece.value && Array.isArray(piece.value.customFieldValues)) {
|
if (piece.value && Array.isArray(piece.value.customFieldValues)) {
|
||||||
piece.value.customFieldValues.push(newValue)
|
piece.value.customFieldValues.push(newValue)
|
||||||
@@ -435,6 +436,7 @@ export function usePieceEdit(pieceId: string) {
|
|||||||
constructeurIdsFromForm,
|
constructeurIdsFromForm,
|
||||||
productSelections,
|
productSelections,
|
||||||
customFieldInputs,
|
customFieldInputs,
|
||||||
|
requiredCustomFieldsFilled,
|
||||||
canEdit,
|
canEdit,
|
||||||
|
|
||||||
// Computed
|
// Computed
|
||||||
|
|||||||
@@ -218,6 +218,9 @@
|
|||||||
</p>
|
</p>
|
||||||
</header>
|
</header>
|
||||||
<CustomFieldInputGrid :fields="customFieldInputs" :disabled="!canEdit || submitting" />
|
<CustomFieldInputGrid :fields="customFieldInputs" :disabled="!canEdit || submitting" />
|
||||||
|
<p v-if="hasRequiredCustomFields && !requiredCustomFieldsFilled" class="text-xs text-warning">
|
||||||
|
Certains champs personnalisés sont obligatoires. Veuillez les renseigner avant de valider.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<EmptyState
|
<EmptyState
|
||||||
v-else
|
v-else
|
||||||
@@ -237,6 +240,9 @@
|
|||||||
Créer la pièce
|
Créer la pièce
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<p v-if="selectedType && hasRequiredCustomFields && !requiredCustomFieldsFilled" class="text-xs text-error text-right">
|
||||||
|
Merci de renseigner tous les champs personnalisés obligatoires avant de créer la pièce.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
@@ -311,7 +317,9 @@ const { fields: customFieldInputs, requiredFilled: requiredCustomFieldsFilled, s
|
|||||||
values: [] as any[],
|
values: [] as any[],
|
||||||
entityType: 'piece' as CustomFieldEntityType,
|
entityType: 'piece' as CustomFieldEntityType,
|
||||||
entityId: createdEntityId,
|
entityId: createdEntityId,
|
||||||
|
context: 'standalone',
|
||||||
})
|
})
|
||||||
|
const hasRequiredCustomFields = computed(() => customFieldInputs.value.some(f => f.required))
|
||||||
const selectedDocuments = ref<File[]>([])
|
const selectedDocuments = ref<File[]>([])
|
||||||
const uploadingDocuments = ref(false)
|
const uploadingDocuments = ref(false)
|
||||||
|
|
||||||
|
|||||||
@@ -274,6 +274,9 @@
|
|||||||
</header>
|
</header>
|
||||||
<template v-if="isEditMode">
|
<template v-if="isEditMode">
|
||||||
<CustomFieldInputGrid :fields="customFieldInputs" :disabled="!canEdit || saving" />
|
<CustomFieldInputGrid :fields="customFieldInputs" :disabled="!canEdit || saving" />
|
||||||
|
<p v-if="hasRequiredCustomFields && !requiredCustomFieldsFilled" class="text-xs text-warning">
|
||||||
|
Certains champs personnalisés sont obligatoires. Veuillez les renseigner avant de valider.
|
||||||
|
</p>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||||
@@ -338,7 +341,7 @@
|
|||||||
Enregistrer les modifications
|
Enregistrer les modifications
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="isEditMode && product && !requiredCustomFieldsFilled" class="text-xs text-error text-right">
|
<p v-if="isEditMode && hasRequiredCustomFields && !requiredCustomFieldsFilled" class="text-xs text-error text-right">
|
||||||
Merci de renseigner tous les champs personnalisés obligatoires.
|
Merci de renseigner tous les champs personnalisés obligatoires.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -409,6 +412,7 @@ const {
|
|||||||
values: cfValues,
|
values: cfValues,
|
||||||
entityType: 'product' as CustomFieldEntityType,
|
entityType: 'product' as CustomFieldEntityType,
|
||||||
entityId,
|
entityId,
|
||||||
|
context: 'standalone',
|
||||||
})
|
})
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const saving = ref(false)
|
const saving = ref(false)
|
||||||
@@ -446,7 +450,7 @@ const editionForm = reactive({
|
|||||||
supplierPrice: '' as string,
|
supplierPrice: '' as string,
|
||||||
})
|
})
|
||||||
|
|
||||||
// requiredCustomFieldsFilled comes from useCustomFieldInputs composable
|
const hasRequiredCustomFields = computed(() => customFieldInputs.value.some(f => f.required))
|
||||||
|
|
||||||
const canSubmit = computed(() =>
|
const canSubmit = computed(() =>
|
||||||
Boolean(canEdit.value && product.value && editionForm.name.trim().length >= 2 && requiredCustomFieldsFilled.value && !saving.value),
|
Boolean(canEdit.value && product.value && editionForm.name.trim().length >= 2 && requiredCustomFieldsFilled.value && !saving.value),
|
||||||
|
|||||||
@@ -158,6 +158,9 @@
|
|||||||
</p>
|
</p>
|
||||||
</header>
|
</header>
|
||||||
<CustomFieldInputGrid :fields="customFieldInputs" :disabled="!canEdit || submitting" />
|
<CustomFieldInputGrid :fields="customFieldInputs" :disabled="!canEdit || submitting" />
|
||||||
|
<p v-if="hasRequiredCustomFields && !requiredCustomFieldsFilled" class="text-xs text-warning">
|
||||||
|
Certains champs personnalisés sont obligatoires. Veuillez les renseigner avant de valider.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<EmptyState
|
<EmptyState
|
||||||
v-else
|
v-else
|
||||||
@@ -177,7 +180,7 @@
|
|||||||
Créer le produit
|
Créer le produit
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="selectedType && !requiredCustomFieldsFilled" class="text-xs text-error text-right">
|
<p v-if="selectedType && hasRequiredCustomFields && !requiredCustomFieldsFilled" class="text-xs text-error text-right">
|
||||||
Merci de renseigner tous les champs personnalisés obligatoires.
|
Merci de renseigner tous les champs personnalisés obligatoires.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -241,7 +244,9 @@ const { fields: customFieldInputs, requiredFilled: requiredCustomFieldsFilled, s
|
|||||||
values: [] as any[],
|
values: [] as any[],
|
||||||
entityType: 'product' as CustomFieldEntityType,
|
entityType: 'product' as CustomFieldEntityType,
|
||||||
entityId: createdEntityId,
|
entityId: createdEntityId,
|
||||||
|
context: 'standalone',
|
||||||
})
|
})
|
||||||
|
const hasRequiredCustomFields = computed(() => customFieldInputs.value.some(f => f.required))
|
||||||
|
|
||||||
const productTypeList = computed<ProductCatalogType[]>(() =>
|
const productTypeList = computed<ProductCatalogType[]>(() =>
|
||||||
(productTypes.value || []) as ProductCatalogType[],
|
(productTypes.value || []) as ProductCatalogType[],
|
||||||
|
|||||||
Reference in New Issue
Block a user