Skip to content

Commit 85b6d91

Browse files
committed
Support example submit screen mod
1 parent 3daacc3 commit 85b6d91

File tree

1 file changed

+31
-54
lines changed

1 file changed

+31
-54
lines changed

examples/support-page/Example.vue

Lines changed: 31 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<flow-form
77
ref="flowform"
88
v-on:complete="onComplete"
9-
v-on:submit="onSubmit"
109
v-bind:questions="questions"
1110
v-bind:language="language"
1211
v-bind:progressbar="false"
@@ -15,18 +14,26 @@
1514
<!-- We've overriden the default "complete" slot content -->
1615
<template v-slot:complete>
1716
<div class="section-wrap">
18-
<p>
19-
<span class="fh2">Thank you for visiting our technical support page. 🙏</span>
20-
<span class="section-text">
21-
Have a great day!
22-
</span>
23-
</p>
17+
<div v-if="questions[0].answer === 'technical_issue'">
18+
<span class="f-tagline">Submit issue &gt; Step 3/3</span>
19+
<div v-if="loading">
20+
<span class="fh2">Please wait, submitting your ticket.</span>
21+
</div>
22+
<div v-else>
23+
<span class="fh2">Your ticket number is: {{ getTicket() }}</span>
24+
<p class="description"><span>Thank You. Our support team will contact you as soon as possible.</span></p>
25+
</div>
26+
</div>
27+
<div v-else>
28+
<span class="f-tagline">Support page &gt; Ticket status</span>
29+
<span class="fh2">Good news - the wheels are turning, your ticket is being processed!😉</span>
30+
</div>
2431
</div>
2532
</template>
2633

2734
<!-- We've overriden the default "completeButton" slot content -->
2835
<template v-slot:completeButton>
29-
<div class="f-submit" v-if="!submitted">
36+
<div class="f-submit">
3037
<!-- Leave empty to hide default submit button -->
3138
</div>
3239
</template>
@@ -54,14 +61,14 @@
5461
},
5562
data() {
5663
return {
57-
submitted: false,
64+
loading: false,
5865
completed: false,
5966
language: new LanguageModel(),
6067
// Create question list with QuestionModel instances
6168
questions: [
6269
new QuestionModel({
6370
id: 'multiple_choice',
64-
tagline: "Welcome to our support page!",
71+
tagline: "Welcome to our demo support page!",
6572
title: 'Hi 👋, how can we help you today?',
6673
type: QuestionType.MultipleChoice,
6774
multiple: false,
@@ -117,13 +124,7 @@
117124
multiple: false,
118125
required: true,
119126
mask: '#-#-#-#-#-#',
120-
placeholder: '#-#-#-#-#-#'
121-
}),
122-
new QuestionModel({
123-
id: 'ticket_status',
124-
tagline: 'Support page > Ticket status',
125-
title: 'Good news - the wheels are turning, your ticket is being processed!😉',
126-
type: QuestionType.SectionBreak,
127+
placeholder: '#-#-#-#-#-#',
127128
jump: {
128129
_other: '_submit'
129130
}
@@ -135,58 +136,31 @@
135136
type: QuestionType.LongText,
136137
required: true,
137138
placeholder: 'Start typing here...',
138-
}),
139-
new QuestionModel({
140-
id: 'ticket',
141-
tagline: 'Submit issue > Step 3/3',
142-
title: 'Your ticket number is: ' + this.getTicket(),
143-
description: 'Thank You. Our support team will contact you as soon as possible.',
144-
type: QuestionType.SectionBreak,
145-
jump: {
146-
_other: '_submit'
147-
}
148139
})
149140
]
150141
}
151142
},
152-
mounted() {
153-
document.addEventListener('keyup', this.onKeyListener)
154-
},
155-
beforeDestroy() {
156-
document.removeEventListener('keyup', this.onKeyListener)
157-
},
158143
methods: {
159-
onKeyListener($event) {
160-
// We've overriden the default "complete" slot so
161-
// we need to implement the "keyup" listener manually.
162-
163-
if ($event.key === 'Enter' && this.completed && !this.submitted) {
164-
this.onSendData()
165-
}
166-
},
167-
168144
/* eslint-disable-next-line no-unused-vars */
169145
onComplete(completed, questionList) {
170146
// This method is called whenever the "completed" status is changed.
171147
this.completed = completed
172-
},
173148
174-
/* eslint-disable-next-line no-unused-vars */
175-
onSubmit(questionList) {
176-
// This method will only be called if you don't override the
177-
// completeButton slot.
149+
// Set `submitted` to true so the form knows not to allow back/forward
150+
// navigation anymore.
151+
this.$refs.flowform.submitted = true
152+
178153
this.onSendData()
179154
},
180155
181156
onSendData() {
182-
// Set `submitted` to true so the form knows not to allow back/forward
183-
// navigation anymore.
184-
this.$refs.flowform.submitted = true
157+
const self = this
158+
const data = this.getData()
185159
186-
this.submitted = true
160+
this.loading = true
187161
188162
/* eslint-disable-next-line no-unused-vars */
189-
const data = this.getData()
163+
190164
/*
191165
You can use Fetch API to send the data to your server, eg.:
192166
@@ -198,6 +172,10 @@
198172
body: JSON.stringify(data)
199173
})
200174
*/
175+
176+
setTimeout(() => {
177+
self.loading = false
178+
}, 1500)
201179
},
202180
203181
getData() {
@@ -222,8 +200,7 @@
222200
},
223201
224202
getTicket() {
225-
const ticket = Math.floor(Math.random() * (999999 - 100000) + 100000).toString();
226-
return ticket
203+
return Math.floor(Math.random() * (999999 - 100000) + 100000).toString()
227204
}
228205
}
229206
}

0 commit comments

Comments
 (0)