Procházet zdrojové kódy

another pre-release (#53)

tags/0.0.3^2
maeda před 3 roky
rodič
revize
205132855e

+ 1
- 1
backend/db/seeds/04-responses.js Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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",

+ 48
- 0
frontend/src/components/onboarding/Aspects.vue Zobrazit soubor

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

+ 24
- 0
frontend/src/entities/survey/survey.js Zobrazit soubor

@@ -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 Zobrazit soubor

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

+ 1
- 1
frontend/src/utils/lang.js Zobrazit soubor

@@ -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 Zobrazit soubor

@@ -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 => {

+ 53
- 0
frontend/src/views/OnboardingView.vue Zobrazit soubor

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

Načítá se…
Zrušit
Uložit