feat(fullstack): Add test application form creation
This commit is contained in:
@@ -203,9 +203,10 @@ const { isSwiping } = usePointerSwipe(stepperScrollEl, {
|
||||
const previousVisibilityMap = ref<Map<string, boolean>>(new Map())
|
||||
|
||||
const allFormElements = computed(() => {
|
||||
return props.formElementSections
|
||||
.filter((section) => section.isTemplate !== true)
|
||||
.flatMap((section) => section.formElementSubSections?.flatMap((subsection) => subsection.formElements) ?? [])
|
||||
const nonTemplateSections = props.formElementSections.filter((section) => section.isTemplate !== true)
|
||||
return nonTemplateSections.flatMap(
|
||||
(section) => section.formElementSubSections?.flatMap((subsection) => subsection.formElements) ?? []
|
||||
)
|
||||
})
|
||||
|
||||
const visibilityMap = computed(() => {
|
||||
@@ -407,15 +408,34 @@ function handleFormElementUpdate(updatedFormElements: FormElementDto[], subsecti
|
||||
}
|
||||
|
||||
function clearNewlyHiddenFormElements(sections: FormElementSectionDto[]): FormElementSectionDto[] {
|
||||
const allElements = sections.flatMap(
|
||||
// Only evaluate visibility for non-template sections to avoid duplicate reference issues
|
||||
const nonTemplateSections = sections.filter((section) => section.isTemplate !== true)
|
||||
const allElements = nonTemplateSections.flatMap(
|
||||
(section) => section.formElementSubSections?.flatMap((subsection) => subsection.formElements) ?? []
|
||||
)
|
||||
const newVisibilityMap = evaluateFormElementVisibility(allElements)
|
||||
|
||||
const clearedSections = clearHiddenFormElementValues(sections, previousVisibilityMap.value, newVisibilityMap)
|
||||
// Only clear values in non-template sections, preserve template sections unchanged
|
||||
const clearedNonTemplateSections = clearHiddenFormElementValues(
|
||||
nonTemplateSections,
|
||||
previousVisibilityMap.value,
|
||||
newVisibilityMap
|
||||
)
|
||||
previousVisibilityMap.value = newVisibilityMap
|
||||
|
||||
return clearedSections
|
||||
// Create a map of cleared sections by their identity for lookup
|
||||
const clearedSectionMap = new Map<FormElementSectionDto, FormElementSectionDto>()
|
||||
nonTemplateSections.forEach((original, index) => {
|
||||
clearedSectionMap.set(original, clearedNonTemplateSections[index]!)
|
||||
})
|
||||
|
||||
// Preserve original order: replace non-template sections with cleared versions, keep templates unchanged
|
||||
return sections.map((section) => {
|
||||
if (section.isTemplate === true) {
|
||||
return section
|
||||
}
|
||||
return clearedSectionMap.get(section) ?? section
|
||||
})
|
||||
}
|
||||
|
||||
function getSubsectionKey(
|
||||
|
||||
Reference in New Issue
Block a user