fix(custom-fields) : fix declaration order in useComponentEdit and useComponentCreate
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -93,18 +93,6 @@ export function useComponentCreate() {
|
|||||||
const lastSuggestedName = ref('')
|
const lastSuggestedName = ref('')
|
||||||
const createdComponentId = ref<string | null>(null)
|
const createdComponentId = ref<string | null>(null)
|
||||||
|
|
||||||
const {
|
|
||||||
fields: customFieldInputs,
|
|
||||||
requiredFilled: requiredCustomFieldsFilled,
|
|
||||||
saveAll: saveAllCustomFields,
|
|
||||||
refresh: refreshCustomFieldInputs,
|
|
||||||
} = useCustomFieldInputs({
|
|
||||||
definitions: computed(() => selectedTypeStructure.value?.customFields ?? []),
|
|
||||||
values: computed(() => []),
|
|
||||||
entityType: 'composant',
|
|
||||||
entityId: createdComponentId,
|
|
||||||
})
|
|
||||||
|
|
||||||
const structureAssignments = ref<StructureAssignmentNode | null>(null)
|
const structureAssignments = ref<StructureAssignmentNode | null>(null)
|
||||||
const selectedDocuments = ref<File[]>([])
|
const selectedDocuments = ref<File[]>([])
|
||||||
const uploadingDocuments = ref(false)
|
const uploadingDocuments = ref(false)
|
||||||
@@ -154,6 +142,18 @@ export function useComponentCreate() {
|
|||||||
return structure ? normalizeStructureForEditor(structure) : null
|
return structure ? normalizeStructureForEditor(structure) : null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const {
|
||||||
|
fields: customFieldInputs,
|
||||||
|
requiredFilled: requiredCustomFieldsFilled,
|
||||||
|
saveAll: saveAllCustomFields,
|
||||||
|
refresh: refreshCustomFieldInputs,
|
||||||
|
} = useCustomFieldInputs({
|
||||||
|
definitions: computed(() => selectedTypeStructure.value?.customFields ?? []),
|
||||||
|
values: computed(() => []),
|
||||||
|
entityType: 'composant',
|
||||||
|
entityId: createdComponentId,
|
||||||
|
})
|
||||||
|
|
||||||
const structureHasRequirements = computed(() =>
|
const structureHasRequirements = computed(() =>
|
||||||
hasAssignments(structureAssignments.value),
|
hasAssignments(structureAssignments.value),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -89,23 +89,6 @@ export function useComponentEdit(componentId: string) {
|
|||||||
const originalConstructeurLinks = ref<ConstructeurLinkEntry[]>([])
|
const originalConstructeurLinks = ref<ConstructeurLinkEntry[]>([])
|
||||||
const constructeurIdsFromForm = computed(() => constructeurIdsFromLinks(constructeurLinks.value))
|
const constructeurIdsFromForm = computed(() => constructeurIdsFromLinks(constructeurLinks.value))
|
||||||
|
|
||||||
const {
|
|
||||||
fields: customFieldInputs,
|
|
||||||
requiredFilled: requiredCustomFieldsFilled,
|
|
||||||
saveAll: saveAllCustomFields,
|
|
||||||
refresh: refreshCustomFieldInputs,
|
|
||||||
} = useCustomFieldInputs({
|
|
||||||
definitions: computed(() => selectedTypeStructure.value?.customFields ?? []),
|
|
||||||
values: computed(() => component.value?.customFieldValues ?? []),
|
|
||||||
entityType: 'composant',
|
|
||||||
entityId: computed(() => component.value?.id ?? null),
|
|
||||||
onValueCreated: (newValue) => {
|
|
||||||
if (component.value && Array.isArray(component.value.customFieldValues)) {
|
|
||||||
component.value.customFieldValues.push(newValue)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const fetchedPieceTypeMap = ref<Record<string, string>>({})
|
const fetchedPieceTypeMap = ref<Record<string, string>>({})
|
||||||
const pieceTypeLabelMap = computed(() =>
|
const pieceTypeLabelMap = computed(() =>
|
||||||
buildTypeLabelMap(pieceTypes.value, fetchedPieceTypeMap.value),
|
buildTypeLabelMap(pieceTypes.value, fetchedPieceTypeMap.value),
|
||||||
@@ -216,6 +199,23 @@ export function useComponentEdit(componentId: string) {
|
|||||||
return structure ? normalizeStructureForEditor(structure) : null
|
return structure ? normalizeStructureForEditor(structure) : null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const {
|
||||||
|
fields: customFieldInputs,
|
||||||
|
requiredFilled: requiredCustomFieldsFilled,
|
||||||
|
saveAll: saveAllCustomFields,
|
||||||
|
refresh: refreshCustomFieldInputs,
|
||||||
|
} = useCustomFieldInputs({
|
||||||
|
definitions: computed(() => selectedTypeStructure.value?.customFields ?? []),
|
||||||
|
values: computed(() => component.value?.customFieldValues ?? []),
|
||||||
|
entityType: 'composant',
|
||||||
|
entityId: computed(() => component.value?.id ?? null),
|
||||||
|
onValueCreated: (newValue) => {
|
||||||
|
if (component.value && Array.isArray(component.value.customFieldValues)) {
|
||||||
|
component.value.customFieldValues.push(newValue)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
const canSubmit = computed(() => Boolean(
|
const canSubmit = computed(() => Boolean(
|
||||||
canEdit.value
|
canEdit.value
|
||||||
&& component.value
|
&& component.value
|
||||||
|
|||||||
Reference in New Issue
Block a user