|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+<template lang="pug">
|
|
|
2
|
+//- br
|
|
|
3
|
+//- br
|
|
|
4
|
+//- article
|
|
|
5
|
+//- form(@submit.prevent="onSubmit")
|
|
|
6
|
+//- .aspects
|
|
|
7
|
+//- .aspect(
|
|
|
8
|
+//- v-for="(aspect, i) in aspects"
|
|
|
9
|
+//- )
|
|
|
10
|
+//- label {{aspect.seeker_question}}
|
|
|
11
|
+//- //- label {{aspect.employer_question}}
|
|
|
12
|
+//- br
|
|
|
13
|
+//- br
|
|
|
14
|
+//- .aspect--response
|
|
|
15
|
+//- .aspect--answers
|
|
|
16
|
+//- h3 {{aspect.answers[0]}}
|
|
|
17
|
+//- h3 {{aspect.answers[1]}}
|
|
|
18
|
+//- .aspect--radio-buttons
|
|
|
19
|
+//- input(type="radio" :id="'q'+(i+1)+'_a1'" :name="'q'+(i+1)" value="a1" v-model="questionnaireAnswers[i]")
|
|
|
20
|
+//- input(type="radio" :id="'q'+(i+1)+'_a2'" :name="'q'+(i+1)" value="a2" v-model="questionnaireAnswers[i]")
|
|
|
21
|
+//- input(type="radio" :id="'q'+(i+1)+'_a3'" :name="'q'+(i+1)" value="a3" v-model="questionnaireAnswers[i]")
|
|
|
22
|
+//- input(type="radio" :id="'q'+(i+1)+'_a4'" :name="'q'+(i+1)" value="a4" v-model="questionnaireAnswers[i]")
|
|
|
23
|
+//- input(type="radio" :id="'q'+(i+1)+'_a5'" :name="'q'+(i+1)" value="a5" v-model="questionnaireAnswers[i]")
|
|
|
24
|
+//- br
|
|
|
25
|
+//- br
|
|
|
26
|
+//- br
|
|
|
27
|
+//- w-flex
|
|
|
28
|
+//- w-button.ma1.grow(type="submit" bg-color="success")
|
|
|
29
|
+//- w-icon.mr1 wi-check
|
|
|
30
|
+//- | SUBMIT ANSWERS
|
|
|
31
|
+br
|
|
|
32
|
+h3 Current Step: {{currentStep}}
|
|
|
33
|
+br
|
|
|
34
|
+ul
|
|
|
35
|
+ li(v-for="question in onboardingStep")
|
|
|
36
|
+ p {{question}}
|
|
|
37
|
+br
|
|
|
38
|
+button(@click="goToStep(currentStep - 1)") previous
|
|
|
39
|
+br
|
|
|
40
|
+button(@click="goToStep(currentStep + 1)") next
|
|
|
41
|
+</template>
|
|
|
42
|
+<script>
|
|
|
43
|
+import aspects from '../utils/aspects'
|
|
|
44
|
+import { surveyFactory } from '@/utils'
|
|
|
45
|
+import { allSteps, possible } from '@/utils/lang'
|
|
|
46
|
+
|
|
|
47
|
+
|
|
|
48
|
+export default {
|
|
|
49
|
+ name:'OnboardingView',
|
|
|
50
|
+ props: {
|
|
|
51
|
+ pid: {
|
|
|
52
|
+ type: Number,
|
|
|
53
|
+ default: () => 45,
|
|
|
54
|
+ },
|
|
|
55
|
+ },
|
|
|
56
|
+ data: () => {
|
|
|
57
|
+ let num_of_ans = aspects.length // need 1 answer for every aspect question
|
|
|
58
|
+ return {
|
|
|
59
|
+ onboardingQuestions: [],
|
|
|
60
|
+ currentStep: 0,
|
|
|
61
|
+ onboardingAnswers: [],
|
|
|
62
|
+ validSurvey: null,
|
|
|
63
|
+ questionnaireAnswers: Array(num_of_ans).join(".").split(".")
|
|
|
64
|
+ }
|
|
|
65
|
+ },
|
|
|
66
|
+ computed:{
|
|
|
67
|
+ aspects() {
|
|
|
68
|
+ return aspects
|
|
|
69
|
+ },
|
|
|
70
|
+ onboardingStep(){
|
|
|
71
|
+ if(!this.onboardingQuestions.length) return []
|
|
|
72
|
+ return this.onboardingQuestions[this.currentStep]
|
|
|
73
|
+ }
|
|
|
74
|
+ },
|
|
|
75
|
+ async created(){
|
|
|
76
|
+ this.validSurvey = await surveyFactory.createSurvey(
|
|
|
77
|
+ allSteps['usa'],
|
|
|
78
|
+ possible['usa']['roles'],
|
|
|
79
|
+ )
|
|
|
80
|
+ var step = []
|
|
|
81
|
+ var fooSteps = [...this.validSurvey.steps]
|
|
|
82
|
+ while(fooSteps.length > (this.validSurvey.steps.length % 3)){
|
|
|
83
|
+ var q = fooSteps.shift()
|
|
|
84
|
+ step.push(q)
|
|
|
85
|
+ if(step.length == 3){
|
|
|
86
|
+ this.onboardingQuestions.push(step)
|
|
|
87
|
+ step = []
|
|
|
88
|
+ }
|
|
|
89
|
+ }
|
|
|
90
|
+ var last_step = [...fooSteps]
|
|
|
91
|
+ this.onboardingQuestions.push(last_step)
|
|
|
92
|
+ },
|
|
|
93
|
+ methods: {
|
|
|
94
|
+ onSubmit() {
|
|
|
95
|
+ this.questionnaireAnswers.forEach((ans,ind)=>{
|
|
|
96
|
+ console.log(`Question ${ind+1} was ${ans==''? 'left blank.' : `answered ${ans}`}`)
|
|
|
97
|
+ })
|
|
|
98
|
+ },
|
|
|
99
|
+ goToStep(num){
|
|
|
100
|
+ if(num < 0){
|
|
|
101
|
+ this.currentStep = this.onboardingQuestions.length-1
|
|
|
102
|
+ }
|
|
|
103
|
+ else if(num >= this.onboardingQuestions.length) {
|
|
|
104
|
+ this.currentStep = 0
|
|
|
105
|
+ }
|
|
|
106
|
+ else
|
|
|
107
|
+ this.currentStep = num
|
|
|
108
|
+ },
|
|
|
109
|
+ },
|
|
|
110
|
+}
|
|
|
111
|
+</script>
|
|
|
112
|
+<style>
|
|
|
113
|
+.aspects{
|
|
|
114
|
+ display: flex;
|
|
|
115
|
+ flex-direction:column;
|
|
|
116
|
+}
|
|
|
117
|
+.aspect--response{
|
|
|
118
|
+ display: flex;
|
|
|
119
|
+ flex-direction: column;
|
|
|
120
|
+}
|
|
|
121
|
+.aspect--answers{
|
|
|
122
|
+ display: flex;
|
|
|
123
|
+ flex-direction: row;
|
|
|
124
|
+ justify-content: space-between;
|
|
|
125
|
+}
|
|
|
126
|
+.aspect--radio-buttons{
|
|
|
127
|
+ width: 90%;
|
|
|
128
|
+ margin: auto;
|
|
|
129
|
+ display: flex;
|
|
|
130
|
+ flex-direction: row;
|
|
|
131
|
+ justify-content: space-between;
|
|
|
132
|
+}
|
|
|
133
|
+</style>
|