瀏覽代碼

:recycle: Further refactoring of QuestionView in case aspect is at end of survey

tabs-content
tomit4 3 年之前
父節點
當前提交
cfbf00a6d8
共有 2 個檔案被更改,包括 14 行新增19 行删除
  1. 12
    19
      frontend/src/components/onboarding/QuestionResponse.vue
  2. 2
    0
      frontend/src/views/OnboardingView.vue

+ 12
- 19
frontend/src/components/onboarding/QuestionResponse.vue 查看文件

@@ -10,33 +10,36 @@ w-card.question
10 10
     )
11 11
     w-button.ma1.grow(
12 12
         @click='handleSubmit'
13
-        v-if='question.id !== aspectsCount'
13
+        v-if='currentStep !== surveyStepsCount'
14 14
     ) NEXT
15
-    w-button.ma1.grow(@click='updateAll' v-else) SUBMIT ANSWERS
15
+    w-button.ma1.grow(@click='handleSubmit' v-else) SUBMIT ANSWERS
16 16
     p(v-if='noChoiceMade') Tough choices, we know! Just answer to the best of your ability. The team over at Siimee values the answers you provide us so that we can show you results catered to your specific needs.
17 17
 </template>
18 18
 
19 19
 <script>
20
-import { aspectsArr } from '../../utils/lang.js'
21
-
22 20
 export default {
23 21
     props: {
24 22
         question: {
25 23
             type: Object,
26 24
             required: true,
27 25
         },
26
+        currentSteps: {
27
+            type: Number,
28
+            required: true,
29
+        },
30
+        surveyStepsCount: {
31
+            type: Number,
32
+            required: true,
33
+        },
28 34
     },
29
-    emits: ['updated', 'update-answers', 'update-all'],
35
+    emits: ['update-answers'],
30 36
     data: () => ({
31 37
         radioItems: [1, 2, 3, 4, 5],
32
-        isAnswered: false,
33 38
         answer: null,
34 39
         noChoiceMade: null,
35
-        aspectsCount: aspectsArr.length,
36 40
     }),
37 41
     methods: {
38 42
         onUpdate(index) {
39
-            this.isAnswered = true
40 43
             this.noChoiceMade = false
41 44
             this.answer = this.radioItems[index]
42 45
         },
@@ -45,19 +48,9 @@ export default {
45 48
                 question: this.question,
46 49
                 input: this.answer,
47 50
             }
48
-            console.log('updated payload :>> ', payload)
51
+            this.noChoiceMade = payload.input === null ? true : false
49 52
             this.$emit('update-answers', payload)
50 53
         },
51
-        updateAnswers() {
52
-            this.isAnswered
53
-                ? this.$emit('update-answers', this.question)
54
-                : (this.noChoiceMade = true)
55
-        },
56
-        updateAll() {
57
-            this.isAnswered
58
-                ? this.$emit('update-all')
59
-                : (this.noChoiceMade = true)
60
-        },
61 54
     },
62 55
 }
63 56
 </script>

+ 2
- 0
frontend/src/views/OnboardingView.vue 查看文件

@@ -14,6 +14,8 @@ main.view--onboarding
14 14
             component(
15 15
                 :is='step.component'
16 16
                 :question='step'
17
+                :currentStep='currentStep'
18
+                :surveyStepsCount='survey.steps.length'
17 19
                 @handle-submit='onSubmit'
18 20
                 @update-answers='updateAnswers'
19 21
                 v-if='step && currentStep == i'

Loading…
取消
儲存