Ver código fonte

:construction: Small optimization in surveycompleteview logic

tags/0.0.4
tomit4 2 anos atrás
pai
commit
09bc193f3e

+ 1
- 1
frontend/src/views/OnboardingView.vue Ver arquivo

55
         invalidResponse: false,
55
         invalidResponse: false,
56
     }),
56
     }),
57
     async created() {
57
     async created() {
58
+        // TODO: Troubleshoot bug where memberships are not returned from backend with 500 err
58
         // TODO: Troubleshoot bug where not all responses are returned at SurveyCompleteView
59
         // TODO: Troubleshoot bug where not all responses are returned at SurveyCompleteView
59
         console.log('currentProfile :=>', currentProfile)
60
         console.log('currentProfile :=>', currentProfile)
60
         this.survey = await surveyFactory.createSurvey()
61
         this.survey = await surveyFactory.createSurvey()
116
             })
117
             })
117
         },
118
         },
118
         async updateAnswers(payload) {
119
         async updateAnswers(payload) {
119
-            console.log('this.survey.steps :=>', this.survey.steps)
120
             if (payload) {
120
             if (payload) {
121
                 const k = payload.question.survey_stage
121
                 const k = payload.question.survey_stage
122
                 this.answered[k] = payload.input
122
                 this.answered[k] = payload.input

+ 5
- 8
frontend/src/views/SurveyCompleteView.vue Ver arquivo

35
     created() {
35
     created() {
36
         // TODO: Troubleshoot bug where not all responses are returned
36
         // TODO: Troubleshoot bug where not all responses are returned
37
         console.log('currentProfile :=>', currentProfile)
37
         console.log('currentProfile :=>', currentProfile)
38
-        this.aspectQuestions = this.parseSurvey(this.surveySteps, false)
39
-        this.surveyStages = this.parseSurvey(this.surveySteps, true)
38
+        this.parseSurvey(this.surveySteps)
40
         this.aspectResponses = this.grabAspectResponses(
39
         this.aspectResponses = this.grabAspectResponses(
41
             currentProfile._profile.responses,
40
             currentProfile._profile.responses,
42
             this.aspectQuestions,
41
             this.aspectQuestions,
48
         )
47
         )
49
     },
48
     },
50
     methods: {
49
     methods: {
51
-        parseSurvey(surveySteps, isStage) {
52
-            const parsedAspects = {}
53
-            const parsedStages = {}
50
+        parseSurvey(surveySteps) {
54
             surveySteps.forEach(step => {
51
             surveySteps.forEach(step => {
55
                 const isAspect = step.category === 'aspect'
52
                 const isAspect = step.category === 'aspect'
56
                 if (isAspect) {
53
                 if (isAspect) {
57
-                    parsedAspects[`${step.response_key_id}`] =
54
+                    this.aspectQuestions[`${step.response_key_id}`] =
58
                         step.response_key_prompt
55
                         step.response_key_prompt
59
                 } else {
56
                 } else {
60
-                    parsedStages[`${step.response_key_id}`] = step.survey_stage
57
+                    this.surveyStages[`${step.response_key_id}`] =
58
+                        step.survey_stage
61
                 }
59
                 }
62
             })
60
             })
63
-            return isStage ? parsedStages : parsedAspects
64
         },
61
         },
65
         grabResponsesFromProfile(aspectQuestions) {
62
         grabResponsesFromProfile(aspectQuestions) {
66
             const aspectQuestionsKeys = Object.keys(aspectQuestions).map(Number)
63
             const aspectQuestionsKeys = Object.keys(aspectQuestions).map(Number)

Carregando…
Cancelar
Salvar