Преглед изворни кода

:recycle: total reorg of survey questions | redid mock data for better detail

tags/0.0.1
J пре 4 година
родитељ
комит
9568f38a92

+ 145
- 14
backend/db/data-generator/mock.js Прегледај датотеку

14
             tag_description: 'verified',
14
             tag_description: 'verified',
15
             is_active: true,
15
             is_active: true,
16
         },
16
         },
17
+        {
18
+            tag_id: 3,
19
+            tag_category: 'reveal',
20
+            tag_description: 'pronoun',
21
+            is_active: true,
22
+        },
23
+        {
24
+            tag_id: 4,
25
+            tag_category: 'reveal',
26
+            tag_description: 'image',
27
+            is_active: true,
28
+        },
29
+        {
30
+            tag_id: 5,
31
+            tag_category: 'reveal',
32
+            tag_description: 'blurb',
33
+            is_active: true,
34
+        },
35
+        {
36
+            tag_id: 6,
37
+            tag_category: 'reveal',
38
+            tag_description: 'urgency',
39
+            is_active: true,
40
+        },
17
     ],
41
     ],
18
     tag_associations: [
42
     tag_associations: [
19
         {
43
         {
39
         },
63
         },
40
         {
64
         {
41
             tag_association_id: 4,
65
             tag_association_id: 4,
42
-            profile_id: 5,
66
+            profile_id: 45,
43
             membership_id: null,
67
             membership_id: null,
44
             tag_id: 1,
68
             tag_id: 1,
45
             is_deleted: false,
69
             is_deleted: false,
46
         },
70
         },
71
+        {
72
+            tag_association_id: 5,
73
+            profile_id: 45,
74
+            membership_id: 1,
75
+            tag_id: 4,
76
+            is_deleted: false,
77
+        },
78
+        {
79
+            tag_association_id: 6,
80
+            profile_id: 45,
81
+            membership_id: 1,
82
+            tag_id: 5,
83
+            is_deleted: false,
84
+        },
85
+        {
86
+            tag_association_id: 7,
87
+            profile_id: 2,
88
+            membership_id: 1,
89
+            tag_id: 5,
90
+            is_deleted: false,
91
+        },
47
     ],
92
     ],
48
     response_keys: [
93
     response_keys: [
49
         {
94
         {
50
             response_key_id: 1,
95
             response_key_id: 1,
51
             response_key_category: 'grit',
96
             response_key_category: 'grit',
52
-            response_key_prompt: 'what is your name',
97
+            response_key_prompt: 'can you power through adversity',
53
             response_key_description: null,
98
             response_key_description: null,
54
         },
99
         },
55
         {
100
         {
56
             response_key_id: 2,
101
             response_key_id: 2,
57
             response_key_category: 'openness',
102
             response_key_category: 'openness',
58
-            response_key_prompt: 'what is your favorite color',
103
+            response_key_prompt: 'are you open with your emotions with everyone',
59
             response_key_description: null,
104
             response_key_description: null,
60
         },
105
         },
61
         {
106
         {
62
             response_key_id: 3,
107
             response_key_id: 3,
63
             response_key_category: 'bravery',
108
             response_key_category: 'bravery',
64
-            response_key_prompt: 'what is your quest',
109
+            response_key_prompt: 'do you speak-up when you feel something is wrong',
65
             response_key_description: null,
110
             response_key_description: null,
66
         },
111
         },
67
         {
112
         {
68
             response_key_id: 4,
113
             response_key_id: 4,
69
             response_key_category: 'empathy',
114
             response_key_category: 'empathy',
70
             response_key_prompt:
115
             response_key_prompt:
71
-                'what is the average flight speed of an unladen swallow',
116
+                'do you stop to help others when they are struggling',
72
             response_key_description: null,
117
             response_key_description: null,
73
         },
118
         },
74
         {
119
         {
75
             response_key_id: 5,
120
             response_key_id: 5,
76
             response_key_category: 'honesty',
121
             response_key_category: 'honesty',
77
-            response_key_prompt: 'what is your favorite color',
122
+            response_key_prompt: 'when telling a story do you exaggerate for dramatic effect',
78
             response_key_description: null,
123
             response_key_description: null,
79
         },
124
         },
80
         {
125
         {
81
             response_key_id: 6,
126
             response_key_id: 6,
82
             response_key_category: 'respect',
127
             response_key_category: 'respect',
83
-            response_key_prompt: 'what kind of schedule are you looking for',
128
+            response_key_prompt: 'do you treat difficult people as well as you treat your close friends',
84
             response_key_description: null,
129
             response_key_description: null,
85
         },
130
         },
86
         {
131
         {
87
             response_key_id: 7,
132
             response_key_id: 7,
88
             response_key_category: 'profile',
133
             response_key_category: 'profile',
89
-            response_key_prompt: 'what is your zip code',
134
+            response_key_prompt: 'zipcode',
90
             response_key_description: null,
135
             response_key_description: null,
91
         },
136
         },
92
         {
137
         {
104
         {
149
         {
105
             response_key_id: 10,
150
             response_key_id: 10,
106
             response_key_category: 'profile',
151
             response_key_category: 'profile',
107
-            response_key_prompt: 'distance',
152
+            response_key_prompt: 'duration',
108
             response_key_description: null,
153
             response_key_description: null,
109
         },
154
         },
110
         {
155
         {
111
             response_key_id: 11,
156
             response_key_id: 11,
112
             response_key_category: 'profile',
157
             response_key_category: 'profile',
113
-            response_key_prompt: 'duration',
158
+            response_key_prompt: 'presence',
114
             response_key_description: null,
159
             response_key_description: null,
115
         },
160
         },
116
         {
161
         {
131
             response_key_prompt: 'role',
176
             response_key_prompt: 'role',
132
             response_key_description: null,
177
             response_key_description: null,
133
         },
178
         },
179
+        {
180
+            response_key_id: 15,
181
+            response_key_category: 'profile',
182
+            response_key_prompt: 'pronouns',
183
+            response_key_description: null,
184
+        },
185
+        {
186
+            response_key_id: 16,
187
+            response_key_category: 'profile',
188
+            response_key_prompt: 'distance',
189
+            response_key_description: null,
190
+        },
134
     ],
191
     ],
135
     responses: [],
192
     responses: [],
136
-    memberships: [],
137
-    groupings: [],
193
+    memberships: [
194
+        {
195
+            membership_id: 1,
196
+            profile_id: 45,
197
+            grouping_id: 1,
198
+            membership_type: 'participant',
199
+            can_edit: 0,
200
+            is_active: 1,
201
+        },
202
+        {
203
+            membership_id: 2,
204
+            profile_id: 2,
205
+            grouping_id: 1,
206
+            membership_type: 'participant',
207
+            can_edit: 0,
208
+            is_active: 1,
209
+        },
210
+        {
211
+            membership_id: 3,
212
+            profile_id: 45,
213
+            grouping_id: 2,
214
+            membership_type: 'participant',
215
+            can_edit: 0,
216
+            is_active: 1,
217
+        },
218
+        {
219
+            membership_id: 4,
220
+            profile_id: 3,
221
+            grouping_id: 2,
222
+            membership_type: 'participant',
223
+            can_edit: 0,
224
+            is_active: 0,
225
+        }
226
+    ],
227
+    groupings: [
228
+        {
229
+            grouping_id: 1,
230
+            grouping_name: '1654664154.291_45_2',
231
+            grouping_type: 'match',
232
+        },
233
+        {
234
+            grouping_id: 2,
235
+            grouping_name: '1654664154.291_45_3',
236
+            grouping_type: 'match',
237
+        }
238
+    ],
138
     messages: [],
239
     messages: [],
139
     match_queues: [
240
     match_queues: [
140
         {
241
         {
146
         {
247
         {
147
             match_queue_id: 2,
248
             match_queue_id: 2,
148
             profile_id: 45,
249
             profile_id: 45,
149
-            target_id: 2,
250
+            target_id: 5,
150
             is_deleted: false,
251
             is_deleted: false,
151
         },
252
         },
152
         {
253
         {
153
             match_queue_id: 3,
254
             match_queue_id: 3,
154
             profile_id: 45,
255
             profile_id: 45,
155
-            target_id: 3,
256
+            target_id: 6,
257
+            is_deleted: false,
258
+        },
259
+        {
260
+            match_queue_id: 4,
261
+            profile_id: 45,
262
+            target_id: 7,
263
+            is_deleted: false,
264
+        },
265
+        {
266
+            match_queue_id: 5,
267
+            profile_id: 45,
268
+            target_id: 8,
269
+            is_deleted: false,
270
+        },
271
+        {
272
+            match_queue_id: 6,
273
+            profile_id: 45,
274
+            target_id: 9,
275
+            is_deleted: false,
276
+        },
277
+        {
278
+            match_queue_id: 7,
279
+            profile_id: 2,
280
+            target_id: 4,
281
+            is_deleted: false,
282
+        },
283
+        {
284
+            match_queue_id: 8,
285
+            profile_id: 2,
286
+            target_id: 10,
156
             is_deleted: false,
287
             is_deleted: false,
157
         },
288
         },
158
     ],
289
     ],

+ 4
- 2
backend/lib/routes/notification/index.js Прегледај датотеку

27
         auth: false,
27
         auth: false,
28
         cors: true,
28
         cors: true,
29
         handler: async (request, h) => {
29
         handler: async (request, h) => {
30
+            const { profile_id } = request.params
30
             const input = new PassThrough({ objectMode: true })
31
             const input = new PassThrough({ objectMode: true })
31
             const eventType = 'stonk'
32
             const eventType = 'stonk'
32
 
33
 
33
-            const msg = { name: 'BDGRS', price: (500 + Math.floor(Math.random() * 100)).toString(), order: null }
34
+            const msg = { profile_id, name: 'BDGRS', price: (500 + Math.floor(Math.random() * 100)).toString(), order: null }
34
 
35
 
35
             // Write to the input stream
36
             // Write to the input stream
36
             setInterval(() => {
37
             setInterval(() => {
40
 
41
 
41
             // h.event() Added at plugin registration
42
             // h.event() Added at plugin registration
42
             // h is the toolkit
43
             // h is the toolkit
43
-            return h.event(input, h, { event: eventType })
44
+            const streamOptions = { event: `${profile_id}.${eventType}` }
45
+            return h.event(input, h, streamOptions)
44
         },
46
         },
45
 
47
 
46
         /** Validate based on validators object */
48
         /** Validate based on validators object */

+ 1
- 0
backend/lib/services/notification.js Прегледај датотеку

94
         //     stream = new Transformer(streamOptions, false)
94
         //     stream = new Transformer(streamOptions, false)
95
         //     event.pipe(stream)
95
         //     event.pipe(stream)
96
         // }
96
         // }
97
+        console.log('streamOptions :', streamOptions)
97
         return h.response(active)
98
         return h.response(active)
98
             .header('content-type', 'text/event-stream')
99
             .header('content-type', 'text/event-stream')
99
             .header('content-encoding', 'identity')
100
             .header('content-encoding', 'identity')

+ 7
- 4
frontend/src/App.vue Прегледај датотеку

42
         */
42
         */
43
         if(DEV_MODE) { this.setPid(DEV_PID) }
43
         if(DEV_MODE) { this.setPid(DEV_PID) }
44
 
44
 
45
-        this.setupChatter()
46
-        this.setupToaster()
45
+        if(currentProfile.isLoggedIn()) {
46
+            console.warn(`setting up Chatter and Toaster for ${this.getPid}...`)
47
+            this.setupChatter()
48
+            this.setupToaster()
49
+        }
47
         console.log('---')
50
         console.log('---')
48
     },
51
     },
49
     methods: {
52
     methods: {
59
          * For push notifications and chat
62
          * For push notifications and chat
60
          */
63
          */
61
         setupToaster() {
64
         setupToaster() {
62
-            const t = new StonkAlert(this.pid)
65
+            const t = new StonkAlert(this.getPid)
63
         },
66
         },
64
         setupChatter() {
67
         setupChatter() {
65
             const c = new Chatter()
68
             const c = new Chatter()
80
     display: flex
83
     display: flex
81
     flex-direction: row
84
     flex-direction: row
82
     text-align: center
85
     text-align: center
83
-    color: $primary
86
+    color: $light
84
     font-family: $sans
87
     font-family: $sans
85
     background-color: $secondary
88
     background-color: $secondary
86
     overflow-x: hidden
89
     overflow-x: hidden

+ 2
- 8
frontend/src/components/ProfileCardList.vue Прегледај датотеку

31
                     :style="{ 'background-image': `url(${profile.avatar})` }"
31
                     :style="{ 'background-image': `url(${profile.avatar})` }"
32
                 )
32
                 )
33
                 .card__content
33
                 .card__content
34
-                    h3.p-1.mv-0.b-solid.rounded {{ profile.pid  }} {{ profile.name }}
34
+                    button(@click="view(profile.pid)").p-1.mv-0.b-solid.rounded {{ profile.pid  }} {{ profile.name }}
35
 </template>
35
 </template>
36
 
36
 
37
 <script setup>
37
 <script setup>
81
 // AHP Button behavior
81
 // AHP Button behavior
82
 
82
 
83
 const accept = async () => {
83
 const accept = async () => {
84
-    console.log('accepted aka do NOT reinsert')
85
     // need to pass these arguments (profileId, targetId, status)
84
     // need to pass these arguments (profileId, targetId, status)
86
     // the url structure is
85
     // the url structure is
87
     // const charmander = await db.get(`/profile/{profile_id}/queue/{target_id}/delete?include_profile=true&reinsert=false`)
86
     // const charmander = await db.get(`/profile/{profile_id}/queue/{target_id}/delete?include_profile=true&reinsert=false`)
92
     // TODO: next step is grouping/membership
91
     // TODO: next step is grouping/membership
93
     const checkMembership = await fetchMembershipsByProfileId(profileId)
92
     const checkMembership = await fetchMembershipsByProfileId(profileId)
94
     if (!checkMembership.length) {
93
     if (!checkMembership.length) {
95
-        console.log('Make membership')
96
         postMembershipByProfileId({ profileId, targetId })
94
         postMembershipByProfileId({ profileId, targetId })
97
     }
95
     }
98
     emit('reload')
96
     emit('reload')
99
 }
97
 }
100
 const view = pid => {
98
 const view = pid => {
101
-    router.push({
102
-        name: 'ProfileView',
103
-        params: { pid },
104
-    })
99
+    router.push({ path: `/matches/${pid}` })
105
 }
100
 }
106
 const pass = () => {
101
 const pass = () => {
107
-    console.log('passed aka do reinsert')
108
     // const charmander = await db.get(`/profile/{profile_id}/queue/{target_id}/delete?include_profile=true&reinsert=true`)
102
     // const charmander = await db.get(`/profile/{profile_id}/queue/{target_id}/delete?include_profile=true&reinsert=true`)
109
     const profileId = props.pid
103
     const profileId = props.pid
110
     const targetId = props.profiles[0].pid
104
     const targetId = props.profiles[0].pid

+ 5
- 0
frontend/src/router/index.js Прегледај датотеку

25
         name: 'MatchesView',
25
         name: 'MatchesView',
26
         meta: { requiresAuth: true, requiresCompleteProfile: true },
26
         meta: { requiresAuth: true, requiresCompleteProfile: true },
27
     },
27
     },
28
+    {
29
+        path: '/matches/:pid',
30
+        component: ProfileView,
31
+        meta: { requiresAuth: true, requiresCompleteProfile: true },
32
+    },
28
     {
33
     {
29
         path: `/survey`,
34
         path: `/survey`,
30
         component: SurveyView,
35
         component: SurveyView,

+ 6
- 4
frontend/src/services/login.service.js Прегледај датотеку

14
         // Make reactive with vue observer
14
         // Make reactive with vue observer
15
         this.id = ref(null)
15
         this.id = ref(null)
16
 
16
 
17
-        this.matches = []
18
         this.responses = []
17
         this.responses = []
18
+        this.tags = []
19
     }
19
     }
20
     isLoading() {
20
     isLoading() {
21
         return this._loading
21
         return this._loading
26
     isComplete() {
26
     isComplete() {
27
         return this.responses.length == surveyFactory.questions.length
27
         return this.responses.length == surveyFactory.questions.length
28
     }
28
     }
29
-    hasMatches() {
30
-        return this.matches.length && this.matches.length > 0
31
-    } 
32
     hasResponses() {
29
     hasResponses() {
33
         return this.responses.length && this.responses.length > 0
30
         return this.responses.length && this.responses.length > 0
34
     } 
31
     } 
42
         return this.id.value
39
         return this.id.value
43
     }
40
     }
44
     logout() { this.id.value = null }
41
     logout() { this.id.value = null }
42
+    
43
+    async getTags() {
44
+        this.tags = []
45
+        return this.tags
46
+    }
45
 
47
 
46
     async getResponses() {
48
     async getResponses() {
47
         try {
49
         try {

+ 1
- 1
frontend/src/services/notification.service.js Прегледај датотеку

24
         super(profileId)
24
         super(profileId)
25
 
25
 
26
         this.stonks = {}
26
         this.stonks = {}
27
-        this.listenFor('stonk', message => {
27
+        this.listenFor(`${profileId}.stonk`, message => {
28
             const parsed = JSON.parse(message.data)
28
             const parsed = JSON.parse(message.data)
29
             this.stonks[parsed.name] = parsed
29
             this.stonks[parsed.name] = parsed
30
             console.log('updated:', this.stonks)
30
             console.log('updated:', this.stonks)

+ 6
- 1
frontend/src/services/survey.service.js Прегледај датотеку

8
  * @returns {array} instantiated Profile objects (see: /entites/profile)
8
  * @returns {array} instantiated Profile objects (see: /entites/profile)
9
  */
9
  */
10
 const fetchQuestions = async () => {
10
 const fetchQuestions = async () => {
11
-    return await db.get(`/survey/questions`)
11
+    const questions = await db.get(`/survey/questions`)
12
+    // Add responses to match the format from the survery factory
13
+    return questions.map(q => {
14
+        q.responses = !q.responses ? [] : q.responses
15
+        return q
16
+    })
12
 }
17
 }
13
 
18
 
14
 const saveSurveyByProfileId = async (surveyResponses, profileId) => {
19
 const saveSurveyByProfileId = async (surveyResponses, profileId) => {

+ 5
- 5
frontend/src/sss/partials/_typography.sss Прегледај датотеку

3
 
3
 
4
 h1
4
 h1
5
     font-size: $ms-5
5
     font-size: $ms-5
6
-    line-height: $ms-4
6
+    line-height: $ms-5
7
 h2
7
 h2
8
     font-size: $ms-3
8
     font-size: $ms-3
9
-    line-height: $ms-2
9
+    line-height: $ms-3
10
 h3
10
 h3
11
     font-size: $ms-2
11
     font-size: $ms-2
12
-    line-height: $ms-1
12
+    line-height: $ms-2
13
 h4
13
 h4
14
     font-size: $ms-1
14
     font-size: $ms-1
15
-    line-height: $ms-0
15
+    line-height: $ms-2
16
 p
16
 p
17
     font-size: $ms-1
17
     font-size: $ms-1
18
-    line-height: $ms-0
18
+    line-height: $ms-2
19
 
19
 
20
 .t
20
 .t
21
     &-center
21
     &-center

+ 44
- 13
frontend/src/utils/lang.js Прегледај датотеку

7
     experience: 'ButtonChoice',
7
     experience: 'ButtonChoice',
8
     role: 'ButtonChoice',
8
     role: 'ButtonChoice',
9
     duration: 'ButtonChoice',
9
     duration: 'ButtonChoice',
10
-    distance: 'ButtonChoice',
10
+    presence: 'ButtonChoice',
11
     language: 'ButtonMulti',
11
     language: 'ButtonMulti',
12
+    pronouns: 'ButtonMulti',
13
+    image: 'InputString',
14
+    zipcode: 'InputString',
15
+    blurb: 'InputString',
16
+    distance: 'InputRange',
12
 }
17
 }
13
-
18
+// TODO: Combine these two
14
 const allSteps = {
19
 const allSteps = {
15
     usa: {
20
     usa: {
16
         name: 'name',
21
         name: 'name',
22
+        pronouns: 'pronouns',
17
         seeking: 'seeking',
23
         seeking: 'seeking',
18
         urgency: 'urgency',
24
         urgency: 'urgency',
19
         experience: 'experience',
25
         experience: 'experience',
20
-        role: 'role',
26
+        roles: 'role',
21
         duration: 'duration',
27
         duration: 'duration',
22
-        distance: 'distance',
28
+        presence: 'presence',
23
         language: 'language',
29
         language: 'language',
30
+        zipcode: 'zipcode',
31
+        distance: 'distance',
32
+        blurb: 'blurb',
33
+        image: 'image',
34
+    }
35
+}
36
+
37
+const allResponses = {
38
+    usa: {
39
+        questionaire: {
40
+            never: 'never',
41
+            rarely: 'rarely',
42
+            not_really: 'not really',
43
+            occasionally: 'occasionally',
44
+            mostly: 'mostly',
45
+            often: 'often',
46
+            everytime: 'everytime',
47
+        }
24
     }
48
     }
25
 }
49
 }
26
 
50
 
43
     urgency: [
67
     urgency: [
44
         'actively_looking',
68
         'actively_looking',
45
         'open_to_the_right_opportunity',
69
         'open_to_the_right_opportunity',
46
-        'just_browsing',
47
-        'networking',
70
+        'casually_browsing',
48
     ],
71
     ],
49
-    // key 10
50
-    distance: [
72
+    // key 11
73
+    presence: [
51
         'remote',
74
         'remote',
52
         'in_person',
75
         'in_person',
53
         'hybrid',
76
         'hybrid',
54
         'flexible'
77
         'flexible'
55
     ],
78
     ],
56
-    // key 11
79
+    // key 10
57
     duration: [
80
     duration: [
58
         'full-time',
81
         'full-time',
59
         'part-time',
82
         'part-time',
60
         'contract',
83
         'contract',
61
         'flexible',
84
         'flexible',
62
     ],
85
     ],
63
-    // Everything else concats under role, key: 14
86
+    // Experience and roles concat, key: 14
64
     experience: [
87
     experience: [
65
         'associate',
88
         'associate',
66
         'junior',
89
         'junior',
67
         'mid-level',
90
         'mid-level',
68
         'senior',
91
         'senior',
69
         'staff',
92
         'staff',
70
-        'chief_of',
71
-        'director_of',
72
     ],
93
     ],
73
     roles: {
94
     roles: {
74
         type: [
95
         type: [
95
             'recruiter',
116
             'recruiter',
96
         ]
117
         ]
97
     },
118
     },
119
+    pronouns: [
120
+        'she/her',
121
+        'she/they',
122
+        'he/him',
123
+        'he/they',
124
+        'they/them',
125
+    ],
126
+    image: [],
127
+    zipcode: [],
128
+    blurb: []
98
 }
129
 }
99
 
130
 
100
-export { allSteps, stepToComponentMap, possible }
131
+export { allSteps, allResponses, stepToComponentMap, possible }

+ 7
- 7
frontend/src/utils/survey.js Прегледај датотеку

4
 class SurveyFactory {
4
 class SurveyFactory {
5
     constructor(responses) {
5
     constructor(responses) {
6
         this.responsesByCategory = responses
6
         this.responsesByCategory = responses
7
-        this.questions = []
7
+        this.questionsFromDb = []
8
     }
8
     }
9
     _setSteps(langFile) {
9
     _setSteps(langFile) {
10
         const stepsToProcess = [...Object.values(langFile) ]
10
         const stepsToProcess = [...Object.values(langFile) ]
11
         const seenIds = []
11
         const seenIds = []
12
         const stepsInCommon = stepsToProcess.map(step => {
12
         const stepsInCommon = stepsToProcess.map(step => {
13
             // Match question to step
13
             // Match question to step
14
-            const match = this.questions.filter(q => q.response_key_prompt == step)[0]
14
+            const match = this.questionsFromDb.filter(q => q.response_key_prompt == step)[0]
15
             if(match) { seenIds.push(match.response_key_id) }
15
             if(match) { seenIds.push(match.response_key_id) }
16
             return {
16
             return {
17
-                response_key_category: match ? match.response_key_category: 'profile',
18
-                response_key_description: match ? match.response_key_description: null,
19
                 response_key_id: match ? match.response_key_id: null,
17
                 response_key_id: match ? match.response_key_id: null,
18
+                response_key_category: match ? match.response_key_category: 'profile',
20
                 response_key_prompt: match ? match.response_key_prompt: step,
19
                 response_key_prompt: match ? match.response_key_prompt: step,
20
+                response_key_description: match ? match.response_key_description: null,
21
                 responses: this.responsesByCategory[step] ? this.responsesByCategory[step] : [] 
21
                 responses: this.responsesByCategory[step] ? this.responsesByCategory[step] : [] 
22
             }
22
             }
23
         })
23
         })
24
-        const unseen = this.questions.filter(q => !seenIds.includes(q.response_key_id))
24
+        const unseen = this.questionsFromDb.filter(q => !seenIds.includes(q.response_key_id))
25
         return [...stepsInCommon, ...unseen]
25
         return [...stepsInCommon, ...unseen]
26
     }
26
     }
27
     async getQuestions() {
27
     async getQuestions() {
28
-        this.questions = await fetchQuestions()
28
+        this.questionsFromDb = await fetchQuestions()
29
     }
29
     }
30
     async createSurvey(langFile, roleTree) {
30
     async createSurvey(langFile, roleTree) {
31
-        if(!this.questions.length) {
31
+        if(!this.questionsFromDb.length) {
32
             console.error('Attempted to create a survey before getting questions')
32
             console.error('Attempted to create a survey before getting questions')
33
             await this.getQuestions()
33
             await this.getQuestions()
34
         }
34
         }

+ 1
- 1
frontend/src/views/ProfileView.vue Прегледај датотеку

5
  
5
  
6
     article(v-if="!loading")
6
     article(v-if="!loading")
7
         h3 {{ profile }}
7
         h3 {{ profile }}
8
-        RouterLink(:to="{ name: 'HomeView' }") back
8
+        button(@click="$router.go(-1)") back
9
 
9
 
10
     p(v-else) Loading...
10
     p(v-else) Loading...
11
 
11
 

+ 69
- 32
frontend/src/views/SurveyView.vue Прегледај датотеку

1
 <template lang="pug">
1
 <template lang="pug">
2
 main.view--survey.f-col.start.w-full
2
 main.view--survey.f-col.start.w-full
3
     header.w-full.f-col
3
     header.w-full.f-col
4
-        p survey for profile: {{ pid }}
4
+        p survey for profile: {{ current }}
5
         //- Transition(name="slide-up" :duration="1600")
5
         //- Transition(name="slide-up" :duration="1600")
6
         //-     h3(v-if="step == 0") hello, what shall i call you?
6
         //-     h3(v-if="step == 0") hello, what shall i call you?
7
         //-         span(v-for="letter in name" class="fade") {{ letter }}
7
         //-         span(v-for="letter in name" class="fade") {{ letter }}
53
     article.match.w-full
53
     article.match.w-full
54
         ul.w-full
54
         ul.w-full
55
             template(v-for="(q, i) in profileQuestions" :key="q.response_key_prompt")
55
             template(v-for="(q, i) in profileQuestions" :key="q.response_key_prompt")
56
-                p {{q}}
57
-                //- li(v-if="step == i").f-col
58
-                //-     p step: {{ i }}
59
-                //-         component(
60
-                //-             v-if="componentMap[q.response_key_prompt]"
61
-                //-             :is="componentMap[q.response_key_prompt]"
62
-                //-             :opts="q.responses"
63
-                //-             :prompt="q.response_key_prompt"
64
-                //-             @selected="onButtonSelect"
65
-                //-             @hovered="onInputChange"
66
-                //-             @input="onInputChange"
67
-                //-         )
68
-                //-     footer.f-row
69
-                //-         button(@click="back(q.response_key_prompt)").w-full back
56
+                li(v-if="step == i")
57
+                    p {{q.response_key_category}}: 
58
+                        span in db:
59
+                        span(v-if="q.response_key_id") true - id:{{q.response_key_id}} | 
60
+                        span(v-else) false | 
61
+                        span {{q.response_key_prompt}}? 
62
+                        span {{q.response_key_description}} 
63
+
64
+                        div(v-if="q.responses.length")
65
+                            button(
66
+                                v-for="(res, index) in q.responses"
67
+                                :key="index"
68
+                                @click="profile[q.response_key_prompt] = res; step++"
69
+                                :disabled="profile[q.response_key_prompt] == res"
70
+                            ).p-0 {{res}}
71
+                        div(v-else-if="q.response_key_category === 'profile'")
72
+                            input(v-model="profile[q.response_key_prompt]" @keyup.enter="step++") 
73
+                            label >{{ profile[q.response_key_prompt]}}
74
+                        div(v-else).f-col
75
+                            input(type="range" min="-3" max="3" list="ticks" v-model="questionaire[q.response_key_category]").w-full
76
+                            label {{ questionaireResponses[parseInt(questionaire[q.response_key_category]) + 3] }} 
77
+                    nav.f-row
78
+                        button(:disabled="step == 0" @click="step--") back
79
+                        p {{step + 1}} of {{profileQuestions.length}}
80
+                        button(@click="step++") next
81
+            li(v-if="step == profileQuestions.length")
82
+                p Does this look correct?
83
+                h4 {{ profile }}
84
+                h4 {{questionaire}}
85
+                nav.f-row
86
+                    button(@click="step--") back
87
+                    p(@click="step = 0").p-1 start over
88
+                    button(@click="$router.push({ name: 'HomeView' })") save
89
+            
70
     MainNav(@show-sidebar="$emit('show-sidebar')")
90
     MainNav(@show-sidebar="$emit('show-sidebar')")
71
 </template>
91
 </template>
72
 
92
 
73
 <script>
93
 <script>
74
-import { surveyFactory } from '../utils'
75
-import { allSteps, possible, stepToComponentMap } from '../utils/lang'
94
+import { surveyFactory } from '@/utils'
95
+import { allSteps, allResponses, possible, stepToComponentMap } from '@/utils/lang'
96
+import { currentProfile } from '@/services'
76
 
97
 
77
-import SurveyForm from '../components/form.vue'
78
-import ButtonMulti from '../components/form/button-multi.vue'
79
-import ButtonChoice from '../components/form/button-choice.vue'
80
-import InputString from '../components/form/input-string.vue'
98
+import SurveyForm from '@/components/form.vue'
99
+import ButtonMulti from '@/components/form/button-multi.vue'
100
+import ButtonChoice from '@/components/form/button-choice.vue'
101
+import InputString from '@/components/form/input-string.vue'
81
 
102
 
82
 export default {
103
 export default {
83
     components: { SurveyForm, ButtonMulti, ButtonChoice, InputString },
104
     components: { SurveyForm, ButtonMulti, ButtonChoice, InputString },
92
             validSurvey: null,
113
             validSurvey: null,
93
             componentMap: stepToComponentMap,
114
             componentMap: stepToComponentMap,
94
             step: 0,
115
             step: 0,
95
-            name: '',
96
-            seeking: '',
97
-            urgency: '',
98
-            role: '',
99
-            duration: '',
100
-            distance: '',
101
-            experience: '',
102
-            position: '',
103
-            language: '',
104
-            pronouns: '',
105
-            zipcode: '',
116
+            profile: {
117
+                name: '',
118
+                seeking: '',
119
+                urgency: '',
120
+                experience: '',
121
+                role: '',
122
+                duration: '',
123
+                distance: '',
124
+                position: '',
125
+                language: '',
126
+                pronouns: '',
127
+                zipcode: '',
128
+                image: '',
129
+                blurb: ''
130
+            },
131
+            questionaire: {
132
+                grit: 0,
133
+                openness: 0,
134
+                bravery: 0,
135
+                empathy: 0,
136
+                honesty: 0,
137
+                respect: 0,
138
+            },
139
+            questionaireResponses: Object.values(allResponses.usa.questionaire)
106
         }
140
         }
107
     },
141
     },
108
     computed: {
142
     computed: {
143
+        current() {
144
+            return currentProfile
145
+        },
109
         profileQuestions() {
146
         profileQuestions() {
110
             if (!this.validSurvey) return []
147
             if (!this.validSurvey) return []
111
             return this.validSurvey.steps
148
             return this.validSurvey.steps

BIN
public/favicon.ico Прегледај датотеку


Loading…
Откажи
Сачувај