Skip to content

Commit 2ab0cdb

Browse files
committed
Merge branch 'master' into feature/vue3-support
2 parents 26a9f9e + 681d98c commit 2ab0cdb

25 files changed

+914
-550
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
## Creating a pull request
2424

2525
* Make your changes on a feature branch. Follow the code style of the project, including indentation.
26+
* Make sure your commit messages are short, descriptive, and written in English.
2627
* Create a new PR with the code changes.
2728
* The PR description should clearly describe the problem and solution, with a reference to the appropriate issue if applicable.
2829

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,22 @@ And then in your App.vue file:
143143
HTML:
144144

145145
```html
146+
<!DOCTYPE html>
146147
<html>
147148
<head>
148149
<!-- Requires Vue version 2.6.x -->
149150
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script>
150151
<!-- Flow Form -->
151-
<script src="https://unpkg.com/@ditdot-dev/vue-flow-form@1.1.6"></script>
152+
<script src="https://unpkg.com/@ditdot-dev/vue-flow-form@1.1.7"></script>
152153
<!-- Flow Form base CSS -->
153-
<link rel="stylesheet" href="https://unpkg.com/@ditdot-dev/vue-flow-form@1.1.6/dist/vue-flow-form.min.css">
154+
<link rel="stylesheet" href="https://unpkg.com/@ditdot-dev/vue-flow-form@1.1.7/dist/vue-flow-form.min.css">
154155
<!-- Optional theme.css -->
155-
<link rel="stylesheet" href="https://unpkg.com/@ditdot-dev/vue-flow-form@1.1.6/dist/vue-flow-form.theme-minimal.min.css">
156+
<link rel="stylesheet" href="https://unpkg.com/@ditdot-dev/vue-flow-form@1.1.7/dist/vue-flow-form.theme-minimal.min.css">
156157
<!-- Optional font -->
157158
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;900&amp;display=swap">
158159
</head>
159160
<body>
160-
<div id="app">
161-
<flow-form v-bind:questions="questions" v-bind:language="language" />
162-
</div>
161+
<div id="app"></div>
163162
<script src="app.js"></script>
164163
</body>
165164
</html>
@@ -170,6 +169,7 @@ JavaScript (content of app.js):
170169
```js
171170
var app = new Vue({
172171
el: '#app',
172+
template: '<flow-form v-bind:questions="questions" v-bind:language="language" />',
173173
data: function() {
174174
return {
175175
language: new FlowForm.LanguageModel({

examples/questionnaire/Example.vue

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,37 @@
102102
type: QuestionType.Email,
103103
required: true,
104104
placeholder: 'Start typing here...'
105+
}),
106+
new QuestionModel({
107+
id: 'multiple_choice_image',
108+
tagline: "Let's take it one step further...",
109+
title: 'Tell us what is your favorite social network hangout.',
110+
helpTextShow: false,
111+
type: QuestionType.MultiplePictureChoice,
112+
multiple: false,
113+
required: true,
114+
options: [
115+
new ChoiceOption({
116+
imageSrc: require('./assets/images/facebook.png'),
117+
imageAlt: 'Facebook logo',
118+
label: 'Facebook'
119+
}),
120+
new ChoiceOption({
121+
imageSrc: require('./assets/images/twitter.png'),
122+
imageAlt: 'Twitter logo',
123+
label: 'Twitter'
124+
}),
125+
new ChoiceOption({
126+
imageSrc: require('./assets/images/instagram.png'),
127+
imageAlt: 'Instagram logo',
128+
label: 'Instagram'
129+
}),
130+
new ChoiceOption({
131+
imageSrc: require('./assets/images/tiktok.png'),
132+
imageAlt: 'TikTok logo',
133+
label: 'TikTok'
134+
}),
135+
]
105136
}),
106137
new QuestionModel({
107138
id: 'phone',
9.99 KB
Loading
14.7 KB
Loading
10.3 KB
Loading
10.4 KB
Loading

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)