|
6 | 6 | <flow-form |
7 | 7 | ref="flowform" |
8 | 8 | v-on:complete="onComplete" |
9 | | - v-on:submit="onSubmit" |
10 | 9 | v-bind:questions="questions" |
11 | 10 | v-bind:language="language" |
12 | 11 | v-bind:progressbar="false" |
|
15 | 14 | <!-- We've overriden the default "complete" slot content --> |
16 | 15 | <template v-slot:complete> |
17 | 16 | <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 > 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 > Ticket status</span> |
| 29 | + <span class="fh2">Good news - the wheels are turning, your ticket is being processed!😉</span> |
| 30 | + </div> |
24 | 31 | </div> |
25 | 32 | </template> |
26 | 33 |
|
27 | 34 | <!-- We've overriden the default "completeButton" slot content --> |
28 | 35 | <template v-slot:completeButton> |
29 | | - <div class="f-submit" v-if="!submitted"> |
| 36 | + <div class="f-submit"> |
30 | 37 | <!-- Leave empty to hide default submit button --> |
31 | 38 | </div> |
32 | 39 | </template> |
|
54 | 61 | }, |
55 | 62 | data() { |
56 | 63 | return { |
57 | | - submitted: false, |
| 64 | + loading: false, |
58 | 65 | completed: false, |
59 | 66 | language: new LanguageModel(), |
60 | 67 | // Create question list with QuestionModel instances |
61 | 68 | questions: [ |
62 | 69 | new QuestionModel({ |
63 | 70 | id: 'multiple_choice', |
64 | | - tagline: "Welcome to our support page!", |
| 71 | + tagline: "Welcome to our demo support page!", |
65 | 72 | title: 'Hi 👋, how can we help you today?', |
66 | 73 | type: QuestionType.MultipleChoice, |
67 | 74 | multiple: false, |
|
117 | 124 | multiple: false, |
118 | 125 | required: true, |
119 | 126 | 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: '#-#-#-#-#-#', |
127 | 128 | jump: { |
128 | 129 | _other: '_submit' |
129 | 130 | } |
|
135 | 136 | type: QuestionType.LongText, |
136 | 137 | required: true, |
137 | 138 | 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 | | - } |
148 | 139 | }) |
149 | 140 | ] |
150 | 141 | } |
151 | 142 | }, |
152 | | - mounted() { |
153 | | - document.addEventListener('keyup', this.onKeyListener) |
154 | | - }, |
155 | | - beforeDestroy() { |
156 | | - document.removeEventListener('keyup', this.onKeyListener) |
157 | | - }, |
158 | 143 | 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 | | -
|
168 | 144 | /* eslint-disable-next-line no-unused-vars */ |
169 | 145 | onComplete(completed, questionList) { |
170 | 146 | // This method is called whenever the "completed" status is changed. |
171 | 147 | this.completed = completed |
172 | | - }, |
173 | 148 |
|
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 | +
|
178 | 153 | this.onSendData() |
179 | 154 | }, |
180 | 155 | |
181 | 156 | 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() |
185 | 159 |
|
186 | | - this.submitted = true |
| 160 | + this.loading = true |
187 | 161 |
|
188 | 162 | /* eslint-disable-next-line no-unused-vars */ |
189 | | - const data = this.getData() |
| 163 | + |
190 | 164 | /* |
191 | 165 | You can use Fetch API to send the data to your server, eg.: |
192 | 166 |
|
|
198 | 172 | body: JSON.stringify(data) |
199 | 173 | }) |
200 | 174 | */ |
| 175 | +
|
| 176 | + setTimeout(() => { |
| 177 | + self.loading = false |
| 178 | + }, 1500) |
201 | 179 | }, |
202 | 180 |
|
203 | 181 | getData() { |
|
222 | 200 | }, |
223 | 201 |
|
224 | 202 | 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() |
227 | 204 | } |
228 | 205 | } |
229 | 206 | } |
|
0 commit comments