Просмотр исходного кода

:recycle: Refactored Onboarding and SurveyComplete based off of recent changes

tabs-content
tomit4 3 лет назад
Родитель
Сommit
4d6a2155d0

+ 1
- 1
frontend/src/components/onboarding/QuestionResponse.vue Просмотреть файл

1
 <template lang="pug">
1
 <template lang="pug">
2
 w-card.question
2
 w-card.question
3
-    p {{ question }}
3
+    p {{ question.survey_stage }}
4
     section.radio-buttons.w-flex.row.justify-space-between
4
     section.radio-buttons.w-flex.row.justify-space-between
5
         p(v-for='label in question.labels') {{ label }}
5
         p(v-for='label in question.labels') {{ label }}
6
     w-radios.w-flex.row.justify-space-between(
6
     w-radios.w-flex.row.justify-space-between(

+ 2
- 4
frontend/src/views/OnboardingView.vue Просмотреть файл

2
 main.view--onboarding
2
 main.view--onboarding
3
     article(
3
     article(
4
         style='display: flex; flex-direction: column; align-items: center'
4
         style='display: flex; flex-direction: column; align-items: center'
5
-        v-if='incomplete'
5
+        v-if='currentStep !== survey.steps.length'
6
     )
6
     )
7
         .answers(v-for='(value, key) in answered')
7
         .answers(v-for='(value, key) in answered')
8
             span(v-if='key == "name" && value && currentStep == 2') Hi {{ value }}!
8
             span(v-if='key == "name" && value && currentStep == 2') Hi {{ value }}!
25
             p {{ survey.steps[currentStep].invalidInputPrompt }}
25
             p {{ survey.steps[currentStep].invalidInputPrompt }}
26
 
26
 
27
         footer
27
         footer
28
-            p(v-if='currentStep != 0') You have completed: {{ currentStep - 1 }} / {{ survey.steps.length - 2 }} survey steps
28
+            p(v-if='currentStep != 0') You have completed: {{ currentStep }} / {{ survey.steps.length }} survey steps
29
 
29
 
30
     article(v-else)
30
     article(v-else)
31
         SurveyCompleteView(:answers='answered' :surveySteps='survey.steps')
31
         SurveyCompleteView(:answers='answered' :surveySteps='survey.steps')
49
         aspectQuestions: [],
49
         aspectQuestions: [],
50
         currentStep: 0,
50
         currentStep: 0,
51
         survey: null,
51
         survey: null,
52
-        incomplete: true,
53
         invalidResponse: false,
52
         invalidResponse: false,
54
     }),
53
     }),
55
     async created() {
54
     async created() {
58
     methods: {
57
     methods: {
59
         onSubmit() {
58
         onSubmit() {
60
             console.log(JSON.stringify(this.answered))
59
             console.log(JSON.stringify(this.answered))
61
-            this.incomplete = null
62
         },
60
         },
63
         goToStep(num) {
61
         goToStep(num) {
64
             this.currentStep = num
62
             this.currentStep = num

+ 32
- 11
frontend/src/views/SurveyCompleteView.vue Просмотреть файл

4
         h2 Thanks for Completing Our Survey!!
4
         h2 Thanks for Completing Our Survey!!
5
         h1 Please review your answers and let us know if you need to change anything.
5
         h1 Please review your answers and let us know if you need to change anything.
6
         br
6
         br
7
-        h1 Your Profile Info:
8
-        div(v-for='(answer, key) in answers')
9
-            span(v-if='answer && key != "aspects"')  Your {{ key }}: {{ answer }}
7
+        p(v-for='input in formInputs')
8
+            p(v-for='(value, key) in answers')
9
+                p(v-if='input.survey_stage == key && key !== "password"')
10
+                    p Your {{ key }}: {{ value }}
10
         br
11
         br
11
-        div(v-if="answers.aspects")
12
-            h1 Your Survey Answers:
13
-        div(v-for='(aspect, index) in answers.aspects')
14
-            div(v-if='aspect')
15
-                p {{ surveyObjects[index].response_key_prompt }}
16
-                p You Answered: {{ aspect }}
12
+        p(v-for='input in formDropdowns')
13
+            p(v-for='(value, key) in answers')
14
+                p(v-if='input.survey_stage == key')
15
+                    p Your {{ key }}: {{ value }}
16
+        br
17
+        p(v-for='(response, responseIndex) in questionResponses')
18
+            p(v-for='(value, key) in answers')
19
+                p(v-if='response.survey_stage == key') 
20
+                    p Survey Question {{ responseIndex + 1 }}: 
21
+                    p {{ key }} 
22
+                    p You Answered: {{ value }}
23
+                    br
17
         w-button.ma1(@click="changeAnswers") Change Answers
24
         w-button.ma1(@click="changeAnswers") Change Answers
18
         w-button.ma1(@click="finalSubmit") Submit Answers
25
         w-button.ma1(@click="finalSubmit") Submit Answers
19
 </template>
26
 </template>
32
     },
39
     },
33
     data: () => ({
40
     data: () => ({
34
         surveyObjects: [],
41
         surveyObjects: [],
42
+        formInputs: [],
43
+        questionResponses: [],
44
+        formDropdowns: [],
35
     }),
45
     }),
36
     created() {
46
     created() {
37
-        // TO ADD ASPECT: when creating new survey aspect step, increment slice number here
38
-        this.surveyObjects = this.surveySteps.slice(-7)
47
+        this.surveySteps.forEach((step) => {
48
+            switch (step.component) {
49
+                case 'FormInput':
50
+                    this.formInputs.push(step)
51
+                    break
52
+                case 'FormDropdown':
53
+                    this.formDropdowns.push(step)
54
+                    break
55
+                case 'QuestionResponse':
56
+                    this.questionResponses.push(step)
57
+                    break
58
+            }
59
+        })
39
     },
60
     },
40
 }
61
 }
41
 </script>
62
 </script>

Загрузка…
Отмена
Сохранить