ソースを参照

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

tags/0.0.3^2
tomit4 3年前
コミット
51b48bd316

+ 12
- 19
frontend/src/components/onboarding/QuestionResponse.vue ファイルの表示

10
     )
10
     )
11
     w-button.ma1.grow(
11
     w-button.ma1.grow(
12
         @click='handleSubmit'
12
         @click='handleSubmit'
13
-        v-if='question.id !== aspectsCount'
13
+        v-if='currentStep !== surveyStepsCount'
14
     ) NEXT
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
     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.
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
 </template>
17
 </template>
18
 
18
 
19
 <script>
19
 <script>
20
-import { aspectsArr } from '../../utils/lang.js'
21
-
22
 export default {
20
 export default {
23
     props: {
21
     props: {
24
         question: {
22
         question: {
25
             type: Object,
23
             type: Object,
26
             required: true,
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
     data: () => ({
36
     data: () => ({
31
         radioItems: [1, 2, 3, 4, 5],
37
         radioItems: [1, 2, 3, 4, 5],
32
-        isAnswered: false,
33
         answer: null,
38
         answer: null,
34
         noChoiceMade: null,
39
         noChoiceMade: null,
35
-        aspectsCount: aspectsArr.length,
36
     }),
40
     }),
37
     methods: {
41
     methods: {
38
         onUpdate(index) {
42
         onUpdate(index) {
39
-            this.isAnswered = true
40
             this.noChoiceMade = false
43
             this.noChoiceMade = false
41
             this.answer = this.radioItems[index]
44
             this.answer = this.radioItems[index]
42
         },
45
         },
45
                 question: this.question,
48
                 question: this.question,
46
                 input: this.answer,
49
                 input: this.answer,
47
             }
50
             }
48
-            console.log('updated payload :>> ', payload)
51
+            this.noChoiceMade = payload.input === null ? true : false
49
             this.$emit('update-answers', payload)
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
 </script>
56
 </script>

+ 2
- 0
frontend/src/views/OnboardingView.vue ファイルの表示

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

読み込み中…
キャンセル
保存