Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b304cf6684 | ||
| 0fe7f3131e | |||
| a6bbcaf6d1 | |||
| 9f2e1da6ec |
@@ -1,2 +1,2 @@
|
||||
parameters:
|
||||
app.version: '1.9.20'
|
||||
app.version: '1.9.21'
|
||||
|
||||
@@ -95,16 +95,6 @@
|
||||
<PieceModelStructureEditor v-model="pieceStructure" />
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else
|
||||
class="space-y-3 rounded-lg border border-base-300 p-4"
|
||||
>
|
||||
<p class="text-sm text-base-content/70">
|
||||
Aperçu :
|
||||
<span class="font-medium text-base-content">{{ productStructurePreview }}</span>
|
||||
</p>
|
||||
<PieceModelStructureEditor v-model="productStructure" />
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
|
||||
@@ -194,15 +184,16 @@ const form = reactive<ModelTypePayload & { referenceFormula?: string | null }>({
|
||||
})
|
||||
|
||||
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[] => {
|
||||
|
||||
@@ -34,7 +34,6 @@ import {
|
||||
import {
|
||||
hasAssignments,
|
||||
initializeStructureAssignments,
|
||||
isAssignmentNodeComplete,
|
||||
serializeStructureAssignments,
|
||||
} from '~/shared/utils/structureAssignmentHelpers'
|
||||
import type { ComponentModelStructure } from '~/shared/types/inventory'
|
||||
@@ -152,24 +151,14 @@ export function useComponentCreate() {
|
||||
values: computed(() => []),
|
||||
entityType: 'composant',
|
||||
entityId: createdComponentId,
|
||||
context: 'standalone',
|
||||
})
|
||||
|
||||
const structureHasRequirements = computed(() =>
|
||||
hasAssignments(structureAssignments.value),
|
||||
)
|
||||
|
||||
const structureSelectionsComplete = computed(() => {
|
||||
if (!structureHasRequirements.value) {
|
||||
return true
|
||||
}
|
||||
if (structureDataLoading.value) {
|
||||
return false
|
||||
}
|
||||
if (!structureAssignments.value) {
|
||||
return false
|
||||
}
|
||||
return isAssignmentNodeComplete(structureAssignments.value, true)
|
||||
})
|
||||
const structureSelectionsComplete = computed(() => true)
|
||||
|
||||
const canSubmit = computed(() => Boolean(
|
||||
canEdit.value
|
||||
@@ -307,11 +296,6 @@ export function useComponentCreate() {
|
||||
payload.productId = rootProductSelection.selectedProductId.trim()
|
||||
}
|
||||
|
||||
if (structureHasRequirements.value && !structureSelectionsComplete.value) {
|
||||
toast.showError('Complétez la sélection des pièces, produits et sous-composants.')
|
||||
return
|
||||
}
|
||||
|
||||
const serializedStructure = structureHasRequirements.value
|
||||
? serializeStructureAssignments(structureAssignments.value)
|
||||
: null
|
||||
@@ -414,6 +398,7 @@ export function useComponentCreate() {
|
||||
structureSelectionsComplete,
|
||||
canEdit,
|
||||
canSubmit,
|
||||
requiredCustomFieldsFilled,
|
||||
|
||||
// Functions
|
||||
typeOptionLabel,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -218,6 +218,9 @@
|
||||
</p>
|
||||
</header>
|
||||
<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>
|
||||
<EmptyState
|
||||
v-else
|
||||
@@ -237,6 +240,9 @@
|
||||
Créer la pièce
|
||||
</button>
|
||||
</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>
|
||||
</section>
|
||||
</main>
|
||||
@@ -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<File[]>([])
|
||||
const uploadingDocuments = ref(false)
|
||||
|
||||
|
||||
@@ -274,6 +274,9 @@
|
||||
</header>
|
||||
<template v-if="isEditMode">
|
||||
<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 v-else>
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
@@ -338,7 +341,7 @@
|
||||
Enregistrer les modifications
|
||||
</button>
|
||||
</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.
|
||||
</p>
|
||||
</div>
|
||||
@@ -409,6 +412,7 @@ const {
|
||||
values: cfValues,
|
||||
entityType: 'product' as CustomFieldEntityType,
|
||||
entityId,
|
||||
context: 'standalone',
|
||||
})
|
||||
const loading = ref(true)
|
||||
const saving = ref(false)
|
||||
@@ -446,7 +450,7 @@ const editionForm = reactive({
|
||||
supplierPrice: '' as string,
|
||||
})
|
||||
|
||||
// requiredCustomFieldsFilled comes from useCustomFieldInputs composable
|
||||
const hasRequiredCustomFields = computed(() => customFieldInputs.value.some(f => f.required))
|
||||
|
||||
const canSubmit = computed(() =>
|
||||
Boolean(canEdit.value && product.value && editionForm.name.trim().length >= 2 && requiredCustomFieldsFilled.value && !saving.value),
|
||||
|
||||
@@ -158,6 +158,9 @@
|
||||
</p>
|
||||
</header>
|
||||
<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>
|
||||
<EmptyState
|
||||
v-else
|
||||
@@ -177,7 +180,7 @@
|
||||
Créer le produit
|
||||
</button>
|
||||
</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.
|
||||
</p>
|
||||
</div>
|
||||
@@ -241,7 +244,9 @@ const { fields: customFieldInputs, requiredFilled: requiredCustomFieldsFilled, s
|
||||
values: [] as any[],
|
||||
entityType: 'product' as CustomFieldEntityType,
|
||||
entityId: createdEntityId,
|
||||
context: 'standalone',
|
||||
})
|
||||
const hasRequiredCustomFields = computed(() => customFieldInputs.value.some(f => f.required))
|
||||
|
||||
const productTypeList = computed<ProductCatalogType[]>(() =>
|
||||
(productTypes.value || []) as ProductCatalogType[],
|
||||
|
||||
Reference in New Issue
Block a user