Skip to content

Commit fa8bb21

Browse files
committed
Create components based on data
1 parent cf82e73 commit fa8bb21

File tree

1 file changed

+90
-85
lines changed

1 file changed

+90
-85
lines changed

examples/support-page/Example.vue

Lines changed: 90 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -10,86 +10,12 @@
1010
v-bind:progressbar="false"
1111
v-bind:standalone="true"
1212
>
13-
<question
14-
type="multipleChoice"
15-
id="multiple_choice"
16-
tagline="Welcome to our demo support page!"
17-
title="Hi 👋, how can we help you today?"
18-
v-bind:multiple="false"
19-
v-bind:helpTextShow="false"
20-
v-bind:options="[
21-
{
22-
label: 'I have a technical issue',
23-
value: 'technical_issue'
24-
},
25-
{
26-
label: 'I wish to check my ticket status',
27-
value: 'enter_ticket'
28-
},
29-
]"
30-
v-bind:jump="{
31-
technical_issue: 'technical_issue',
32-
enter_ticket: 'enter_ticket'
33-
}"
34-
>
35-
</question>
36-
<question
37-
type="multipleChoice"
38-
id="technical_issue"
39-
tagline="Submit issue > Step 1/3"
40-
title="Have you read our technical FAQ?"
41-
v-bind:multiple="false"
42-
required
43-
v-bind:helpTextShow="false"
44-
description="Here you'll find answers to"
45-
v-bind:descriptionLink="[
46-
{
47-
url: '#',
48-
text: 'FAQs',
49-
target: '_self'
50-
}
51-
]"
52-
v-bind:options="[
53-
{
54-
label: 'Yes, but I couldn’t find the answer',
55-
value: 'faq_no'
56-
}
57-
]"
58-
v-bind:jump="{
59-
faq_no: 'faq_no'
60-
}"
61-
>
62-
</question>
63-
<question
64-
type="text"
65-
id="enter_ticket"
66-
tagline="Support page > Ticket status"
67-
title="Please enter your 6-digit code."
68-
subtitle="You received this when you reported your problem."
69-
v-bind:multiple="false"
70-
required
71-
mask="#-#-#-#-#-#"
72-
placeholder="#-#-#-#-#-#"
73-
v-bind:jump="{
74-
_other: '_submit'
75-
}"
76-
v-model="ticket"
77-
>
78-
</question>
79-
<question
80-
id="faq_no"
81-
tagline="Submit issue > Step 2/3"
82-
title="Please describe your problem."
83-
type="longText"
84-
required
85-
placeholder="Start typing here..."
86-
>
87-
</question>
13+
<question v-for="(question, index) in questions" v-bind="question" v-bind:key="'m' + index" v-model="question.model"></question>
8814

8915
<!-- Custom content for the Complete/Submit screen slots in the FlowForm component -->
9016
<template v-slot:complete>
9117
<div class="f-section-wrap">
92-
<div v-if="answer === 'technical_issue'">
18+
<div v-if="questions[0].model === 'technical_issue'">
9319
<span class="f-tagline">Submit issue &gt; Step 3/3</span>
9420
<div v-if="loading">
9521
<span class="fh2">Please wait, submitting...</span>
@@ -101,7 +27,7 @@
10127
</div>
10228
<div v-else>
10329
<span class="f-tagline">Support page &gt; Ticket status</span>
104-
<span class="fh2">Good news - the wheels are turning, your ticket {{ ticket }} is being processed!😉</span>
30+
<span class="fh2">Good news - the wheels are turning, your ticket {{" No. " + formatTicket(questions[2].model) + " " }} is being processed!😉</span>
10531
<p class="f-description"><span>Have a great day!</span></p>
10632
</div>
10733
</div>
@@ -136,8 +62,83 @@
13662
loading: false,
13763
completed: false,
13864
language: new LanguageModel(),
139-
answer: '',
140-
ticket: '',
65+
questions: [
66+
{
67+
type: 'multiplechoice',
68+
id: 'multiple_choice',
69+
tagline: 'Welcome to our demo support page!',
70+
title: 'Hi 👋, how can we help you today?',
71+
multiple: false,
72+
required: true,
73+
helpTextShow: false,
74+
options: [
75+
{
76+
label: 'I have a technical issue',
77+
value: 'technical_issue'
78+
},
79+
{
80+
label: 'I wish to check my ticket status',
81+
value: 'enter_ticket'
82+
},
83+
],
84+
jump: {
85+
technical_issue: 'technical_issue',
86+
enter_ticket: 'enter_ticket'
87+
},
88+
model: null,
89+
},
90+
{
91+
type: 'multiplechoice',
92+
id: 'technical_issue',
93+
tagline: 'Submit issue > Step 1/3',
94+
title: 'Have you read our technical FAQ?',
95+
multiple: false,
96+
required: true,
97+
helpTextShow: false,
98+
description: "Here you'll find answers to",
99+
descriptionLink: [
100+
{
101+
url: '#',
102+
text: 'FAQs',
103+
target: '_self'
104+
}
105+
],
106+
options: [
107+
{
108+
label: 'Yes, but I couldn’t find the answer',
109+
value: 'faq_no'
110+
}
111+
],
112+
jump: {
113+
faq_no: 'faq_no'
114+
},
115+
model: null,
116+
},
117+
{
118+
type: 'text',
119+
id: 'enter_ticket',
120+
tagline: 'Support page > Ticket status',
121+
title: 'Please enter your 6-digit code.',
122+
subtitle: 'You received this when you reported your problem.',
123+
multiple: false,
124+
required: true,
125+
mask: '#-#-#-#-#-#',
126+
placeholder: '#-#-#-#-#-#',
127+
jump: {
128+
_other: '_submit'
129+
},
130+
model: null
131+
},
132+
{
133+
type: 'longText',
134+
id: "faq_no",
135+
tagline: 'Submit issue > Step 2/3',
136+
title: 'Please describe your problem.',
137+
required: true,
138+
placeholder: 'Start typing here...',
139+
model: null
140+
}
141+
]
141142
}
142143
},
143144
methods: {
@@ -155,7 +156,7 @@
155156
156157
onSendData() {
157158
const self = this
158-
// const data = this.getData()
159+
const data = this.getData()
159160
160161
this.loading = true
161162
@@ -175,16 +176,16 @@
175176
self.loading = false
176177
}, 1500)
177178
},
178-
/*
179+
179180
getData() {
180181
const data = {
181182
questions: [],
182183
answers: []
183184
}
184-
185+
185186
this.questions.forEach(question => {
186187
if (question.title) {
187-
let answer = question.answer
188+
let answer = question.model
188189
if (Array.isArray(answer)) {
189190
answer = answer.join(', ')
190191
}
@@ -193,9 +194,13 @@
193194
data.answers.push(answer)
194195
}
195196
})
196-
197+
197198
return data
198-
},*/
199+
},
200+
201+
formatTicket(ticket) {
202+
return ticket.replace(/-/g, '')
203+
},
199204
200205
getTicket() {
201206
return Math.floor(Math.random() * (999999 - 100000) + 100000).toString()

0 commit comments

Comments
 (0)