Quellcode durchsuchen

Merge branch 'onboarding-submission' of fyindr/siimee into dev

tags/0.0.3^2
maeda vor 3 Jahren
Ursprung
Commit
be2e623699

+ 1
- 1
backend/db/seeds/04-responses.js Datei anzeigen

@@ -28,7 +28,7 @@ exports.seed = async knex => {
28 28
     for (let i = 1; i <= len; i += 1) {
29 29
         responsesToPush.push(responses.shift())
30 30
         if (i % batchSize === 0 || i > responses.length) {
31
-            await knex('responses').insert(responsesToPush)
31
+            // await knex('responses').insert(responsesToPush)
32 32
             responsesToPush = []
33 33
         }
34 34
     }

+ 41
- 0
frontend/src/components/DynamicTagList.vue Datei anzeigen

@@ -0,0 +1,41 @@
1
+<template lang="pug">
2
+.ListControls(style="display:flex; flex-direction:row;")
3
+    input(type="text" :placeholder='`Add ${placeholder}...`' v-model="newTag")
4
+    w-button.ma1(@click="addTag") +
5
+TagList(:tags="mutableTags")
6
+</template>
7
+<script>
8
+import TagList from './TagList.vue'
9
+export default {
10
+    name: 'DynamicTagList',
11
+    components:{
12
+        TagList,
13
+    },
14
+    props:{
15
+        tags: {
16
+            required: true,
17
+            type: Array,
18
+        },
19
+        placeholder:{
20
+            required: true,
21
+            type: String,
22
+        }
23
+    },
24
+    data() {
25
+        return {
26
+            newTag: null,
27
+            mutableTags: this.tags,
28
+        }    
29
+    },
30
+    methods:{
31
+        addTag(){
32
+            if(!this.newTag){
33
+                console.warn('Type a new tag before adding')
34
+                return
35
+            }
36
+            this.mutableTags.push(this.newTag)
37
+            this.newTag = ''
38
+        }
39
+    }
40
+}
41
+</script>

+ 28
- 7
frontend/src/components/onboarding/AccountType.vue Datei anzeigen

@@ -1,17 +1,38 @@
1 1
 <template lang="pug">
2
-h3 {Name}, let's get started on your profile while we verify your account
3
-w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") CANDIDATES
4
-w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") JOBS
2
+.account-typpe
3
+    h3 {{ question }}
4
+    //- w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") CANDIDATES
5
+    w-button.ma1.grow(@click='handleSubmit("Recruiter")') CANDIDATES
6
+    w-button.ma1.grow(@click='handleSubmit("Jobseeker")') JOBS
5 7
 </template>
6 8
 <script>
7 9
 export default {
8 10
     name: 'AccountType',
9 11
     props: {
10
-        currentStep:{
12
+        currentStep: {
11 13
             required: true,
12 14
             type: Number,
13
-            default: 0
14
-        }
15
+            default: 0,
16
+        },
17
+        aspectQuestions: {
18
+            required: false,
19
+        },
20
+    },
21
+    emits: ['go-to-step', 'update-answers'],
22
+    data: () => ({
23
+        question:
24
+            "{Name}, let's get started on your profile while we verify your account.",
25
+    }),
26
+    methods: {
27
+        handleSubmit(accountType) {
28
+            let payload = {
29
+                key: 'AccountType',
30
+                question: this.question,
31
+                answer: accountType,
32
+            }
33
+            this.$emit('update-answers', payload)
34
+            this.$emit('go-to-step', this.currentStep + 1)
35
+        },
15 36
     },
16 37
 }
17
-</script>
38
+</script>

+ 33
- 14
frontend/src/components/onboarding/Aspects.vue Datei anzeigen

@@ -1,28 +1,47 @@
1 1
 <template lang="pug">
2
-form(@submit.prevent="this.$emit('handle-submit')").questionnaire
3
-    QuestionResponse(v-for="question in aspectQuestions" :question="question")
4
-    w-button.ma1.grow(type="submit" bg-color="success")
5
-        w-icon.mr1 wi-check
6
-        | SUBMIT ANSWERS
2
+.aspects
3
+    form.questionnaire(@submit.prevent='this.$emit("handle-submit")')
4
+        QuestionResponse(
5
+            :question='question'
6
+            @updated='updateRadio'
7
+            v-for='question in aspectQuestions'
8
+        )
9
+        w-button.ma1.grow(bg-color='success' type='submit')
10
+            w-icon.mr1 wi-check
11
+            | SUBMIT ANSWERS
7 12
 </template>
8 13
 <script>
9 14
 import QuestionResponse from './QuestionResponse.vue'
15
+const answered = [null, null, null, null, null, null]
10 16
 
11 17
 export default {
12 18
     name: 'Aspects',
13 19
     components: {
14
-        QuestionResponse
20
+        QuestionResponse,
15 21
     },
16 22
     props: {
17
-        aspectQuestions:{
23
+        aspectQuestions: {
18 24
             required: true,
19
-            type: Array
25
+            type: Array,
26
+        },
27
+    },
28
+    emits: ['handle-submit', 'update-answers'],
29
+    async created() {
30
+        this.aspectQuestions.forEach((q,i) => {
31
+            console.log(`Aspect #${i}: ${JSON.stringify(q)}`) 
32
+        })
33
+    },
34
+    methods: {
35
+        updateRadio(onRadioSelect) {
36
+            answered[onRadioSelect.id-1] = onRadioSelect.answer
37
+            this.$emit('update-answers', {
38
+                key: 'Aspects',
39
+                question: {
40
+                    response_key_prompt: 'aspects'
41
+                },
42
+                answer: answered,
43
+            })
20 44
         },
21
-        currentStep:{
22
-            required: true,
23
-            type: Number,
24
-            default: 0
25
-        }
26 45
     },
27 46
 }
28
-</script>
47
+</script>

+ 29
- 9
frontend/src/components/onboarding/CompanyID.vue Datei anzeigen

@@ -1,19 +1,39 @@
1 1
 <template lang="pug">
2
-h3 Company ID
3
-p PLEASE ENTER YOUR COMPANY ID#:
4
-input(type="text" placeholder="Get this from your admin.")
5
-w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") NEXT
2
+.company-id
3
+    h3 Company ID
4
+    p {{ question }}
5
+    input(
6
+        placeholder='Get this from your admin.'
7
+        type='text'
8
+        v-model='companyID'
9
+    )
10
+    w-button.ma1.grow(@click='handleSubmit') NEXT
6 11
 </template>
7 12
 <script>
8
-// todo add v-model to input, pass down answers array from parent
9 13
 export default {
10 14
     name: 'CompanyID',
11 15
     props: {
12
-        currentStep:{
16
+        currentStep: {
13 17
             required: true,
14 18
             type: Number,
15
-            default: 0
16
-        }
19
+            default: 0,
20
+        },
21
+    },
22
+    emits: ['go-to-step', 'update-answers'],
23
+    data: () => ({
24
+        companyID: null,
25
+        question: 'PLEASE ENTER YOUR COMPANY ID#:',
26
+    }),
27
+    methods: {
28
+        handleSubmit() {
29
+            let payload = {
30
+                key: 'CompanyID',
31
+                question: this.question,
32
+                answer: this.companyID,
33
+            }
34
+            this.$emit('update-answers', payload)
35
+            this.$emit('go-to-step', this.currentStep + 1)
36
+        },
17 37
     },
18 38
 }
19
-</script>
39
+</script>

+ 41
- 0
frontend/src/components/onboarding/FormDropdown.vue Datei anzeigen

@@ -0,0 +1,41 @@
1
+<template lang="pug">
2
+.role
3
+    h3 {{ question.response_key_category }}
4
+    p {{ question.response_key_prompt }}
5
+    w-select.mt4(:items='items' placeholder='i am' v-model='selection')
6
+    w-button.ma1.grow(@click='handleSubmit') NEXT
7
+</template>
8
+
9
+<script>
10
+export default {
11
+    name: 'FormDropdown',
12
+    props: {
13
+        question: {
14
+            required: true,
15
+            type: Object,
16
+        },
17
+    },
18
+    emits: ['update-answers'],
19
+    data: () => ({
20
+        selection: null,
21
+    }),
22
+    computed: {
23
+        items() {
24
+            return this.question.responses.map(res => ({ label: res }))
25
+        },
26
+    },
27
+    methods: {
28
+        handleSubmit() {
29
+            if (!this.selection) {
30
+                console.warn('Please select a role.')
31
+                return
32
+            }
33
+            let payload = {
34
+                question: this.question,
35
+                answer: this.selection,
36
+            }
37
+            this.$emit('update-answers', payload)
38
+        },
39
+    },
40
+}
41
+</script>

+ 36
- 0
frontend/src/components/onboarding/FormInput.vue Datei anzeigen

@@ -0,0 +1,36 @@
1
+<template lang="pug">
2
+.form-input
3
+    h3 {{ question.response_key_category }}
4
+    p {{ question.response_key_prompt }}
5
+    input(placeholder='i am a little teapot' type='text' v-model='input')
6
+    w-button.ma1.grow(@click='handleSubmit') NEXT
7
+</template>
8
+<script>
9
+export default {
10
+    name: 'FormInput',
11
+    props: {
12
+        question: {
13
+            required: true,
14
+            type: Object,
15
+        },
16
+    },
17
+    emits: ['update-answers'],
18
+    data: () => ({
19
+        input: null,
20
+    }),
21
+    methods: {
22
+        handleSubmit() {
23
+            if(this.question.response_key_prompt === 'password') {
24
+                this.$emit('update-answers') // no password collection
25
+                return
26
+            }
27
+
28
+            let payload = {
29
+                question: this.question,
30
+                answer: this.input,
31
+            }
32
+            this.$emit('update-answers', payload)
33
+        },
34
+    },
35
+}
36
+</script>

+ 36
- 0
frontend/src/components/onboarding/FormTags.vue Datei anzeigen

@@ -0,0 +1,36 @@
1
+<template lang="pug">
2
+.form-tags
3
+    h3 {{ question.response_key_category }}
4
+    p {{ question.response_key_prompt }}
5
+    DynamicTagList(:placeholder='"a tag"' :tags='tags')
6
+    w-button.ma1.grow(@click='handleSubmit') NEXT
7
+</template>
8
+<script>
9
+import DynamicTagList from '../DynamicTagList.vue'
10
+
11
+export default {
12
+    name: 'FormTags',
13
+    components: {
14
+        DynamicTagList,
15
+    },
16
+    props: {
17
+        question: {
18
+            required: true,
19
+            type: Object,
20
+        },
21
+    },
22
+    emits: ['update-answers'],
23
+    data: () => ({
24
+        tags: [],
25
+    }),
26
+    methods: {
27
+        handleSubmit() {
28
+            let payload = {
29
+                question: this.question,
30
+                answer: this.tags,
31
+            }
32
+            this.$emit('update-answers', payload)
33
+        },
34
+    },
35
+}
36
+</script>

+ 31
- 7
frontend/src/components/onboarding/Interests.vue Datei anzeigen

@@ -1,17 +1,41 @@
1 1
 <template lang="pug">
2
-h3 Interests
3
-p What are some interests you would like in your next candidates?
4
-w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") NEXT
2
+.interests
3
+    h3 Interests
4
+    p {{ question }}
5
+    DynamicTagList(:placeholder='"interest"' :tags='interests')
6
+    w-button.ma1.grow(@click='handleSubmit') NEXT
5 7
 </template>
8
+
6 9
 <script>
10
+import DynamicTagList from '../DynamicTagList.vue'
7 11
 export default {
8 12
     name: 'Interests',
13
+    components: {
14
+        DynamicTagList,
15
+    },
9 16
     props: {
10
-        currentStep:{
17
+        currentStep: {
11 18
             required: true,
12 19
             type: Number,
13
-            default: 0
14
-        }
20
+            default: 0,
21
+        },
22
+    },
23
+    emits: ['go-to-step', 'update-answers'],
24
+    data: () => ({
25
+        interests: [],
26
+        question:
27
+            'What are some interests you would like in your next candidates?',
28
+    }),
29
+    methods: {
30
+        handleSubmit() {
31
+            let payload = {
32
+                key: 'Interests',
33
+                question: this.question,
34
+                answer: this.interests,
35
+            }
36
+            this.$emit('update-answers', payload)
37
+            this.$emit('go-to-step', this.currentStep + 1)
38
+        },
15 39
     },
16 40
 }
17
-</script>
41
+</script>

+ 32
- 7
frontend/src/components/onboarding/LicensesAndCertifications.vue Datei anzeigen

@@ -1,17 +1,42 @@
1 1
 <template lang="pug">
2
-h3 Licenses & Certifications
3
-p Are there any licenses and certification requirements?
4
-w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") NEXT
2
+.licenses-certifications
3
+    h3 Licenses &amp; Certifications
4
+    p {{ question }}
5
+    DynamicTagList(
6
+        :placeholder='"requirement"'
7
+        :tags='licensesAndCertifications'
8
+    )
9
+    w-button.ma1.grow(@click='handleSubmit') NEXT
5 10
 </template>
6 11
 <script>
12
+import DynamicTagList from '../DynamicTagList.vue'
7 13
 export default {
8 14
     name: 'LicensesAndCertifications',
15
+    components: {
16
+        DynamicTagList,
17
+    },
9 18
     props: {
10
-        currentStep:{
19
+        currentStep: {
11 20
             required: true,
12 21
             type: Number,
13
-            default: 0
14
-        }
22
+            default: 0,
23
+        },
24
+    },
25
+    emits: ['go-to-step', 'update-answers'],
26
+    data: () => ({
27
+        licensesAndCertifications: [],
28
+        question: 'Are there any licenses and certification requirements?',
29
+    }),
30
+    methods: {
31
+        handleSubmit() {
32
+            let payload = {
33
+                key: 'LicensesAndCertifications',
34
+                question: this.question,
35
+                answer: this.licensesAndCertifications,
36
+            }
37
+            this.$emit('update-answers', payload)
38
+            this.$emit('go-to-step', this.currentStep + 1)
39
+        },
15 40
     },
16 41
 }
17
-</script>
42
+</script>

+ 29
- 7
frontend/src/components/onboarding/Location.vue Datei anzeigen

@@ -1,17 +1,39 @@
1 1
 <template lang="pug">
2
-h3 Location
3
-p Where would you like to select your candidates from?
4
-w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") NEXT
2
+.location
3
+    h3 Location
4
+    p {{ question }}
5
+    DynamicTagList(:placeholder='"location"' :tags='locations')
6
+    w-button.ma1.grow(@click='handleSubmit') NEXT
5 7
 </template>
6 8
 <script>
9
+import DynamicTagList from '../DynamicTagList.vue'
7 10
 export default {
8 11
     name: 'Location',
12
+    components: {
13
+        DynamicTagList,
14
+    },
9 15
     props: {
10
-        currentStep:{
16
+        currentStep: {
11 17
             required: true,
12 18
             type: Number,
13
-            default: 0
14
-        }
19
+            default: 0,
20
+        },
21
+    },
22
+    emits: ['go-to-step', 'update-answers'],
23
+    data: () => ({
24
+        locations: [],
25
+        question: 'Where would you like to select your candidates from?',
26
+    }),
27
+    methods: {
28
+        handleSubmit() {
29
+            let payload = {
30
+                key: 'Location',
31
+                question: this.question,
32
+                answer: this.locations,
33
+            }
34
+            this.$emit('update-answers', payload)
35
+            this.$emit('go-to-step', this.currentStep + 1)
36
+        },
15 37
     },
16 38
 }
17
-</script>
39
+</script>

+ 30
- 10
frontend/src/components/onboarding/Role.vue Datei anzeigen

@@ -1,20 +1,40 @@
1 1
 <template lang="pug">
2
-h3 ACTIVELY SEARCHING
3
-p What is your role at your company?
4
-w-select.mt4(
5
-    :items="[{label: 'RECRUITER'},{label: 'HIRING MANAGER'}]"
6
-    placeholder="i am")
7
-w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") NEXT
2
+.role
3
+    h3 ACTIVELY SEARCHING
4
+    p {{ question }}
5
+    w-select.mt4(:items='items' placeholder='i am' v-model='selectedRole')
6
+    w-button.ma1.grow(@click='handleSubmit') NEXT
8 7
 </template>
8
+
9 9
 <script>
10 10
 export default {
11 11
     name: 'Role',
12 12
     props: {
13
-        currentStep:{
13
+        currentStep: {
14 14
             required: true,
15 15
             type: Number,
16
-            default: 0
17
-        }
16
+            default: 0,
17
+        },
18
+    },
19
+    data: () => ({
20
+        items: [{ label: 'RECRUITER' }, { label: 'HIRING MANAGER' }],
21
+        question: 'What is your role at your company?',
22
+        selectedRole: null,
23
+    }),
24
+    methods: {
25
+        handleSubmit() {
26
+            if (!this.selectedRole) {
27
+                console.warn('Please select a role.')
28
+                return
29
+            }
30
+            let payload = {
31
+                key: 'Role',
32
+                question: this.question,
33
+                answer: this.selectedRole,
34
+            }
35
+            this.$emit('update-answers', payload)
36
+            this.$emit('go-to-step', this.currentStep + 1)
37
+        },
18 38
     },
19 39
 }
20
-</script>
40
+</script>

+ 29
- 7
frontend/src/components/onboarding/Skills.vue Datei anzeigen

@@ -1,17 +1,39 @@
1 1
 <template lang="pug">
2
-h3 RECRUITER
3
-p What are some skills you are looking for at your company?
4
-w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") NEXT
2
+.skills
3
+    h3 RECRUITER
4
+    p {{ question }}
5
+    DynamicTagList(:placeholder='"skill"' :tags='skills')
6
+    w-button.ma1.grow(@click='handleSubmit') NEXT
5 7
 </template>
6 8
 <script>
9
+import DynamicTagList from '../DynamicTagList.vue'
7 10
 export default {
8 11
     name: 'Skills',
12
+    components: {
13
+        DynamicTagList,
14
+    },
9 15
     props: {
10
-        currentStep:{
16
+        currentStep: {
11 17
             required: true,
12 18
             type: Number,
13
-            default: 0
14
-        }
19
+            default: 0,
20
+        },
21
+    },
22
+    emits: ['go-to-step', 'update-answers'],
23
+    data: () => ({
24
+        question: 'What are some skills you are looking for at your company?',
25
+        skills: [],
26
+    }),
27
+    methods: {
28
+        handleSubmit() {
29
+            let payload = {
30
+                key: 'Skills',
31
+                question: this.question,
32
+                answer: this.skills,
33
+            }
34
+            this.$emit('update-answers', payload)
35
+            this.$emit('go-to-step', this.currentStep + 1)
36
+        },
15 37
     },
16 38
 }
17
-</script>
39
+</script>

+ 17
- 7
frontend/src/components/onboarding/Splash.vue Datei anzeigen

@@ -1,17 +1,27 @@
1 1
 <template lang="pug">
2
-.splash-icon(style="width:347px; height:347px; background-color: red;")
3
-div(style="text-align:center;")
4
-    w-button.ma1.grow(@click="this.$emit('go-to-step', currentStep + 1)") GET STARTED
2
+.splash
3
+    .splash--icon(style='width: 347px; height: 347px; background-color: red')
4
+    div(style='text-align: center')
5
+        w-button.ma1.grow(@click='handleSubmit') GET STARTED
6
+
5 7
 </template>
8
+
6 9
 <script>
7 10
 export default {
8 11
     name: 'Splash',
9 12
     props: {
10
-        currentStep:{
13
+        currentStep: {
11 14
             required: true,
12 15
             type: Number,
13
-            default: 0
14
-        }
16
+            default: 0,
17
+        },
15 18
     },
19
+    emits: ['update-answers'],
20
+    methods: {
21
+        handleSubmit() {
22
+            this.$emit('update-answers', null)
23
+        },
24
+    },
25
+
16 26
 }
17
-</script>
27
+</script>

+ 7
- 1
frontend/src/components/onboarding/index.js Datei anzeigen

@@ -7,6 +7,9 @@ import Location from './Location.vue'
7 7
 import Interests from './Interests.vue'
8 8
 import LicensesAndCertifications from './LicensesAndCertifications.vue'
9 9
 import Aspects from './Aspects.vue'
10
+import FormInput from './FormInput.vue'
11
+import FormTags from './FormTags.vue'
12
+import FormDropdown from './FormDropdown.vue'
10 13
 
11 14
 export default {
12 15
     Splash,
@@ -18,4 +21,7 @@ export default {
18 21
     Interests,
19 22
     LicensesAndCertifications,
20 23
     Aspects,
21
-}
24
+    FormDropdown,
25
+    FormTags,
26
+    FormInput,
27
+}

+ 28
- 10
frontend/src/entities/survey/survey.js Datei anzeigen

@@ -2,24 +2,42 @@
2 2
 import { _baseRecord } from '../index.js'
3 3
 import { surveySchema } from './survey.schema.js'
4 4
 
5
+const SCORED = [1, 2, 3, 4, 5, 6]
6
+const _isScored = id => SCORED.includes(id)
7
+const _makeCategoryFriendly = responseCategory => {
8
+    const labels = responseCategory.split('_vs_')
9
+    labels.forEach((a, i) => {
10
+        if (a.indexOf('_') == -1) return
11
+        labels[i] = a.split('_').join(' ')
12
+    })
13
+    return labels
14
+}
15
+const _formatAspectQuestions = steps => {
16
+    return steps
17
+        .map(q => {
18
+            if (!_isScored(q.response_key_id)) return null
19
+            return {
20
+                id: q.response_key_id,
21
+                question: q.response_key_prompt,
22
+                labels: _makeCategoryFriendly(q.response_key_category),
23
+                answer: null,
24
+            }
25
+        })
26
+        .filter(step => step != null)
27
+}
28
+
5 29
 class Survey extends _baseRecord {
6
-    constructor(questionSteps, roles) {
30
+    constructor(questionSteps) {
7 31
         super()
8 32
 
9 33
         this.type = this.constructor.name.toLowerCase()
10 34
 
11 35
         /**  Fields */
12 36
         this.steps = [...questionSteps] // ! required
13
-        this.roleTree = roles
14
-
15
-        return this
16
-    }
17
-    setRoleResponses(position) {
18
-        const roleStep = this.steps.filter(
19
-            step => step.response_key_prompt == 'role',
20
-        )[0]
21
-        roleStep.responses = this.roleTree[position]
37
+        this.aspectQuestions = _formatAspectQuestions(this.steps)
38
+        console.log('this.aspectQuestions: ', JSON.stringify(this.aspectQuestions))
22 39
     }
40
+
23 41
     isValid() {
24 42
         const validate = surveySchema.validate(this)
25 43
 

+ 1
- 1
frontend/src/utils/index.js Datei anzeigen

@@ -41,7 +41,7 @@ const makeKebob = input => {
41 41
     return input.toLowerCase().split(' ').join('-')
42 42
 }
43 43
 
44
-const surveyFactory = new SurveyFactory(possible['usa'])
44
+const surveyFactory = new SurveyFactory()
45 45
 
46 46
 const mixins = { pidMixin, profileMixin }
47 47
 

+ 14
- 21
frontend/src/utils/lang.js Datei anzeigen

@@ -3,20 +3,23 @@ const DELIMITER = '_'
3 3
 // TODO: Combine these two
4 4
 const allSteps = {
5 5
     usa: {
6
-        email: 'email',
6
+        splash: 'splash',
7 7
         name: 'name',
8
-        pronouns: 'pronouns',
9
-        seeking: 'seeking',
10
-        urgency: 'urgency',
11
-        experience: 'experience',
12
-        roles: 'role',
13
-        duration: 'duration',
14
-        presence: 'presence',
15
-        language: 'language',
8
+        email: 'email',
9
+        password: 'password',
10
+        // pronouns: 'pronouns',
11
+        // seeking: 'seeking',
12
+        // urgency: 'urgency',
13
+        // experience: 'experience',
14
+        // roles: 'role',
15
+        // duration: 'duration',
16
+        // presence: 'presence',
17
+        // language: 'language',
16 18
         zipcode: 'zipcode',
17
-        distance: 'distance',
19
+        // distance: 'distance',
18 20
         blurb: 'blurb',
19 21
         image: 'image',
22
+        aspects: 'aspects'
20 23
     },
21 24
 }
22 25
 
@@ -37,17 +40,7 @@ possible.usa = {
37 40
     email: [],
38 41
     name: [],
39 42
     seeking: ['position', 'candidate'],
40
-    language: [
41
-        'javascript',
42
-        'python',
43
-        'c#',
44
-        'c++',
45
-        'go',
46
-        'java',
47
-        'ruby',
48
-        'html',
49
-        'css',
50
-    ],
43
+    language: ['english', 'spanish'],
51 44
     // key 13
52 45
     urgency: [
53 46
         'actively_looking',

+ 0
- 39
frontend/src/utils/onboardingStepComponents.js Datei anzeigen

@@ -1,39 +0,0 @@
1
-const OnboardingStepComponents = [
2
-    {
3
-        id: 0,
4
-        component:'Splash',
5
-    },
6
-    {
7
-        id: 1,
8
-        component:'AccountType',
9
-    },
10
-    {
11
-        id: 2,
12
-        component:'CompanyID',
13
-    },
14
-    {
15
-        id: 3,
16
-        component:'Role',
17
-    },
18
-    {
19
-        id: 4,
20
-        component:'Skills',
21
-    },
22
-    {
23
-        id: 5,
24
-        component:'Location',
25
-    },
26
-    {
27
-        id: 6,
28
-        component:'Interests',
29
-    },
30
-    {
31
-        id: 7,
32
-        component:'LicensesAndCertifications',
33
-    },
34
-    {
35
-        id: 8,
36
-        component:'Aspects',
37
-    }
38
-]
39
-export default OnboardingStepComponents

+ 56
- 20
frontend/src/utils/survey.js Datei anzeigen

@@ -1,9 +1,55 @@
1 1
 import { Survey } from '../entities/index.js'
2 2
 import { fetchQuestions } from '../services/index.js'
3
+import { possible } from './lang.js'
4
+
5
+const promptToComponent = {
6
+    splash: 'Splash',
7
+    name: 'FormInput',
8
+    email: 'FormInput',
9
+    password: 'FormInput',
10
+    zipcode: 'FormInput',
11
+    // seeking: 'FormDropdown',
12
+    // urgency: 'FormDropdown',
13
+    // presence: 'FormDropdown',
14
+    // duration: 'FormDropdown',
15
+    // experience: 'FormTags',
16
+    // pronouns: 'FormDropdown',
17
+    // language: 'FormDropdown',
18
+    image: 'FormInput',
19
+    // distance: 'FormInput',
20
+    blurb: 'FormInput',
21
+    aspects: 'Aspects'
22
+}
23
+/**
24
+ * Make a step from match or step information
25
+ * @param {object} match
26
+ * @param {object} step
27
+ * @returns something like a response_key with possible responses
28
+ */
29
+const formatStep = (match, step) => {
30
+    const responsesByCategory = possible['usa']
31
+    const responseKey = {
32
+        response_key_id: match ? match.response_key_id : null,
33
+        response_key_category: match ? match.response_key_category : 'profile',
34
+        response_key_prompt: match ? match.response_key_prompt : step,
35
+        response_key_description: match ? match.response_key_description : null,
36
+    }
37
+    return {
38
+        ...responseKey,
39
+        responses: responsesByCategory[step] ? responsesByCategory[step] : [],
40
+    }
41
+}
42
+const associateWithComponent = responseKeyLike => {
43
+    let component = promptToComponent[responseKeyLike.response_key_prompt]
44
+    return { ...responseKeyLike, component }
45
+}
46
+
47
+const hasMatch = (step, inArray) => {
48
+    return inArray.find(q => q.response_key_prompt == step)
49
+}
3 50
 
4 51
 class SurveyFactory {
5
-    constructor(responses) {
6
-        this.responsesByCategory = responses
52
+    constructor() {
7 53
         this.questionsFromDb = []
8 54
     }
9 55
     _setSteps(langFile) {
@@ -11,28 +57,18 @@ class SurveyFactory {
11 57
         const seenIds = []
12 58
         const stepsInCommon = stepsToProcess.map(step => {
13 59
             // Match question to step
14
-            const match = this.questionsFromDb.filter(
15
-                q => q.response_key_prompt == step,
16
-            )[0]
60
+            const match = hasMatch(step, this.questionsFromDb)
17 61
             if (match) {
18 62
                 seenIds.push(match.response_key_id)
19 63
             }
20
-            return {
21
-                response_key_id: match ? match.response_key_id : null,
22
-                response_key_category: match
23
-                    ? match.response_key_category
24
-                    : 'profile',
25
-                response_key_prompt: match ? match.response_key_prompt : step,
26
-                response_key_description: match
27
-                    ? match.response_key_description
28
-                    : null,
29
-                responses: this.responsesByCategory[step]
30
-                    ? this.responsesByCategory[step]
31
-                    : [],
32
-            }
64
+            const responseKeyLike = formatStep(match, step)
65
+            const withComponent = associateWithComponent(responseKeyLike)
66
+            console.log('withComponent :>> ', withComponent)
67
+            return withComponent
33 68
         })
34
-        const unseen = this.questionsFromDb.filter(
35
-            q => !seenIds.includes(q.response_key_id),
69
+        // temporary extra condition in filter 
70
+        let unseen = this.questionsFromDb.filter(
71
+            q => !seenIds.includes(q.response_key_id) && [1,2,3,4,5,6].includes(q.response_key_id),
36 72
         )
37 73
         return [...stepsInCommon, ...unseen]
38 74
     }

+ 0
- 2
frontend/src/views/HomeView.vue Datei anzeigen

@@ -15,7 +15,6 @@ main.view--home
15 15
 <script>
16 16
 import 'wave-ui/dist/wave-ui.css'
17 17
 import ProfileCardList from '../components/ProfileCardList.vue'
18
-import TagList from '../components/TagList.vue'
19 18
 import AspectBar from '../components/AspectBar.vue'
20 19
 import SummaryBar from '../components/SummaryBar.vue'
21 20
 import PairingButton from '../components/PairingButton.vue'
@@ -57,7 +56,6 @@ export default {
57 56
     components: {
58 57
         ProfileCardList,
59 58
         AspectBar,
60
-        TagList,
61 59
         SummaryBar,
62 60
         PairingButton,
63 61
     },

+ 28
- 57
frontend/src/views/OnboardingView.vue Datei anzeigen

@@ -1,46 +1,24 @@
1 1
 <template lang="pug">
2 2
 main.view--onboarding
3
-    article(style='display: flex; flex-direction: column; align-items: center')
4
-        component(
5
-            :aspectQuestions='onboardingStep.component == "Aspects" ? aspectQuestions : null'
6
-            :currentStep='currentStep'
7
-            :is='onboardingStep.component'
8
-            @go-to-step='goToStep'
9
-            @handle-submit='onboardingStep.component == "Aspects" ? onSubmit : null'
10
-        )
11
-    //- MainNav
3
+    article(
4
+        style='display: flex; flex-direction: column; align-items: center'
5
+        v-if='survey'
6
+    )
7
+        .step(v-for='(step, i) in survey.steps')
8
+            component(
9
+                :aspect-questions='step.component == "Aspects" ? survey.aspectQuestions : null'
10
+                :is='step.component'
11
+                :question='step'
12
+                @handle-submit='onSubmit'
13
+                @update-answers='updateAnswers'
14
+                v-if='step && currentStep == i'
15
+            )
12 16
 </template>
13 17
 
14 18
 <script>
15 19
 import { surveyFactory } from '@/utils'
16
-import { allSteps, possible } from '@/utils/lang'
20
+import { allSteps } from '@/utils/lang'
17 21
 import stepViews from '@/components/onboarding'
18
-import OnboardingStepComponents from '../utils/onboardingStepComponents'
19
-
20
-const SCORED = [1, 2, 3, 4, 5, 6] // consider expanding + modifying DB table
21
-const _isScored = id => SCORED.includes(id)
22
-
23
-const _makeCategoryFriendly = responseCategory => {
24
-    const labels = responseCategory.split('_vs_')
25
-    labels.forEach((a, i) => {
26
-        if (a.indexOf('_') == -1) return
27
-        labels[i] = a.split('_').join(' ')
28
-    })
29
-    return labels
30
-}
31
-
32
-const _formatAspectQuestions = steps => {
33
-    return steps
34
-        .map(q => {
35
-            if (!_isScored(q.response_key_id)) return null
36
-            return {
37
-                id: q.response_key_id,
38
-                question: q.response_key_prompt,
39
-                labels: _makeCategoryFriendly(q.response_key_category),
40
-            }
41
-        })
42
-        .filter(step => step != null)
43
-}
44 22
 
45 23
 // import savesurveybyprfileid - call it on submit
46 24
 // paginate to save every steps answers
@@ -53,36 +31,29 @@ export default {
53 31
         answered: {},
54 32
         aspectQuestions: [],
55 33
         currentStep: 0,
56
-        onboardingStepComponents: [],
57
-        validSurvey: null,
34
+        survey: null,
58 35
     }),
59
-    computed: {
60
-        onboardingStep() {
61
-            if (!this.onboardingStepComponents.length) return []
62
-            return this.onboardingStepComponents[this.currentStep]
63
-        },
64
-    },
65 36
     async created() {
66
-        const survey = await surveyFactory.createSurvey(
67
-            allSteps['usa'],
68
-            possible['usa']['roles'],
69
-        )
70
-        this.aspectQuestions = _formatAspectQuestions(survey.steps)
71
-        this.onboardingStepComponents = OnboardingStepComponents
37
+        this.survey = await surveyFactory.createSurvey(allSteps['usa'])
72 38
     },
73 39
     methods: {
74
-        onUpdate(payload) {
75
-            console.log('payload: ', payload)
76
-            // this.answered[payload.id] = payload
77
-        },
78 40
         onSubmit() {
79
-            Object.values(this.answered).forEach(ans =>
80
-                console.log(ans.question, ans.answer),
81
-            )
41
+            console.log(JSON.stringify(this.answered))
82 42
         },
83 43
         goToStep(num) {
84 44
             this.currentStep = num
85 45
         },
46
+        updateAnswers(payload) {
47
+            // null payload is passed on splash page
48
+            if(payload){
49
+                const k = payload.question.response_key_prompt
50
+                this.answered[k] = payload.answer
51
+                console.log(`${k}:`, this.answered[k])
52
+                console.log(`Updated answers: ${JSON.stringify(this.answered)}`)
53
+                if(k === 'aspects') return
54
+            }
55
+            this.goToStep(this.currentStep + 1)
56
+        },
86 57
     },
87 58
 }
88 59
 </script>

Laden…
Abbrechen
Speichern