diff options
| author | Thomas Hackl <hackl@data-quest.de> | 2026-03-17 08:58:39 +0100 |
|---|---|---|
| committer | Thomas Hackl <hackl@data-quest.de> | 2026-03-17 09:01:06 +0100 |
| commit | 7ab6009e8c6d420803d0ce249f1373bf62c59a5d (patch) | |
| tree | 9815d978be67d3dcf077f23310d3498244a3c849 /resources/vue/apps | |
| parent | 0062fad070cffd7d38024118939fe5c9d9be79d6 (diff) | |
working form validationwizard
Diffstat (limited to 'resources/vue/apps')
| -rw-r--r-- | resources/vue/apps/StudipWizard.vue | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/resources/vue/apps/StudipWizard.vue b/resources/vue/apps/StudipWizard.vue index 941f1a8..5acca93 100644 --- a/resources/vue/apps/StudipWizard.vue +++ b/resources/vue/apps/StudipWizard.vue @@ -113,32 +113,41 @@ const currentStep = ref(0); // HTML content of current step let stepContent = ref(''); let mountedApp = null; +let appInstance = null; const currentStepType = ref(null); const visibleSteps = ref(props.showAllSteps ? props.steps : [props.steps[0]]); -const checkValidity = () => { +const validate = async () => { if (currentStepType.value === 'form') { - STUDIP.Vue.emit('form.submit', props.steps[currentStep.value].id); + return appInstance.submit() + .then(() => { + return true; + }).catch(errors => { + return false; + }); + } else { + return true; } }; -const jumpToStep = (number) => { - checkValidity(); - - if (mountedApp !== null) { - mountedApp.unmount(); - } +const jumpToStep = async (number) => { + const success = await validate(); + if (success) { + if (mountedApp !== null) { + mountedApp.unmount(); + } - if (!visibleSteps.value.includes(props.steps[number])) { - visibleSteps.value[number] = props.steps[number]; + if (!visibleSteps.value.includes(props.steps[number])) { + console.log('Visible steps', visibleSteps.value); + visibleSteps.value[number] = props.steps[number]; + } + currentStep.value = number; + initializeContent(number); } - currentStep.value = number; - initializeContent(number); }; const finishWizard = () => { - checkValidity(); }; const initializeContent = async (stepNumber) => { @@ -165,20 +174,13 @@ onMounted(() => { STUDIP.Vue.on('form.mounted', (mounted) => { mountedApp = mounted.app; + appInstance = mounted.instance; }); STUDIP.Vue.on('vueApp.mounted', (mounted) => { if (mounted.config.appPath === stepContent.value.appPath) { mountedApp = mounted.app; } }); - - visibleSteps.value.push({ - type: 'Vue', - id: 'stock-images', - title: 'Bilderpool', - content: StockImages, - icon: 'block-gallery' - }); }); </script> |
