Преглед на файлове

:recycle: simplify card view further

tags/0.0.1
J преди 4 години
родител
ревизия
a9bca1d852

+ 1
- 0
backend/lib/schemas/profiles.js Целия файл

@@ -10,6 +10,7 @@ const singleProfile = Joi.object({
10 10
     user_name: Joi.string(),
11 11
     user_email: Joi.string(),
12 12
     responses: surveyResponseSchema.list,
13
+    reveal: Joi.array().items(),
13 14
     tags: Joi.array().items(),
14 15
     user_type: Joi.any(),
15 16
     user: userSchema.single,

+ 8
- 3
backend/lib/services/profile.js Целия файл

@@ -33,8 +33,9 @@ const scoreResponses = (seeker, potentialMatch, prescoreLookup) => {
33 33
         }
34 34
         composite.push(prescoreLookup[mKey(aRes)][mKey(bRes)])
35 35
     }
36
+    const scoreAvg = composite.reduce((a, b) => a + b) / composite.length
36 37
     return {
37
-        total: Math.round(composite.reduce((a, b) => a + b) / composite.length),
38
+        total: Math.round(scoreAvg),
38 39
         aspects: composite,
39 40
     }
40 41
 }
@@ -97,14 +98,17 @@ class CompleteProfile {
97 98
         this.user_name = profile.user.user_name // string user_name
98 99
         this.user_email = profile.user.user_email
99 100
         this.responses = []
100
-        this.tags = profile.tags // [] of all tags
101 101
         this.user_type = type
102
+        this.tags = profile.tags.filter(t => t.category != 'reveal')
103
+        this.reveal = profile.tags.filter(t => t.category == 'reveal')
102 104
 
103 105
         // TODO: generalize this for multiple images, and languages
104 106
         this.profile_description = ''
105 107
         this.profile_media = []
106 108
         this.profile_languages = []
107 109
         this.profile_prefs = {}
110
+
111
+        // TODO: filter these correctly
108 112
         if (profile?.responses?.length) {
109 113
             // [] of all "profile" responses
110 114
             this.responses = profile.responses
@@ -116,7 +120,6 @@ class CompleteProfile {
116 120
                     r => r.response_key_id === prefsKeys[i]
117 121
                 )[0]
118 122
             })
119
-            // TODO: filter these correctly
120 123
             this.profile_description = this.responses.filter(r => r.response_key_id === config.blurbKey).map(r => r.val)[0]
121 124
             this.profile_media = this.responses.filter(r => r.response_key_id === config.mediaKey).map(r => r.val)
122 125
             this.profile_languages = this.responses.filter(r => r.response_key_id === config.langKey).map(r => r.val)
@@ -127,7 +130,9 @@ class CompleteProfile {
127 130
 module.exports = class ProfileService extends Schmervice.Service {
128 131
     constructor(...args) {
129 132
         super(...args)
133
+        /** Scores available in the db to map against score indices*/
130 134
         this.scoreLookup = {}
135
+        /** Tags available in the db to map against tagg_associations*/
131 136
         this.tagLookup = {}
132 137
         // this.responseKeyLookup = ResponseKey.query()
133 138
     }

+ 50
- 48
frontend/src/components/ProfileCardList.vue Целия файл

@@ -1,37 +1,41 @@
1 1
 <template lang="pug">
2
-section.profile_card_list.w-full
3
-    .profile_card_list_container.w-full
4
-        .swipe(
5
-            v-if="!isGrid"
6
-            :config="config"
7
-            :key="profile.pid"
8
-            @throwout="swipped(profile)"
9
-            v-for="(profile, i) in loadedProfiles"
10
-            :style="{ 'z-index': 1000-i }"
2
+section.profile-card-list.w-full
3
+    .swipe(
4
+        v-if="!isGrid"
5
+        :config="config"
6
+        :key="profile.pid"
7
+        @throwout="swipped(profile)"
8
+        v-for="(profile, i) in loadedProfiles"
9
+        :style="{ 'z-index': 1000-i }"
10
+    )
11
+        .card.b-solid.bg-cover.randomize(
12
+            :style="{ 'background-image': `url(${profile.avatar})`, 'top': `${randomize(10)}px`, 'right': `${randomize(20)}px`, 'transform': `rotate(${randomize(7)}deg)` }"
11 13
         )
12
-            .card.b-solid.rounded.bg-cover.randomize(
13
-                :style="{ 'background-image': `url(${profile.avatar})`, 'top': `${randomize(10)}px`, 'right': `${randomize(20)}px`, 'transform': `rotate(${randomize(7)}deg)` }"
14
+            .card--content.f-col.between
15
+                p(style="color: magenta;").f-grow profile: {{ profile.pid }}
16
+                .card--content--lower.ph-1.w-full.f-col.between
17
+                    h4.w-full.pv-1 {{ profile.name }}
18
+                    nav.swipe_icons.pv-1.w-full.f-grow.f-row
19
+                        //- Accept
20
+                        button(@click="accept") Accept
21
+                        button(@click="view(profile.pid)") view
22
+                        //- Pass
23
+                        button(@click="pass") Pass
24
+    
25
+    .match-layout(
26
+        v-else
27
+        :key="profile.pid"
28
+        v-for="(profile, i) in loadedProfiles"
29
+    ).f-row
30
+            .card.b-solid.bg-cover(
31
+                :style="{ 'background-image': `url(${profile.avatar})` }"
14 32
             )
15
-                .card__content
16
-                    h3.p-1.mv-0.b-solid.rounded {{ profile.pid  }} {{ profile.name }}
17
-                nav.swipe_icons.w-full.f-row.between
18
-                    //- Accept
19
-                    button.p-1(@click="accept") Accept
20
-                    //- Hold
21
-                    button.p-1(@click="view(profile.pid)") view
22
-                    //- Pass
23
-                    button.p-1(@click="pass") Pass
24
-        
25
-        .match-layout(
26
-            v-else
27
-            :key="profile.pid"
28
-            v-for="(profile, i) in loadedProfiles"
29
-        )
30
-                .card.b-solid.rounded.bg-cover(
31
-                    :style="{ 'background-image': `url(${profile.avatar})` }"
32
-                )
33
-                .card__content
34
-                    button(@click="view(profile.pid)").p-1.mv-0.b-solid.rounded {{ profile.pid  }} {{ profile.name }}
33
+                .card--content.f-col.between
34
+                    p(style="color: magenta;").f-grow profile: {{ profile.pid }}
35
+                    .card--content--lower.ph-1.w-full.f-col.between
36
+                        h4.w-full.pv-1 {{ profile.name }}
37
+                        nav.swipe_icons.pv-1.w-full.f-grow.f-row
38
+                            button(@click="view(profile.pid)") view
35 39
 </template>
36 40
 
37 41
 <script setup>
@@ -44,8 +48,7 @@ import {
44 48
 
45 49
 const router = useRouter()
46 50
 const emit = defineEmits(['reload'])
47
-// TODO: Please review this conversion from script to script setup
48
-// converted from the props section
51
+
49 52
 const props = defineProps({
50 53
     profiles: {
51 54
         type: [Object, Array],
@@ -66,6 +69,7 @@ const props = defineProps({
66 69
         type: Boolean,
67 70
     },
68 71
 })
72
+
69 73
 const swipped = profile => {
70 74
     const index = loadedProfiles.findIndex(u => u.pid == profile.pid)
71 75
     loadedProfiles.splice(index, 1)
@@ -99,10 +103,8 @@ const view = pid => {
99 103
     router.push({ path: `/matches/${pid}` })
100 104
 }
101 105
 const pass = () => {
102
-    // const charmander = await db.get(`/profile/{profile_id}/queue/{target_id}/delete?include_profile=true&reinsert=true`)
103
-    const profileId = props.pid
104 106
     const targetId = props.profiles[0].pid
105
-    updateQueueByProfileId(profileId, targetId, true)
107
+    updateQueueByProfileId(props.pid, targetId, true)
106 108
     emit('reload')
107 109
 }
108 110
 
@@ -118,7 +120,7 @@ const loadedProfiles = [...props.profiles]
118 120
 </script>
119 121
 
120 122
 <style lang="postcss">
121
-.profile_card_list_container
123
+.profile-card-list
122 124
     display: flex
123 125
     justify-content: center
124 126
 
@@ -130,19 +132,19 @@ const loadedProfiles = [...props.profiles]
130 132
 .card
131 133
     position: relative
132 134
     background-color: #fff
133
-    width: 250px
134
-    max-width: 85vw
135
-    height: 50vh
135
+    height: 60vw
136
+    width: 40vw
137
+    max-height: 600px
138
+    max-width: 400px
136 139
     background-position: center
137
-    &_content
140
+    &--content
138 141
         width: 100%
139 142
         height: 100%
140
-    h3
141
-        position: absolute
142
-        bottom: 0
143
+        font-size: 3vw
144
+        &--lower
145
+            background-color: goldenrod
146
+            nav > button
147
+                font-size: 2vw
148
+
143 149
 
144
-.swipe_icons
145
-    position: fixed
146
-    bottom: 5vh
147
-    width: 250px
148 150
 </style>

+ 2
- 0
frontend/src/entities/profile/profile.schema.js Целия файл

@@ -26,12 +26,14 @@ const profileSchema = {
26 26
         /** fields that should match backend service*/
27 27
         user_name: Joi.string(),
28 28
         user_id: Joi.number(),
29
+        user_email: Joi.string(),
29 30
         profile_id: Joi.number(),
30 31
         profile_description: Joi.string(),
31 32
         profile_media: Joi.array().items(Joi.string()),
32 33
         profile_languages: Joi.array().items(Joi.string()),
33 34
         profile_prefs: Joi.object(),
34 35
         responses: Joi.array().items(responseSchema), // response entity schema goes here
36
+        reveal: Joi.array().items(),
35 37
         tags: Joi.array().items(),
36 38
         user_type: Joi.string(),
37 39
 

+ 3
- 2
frontend/src/router/guards.js Целия файл

@@ -2,8 +2,9 @@ import { currentProfile } from '../services'
2 2
 
3 3
 
4 4
 const checkLoginStatus = (destination, nextCb) => {
5
-    console.warn(`profile: ${currentProfile.id.value} | login:${currentProfile.isLoggedIn} | completed: ${currentProfile.isComplete}`)
6
-    
5
+    if(!currentProfile.isLoggedIn || !currentProfile.isComplete) {
6
+        console.warn(`profile: ${currentProfile.id.value} | login: ${currentProfile.isLoggedIn} | completed: ${currentProfile.isComplete}`)
7
+    }
7 8
     if (
8 9
         destination.meta.requiresCompleteProfile &&
9 10
         !currentProfile.isLoggedIn &&

+ 9
- 4
frontend/src/views/ProfileView.vue Целия файл

@@ -5,8 +5,8 @@ main.view--profile.f-col.start.w-full
5 5
  
6 6
     article(v-if="!loading")
7 7
         h3 name: {{ profile.user_name }}
8
-            span(v-if="profile.user_email") | email: {{ profile.user_email }}
9
-        h5(v-if="profile.profile_prefs.pronouns") My pronouns are {{ profile.profile_prefs.pronouns.val }}
8
+            span(v-if="profile.profile_prefs.pronouns") &nbsp;({{ profile.profile_prefs.pronouns.val }})
9
+        p(v-if="profile.user_email") {{ profile.user_email }}
10 10
         
11 11
         p I am looking for a&nbsp;
12 12
             span {{ profile.profile_prefs.presence.val }}&nbsp;
@@ -15,10 +15,15 @@ main.view--profile.f-col.start.w-full
15 15
             span no further than {{ profile.profile_prefs.distance.val }} miles away&nbsp;
16 16
             span from {{ profile.profile_prefs.zipcode.val }}
17 17
 
18
-        p About: {{ profile.profile_description}}
19 18
         p I am {{ profile.profile_prefs.urgency.val.split("_").join(" ") }}.
19
+        
20
+        img(v-if="profile.reveal.map(t => t.description).includes('image')" :src="profile.profile_media[0]" alt="profile-avatar" style="max-height: 200px; width: auto;")
21
+        h3(v-else) image not revealed
22
+        
23
+        p About: {{ profile.profile_description}}
20 24
 
21
-        p tags: {{ profile.tags }}
25
+        p reveal: {{ profile.reveal.map(t => t.description) }}
26
+        p tags: {{ profile.tags.map(t => t.description) }}
22 27
         p images: {{ profile.profile_media }}
23 28
         p responses: {{ profile.responses.length }}
24 29
         button(@click="$router.go(-1)") back

+ 0
- 1
frontend/src/views/SurveyView.vue Целия файл

@@ -69,7 +69,6 @@ export default {
69 69
     props: {
70 70
         pid: {
71 71
             type: Number,
72
-            required: true,
73 72
         },
74 73
     },
75 74
     data() {

Loading…
Отказ
Запис