Kaynağa Gözat

:recycle: Refactored flow of how aspects are created, removed tests

tags/0.0.3^2
tomit4 3 yıl önce
ebeveyn
işleme
60efd6f5d1

+ 9
- 24
backend/db/data-generator/mock.js Dosyayı Görüntüle

@@ -463,85 +463,70 @@ module.exports = {
463 463
             response_key_prompt: 'Do you prefer to Guide your employees towards achieving the team goals, or do you prefer your employees to be Self-Managed?',
464 464
             response_key_description: 'first round draft scoring question',
465 465
         },
466
-        // TO ADD ASPECT: when creating new survey aspect step, add here, re-order response_key_id and run npm run reseed
467 466
         {
468 467
             response_key_id: 7,
469
-            response_key_category: 'love_vs_hate',
470
-            response_key_prompt: 'Do you prefer to be loved our hated?',
471
-            response_key_description: 'total test question, to be deleted',
472
-        },
473
-        {
474
-            response_key_id: 8,
475 468
             response_key_category: 'profile',
476 469
             response_key_prompt: 'zipcode',
477 470
             response_key_description: 'required for distance calculations',
478 471
         },
479 472
         {
480
-            response_key_id: 9,
473
+            response_key_id: 8,
481 474
             response_key_category: 'profile',
482 475
             response_key_prompt: 'image',
483 476
             response_key_description: 'required for profile pictures',
484 477
         },
485 478
         {
486
-            response_key_id: 10,
479
+            response_key_id: 9,
487 480
             response_key_category: 'profile',
488 481
             response_key_prompt: 'language',
489 482
             response_key_description:
490 483
                 'programming and spoken language preference',
491 484
         },
492 485
         {
493
-            response_key_id: 11,
486
+            response_key_id: 10,
494 487
             response_key_category: 'profile',
495 488
             response_key_prompt: 'duration',
496 489
             response_key_description:
497 490
                 'duration preference for hours able to dedicate to work',
498 491
         },
499 492
         {
500
-            response_key_id: 12,
493
+            response_key_id: 11,
501 494
             response_key_category: 'profile',
502 495
             response_key_prompt: 'presence',
503 496
             response_key_description:
504 497
                 'location preference for where work happens',
505 498
         },
506 499
         {
507
-            response_key_id: 13,
500
+            response_key_id: 12,
508 501
             response_key_category: 'profile',
509 502
             response_key_prompt: 'blurb',
510 503
             response_key_description: 'required for profile description',
511 504
         },
512 505
         {
513
-            response_key_id: 14,
506
+            response_key_id: 13,
514 507
             response_key_category: 'profile',
515 508
             response_key_prompt: 'urgency',
516 509
             response_key_description: 'urgency for when work is required',
517 510
         },
518 511
         {
519
-            response_key_id: 15,
512
+            response_key_id: 14,
520 513
             response_key_category: 'profile',
521 514
             response_key_prompt: 'role',
522 515
             response_key_description: 'current and desired role',
523 516
         },
524 517
         {
525
-            response_key_id: 16,
518
+            response_key_id: 15,
526 519
             response_key_category: 'profile',
527 520
             response_key_prompt: 'pronouns',
528 521
             response_key_description: 'required for profile pronouns',
529 522
         },
530 523
         {
531
-            response_key_id: 17,
524
+            response_key_id: 16,
532 525
             response_key_category: 'profile',
533 526
             response_key_prompt: 'distance',
534 527
             response_key_description:
535 528
                 'preference for commuting distance cutoff',
536 529
         },
537
-        // TO ADD: when creating new survey step, add here and run npm run reseed
538
-        {
539
-            response_key_id: 18,
540
-            response_key_category: 'profile',
541
-            response_key_prompt: 'test',
542
-            response_key_description:
543
-                'this is just for testing stuff...',
544
-        },
545 530
     ],
546 531
     responses: [],
547 532
     memberships: [

+ 9
- 4
frontend/src/components/onboarding/Aspects.vue Dosyayı Görüntüle

@@ -12,8 +12,7 @@ p(v-for='question in aspectQuestions')
12 12
 
13 13
 <script>
14 14
 import QuestionResponse from './QuestionResponse.vue'
15
-// TO ADD ASPECT: when creating new survey aspect step, increment additional null slots here
16
-const answered = [null, null, null, null, null, null, null]
15
+import { aspectsArr } from '../../utils/lang.js'
17 16
 
18 17
 export default {
19 18
     name: 'Aspects',
@@ -27,24 +26,30 @@ export default {
27 26
         },
28 27
     },
29 28
     emits: ['handle-submit', 'update-answers'],
29
+    data: () => ({
30
+        answered: [],
31
+    }),
30 32
     async created() {
31 33
         this.aspectQuestions.forEach((q, i) => {
32 34
             console.log(`Aspect #${i}: ${JSON.stringify(q)}`)
33 35
             q.isBeingAnswered = i === 0 ? true : false
34 36
         })
37
+        aspectsArr.forEach(() => {
38
+            this.answered.push(null)
39
+        })
35 40
     },
36 41
     methods: {
37 42
         updateAll() {
38 43
             this.$emit('handle-submit')
39 44
         },
40 45
         updateRadio(onRadioSelect) {
41
-            answered[onRadioSelect.id - 1] = onRadioSelect.answer
46
+            this.answered[onRadioSelect.id - 1] = onRadioSelect.answer
42 47
             this.$emit('update-answers', {
43 48
                 key: 'Aspects',
44 49
                 question: {
45 50
                     survey_stage: 'aspects',
46 51
                 },
47
-                input: answered,
52
+                input: this.answered,
48 53
             })
49 54
         },
50 55
         updateIsAnswered(id) {

+ 4
- 2
frontend/src/components/onboarding/QuestionResponse.vue Dosyayı Görüntüle

@@ -4,13 +4,14 @@ w-card.question
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(@update:model-value="onUpdate" :items="radioItems" color="red")
7
-    // TO ADD ASPECT: when creating new survey aspect step, increment increment !== statement here
8
-    w-button.ma1.grow(v-if='question.id !== 7' @click="updateAnswers") NEXT
7
+    w-button.ma1.grow(v-if='question.id !== aspectsCount' @click="updateAnswers") NEXT
9 8
     w-button.ma1.grow(v-else @click="updateAll") SUBMIT ANSWERS
10 9
     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.
11 10
 </template>
12 11
 
13 12
 <script>
13
+import { aspectsArr } from '../../utils/lang.js'
14
+
14 15
 export default {
15 16
     props: {
16 17
         question: {
@@ -29,6 +30,7 @@ export default {
29 30
         ],
30 31
         isAnswered: false,
31 32
         noChoiceMade: null,
33
+        aspectsCount: aspectsArr.length
32 34
     }),
33 35
     methods: {
34 36
         onUpdate(e) {

+ 2
- 2
frontend/src/entities/card/card.js Dosyayı Görüntüle

@@ -1,4 +1,5 @@
1 1
 /** @module card/card */
2
+import { aspectsArr } from "../../utils/lang.js"
2 3
 
3 4
 const DEFAULT_ABOUT =
4 5
     'Hello! My name is L.L. and I am a nurse from New York. I have been in the healthcare industry for over 6 years.'
@@ -139,8 +140,7 @@ const makeCardFromProfile = profile => {
139 140
     c.locale = `${profile.city}, ${profile.state}`
140 141
     c.email = profile.user_email
141 142
 
142
-    // TO ADD ASPECT: when creating new survey aspect step, increment array.indexOf here
143
-    let aspectResponses = profile?.responses.filter(r => [1,2,3,4,5,6,7].indexOf(r.response_key_id) !== -1)
143
+    let aspectResponses = profile?.responses.filter(r => aspectsArr.indexOf(r.response_key_id) !== -1)
144 144
     if(aspectResponses.length){ // if user has responses for aspects we overwrite default percentages
145 145
         c.aspects.map(a => {
146 146
             a.percentage = Number(aspectResponses.find(r => responseKeyIdToAspectName[r.response_key_id] == a.name).val )

+ 2
- 2
frontend/src/entities/survey/survey.js Dosyayı Görüntüle

@@ -2,9 +2,9 @@
2 2
 import { _baseRecord } from '../index.js'
3 3
 import { surveySchema } from './survey.schema.js'
4 4
 import { answersSchema } from './survey.answer.schema.js'
5
+import { aspectsArr } from '../../utils/lang.js'
5 6
 
6
-// TO ADD ASPECT: when creating new survey aspect step, add additional number here
7
-const SCORED = [1, 2, 3, 4, 5, 6, 7]
7
+const SCORED = aspectsArr
8 8
 const _isScored = id => SCORED.includes(id)
9 9
 const _makeCategoryFriendly = responseCategory => {
10 10
     const labels = responseCategory.split('_vs_')

+ 3
- 20
frontend/src/utils/lang.js Dosyayı Görüntüle

@@ -1,4 +1,6 @@
1 1
 const DELIMITER = '_'
2
+// TO ADD ASPECT, increment aspectsArr here
3
+const aspectsArr = [1, 2, 3, 4, 5, 6]
2 4
 
3 5
 // TODO: Combine these two
4 6
 const allSteps = {
@@ -17,10 +19,6 @@ const allSteps = {
17 19
         image: 'image',
18 20
         distance: 'distance',
19 21
         blurb: 'blurb',
20
-        // TO ADD: when creating a new step, place before aspects
21
-        test: 'test',
22
-        // TO ADD DROP DOWN: when creating a new step, place before aspects
23
-        testOptions: 'testOptions',
24 22
         aspects: 'aspects',
25 23
         // experience: 'experience',
26 24
         // roles: 'role',
@@ -55,9 +53,6 @@ possible.usa = {
55 53
     presence: ['remote', 'in_person', 'hybrid', 'flexible'],
56 54
     // key 10
57 55
     duration: ['full-time', 'part-time', 'contract', 'flexible'],
58
-    // TO ADD DROP DOWN: When adding new survey Form Drop Down step, add all
59
-    // options in array
60
-    testOptions: ['test-option-1', 'test-option-2', 'test-option-3'],
61 56
     // Experience and roles concat, key: 14
62 57
     experience: ['associate', 'junior', 'mid-level', 'senior', 'staff'],
63 58
     roles: {
@@ -83,7 +78,6 @@ possible.usa = {
83 78
     image: [],
84 79
     zipcode: [],
85 80
     blurb: [],
86
-    test: []
87 81
 }
88 82
 
89 83
 // TODO: set up a separate object of similar prompts based off of
@@ -103,10 +97,6 @@ const promptOverrides = {
103 97
     duration: "What kind of duration would you prefer? Are you looking for part-time, full-time, other?[break] Currently, I'm looking for a [break] job at this time.",
104 98
     language: "What language is your native language?[break] I consider [break] language as my native language.",
105 99
     distance: "What distance from your home are you looking to work in?[break] Preferably, I'd like to work [break] from my place of residence.",
106
-    // TO ADD: add new prompt for new survey steps here
107
-    test: 'this[break]is just[break] a test.',
108
-    // TO ADD DROP DOWN: add new prompt for new survey steps here
109
-    testOptions: 'this[break]is another[break] test with options.'
110 100
 }
111 101
 
112 102
 const inputPlaceholders = {
@@ -116,10 +106,6 @@ const inputPlaceholders = {
116 106
     password: 'supersecr3tp@ssword',
117 107
     blurb: 'my backstory starts long long ago...',
118 108
     distance: '5 mi',
119
-    // TO ADD: add new input place holder here
120
-    test: 'test',
121
-    // TO ADD DROP DOWN: add new input place holder here
122
-    testOptions: 'testOptions'
123 109
 }
124 110
 
125 111
 const invalidInputPrompts = {
@@ -136,10 +122,6 @@ const invalidInputPrompts = {
136 122
     duration: "Looks like you haven't filled out what kind of work you're most interested in. As in, part-time, full-time. Take a look at our above options and choose whatever feels right for you right now. You can always edit them later!",
137 123
     language: "We try our best to provide results in the language of your choosing. ¿Prefieres ver resultados en español? Or would you prefer to see results in english?",
138 124
     distance: "Whoa! You either left this field blank or tried to input an astronomically large distance you'd like to see results from. Please input a distance you'd like to see results in.",
139
-    // TO ADD: add new input invalid message here
140
-    test: 'oh goodness, why test this!',
141
-    // TO ADD DROP DOWN: add new input invalid message here
142
-    testOptions: 'oh goodness, why test this with Options!'
143 125
 }
144 126
 
145 127
 export {
@@ -148,6 +130,7 @@ export {
148 130
     invalidInputPrompts,
149 131
     allSteps,
150 132
     aspectResponses,
133
+    aspectsArr,
151 134
     possible,
152 135
     DELIMITER,
153 136
 }

+ 4
- 3
frontend/src/utils/survey.js Dosyayı Görüntüle

@@ -1,6 +1,6 @@
1 1
 import { Survey } from '../entities/index.js'
2 2
 import { fetchQuestions } from '../services/index.js'
3
-import { promptOverrides, inputPlaceholders, invalidInputPrompts ,possible } from './lang.js'
3
+import { promptOverrides, inputPlaceholders, invalidInputPrompts ,possible, aspectsArr } from './lang.js'
4 4
 
5 5
 const promptToComponent = {
6 6
     splash: 'Splash',
@@ -56,6 +56,8 @@ const hasMatch = (step, inArray) => {
56 56
 class SurveyFactory {
57 57
     constructor() {
58 58
         this.questionsFromDb = []
59
+        // consider moving this into something like lang.js to be imported
60
+        // wherever aspects needs to be incremented, ie TO ADD ASPECTS
59 61
     }
60 62
     _setSteps(langFile) {
61 63
         const stepsToProcess = [...Object.values(langFile)]
@@ -84,8 +86,7 @@ class SurveyFactory {
84 86
         let unseen = this.questionsFromDb.filter(
85 87
             q =>
86 88
                 !seenIds.includes(q.response_key_id) &&
87
-                // TO ADD ASPECTS: increment array here
88
-                [1, 2, 3, 4, 5, 6, 7].includes(q.response_key_id),
89
+                aspectsArr.includes(q.response_key_id)
89 90
         )
90 91
         return [...stepsInCommon, ...unseen]
91 92
     }

Loading…
İptal
Kaydet