Skip to content

Commit 9de91b2

Browse files
authored
Merge pull request #174 from ditdot-dev/test/components
Test/components
2 parents 5e6d95c + 0f5591d commit 9de91b2

File tree

1 file changed

+58
-40
lines changed

1 file changed

+58
-40
lines changed

examples/support-page/Example.vue

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@
66
<flow-form
77
ref="flowform"
88
v-on:complete="onComplete"
9-
v-bind:questions="questions"
109
v-bind:language="language"
1110
v-bind:progressbar="false"
1211
v-bind:standalone="true"
1312
>
13+
<question
14+
v-for="(question, index) in questions"
15+
v-bind="question"
16+
v-bind:key="'m' + index"
17+
v-model="question.model"
18+
>
19+
</question>
20+
1421
<!-- Custom content for the Complete/Submit screen slots in the FlowForm component -->
15-
<!-- We've overriden the default "complete" slot content -->
1622
<template v-slot:complete>
1723
<div class="f-section-wrap">
18-
<div v-if="questions[0].answer === 'technical_issue'">
24+
<div v-if="questions[0].model === 'technical_issue'">
1925
<span class="f-tagline">Submit issue &gt; Step 3/3</span>
2026
<div v-if="loading">
2127
<span class="fh2">Please wait, submitting...</span>
@@ -27,13 +33,17 @@
2733
</div>
2834
<div v-else>
2935
<span class="f-tagline">Support page &gt; Ticket status</span>
30-
<span class="fh2">Good news - the wheels are turning, your ticket is being processed!😉</span>
31-
<p class="f-description"><span>Have a great day!</span></p>
36+
<div v-if="loading">
37+
<span class="fh2">Please wait, checking...</span>
38+
</div>
39+
<div v-else>
40+
<span class="fh2">Good news - the wheels are turning, your ticket No. {{ formatTicket(questions[2].model) }} is being processed!😉</span>
41+
<p class="f-description"><span>Have a great day!</span></p>
42+
</div>
3243
</div>
3344
</div>
3445
</template>
35-
36-
<!-- We've overriden the default "completeButton" slot content -->
46+
<!-- We've overriden the default "complete" slot content -->
3747
<template v-slot:completeButton>
3848
<div class="f-submit">
3949
<!-- Leave empty to hide default submit button -->
@@ -51,94 +61,98 @@
5161
5262
// Import necessary components and classes
5363
import FlowForm from '../../src/components/FlowForm.vue'
54-
import QuestionModel, { QuestionType, ChoiceOption, LinkOption } from '../../src/models/QuestionModel'
64+
import Question from '../../src/components/Question.vue'
5565
import LanguageModel from '../../src/models/LanguageModel'
5666
// If using the npm package, use the following line instead of the ones above.
57-
// import FlowForm, { QuestionModel, QuestionType, ChoiceOption, LinkOption, LanguageModel } from '@ditdot-dev/vue-flow-form'
67+
// import FlowForm, Question, { LanguageModel } from '@ditdot-dev/vue-flow-form'
5868
5969
export default {
6070
name: 'example',
6171
components: {
62-
FlowForm
72+
FlowForm,
73+
Question
6374
},
6475
data() {
6576
return {
6677
loading: false,
6778
completed: false,
6879
language: new LanguageModel(),
69-
// Create question list with QuestionModel instances
7080
questions: [
71-
new QuestionModel({
81+
{
82+
type: 'multiplechoice',
7283
id: 'multiple_choice',
73-
tagline: "Welcome to our demo support page!",
84+
tagline: 'Welcome to our demo support page!',
7485
title: 'Hi 👋, how can we help you today?',
75-
type: QuestionType.MultipleChoice,
7686
multiple: false,
7787
required: true,
7888
helpTextShow: false,
7989
options: [
80-
new ChoiceOption({
90+
{
8191
label: 'I have a technical issue',
8292
value: 'technical_issue'
83-
}),
84-
new ChoiceOption({
93+
},
94+
{
8595
label: 'I wish to check my ticket status',
8696
value: 'enter_ticket'
87-
}),
97+
},
8898
],
8999
jump: {
90100
technical_issue: 'technical_issue',
91101
enter_ticket: 'enter_ticket'
92-
}
93-
}),
94-
new QuestionModel({
102+
},
103+
model: '',
104+
},
105+
{
106+
type: 'multiplechoice',
95107
id: 'technical_issue',
96108
tagline: 'Submit issue > Step 1/3',
97109
title: 'Have you read our technical FAQ?',
98-
type: QuestionType.MultipleChoice,
99110
multiple: false,
100111
required: true,
101112
helpTextShow: false,
102113
description: "Here you'll find answers to",
103114
descriptionLink: [
104-
new LinkOption({
115+
{
105116
url: '#',
106117
text: 'FAQs',
107118
target: '_self'
108-
})
119+
}
109120
],
110121
options: [
111-
new ChoiceOption({
122+
{
112123
label: 'Yes, but I couldn’t find the answer',
113124
value: 'faq_no'
114-
}),
125+
}
115126
],
116127
jump: {
117128
faq_no: 'faq_no'
118-
}
119-
}),
120-
new QuestionModel({
129+
},
130+
model: '',
131+
},
132+
{
133+
type: 'text',
121134
id: 'enter_ticket',
122135
tagline: 'Support page > Ticket status',
123136
title: 'Please enter your 6-digit code.',
124137
subtitle: 'You received this when you reported your problem.',
125-
type: QuestionType.Text,
126-
multiple: false,
138+
multiple: false,
127139
required: true,
128140
mask: '#-#-#-#-#-#',
129141
placeholder: '#-#-#-#-#-#',
130142
jump: {
131143
_other: '_submit'
132-
}
133-
}),
134-
new QuestionModel({
135-
id: 'faq_no',
144+
},
145+
model: ''
146+
},
147+
{
148+
type: 'longtext',
149+
id: "faq_no",
136150
tagline: 'Submit issue > Step 2/3',
137151
title: 'Please describe your problem.',
138-
type: QuestionType.LongText,
139152
required: true,
140153
placeholder: 'Start typing here...',
141-
})
154+
model: ''
155+
}
142156
]
143157
}
144158
},
@@ -183,10 +197,10 @@
183197
questions: [],
184198
answers: []
185199
}
186-
200+
187201
this.questions.forEach(question => {
188202
if (question.title) {
189-
let answer = question.answer
203+
let answer = question.model
190204
if (Array.isArray(answer)) {
191205
answer = answer.join(', ')
192206
}
@@ -195,10 +209,14 @@
195209
data.answers.push(answer)
196210
}
197211
})
198-
212+
199213
return data
200214
},
201215
216+
formatTicket(ticket) {
217+
return ticket && ticket.replace(/-/g, '')
218+
},
219+
202220
getTicket() {
203221
return Math.floor(Math.random() * (999999 - 100000) + 100000).toString()
204222
}

0 commit comments

Comments
 (0)