JSON preguntas corregido
This commit is contained in:
@@ -46,6 +46,11 @@ export default {
|
|||||||
"bg-surface cursor-not-allowed text-accent/50 border border-accent/50 rounded-lg":
|
"bg-surface cursor-not-allowed text-accent/50 border border-accent/50 rounded-lg":
|
||||||
this.color === "surface" && this.disabled,
|
this.color === "surface" && this.disabled,
|
||||||
|
|
||||||
|
"border border-accent focus:border-surface hover:bg-accent hover:border-surface hover:text-surface text-accent focus:text-accent rounded-lg":
|
||||||
|
this.color === "transparent" && !this.disabled,
|
||||||
|
"bg-accent/55 border border-accent/10 cursor-not-allowed text-white rounded-lg":
|
||||||
|
this.color === "accent" && this.disabled,
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="flex flex-1 sm:items-center justify-center pt-10 pb-[60px] px-4 sm:p-4">
|
<section class="flex flex-1 sm:items-center justify-center pt-10 pb-[60px] px-4 sm:p-4 bg-mapamundi">
|
||||||
<div
|
<div
|
||||||
class="rounded-2xl px-4 sm:px-10 py-12 w-full max-w-2xl"
|
class="rounded-2xl px-4 sm:px-10 py-12 w-full max-w-2xl"
|
||||||
:class="{
|
:class="{
|
||||||
'bg-surface text-white': type === 'welcome',
|
|
||||||
'bg-surface text-white h-fit': type === 'question',
|
'bg-surface text-white h-fit': type === 'question',
|
||||||
'bg-[#82DBDF] text-surface': type === 'feedback'
|
'bg-surface text-white': type === 'welcome' || (type === 'feedback' && (id !== 'P1-F4-1' || id !== 'P2-F4-1')),
|
||||||
|
'bg-[#82DBDF] text-surface': type === 'feedback' && (id === 'P1-F4-1' || id === 'P2-F4-1'),
|
||||||
}">
|
}">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
@@ -17,6 +17,10 @@
|
|||||||
export default {
|
export default {
|
||||||
//components: { FullscreenButton },
|
//components: { FullscreenButton },
|
||||||
props: {
|
props: {
|
||||||
|
id: {
|
||||||
|
type: String,
|
||||||
|
default: ""
|
||||||
|
},
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "default"
|
default: "default"
|
||||||
@@ -38,7 +42,7 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
section {
|
.bg-mapamundi {
|
||||||
background-image: url('/assets/img/mapamundi-fondo.png');
|
background-image: url('/assets/img/mapamundi-fondo.png');
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<label for="file-upload" class="block text-sm text-gray-900">
|
<label for="file-upload" class="block text-sm ">
|
||||||
<p class="mb-2">{{ label }}</p>
|
<p class="mb-2">{{ label }}</p>
|
||||||
<div class="flex justify-between items-center p-2 cursor-pointer rounded-md bg-white outline-1 -outline-offset-1 outline-gray-300 focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-indigo-600 hover:text-indigo-500">
|
<div class="flex justify-between items-center p-2 cursor-pointer rounded-md bg-white outline-1 -outline-offset-1 outline-gray-300 focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-indigo-600 hover:text-indigo-500">
|
||||||
<span v-if="file && file.name" class="text-sm text-gray-500">{{ file.name }}</span>
|
<span v-if="file && file.name" class="text-sm text-gray-500">{{ file.name }}</span>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
class="w-4 h-4 text-indigo-600 bg-gray-100 border-gray-300 rounded-sm focus:ring-indigo-500 dark:focus:ring-indigo-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
|
class="w-4 h-4 text-indigo-600 bg-gray-100 border-gray-300 rounded-sm focus:ring-indigo-500 dark:focus:ring-indigo-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600">
|
||||||
<label
|
<label
|
||||||
for="default-checkbox"
|
for="default-checkbox"
|
||||||
class="ms-2 text-sm text-gray-900 dark:text-gray-300"
|
class="ms-2 text-sm dark:text-gray-300"
|
||||||
>{{ label }}</label>
|
>{{ label }}</label>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<label for="mail" class="block text-sm text-gray-900 dark:text-white">{{ label }} <span>{{ required ? '*' : '' }}</span></label>
|
<label for="mail" class="block text-sm">{{ label[langcode] }} <span>{{ required ? '*' : '' }}</span></label>
|
||||||
<div class="mt-2 h-10 flex items-center rounded-md bg-white pl-3 outline-1 -outline-offset-1 outline-gray-300 has-[input:focus-within]:outline-2 has-[input:focus-within]:-outline-offset-2 has-[input:focus-within]:outline-indigo-600 dark:bg-white/5 dark:outline-gray-600 dark:has-[input:focus-within]:outline-indigo-500">
|
<div class="mt-2 h-10 flex items-center rounded-md bg-white pl-3 outline-1 -outline-offset-1 outline-gray-300 has-[input:focus-within]:outline-2 has-[input:focus-within]:-outline-offset-2 has-[input:focus-within]:outline-indigo-600 dark:bg-white/5 dark:outline-gray-600 dark:has-[input:focus-within]:outline-indigo-500">
|
||||||
<img src="@/assets/svg/mail.svg" alt="" class="h-5 w-5" />
|
<img src="@/assets/svg/mail.svg" alt="" class="h-5 w-5" />
|
||||||
<input
|
<input
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
type="text"
|
type="text"
|
||||||
name="mail"
|
name="mail"
|
||||||
class="block min-w-0 grow py-1.5 pr-3 pl-1 text-base text-gray-900 placeholder:text-gray-400 focus:outline-none sm:text-sm/6 dark:bg-gray-800 dark:text-white dark:placeholder:text-gray-500"
|
class="block min-w-0 grow py-1.5 pr-3 pl-1 text-base text-gray-900 placeholder:text-gray-400 focus:outline-none sm:text-sm/6 dark:bg-gray-800 dark:text-white dark:placeholder:text-gray-500"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder[langcode]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="error" class="mt-2 text-sm text-error dark:text-error">{{ error }}</p>
|
<p v-if="error" class="mt-2 text-sm text-error dark:text-error">{{ error }}</p>
|
||||||
@@ -17,11 +17,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
label: { type: String, required: true },
|
label: { type: Object, default: () => ({}) },
|
||||||
required: { type: Boolean, default: true },
|
required: { type: Boolean, default: true },
|
||||||
placeholder: { type: String, default: '' },
|
placeholder: { type: Object, default: () => ({}) },
|
||||||
},
|
},
|
||||||
emits: ['input-value'],
|
emits: ['input-value'],
|
||||||
data() {
|
data() {
|
||||||
@@ -30,6 +31,9 @@ export default {
|
|||||||
error: ''
|
error: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(["langcode"]),
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
email(newVal) {
|
email(newVal) {
|
||||||
this.error = '';
|
this.error = '';
|
||||||
@@ -42,7 +46,10 @@ export default {
|
|||||||
if (pattern.test(String(email).toLowerCase())) {
|
if (pattern.test(String(email).toLowerCase())) {
|
||||||
this.$emit('input-value', email);
|
this.$emit('input-value', email);
|
||||||
} else {
|
} else {
|
||||||
this.error = "Por favor, introduce un correo electrónico válido.";
|
this.error = {
|
||||||
|
es: 'Por favor, introduce una dirección de correo electrónico válida.',
|
||||||
|
pt: 'Por favor, introduza um endereço de e-mail válido.',
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,27 +3,35 @@
|
|||||||
v-if="label"
|
v-if="label"
|
||||||
class="mb-4 font-medium"
|
class="mb-4 font-medium"
|
||||||
>
|
>
|
||||||
<p class="mb-2 block">{{ label }} <span v-if="required" class="text-red-500">*</span></p>
|
<p class="mb-2 block">{{ label[langcode] }} <span v-if="required" class="text-white">*</span></p>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-for="(opt, index) in options" :key="`${opt.value}-radio-${index}`"
|
|
||||||
class="flex items-center gap-2 mb-4 bg-white hover:bg-accent/20 pl-2 outline-1 -outline-offset-1 outline-gray-300 rounded-md cursor-pointer">
|
|
||||||
<input
|
|
||||||
:id="`radio-` + opt.label"
|
|
||||||
v-model="picked"
|
|
||||||
type="radio"
|
|
||||||
:value="opt"
|
|
||||||
/>
|
|
||||||
<label :for="`radio-` + opt.label" class="cursor-pointer w-full py-2 pr-2">{{ opt.label }}</label>
|
|
||||||
</div>
|
</div>
|
||||||
|
<section class="flex flex-wrap gap-2 md:gap-4">
|
||||||
|
<div
|
||||||
|
v-for="(opt, index) in options" :key="`${opt.value}-radio-${index}`"
|
||||||
|
class="relative "
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
:id="`radio-` + opt.label[langcode]"
|
||||||
|
v-model="picked"
|
||||||
|
type="radio"
|
||||||
|
:value="opt"
|
||||||
|
class="absolute opacity-0 peer"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
:for="`radio-` + opt.label[langcode]"
|
||||||
|
class="cursor-pointer w-full py-2 pr-2 text-sm flex items-center gap-2 bg-accent hover:bg-muted peer-checked:bg-muted text-surface pl-2 outline-1 -outline-offset-1 outline-gray-300 rounded-md">
|
||||||
|
{{ opt.label[langcode] }}</label>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
type: { type: String, default: 'radio' },
|
type: { type: String, default: 'radio' },
|
||||||
label: { type: String, default: '' },
|
label: { type: Object, default: () => ({}) },
|
||||||
options: { type: Array, default: () => [] },
|
options: { type: Array, default: () => [] },
|
||||||
required: { type: Boolean, default: false }
|
required: { type: Boolean, default: false }
|
||||||
},
|
},
|
||||||
@@ -33,6 +41,9 @@ export default {
|
|||||||
picked: ''
|
picked: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(["langcode"]),
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
picked(newVal) {
|
picked(newVal) {
|
||||||
//////console.log('radio', newVal);
|
//////console.log('radio', newVal);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<label for="text" class="block text-sm text-gray-900">{{label}} <span>{{ required ? '*' : '' }}</span></label>
|
<label for="text" class="block text-sm">{{ label[langcode]}} <span>{{ required ? '*' : '' }}</span></label>
|
||||||
<div class="h-10 flex items-center rounded-md bg-white pl-3 outline-1 -outline-offset-1 outline-gray-300 has-[input:focus-within]:outline-2 has-[input:focus-within]:-outline-offset-2 has-[input:focus-within]:outline-indigo-600">
|
<div class="h-10 flex items-center rounded-md bg-white pl-3 outline-1 -outline-offset-1 outline-gray-300 has-[input:focus-within]:outline-2 has-[input:focus-within]:-outline-offset-2 has-[input:focus-within]:outline-indigo-600">
|
||||||
<input
|
<input
|
||||||
id="text"
|
id="text"
|
||||||
type="text"
|
type="text"
|
||||||
name="text"
|
name="text"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder[langcode]"
|
||||||
class="block min-w-0 grow py-1.5 pr-3 pl-1 text-base text-gray-900 placeholder:text-gray-400 focus:outline-none sm:text-sm/6 dark:bg-gray-800 dark:text-white dark:placeholder:text-gray-500"
|
class="block min-w-0 grow py-1.5 pr-3 pl-1 text-base text-gray-900 placeholder:text-gray-400 focus:outline-none sm:text-sm/6 dark:bg-gray-800 dark:text-white dark:placeholder:text-gray-500"
|
||||||
:required="required"
|
:required="required"
|
||||||
:value="modelValue"
|
:value="modelValue"
|
||||||
@@ -17,11 +17,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
label: {
|
label: {
|
||||||
type: String,
|
type: Object,
|
||||||
required: true
|
default: () => ({})
|
||||||
},
|
},
|
||||||
required: {
|
required: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -32,11 +33,14 @@ export default {
|
|||||||
default: ''
|
default: ''
|
||||||
},
|
},
|
||||||
placeholder: {
|
placeholder: {
|
||||||
type: String,
|
type: Object,
|
||||||
default: 'Input'
|
default: () => ({})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['input-value'],
|
emits: ['input-value'],
|
||||||
|
computed: {
|
||||||
|
...mapGetters(["langcode"]),
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateValue(event) {
|
updateValue(event) {
|
||||||
this.$emit('input-value', event.target.value)
|
this.$emit('input-value', event.target.value)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="pdf-content" class="space-y-4">
|
<div id="pdf-content" class="space-y-4 bg-surface">
|
||||||
<h2 class="text-xl font-semibold text-center">{{ data.title }}</h2>
|
<h2 class="text-xl font-semibold text-center">{{ data.title }}</h2>
|
||||||
<p class="text-center text-muted">{{ data.subtitle }}</p>
|
<p class="text-center text-muted">{{ data.subtitle }}</p>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col justify-center items-start space-y-4">
|
<div class="flex flex-col justify-center items-start space-y-4">
|
||||||
<h1 class="text-3xl font-bold">
|
<h1 class="text-3xl font-bold">
|
||||||
{{ data.title }}
|
{{data.id}} • {{ data.title[langcode]}}
|
||||||
</h1>
|
</h1>
|
||||||
<p class="text-sm" v-html="feedbackText"></p>
|
<p class="text-sm" v-html="data.subtitle[langcode]"></p>
|
||||||
<button-CTA
|
<button-CTA
|
||||||
color="accent"
|
color="accent"
|
||||||
class="ml-auto"
|
class="ml-auto"
|
||||||
@click="$emit('next')"
|
@click="$emit('next')"
|
||||||
>
|
>
|
||||||
{{ data.button }}
|
{{ data.button[langcode] }}
|
||||||
</button-CTA>
|
</button-CTA>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
data: {
|
data: {
|
||||||
@@ -30,6 +31,9 @@ export default {
|
|||||||
feedbackText: ""
|
feedbackText: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters(['langcode'])
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.generateFeedbackText();
|
this.generateFeedbackText();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,50 +1,58 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
<form class="" @submit.prevent="handleSubmit">
|
<form @submit.prevent="handleSubmit">
|
||||||
<!-- <p class="text-sm text-muted">
|
|
||||||
Pregunta {{ currentIndex + 1 }} de {{ total }}
|
|
||||||
</p> -->
|
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<div class="flex gap-2">
|
<!-- Cabecera de sección -->
|
||||||
|
<!-- <div class="flex gap-2">
|
||||||
<img src="../public/icono-bravioo.svg" alt="logo-bravio" class="h-6 w-6 object-cover" />
|
<img src="../public/icono-bravioo.svg" alt="logo-bravio" class="h-6 w-6 object-cover" />
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<h2 class="text-xl font-semibold">{{ data.section.title[langcode] }}</h2>
|
<h2 class="text-xl font-semibold">{{ data.section.title[langcode] }}</h2>
|
||||||
<p v-if="data.section.description" class="text-muted text-xs">{{ data.section.description[langcode] }}</p>
|
<p v-if="data.section.description[langcode]" class="text-muted text-xs">
|
||||||
|
{{ data.section.description[langcode] }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> -->
|
||||||
<div class="flex flex-col gap-1">
|
<h1>{{ data.id }}</h1>
|
||||||
|
<!-- Título de pregunta -->
|
||||||
|
<div v-if="data.question" class="flex gap-2">
|
||||||
|
<img src="../public/icono-bravioo.svg" alt="logo-bravio" class="h-6 w-6 object-cover" />
|
||||||
<h3 class="text-base font-semibold">{{ data.question.title[langcode] }}</h3>
|
<h3 class="text-base font-semibold">{{ data.question.title[langcode] }}</h3>
|
||||||
<p v-if="data.question.description" class="text-muted text-xs">{{ data.question.description[langcode] }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- <p v-if="data.question.recommendation" class="w-fit text-xs bg-[#AFE3D2] px-3 py-1 rounded-3xl"><strong>Recomendado:</strong> {{ data.question.recommendation[langcode] }}</p> -->
|
<p v-if="data.question.description[langcode]" class="text-muted text-xs">
|
||||||
|
{{ data.question.description[langcode] }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template v-if="inputComponent">
|
<!-- Render dinámico de inputs -->
|
||||||
<component
|
<div class="space-y-4 mt-4">
|
||||||
:is="inputComponent"
|
<div
|
||||||
:key="data.question.id"
|
v-for="(input, idx) in data.inputs"
|
||||||
v-bind="inputProps"
|
:key="idx"
|
||||||
:required="data.input.required || false"
|
class="flex flex-col gap-2"
|
||||||
@input-value="localValue = $event"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<div class="flex justify-start gap-4 mt-6">
|
|
||||||
<button-CTA
|
|
||||||
color="transparent"
|
|
||||||
@click="$emit('previous')"
|
|
||||||
>
|
>
|
||||||
Atrás
|
<!-- <label class="font-medium text-sm">{{ input.label[langcode] }}</label> -->
|
||||||
</button-CTA>
|
|
||||||
|
<component
|
||||||
|
:is="resolveComponent(input.type)"
|
||||||
|
:key="data.id + '-' + input.label[langcode] + '-' + idx"
|
||||||
|
v-bind="input"
|
||||||
|
:required="input.required || false"
|
||||||
|
@input-value="updateValue($event)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Botones navegación -->
|
||||||
|
<div class="flex justify-end gap-4 mt-6">
|
||||||
|
<!-- <button-CTA color="transparent" @click="$emit('previous')">Atrás</button-CTA> -->
|
||||||
<button-CTA
|
<button-CTA
|
||||||
color="accent"
|
color="accent"
|
||||||
:disabled="localValue ? false : true"
|
:disabled="!isValid"
|
||||||
@click="$emit('next', localValue)"
|
@click="$emit('next', values)"
|
||||||
>
|
>
|
||||||
Siguiente
|
Continuar
|
||||||
</button-CTA>
|
</button-CTA>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -61,6 +69,7 @@ import InputAttach from "@/components/InputAttach.vue"
|
|||||||
import InputTelephone from "@/components/InputTelephone.vue"
|
import InputTelephone from "@/components/InputTelephone.vue"
|
||||||
import InputUrl from "@/components/InputUrl.vue"
|
import InputUrl from "@/components/InputUrl.vue"
|
||||||
import RangeInputs from "@/components/RangeInputs.vue"
|
import RangeInputs from "@/components/RangeInputs.vue"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
InputText,
|
InputText,
|
||||||
@@ -74,6 +83,7 @@ export default {
|
|||||||
InputUrl,
|
InputUrl,
|
||||||
RangeInputs
|
RangeInputs
|
||||||
},
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
data: { type: Object, required: true },
|
data: { type: Object, required: true },
|
||||||
currentIndex: { type: Number, default: 0 },
|
currentIndex: { type: Number, default: 0 },
|
||||||
@@ -84,14 +94,36 @@ export default {
|
|||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
localValue: null
|
values: {}, // aquí se guardan los valores de todos los inputs
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['langcode']),
|
...mapGetters(["langcode"]),
|
||||||
inputComponent() {
|
isValid() {
|
||||||
switch (this.data.input.type) {
|
const totalInputs = this.data.inputs.length
|
||||||
|
//console.log("totalInputs -----------", totalInputs, this.values)
|
||||||
|
if (totalInputs === 1) {
|
||||||
|
// Si solo hay un input, comprobar que values solo tiene un valor
|
||||||
|
const isNotEmpty = this.values !== null &&
|
||||||
|
typeof this.values === "object" &&
|
||||||
|
!Array.isArray(this.values) &&
|
||||||
|
Object.keys(this.values).length > 0
|
||||||
|
//console.log("isValid 1 Input -----------", isNotEmpty)
|
||||||
|
return isNotEmpty
|
||||||
|
} else if (totalInputs > 1) {
|
||||||
|
// Si hay múltiples inputs, comprobar que values existen dentro de data.inputs
|
||||||
|
const filled = Object.values(this.values).length
|
||||||
|
//console.log("isValid Varios Inputs -----------", { totalInputs, filled })
|
||||||
|
return filled === totalInputs
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
resolveComponent(type) {
|
||||||
|
switch (type) {
|
||||||
case "text": return "InputText"
|
case "text": return "InputText"
|
||||||
case "email": return "InputEmail"
|
case "email": return "InputEmail"
|
||||||
case "textarea": return "InputTextarea"
|
case "textarea": return "InputTextarea"
|
||||||
@@ -105,15 +137,30 @@ export default {
|
|||||||
default: return "InputText"
|
default: return "InputText"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inputProps() {
|
|
||||||
return this.data.input
|
updateValue(value) {
|
||||||
}
|
//console.log("updateValue recibido →", value)
|
||||||
},
|
// Si el valor es un objeto pero no tiene id, lo mergeamos directamente
|
||||||
|
if (value && typeof value === "object") {
|
||||||
methods: {
|
this.values = { ...this.values, ...value }
|
||||||
|
}
|
||||||
|
// Si es un valor simple, lo guardamos en una key genérica o incremental
|
||||||
|
else if (typeof value !== "object") {
|
||||||
|
// Lo agregamos al objeto values con una key genérica
|
||||||
|
const key = Object.keys(this.values).length + 1
|
||||||
|
this.values = { ...this.values, [key]: value }
|
||||||
|
}
|
||||||
|
|
||||||
|
//console.log("updateValue →", this.values)
|
||||||
|
},
|
||||||
|
|
||||||
handleSubmit() {
|
handleSubmit() {
|
||||||
this.$emit("answer", { id: this.data.question, value: this.localValue })
|
this.$emit("answer", {
|
||||||
this.$emit("next", this.localValue)
|
id: this.data.id,
|
||||||
|
value: this.values
|
||||||
|
})
|
||||||
|
this.$emit("next", this.values)
|
||||||
|
this.values = {} // resetear valores después de enviar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3411
data/bravioo.js
Normal file
3411
data/bravioo.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<FormSlice :type="currentSlice.type">
|
<FormSlice :id="currentSlice.id" :type="currentSlice.type">
|
||||||
<template v-if="currentSliceComponent">
|
<template v-if="currentSliceComponent">
|
||||||
<transition name="fade" mode="out-in">
|
<transition name="fade" mode="out-in">
|
||||||
<component
|
<component
|
||||||
@@ -103,6 +103,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
goToNext(event) {
|
goToNext(event) {
|
||||||
|
console.log("Evento recibido para ir al siguiente slice:", event)
|
||||||
if (this.currentSlice.type === "question" && event !== undefined) {
|
if (this.currentSlice.type === "question" && event !== undefined) {
|
||||||
const answerObj = {
|
const answerObj = {
|
||||||
sectionId: this.currentSlice.section.id,
|
sectionId: this.currentSlice.section.id,
|
||||||
@@ -116,7 +117,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const nextConfig = this.currentSlice.next
|
const nextConfig = this.currentSlice.next
|
||||||
//console.log("Navegando desde slice:", this.currentSliceId, "con configuración next:", nextConfig)
|
console.log("Navegando desde slice:", this.currentSliceId, "con configuración next:", nextConfig)
|
||||||
if (!nextConfig) {
|
if (!nextConfig) {
|
||||||
////console.log("Encuesta finalizada", this.answers)
|
////console.log("Encuesta finalizada", this.answers)
|
||||||
return
|
return
|
||||||
@@ -128,13 +129,15 @@ export default {
|
|||||||
previousSlices.push(this.currentSliceId)
|
previousSlices.push(this.currentSliceId)
|
||||||
localStorage.setItem('previous-slices', JSON.stringify(previousSlices))
|
localStorage.setItem('previous-slices', JSON.stringify(previousSlices))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof nextConfig === "string") {
|
if (typeof nextConfig === "string") {
|
||||||
// Navegación lineal
|
// Navegación lineal
|
||||||
|
console.log("--- Navegación LINEAL (string) al slice:", nextConfig)
|
||||||
this.currentSliceId = nextConfig
|
this.currentSliceId = nextConfig
|
||||||
} else if (typeof nextConfig === "object") {
|
} else if (typeof nextConfig === "object") {
|
||||||
// Navegación condicional por valor de respuesta
|
// Navegación condicional por valor de respuesta
|
||||||
const nextSlice = nextConfig[event]
|
console.log("--- Navegación CONDICIONAL (object) al slice:", nextConfig)
|
||||||
|
const nextSlice = nextConfig[event.value]
|
||||||
if (nextSlice) {
|
if (nextSlice) {
|
||||||
this.currentSliceId = nextSlice
|
this.currentSliceId = nextSlice
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user