Просмотр исходного кода

Merge branch 'dynamic-spider-chart' of fyindr/siimee into dev

tags/0.0.3^2
maeda 3 лет назад
Родитель
Сommit
d405bf48e1

+ 4
- 4
backend/db/data-generator/mock.js Просмотреть файл

@@ -443,16 +443,16 @@ module.exports = {
443 443
         },
444 444
         {
445 445
             response_key_id: 3,
446
-            response_key_category: 'collaborative_vs_independent',
446
+            response_key_category: 'dynamic_vs_ordered',
447 447
             response_key_prompt:
448
-                'Do you structure and encourage your team to be a Collaborative or Independent environment?',
448
+                'Do you structure and encourage your team to be a Collaborative or Independent environment? (NEEDS UPDATED COPY)',
449 449
             response_key_description: 'first round draft scoring question',
450 450
         },
451 451
         {
452 452
             response_key_id: 4,
453
-            response_key_category: 'innovative_vs_conventional',
453
+            response_key_category: 'precise_vs_resourceful',
454 454
             response_key_prompt:
455
-                'Do you find higher success in employees on your team that are Innovative or Conventional?',
455
+                'Do you find higher success in employees on your team that are Innovative or Conventional? (NEEDS UPDATED COPY)',
456 456
             response_key_description: 'first round draft scoring question',
457 457
         },
458 458
         {

+ 1
- 1
backend/db/seeds/04-responses.js Просмотреть файл

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

+ 1
- 2
backend/lib/services/profile/index.js Просмотреть файл

@@ -62,9 +62,8 @@ module.exports = class ProfileService extends Schmervice.Service {
62 62
             .withGraphFetched('tags')
63 63
             .withGraphFetched('responses')
64 64
             .withGraphFetched('user')
65
-
66 65
         tagger.setProfileTags(matchingProfile, matchingProfile, this.tagLookup)
67
-        const complete = new profiler.CompleteProfile(matchingProfile)
66
+        const complete = new profiler.CompleteProfile(matchingProfile, true)
68 67
         return complete
69 68
     }
70 69
 

+ 1
- 1
backend/lib/services/profile/profiler.js Просмотреть файл

@@ -7,7 +7,7 @@ const tagger = require('./tagger')
7 7
  * !: This needs to match the responseSchema in profiles.js
8 8
  */
9 9
 class CompleteProfile {
10
-    constructor(profile, type, includeResponses = false) {
10
+    constructor(profile, includeResponses = false, type) {
11 11
         this.user_id = profile.user_id // int user_id
12 12
         this.profile_id = profile.profile_id // int profile_id
13 13
         this.user_name = profile.user.user_name // string user_name

+ 1
- 0
frontend/src/components/ProfileCard.vue Просмотреть файл

@@ -29,6 +29,7 @@ w-card.profile-card-list--card.xs12
29 29
             SummaryBar(
30 30
                 :aspects='aspects'
31 31
                 :is-tab='true'
32
+                :name='card.name'
32 33
                 :tab-content='card.summary'
33 34
                 @tab-change='onTab'
34 35
             )

+ 19
- 6
frontend/src/components/SummaryBar.vue Просмотреть файл

@@ -30,9 +30,9 @@ section.w-flex.column.pb5
30 30
                     p {{ tabContent[item].tab }}
31 31
                     SpiderChart(
32 32
                         :labels='aspects.map(label => label.name)'
33
-                        :profile-data='profileScore'
33
+                        :profile-data='aspects.map(data => data.percentage)'
34 34
                         :target-data='targetScore'
35
-                        profile-name='lucy'
35
+                        :profile-name='name'
36 36
                         v-if='isTab'
37 37
                     )
38 38
 
@@ -62,6 +62,7 @@ section.w-flex.column.pb5
62 62
 
63 63
 <script>
64 64
 import SpiderChart from './SpiderChart.vue'
65
+import { currentProfile } from '../services'
65 66
 
66 67
 export default {
67 68
     components: { SpiderChart },
@@ -74,6 +75,10 @@ export default {
74 75
             required: true,
75 76
             type: Object,
76 77
         },
78
+        name:{
79
+            required:true,
80
+            type: String
81
+        },
77 82
         isTab: {
78 83
             required: false,
79 84
             type: Boolean,
@@ -86,10 +91,18 @@ export default {
86 91
         },
87 92
     },
88 93
     emits: ['tab-change'],
89
-    data: () => ({
90
-        profileScore: [5.7, 5.2, 4.8, 5.2, 4.9, 4.9],
91
-        targetScore: [5.3, 4.8, 5.7, 4.8, 5.6, 4.8],
92
-    }),
94
+    computed: {
95
+        targetScore(){
96
+            try{
97
+                let aspectResponses = currentProfile._profile.responses.filter(r => [1,2,3,4,5,6].indexOf(r.response_key_id) !== -1)
98
+                return aspectResponses.map(r => Number(r.val)) 
99
+            }
100
+            catch(e){
101
+                console.warn('error: No aspect responses for current profile.')
102
+                return [1,1,1,1,1,1]
103
+            }
104
+        }
105
+    },
93 106
     methods: {
94 107
         onTabChanged(tabs) {
95 108
             this.$emit('tab-change', tabs)

+ 20
- 1
frontend/src/entities/card/card.js Просмотреть файл

@@ -40,7 +40,7 @@ class SummaryGroup {
40 40
 }
41 41
 
42 42
 class Aspect {
43
-    constructor({ name, labels, percentage = 50 }) {
43
+    constructor({ name, labels, percentage = 1 }) {
44 44
         this.name = name
45 45
         this.labels = labels
46 46
         this.percentage = percentage
@@ -73,6 +73,15 @@ const cardAspects = [
73 73
     }),
74 74
 ]
75 75
 
76
+const responseKeyIdToAspectName = {
77
+    1: 'vision',
78
+    2: 'creativity',
79
+    3: 'dynamism',
80
+    4: 'precision',
81
+    5: 'focus',
82
+    6: 'attention',
83
+}
84
+
76 85
 /**
77 86
  * Class representing a profile card
78 87
  * NOT to be confused with a profile
@@ -123,6 +132,16 @@ const makeCardFromProfile = profile => {
123 132
     c.ethinicity = profile?.profile_prefs?.ethnicity?.val
124 133
     c.locale = `${profile.city}, ${profile.state}`
125 134
     c.email = profile.user_email
135
+
136
+
137
+    let aspectResponses = profile?.responses.filter(r => [1,2,3,4,5,6].indexOf(r.response_key_id) !== -1)
138
+    if(aspectResponses.length){ // if user has responses for aspects we overwrite default percentages
139
+        c.aspects.map(a => {
140
+            a.percentage = Number(aspectResponses.find(r => responseKeyIdToAspectName[r.response_key_id] == a.name).val )
141
+            return a 
142
+        })
143
+    }
144
+
126 145
     // TODO: delete me later
127 146
     if (profile.profile_description) {
128 147
         c.summary.updateTab('about', profile.profile_description)

Загрузка…
Отмена
Сохранить