Kaynağa Gözat

:recycle: simplify card view further

tags/0.0.1
J 4 yıl önce
ebeveyn
işleme
a9bca1d852

+ 1
- 0
backend/lib/schemas/profiles.js Dosyayı Görüntüle

10
     user_name: Joi.string(),
10
     user_name: Joi.string(),
11
     user_email: Joi.string(),
11
     user_email: Joi.string(),
12
     responses: surveyResponseSchema.list,
12
     responses: surveyResponseSchema.list,
13
+    reveal: Joi.array().items(),
13
     tags: Joi.array().items(),
14
     tags: Joi.array().items(),
14
     user_type: Joi.any(),
15
     user_type: Joi.any(),
15
     user: userSchema.single,
16
     user: userSchema.single,

+ 8
- 3
backend/lib/services/profile.js Dosyayı Görüntüle

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

+ 50
- 48
frontend/src/components/ProfileCardList.vue Dosyayı Görüntüle

1
 <template lang="pug">
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
 </template>
39
 </template>
36
 
40
 
37
 <script setup>
41
 <script setup>
44
 
48
 
45
 const router = useRouter()
49
 const router = useRouter()
46
 const emit = defineEmits(['reload'])
50
 const emit = defineEmits(['reload'])
47
-// TODO: Please review this conversion from script to script setup
48
-// converted from the props section
51
+
49
 const props = defineProps({
52
 const props = defineProps({
50
     profiles: {
53
     profiles: {
51
         type: [Object, Array],
54
         type: [Object, Array],
66
         type: Boolean,
69
         type: Boolean,
67
     },
70
     },
68
 })
71
 })
72
+
69
 const swipped = profile => {
73
 const swipped = profile => {
70
     const index = loadedProfiles.findIndex(u => u.pid == profile.pid)
74
     const index = loadedProfiles.findIndex(u => u.pid == profile.pid)
71
     loadedProfiles.splice(index, 1)
75
     loadedProfiles.splice(index, 1)
99
     router.push({ path: `/matches/${pid}` })
103
     router.push({ path: `/matches/${pid}` })
100
 }
104
 }
101
 const pass = () => {
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
     const targetId = props.profiles[0].pid
106
     const targetId = props.profiles[0].pid
105
-    updateQueueByProfileId(profileId, targetId, true)
107
+    updateQueueByProfileId(props.pid, targetId, true)
106
     emit('reload')
108
     emit('reload')
107
 }
109
 }
108
 
110
 
118
 </script>
120
 </script>
119
 
121
 
120
 <style lang="postcss">
122
 <style lang="postcss">
121
-.profile_card_list_container
123
+.profile-card-list
122
     display: flex
124
     display: flex
123
     justify-content: center
125
     justify-content: center
124
 
126
 
130
 .card
132
 .card
131
     position: relative
133
     position: relative
132
     background-color: #fff
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
     background-position: center
139
     background-position: center
137
-    &_content
140
+    &--content
138
         width: 100%
141
         width: 100%
139
         height: 100%
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
 </style>
150
 </style>

+ 2
- 0
frontend/src/entities/profile/profile.schema.js Dosyayı Görüntüle

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

+ 3
- 2
frontend/src/router/guards.js Dosyayı Görüntüle

2
 
2
 
3
 
3
 
4
 const checkLoginStatus = (destination, nextCb) => {
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
     if (
8
     if (
8
         destination.meta.requiresCompleteProfile &&
9
         destination.meta.requiresCompleteProfile &&
9
         !currentProfile.isLoggedIn &&
10
         !currentProfile.isLoggedIn &&

+ 9
- 4
frontend/src/views/ProfileView.vue Dosyayı Görüntüle

5
  
5
  
6
     article(v-if="!loading")
6
     article(v-if="!loading")
7
         h3 name: {{ profile.user_name }}
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
         p I am looking for a&nbsp;
11
         p I am looking for a&nbsp;
12
             span {{ profile.profile_prefs.presence.val }}&nbsp;
12
             span {{ profile.profile_prefs.presence.val }}&nbsp;
15
             span no further than {{ profile.profile_prefs.distance.val }} miles away&nbsp;
15
             span no further than {{ profile.profile_prefs.distance.val }} miles away&nbsp;
16
             span from {{ profile.profile_prefs.zipcode.val }}
16
             span from {{ profile.profile_prefs.zipcode.val }}
17
 
17
 
18
-        p About: {{ profile.profile_description}}
19
         p I am {{ profile.profile_prefs.urgency.val.split("_").join(" ") }}.
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
         p images: {{ profile.profile_media }}
27
         p images: {{ profile.profile_media }}
23
         p responses: {{ profile.responses.length }}
28
         p responses: {{ profile.responses.length }}
24
         button(@click="$router.go(-1)") back
29
         button(@click="$router.go(-1)") back

+ 0
- 1
frontend/src/views/SurveyView.vue Dosyayı Görüntüle

69
     props: {
69
     props: {
70
         pid: {
70
         pid: {
71
             type: Number,
71
             type: Number,
72
-            required: true,
73
         },
72
         },
74
     },
73
     },
75
     data() {
74
     data() {

Loading…
İptal
Kaydet