feat(frontend): Add useFormElementDuplication test
This commit is contained in:
@@ -198,7 +198,7 @@ const hasOverflow = ref(false)
|
||||
const { evaluateFormElementVisibility } = useFormElementVisibility()
|
||||
const { clearHiddenFormElementValues } = useFormElementValueClearing()
|
||||
const { processSpawnTriggers } = useSectionSpawning()
|
||||
const { cloneElement } = useClonableElements()
|
||||
const { cloneElement } = useFormElementDuplication()
|
||||
|
||||
const { isSwiping } = usePointerSwipe(stepperScrollEl, {
|
||||
threshold: 0,
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import type { FormElementDto } from '~~/.api-client'
|
||||
|
||||
export function useClonableElements() {
|
||||
function cloneElement(element: FormElementDto, existingElements: FormElementDto[]): FormElementDto {
|
||||
const newReference = element.reference ? generateNextReference(existingElements, element.reference) : undefined
|
||||
const isTextField = element.type === 'TEXTAREA' || element.type === 'TEXTFIELD'
|
||||
export function useFormElementDuplication() {
|
||||
function cloneElement(elementToClone: FormElementDto, existingElements: FormElementDto[]): FormElementDto {
|
||||
const newReference = elementToClone.reference
|
||||
? generateNextReference(existingElements, elementToClone.reference)
|
||||
: undefined
|
||||
const isTextField = elementToClone.type === 'TEXTAREA' || elementToClone.type === 'TEXTFIELD'
|
||||
|
||||
const clonedElement = JSON.parse(JSON.stringify(element)) as FormElementDto
|
||||
const clonedElement = JSON.parse(JSON.stringify(elementToClone)) as FormElementDto
|
||||
const resetOptions = clonedElement.options.map((option) => ({
|
||||
...option,
|
||||
value: isTextField ? '' : option.value
|
||||
Reference in New Issue
Block a user