Преглед изворни кода

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

tabs-content
tomit4 пре 3 година
родитељ
комит
4d6a2155d0

+ 1
- 1
frontend/src/components/onboarding/QuestionResponse.vue Прегледај датотеку

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

+ 2
- 4
frontend/src/views/OnboardingView.vue Прегледај датотеку

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

+ 32
- 11
frontend/src/views/SurveyCompleteView.vue Прегледај датотеку

@@ -4,16 +4,23 @@ main.view--surveycomplete
4 4
         h2 Thanks for Completing Our Survey!!
5 5
         h1 Please review your answers and let us know if you need to change anything.
6 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 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 24
         w-button.ma1(@click="changeAnswers") Change Answers
18 25
         w-button.ma1(@click="finalSubmit") Submit Answers
19 26
 </template>
@@ -32,10 +39,24 @@ export default {
32 39
     },
33 40
     data: () => ({
34 41
         surveyObjects: [],
42
+        formInputs: [],
43
+        questionResponses: [],
44
+        formDropdowns: [],
35 45
     }),
36 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 62
 </script>

Loading…
Откажи
Сачувај