Sfoglia il codice sorgente

another pre-release (#53)

undefined
maeda 3 anni fa
parent
commit
c308291072

+ 1
- 1
backend/db/seeds/04-responses.js Vedi File

@@ -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
     }

+ 17
- 12
backend/package-lock.json Vedi File

@@ -1,7 +1,7 @@
1 1
 {
2 2
     "name": "siimee-backend",
3 3
     "version": "1.0.0",
4
-    "lockfileVersion": 2,
4
+    "lockfileVersion": 1,
5 5
     "requires": true,
6 6
     "packages": {
7 7
         "": {
@@ -9597,8 +9597,7 @@
9597 9597
             "version": "5.3.1",
9598 9598
             "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz",
9599 9599
             "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==",
9600
-            "dev": true,
9601
-            "requires": {}
9600
+            "dev": true
9602 9601
         },
9603 9602
         "acorn-walk": {
9604 9603
             "version": "8.1.0",
@@ -9638,7 +9637,11 @@
9638 9637
             "dependencies": {
9639 9638
                 "ansi-regex": {
9640 9639
                     "version": "4.1.0",
9640
+<<<<<<< HEAD
9641 9641
                     "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
9642
+=======
9643
+                    "resolved": "",
9644
+>>>>>>> b0c2120 (another pre-release (#53))
9642 9645
                     "dev": true
9643 9646
                 },
9644 9647
                 "emoji-regex": {
@@ -10713,6 +10716,7 @@
10713 10716
             "version": "3.2.7",
10714 10717
             "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
10715 10718
             "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
10719
+            "dev": true,
10716 10720
             "requires": {
10717 10721
                 "ms": "^2.1.1"
10718 10722
             }
@@ -12958,7 +12962,8 @@
12958 12962
         "ms": {
12959 12963
             "version": "2.1.3",
12960 12964
             "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
12961
-            "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
12965
+            "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
12966
+            "dev": true
12962 12967
         },
12963 12968
         "mysql": {
12964 12969
             "version": "2.18.1",
@@ -14577,14 +14582,6 @@
14577 14582
                 }
14578 14583
             }
14579 14584
         },
14580
-        "string_decoder": {
14581
-            "version": "1.1.1",
14582
-            "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
14583
-            "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
14584
-            "requires": {
14585
-                "safe-buffer": "~5.1.0"
14586
-            }
14587
-        },
14588 14585
         "string-width": {
14589 14586
             "version": "4.2.2",
14590 14587
             "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz",
@@ -14596,6 +14593,14 @@
14596 14593
                 "strip-ansi": "^6.0.0"
14597 14594
             }
14598 14595
         },
14596
+        "string_decoder": {
14597
+            "version": "1.1.1",
14598
+            "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
14599
+            "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
14600
+            "requires": {
14601
+                "safe-buffer": "~5.1.0"
14602
+            }
14603
+        },
14599 14604
         "strip-ansi": {
14600 14605
             "version": "6.0.0",
14601 14606
             "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",

+ 27
- 10
frontend/src/components/PairsList.vue Vedi File

@@ -2,24 +2,41 @@
2 2
 section.pairs-list
3 3
     article(v-if='pairs.length')
4 4
         template(v-for='pair in pairs')
5
-            w-flex().align-center.flex-start
5
+            w-flex.align-center.flex-start
6 6
                 router-link.pair.w-flex.align-center.flex-start(
7
-    :to='`/profile/${pair.profile.pid}`')
7
+                    :to='`/profile/${pair.profile.pid}`'
8
+                )
8 9
                     .dot--icon
9 10
                     .avatar
10 11
                     .idCard
11 12
                         h3 {{ pair.profile.name }} {{ pair.profile.pid }}
12 13
                         p registered nurse
13 14
 
14
-                w-menu( left v-model='showMenu')
15
+                w-menu(left v-model='showMenu')
15 16
                     template(#activator)
16
-                        w-button.mr3(@click='showMenu = !showMenu' icon="icon-dots-three-horizontal")
17
-                    w-flex()
18
-                        router-link(
19
-                            :to='`/chat/${pair.profile.pid}`')
20
-                            w-button.mx2(@click='showMenu = false' bg-color="success" tile icon="icon-chat") Chat
21
-                        w-button.mx2.icon-calendar(@click='showMenu = false' bg-color="info" tile icon="icon-calendar") Calendar
22
-                        w-button.mx2(@click='showMenu = false' bg-color="primary" icon="icon-cross")
17
+                        w-button.mr3(
18
+                            @click='showMenu = !showMenu'
19
+                            icon='icon-dots-three-horizontal'
20
+                        )
21
+                    w-flex
22
+                        router-link(:to='`/chat/${pair.profile.pid}`')
23
+                            w-button.mx2(
24
+                                @click='showMenu = false'
25
+                                bg-color='success'
26
+                                icon='icon-chat'
27
+                                tile
28
+                            ) Chat
29
+                        w-button.mx2.icon-calendar(
30
+                            @click='showMenu = false'
31
+                            bg-color='info'
32
+                            icon='icon-calendar'
33
+                            tile
34
+                        ) Calendar
35
+                        w-button.mx2(
36
+                            @click='showMenu = false'
37
+                            bg-color='primary'
38
+                            icon='icon-cross'
39
+                        )
23 40
 
24 41
     p(v-else) No {{ tabName }} profiles.
25 42
 </template>

+ 48
- 0
frontend/src/components/onboarding/Aspects.vue Vedi File

@@ -0,0 +1,48 @@
1
+<template lang="pug">
2
+w-card.aspects.w-flex.column
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
12
+</template>
13
+
14
+<script>
15
+import QuestionResponse from './QuestionResponse.vue'
16
+const answered = [null, null, null, null, null, null]
17
+
18
+export default {
19
+    name: 'Aspects',
20
+    components: {
21
+        QuestionResponse,
22
+    },
23
+    props: {
24
+        aspectQuestions: {
25
+            required: true,
26
+            type: Array,
27
+        },
28
+    },
29
+    emits: ['handle-submit', 'update-answers'],
30
+    async created() {
31
+        this.aspectQuestions.forEach((q, i) => {
32
+            console.log(`Aspect #${i}: ${JSON.stringify(q)}`)
33
+        })
34
+    },
35
+    methods: {
36
+        updateRadio(onRadioSelect) {
37
+            answered[onRadioSelect.id - 1] = onRadioSelect.answer
38
+            this.$emit('update-answers', {
39
+                key: 'Aspects',
40
+                question: {
41
+                    response_key_prompt: 'aspects',
42
+                },
43
+                answer: answered,
44
+            })
45
+        },
46
+    },
47
+}
48
+</script>

+ 5
- 4
frontend/src/components/onboarding/FormDropdown.vue Vedi File

@@ -1,10 +1,10 @@
1 1
 <template lang="pug">
2 2
 .role
3
-    span(style='text-align:center;') {{ parsedPrompt.start }}
4
-    span(style='text-align:center;') {{ parsedPrompt.mid }}
3
+    span(style='text-align: center') {{ parsedPrompt.start }}
4
+    span(style='text-align: center') {{ parsedPrompt.mid }}
5 5
     w-select.mt4(:items='items' placeholder='i am' v-model='selection')
6 6
     br
7
-    p(style='text-align:center;') {{ parsedPrompt.end }}
7
+    p(style='text-align: center') {{ parsedPrompt.end }}
8 8
     w-button.ma1.grow(@click='handleSubmit') NEXT
9 9
 </template>
10 10
 
@@ -28,7 +28,8 @@ export default {
28 28
         },
29 29
     },
30 30
     created() {
31
-        const parsedPromptArr = this.question.response_key_prompt.split('[break]')
31
+        const parsedPromptArr =
32
+            this.question.response_key_prompt.split('[break]')
32 33
         this.parsedPrompt.start = parsedPromptArr[0]
33 34
         this.parsedPrompt.mid = parsedPromptArr[1]
34 35
         this.parsedPrompt.end = parsedPromptArr[2]

+ 2
- 2
frontend/src/components/onboarding/FormInput.vue Vedi File

@@ -8,9 +8,9 @@
8 8
         :placeholder='question.placeholder'
9 9
         @keyup.enter='handleSubmit({ question, input })'
10 10
         type='text'
11
+        v-focus
11 12
         v-if='question.survey_stage !== "image" && question.survey_stage !== "blurb" && question.survey_stage !== "password"'
12 13
         v-model='input'
13
-        v-focus
14 14
     )
15 15
     input.pass(
16 16
         :placeholder='question.placeholder'
@@ -18,8 +18,8 @@
18 18
         style='-webkit-text-security: circle'
19 19
         type='password'
20 20
         v-else-if='question.survey_stage === "password"'
21
-        v-model='input'
22 21
         v-focus
22
+        v-model='input'
23 23
     )
24 24
     w-button.ma1.grow(
25 25
         @click='submitImage'

+ 1
- 1
frontend/src/components/onboarding/Splash.vue Vedi File

@@ -15,7 +15,7 @@ w-flex.column
15 15
         text
16 16
         xl
17 17
     ) SIGN UP
18
-    router-link(to="/login")
18
+    router-link(to='/login')
19 19
         w-button.ma1.grow.next-btn(
20 20
             :height='50'
21 21
             :width='315'

+ 24
- 0
frontend/src/entities/survey/survey.js Vedi File

@@ -28,6 +28,30 @@ const _formatAspectQuestions = steps => {
28 28
         .filter(step => step != null)
29 29
 }
30 30
 
31
+const SCORED = [1, 2, 3, 4, 5, 6]
32
+const _isScored = id => SCORED.includes(id)
33
+const _makeCategoryFriendly = responseCategory => {
34
+    const labels = responseCategory.split('_vs_')
35
+    labels.forEach((a, i) => {
36
+        if (a.indexOf('_') == -1) return
37
+        labels[i] = a.split('_').join(' ')
38
+    })
39
+    return labels
40
+}
41
+const _formatAspectQuestions = steps => {
42
+    return steps
43
+        .map(q => {
44
+            if (!_isScored(q.response_key_id)) return null
45
+            return {
46
+                id: q.response_key_id,
47
+                question: q.response_key_prompt,
48
+                labels: _makeCategoryFriendly(q.response_key_category),
49
+                answer: null,
50
+            }
51
+        })
52
+        .filter(step => step != null)
53
+}
54
+
31 55
 class Survey extends _baseRecord {
32 56
     constructor(questionSteps) {
33 57
         super()

+ 2
- 1
frontend/src/main.js Vedi File

@@ -8,7 +8,8 @@ import components from './wave'
8 8
 import App from './App.vue'
9 9
 import MainNav from './components/MainNav.vue'
10 10
 
11
-const DEV = import.meta.env.VITE_DEV == 'true'
11
+// const DEV = import.meta.env.VITE_DEV == 'true'
12
+const DEV = false
12 13
 
13 14
 /**
14 15
  * Check between route changes for login/timeout

+ 4
- 1
frontend/src/services/chat.service.js Vedi File

@@ -116,7 +116,10 @@ class Chatter {
116 116
         } catch (error) {
117 117
             console.error('[chatter]', error)
118 118
         }
119
-        const channelHistory = pastMessages && pastMessages.channels ? pastMessages.channels[channel] : null
119
+        const channelHistory =
120
+            pastMessages && pastMessages.channels
121
+                ? pastMessages.channels[channel]
122
+                : null
120 123
         console.log('channelHistory :>> ', channelHistory)
121 124
         return channelHistory
122 125
             ? channelHistory.map(msg => ({

+ 1
- 1
frontend/src/utils/lang.js Vedi File

@@ -32,7 +32,7 @@ const auth = {
32 32
 // Easily reorder steps of survey here:
33 33
 const allSteps = {
34 34
     usa: {
35
-        email: 'email',
35
+        splash: 'splash',
36 36
         name: 'name',
37 37
         seeking: 'seeking',
38 38
         password: 'password',

+ 4
- 0
frontend/src/utils/survey.js Vedi File

@@ -15,6 +15,10 @@ class SurveyFactory {
15 15
                 existingResponses[categoryKey] =
16 16
                     responsesByCategory[categoryKey]
17 17
             }
18
+            const responseKeyLike = formatStep(match, step)
19
+            const withComponent = associateWithComponent(responseKeyLike)
20
+            console.log('withComponent :>> ', withComponent)
21
+            return withComponent
18 22
         })
19 23
         // Adds form drop down options to each responseKey
20 24
         Object.keys(existingResponses).forEach(inputKey => {

+ 17
- 13
frontend/src/views/ChatView.vue Vedi File

@@ -2,13 +2,13 @@
2 2
 main.view--chat
3 3
     header.mb6(v-if='profile && grouping')
4 4
         h3 chatting with:
5
-        span {{ target.profile_id }} | 
6
-        span(v-if="grouping.revealedFromNotification.length")
7
-            span(v-for="revealed in grouping.revealedFromNotification")
8
-                span(v-if="revealed.profile_id === target.profile_id")
9
-                    span {{ revealed[revealed.tag_description] }} | 
5
+        span {{ target.profile_id }} |
6
+        span(v-if='grouping.revealedFromNotification.length')
7
+            span(v-for='revealed in grouping.revealedFromNotification')
8
+                span(v-if='revealed.profile_id === target.profile_id')
9
+                    span {{ revealed[revealed.tag_description] }} |
10 10
         span(v-else)
11
-            span  {{ grouping.profile.user_name }} | {{ grouping.profile.user_email }}
11
+            span {{ grouping.profile.user_name }} | {{ grouping.profile.user_email }}
12 12
         h3 logged in as:
13 13
         p {{ profile.id }} | {{ profile._profile.user_name }} | {{ profile._profile.user_email }}
14 14
         //- p subscriptions: {{ profile.chatter.subscriptions }}
@@ -20,18 +20,22 @@ main.view--chat
20 20
                 button(@click='reveal(8)') reveal my email
21 21
                 // TODO: Remove later, only for testing
22 22
                 button(@click='checkData()') check data
23
-            span(v-if="grouping.revealed[profile.id.value]")
23
+            span(v-if='grouping.revealed[profile.id.value]')
24 24
                 p you revealed:
25
-                ul(v-for="reveal in [...new Set(grouping.revealed[profile.id.value])]")
25
+                ul(
26
+                    v-for='reveal in [...new Set(grouping.revealed[profile.id.value])]'
27
+                )
26 28
                     li {{ reveal.description }}
27
-            span(v-if="grouping.revealed[target.profile_id]")
29
+            span(v-if='grouping.revealed[target.profile_id]')
28 30
                 p they revealed:
29
-                ul(v-for="reveal in grouping.revealed[target.profile_id]")
31
+                ul(v-for='reveal in grouping.revealed[target.profile_id]')
30 32
                     li {{ reveal.description }}: {{ target[reveal.description] }}
31
-            span(v-if="grouping.revealedFromNotification.length")
33
+            span(v-if='grouping.revealedFromNotification.length')
32 34
                 p recently revealed:
33
-                ul(v-for="revealed in grouping.revealedFromNotification")
34
-                    li(v-if="revealed[revealed.tag_description] !== profile._profile[revealed.tag_description]") {{ revealed.tag_description }}: {{ revealed[revealed.tag_description] }}
35
+                ul(v-for='revealed in grouping.revealedFromNotification')
36
+                    li(
37
+                        v-if='revealed[revealed.tag_description] !== profile._profile[revealed.tag_description]'
38
+                    ) {{ revealed.tag_description }}: {{ revealed[revealed.tag_description] }}
35 39
 
36 40
     article
37 41
         template(v-if='isLoading')

+ 53
- 0
frontend/src/views/OnboardingView.vue Vedi File

@@ -2,6 +2,7 @@
2 2
 main.view--onboarding
3 3
     article(
4 4
         style='display: flex; flex-direction: column; align-items: center'
5
+<<<<<<< HEAD
5 6
         v-if='currentStep !== survey.steps.length'
6 7
     )
7 8
         .answers(v-for='(value, key) in answered')
@@ -31,20 +32,41 @@ main.view--onboarding
31 32
 
32 33
     article(v-else)
33 34
         SurveyCompleteView(:answers='answered' :surveySteps='survey.steps')
35
+=======
36
+        v-if='survey'
37
+    )
38
+        .step(v-for='(step, i) in survey.steps')
39
+            component(
40
+                :aspect-questions='step.component == "Aspects" ? survey.aspectQuestions : null'
41
+                :is='step.component'
42
+                :question='step'
43
+                @handle-submit='onSubmit'
44
+                @update-answers='updateAnswers'
45
+                v-if='step && currentStep == i'
46
+            )
47
+>>>>>>> b0c2120 (another pre-release (#53))
34 48
 </template>
35 49
 
36 50
 <script>
37 51
 import { Authenticator } from '../services/auth.service.js'
38 52
 import { surveyFactory } from '@/utils'
53
+<<<<<<< HEAD
39 54
 import stepViews from '@/components/onboarding'
40 55
 import SurveyCompleteView from './SurveyCompleteView.vue'
41 56
 let hashedAccessToken = null
42 57
 let currentProfileId = null
58
+=======
59
+import { allSteps } from '@/utils/lang'
60
+import stepViews from '@/components/onboarding'
61
+>>>>>>> b0c2120 (another pre-release (#53))
43 62
 
63
+// import savesurveybyprfileid - call it on submit
64
+// paginate to save every steps answers
44 65
 export default {
45 66
     name: 'OnboardingView',
46 67
     components: {
47 68
         ...stepViews,
69
+<<<<<<< HEAD
48 70
         SurveyCompleteView,
49 71
     },
50 72
     data: () => ({
@@ -71,10 +93,23 @@ export default {
71 93
             this.goToStep(0)
72 94
         }
73 95
     },
96
+=======
97
+    },
98
+    data: () => ({
99
+        answered: {},
100
+        aspectQuestions: [],
101
+        currentStep: 0,
102
+        survey: null,
103
+    }),
104
+    async created() {
105
+        this.survey = await surveyFactory.createSurvey(allSteps['usa'])
106
+    },
107
+>>>>>>> b0c2120 (another pre-release (#53))
74 108
     methods: {
75 109
         onSubmit() {
76 110
             console.log(JSON.stringify(this.answered))
77 111
         },
112
+<<<<<<< HEAD
78 113
         async goToStep(num) {
79 114
             this.currentStep = num
80 115
         },
@@ -140,6 +175,21 @@ export default {
140 175
             } else {
141 176
                 this.goToStep(this.currentStep + 1)
142 177
             }
178
+=======
179
+        goToStep(num) {
180
+            this.currentStep = num
181
+        },
182
+        updateAnswers(payload) {
183
+            // null payload is passed on splash page
184
+            if (payload) {
185
+                const k = payload.question.response_key_prompt
186
+                this.answered[k] = payload.answer
187
+                console.log(`${k}:`, this.answered[k])
188
+                console.log(`Updated answers: ${JSON.stringify(this.answered)}`)
189
+                if (k === 'aspects') return
190
+            }
191
+            this.goToStep(this.currentStep + 1)
192
+>>>>>>> b0c2120 (another pre-release (#53))
143 193
         },
144 194
     },
145 195
 }
@@ -157,9 +207,12 @@ export default {
157 207
     article
158 208
         height: 100vh
159 209
 
210
+<<<<<<< HEAD
160 211
     .answers
161 212
         text-align: center
162 213
 
214
+=======
215
+>>>>>>> b0c2120 (another pre-release (#53))
163 216
     .w-button
164 217
             display: flex
165 218
             width: 315px

Loading…
Annulla
Salva