Skip to content

Commit d0e8489

Browse files
committed
Revert changes to questionnaire example
1 parent 6743836 commit d0e8489

File tree

1 file changed

+177
-12
lines changed

1 file changed

+177
-12
lines changed

examples/questionnaire/Example.vue

Lines changed: 177 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,167 @@
9090
// Create question list with QuestionModel instances
9191
questions: [
9292
new QuestionModel({
93-
id: 'file',
94-
title: 'File here',
95-
type: QuestionType.File,
93+
id: 'first_name',
94+
tagline: 'Hi! Welcome to our demo survey 😊',
95+
title: 'What is your first name?',
96+
type: QuestionType.Text,
9697
required: true,
97-
accept: 'image/*',
98+
placeholder: 'Start typing here...'
99+
}),
100+
new QuestionModel({
101+
id: 'email',
102+
tagline: "Nice to meet you 👀, let's continue",
103+
title: 'Provide an example email.',
104+
type: QuestionType.Email,
105+
required: true,
106+
placeholder: 'Start typing here...'
107+
}),
108+
new QuestionModel({
109+
id: 'multiple_choice_image',
110+
tagline: "Let's take it one step further...",
111+
title: 'Tell us what is your favorite social network hangout.',
112+
helpTextShow: false,
113+
type: QuestionType.MultiplePictureChoice,
114+
multiple: false,
115+
required: true,
116+
options: [
117+
new ChoiceOption({
118+
imageSrc: require('./assets/images/facebook.png'),
119+
imageAlt: 'Facebook logo',
120+
label: 'Facebook'
121+
}),
122+
new ChoiceOption({
123+
imageSrc: require('./assets/images/twitter.png'),
124+
imageAlt: 'Twitter logo',
125+
label: 'Twitter'
126+
}),
127+
new ChoiceOption({
128+
imageSrc: require('./assets/images/instagram.png'),
129+
imageAlt: 'Instagram logo',
130+
label: 'Instagram'
131+
}),
132+
new ChoiceOption({
133+
imageSrc: require('./assets/images/tiktok.png'),
134+
imageAlt: 'TikTok logo',
135+
label: 'TikTok'
136+
}),
137+
]
138+
}),
139+
new QuestionModel({
140+
id: 'phone',
141+
title: 'Doing great! 👍 Go ahead and try with a phone number.',
142+
type: QuestionType.Phone,
143+
required: true,
144+
mask: '(###) ###-####'
145+
}),
146+
new QuestionModel({
147+
id: 'movies',
148+
title: 'List your favorite movies. 🍿',
149+
type: QuestionType.LongText,
150+
required: true,
151+
placeholder: 'Start typing here...'
152+
}),
153+
new QuestionModel({
154+
id: 'multiple_choice',
155+
tagline: 'FYI, You can always go back 👈, use the up arrow on the bottom.',
156+
title: 'Multiple choice question:',
157+
helpTextShow: false,
158+
type: QuestionType.MultipleChoice,
159+
multiple: false,
160+
allowOther: true,
161+
required: true,
162+
options: [
163+
new ChoiceOption({
164+
label: 'Answer 1'
165+
}),
166+
new ChoiceOption({
167+
label: 'Answer 2'
168+
}),
169+
new ChoiceOption({
170+
label: 'Answer 3'
171+
})
172+
]
173+
}),
174+
new QuestionModel({
175+
id: 'multiple_choices',
176+
title: 'Multiple choices question:',
177+
type: QuestionType.MultipleChoice,
98178
multiple: true,
99-
description: 'Upload your profile image here',
100-
max: 5,
101-
min: 1,
102-
maxSize: 1024 * 1024 * 1.33
179+
helpText: 'Select all that apply. 👇',
180+
required: true,
181+
options: [
182+
new ChoiceOption({
183+
label: 'Answer 1'
184+
}),
185+
new ChoiceOption({
186+
label: 'Answer 2'
187+
}),
188+
new ChoiceOption({
189+
label: 'Answer 3'
190+
}),
191+
new ChoiceOption({
192+
label: 'Answer 4'
193+
})
194+
]
195+
}),
196+
new QuestionModel({
197+
id: 'break_1',
198+
title: 'Awesome, thank you. 🙏',
199+
content: 'You arrived at the section break of our little demo survey. To continue exploring, just press enter or use the continue button.',
200+
description: 'Note: We will take a look at our multiple path feature next.',
201+
type: QuestionType.SectionBreak
202+
}),
203+
new QuestionModel({
204+
id: 'choose_path',
205+
tagline: 'Where would you like to go? 🤔',
206+
title: 'Choose your path:',
207+
type: QuestionType.Dropdown,
208+
multiple: false,
209+
placeholder: 'Select',
210+
inline: true,
211+
required: true,
212+
options: [
213+
new ChoiceOption({
214+
label: 'Path A'
215+
}),
216+
new ChoiceOption({
217+
label: 'Path B',
218+
value: 'path_b'
219+
})
220+
],
221+
jump: {
222+
path_b: 'path_b'
223+
}
224+
}),
225+
new QuestionModel({
226+
id: 'path_a',
227+
title: 'Excellent choice! 🥳',
228+
content: 'Press enter or use the continue button for the final submit screen.',
229+
type: QuestionType.SectionBreak,
230+
jump: {
231+
_other: '_submit'
232+
}
233+
}),
234+
new QuestionModel({
235+
id: 'path_b',
236+
tagline: 'Path B',
237+
title: 'Hmm, are you sure?',
238+
helpText: 'Path A sounds like a winner! 😉',
239+
type: QuestionType.MultipleChoice,
240+
multiple: false,
241+
required: true,
242+
options: [
243+
new ChoiceOption({
244+
label: 'Ok, let\'s go with A',
245+
value: 'path_a'
246+
}),
247+
new ChoiceOption({
248+
label: 'Yes, finish the survey'
249+
})
250+
],
251+
jump: {
252+
path_a: 'path_a'
253+
}
103254
})
104255
]
105256
}
@@ -150,19 +301,33 @@
150301
151302
fetch(url, {
152303
method: 'POST',
153-
body: data
304+
headers: {
305+
'Content-Type': 'application/json'
306+
},
307+
body: JSON.stringify(data)
154308
})
155309
*/
156310
},
157311
158312
getData() {
159-
const formData = new FormData()
313+
const data = {
314+
questions: [],
315+
answers: []
316+
}
160317
161318
this.questions.forEach(question => {
162-
formData.append(question.id, question.answer)
319+
if (question.title) {
320+
let answer = question.answer
321+
if (Array.isArray(answer)) {
322+
answer = answer.join(', ')
323+
}
324+
325+
data.questions.push(question.title)
326+
data.answers.push(answer)
327+
}
163328
})
164329
165-
return formData
330+
return data
166331
}
167332
}
168333
}

0 commit comments

Comments
 (0)