Skip to content

Commit 4904c62

Browse files
committed
decoupled dropdown component from recommendaitons component
1 parent 612541e commit 4904c62

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

frontend/src/components/app/recommendations/HistoryRecommendations.vue

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,54 @@
11
<template>
22
<!-- eslint-disable max-len -->
33
<section class="mb-4 sm:mb-16 lg:mb-32">
4-
<div v-if="recommendations.length && ready" class="flex w-full items-stretch sm:items-center justify-center md:justify-start mb-12 relative">
4+
<div v-if="recommendations.length"
5+
v-bind:class="{
6+
'flex': true,
7+
'w-full': true,
8+
'items-stretch': true,
9+
'sm:items-center': true,
10+
'justify-center': true,
11+
'md:justify-start': true,
12+
'mb-12': recommendations.length > 1,
13+
'relative': true}">
514
<Sort
15+
v-if="recommendations.length > 1"
616
v-bind:position="'left'"
717
v-bind:startingOption="'Closest'"
818
v-bind:options="['Closest', 'Furthest', 'Youngest',
919
'Oldest', 'Most popular', 'Least popular', 'Most common interests', 'Least common interests']"
1020
v-on:save-sort="saveSort"></Sort>
1121
<FilterSliderDropdown
22+
v-if="recommendationsAnalysis.age.min !== recommendationsAnalysis.age.max"
1223
v-bind:min="recommendationsAnalysis.age.min"
1324
v-bind:max="recommendationsAnalysis.age.max"
1425
v-bind:name="'age'"
1526
v-on:save-filter="saveFilter"></FilterSliderDropdown>
1627
<FilterSliderDropdown
28+
v-if="recommendationsAnalysis.distance.min !== recommendationsAnalysis.distance.max"
1729
v-bind:min="recommendationsAnalysis.distance.min"
1830
v-bind:max="recommendationsAnalysis.distance.max"
1931
v-bind:unit="'km'"
2032
v-bind:name="'distance'"
2133
v-on:save-filter="saveFilter"></FilterSliderDropdown>
2234
<FilterSliderDropdown
35+
v-if="recommendationsAnalysis.popularity.min !== recommendationsAnalysis.popularity.max"
2336
v-bind:min="recommendationsAnalysis.popularity.min"
2437
v-bind:max="recommendationsAnalysis.popularity.max"
2538
v-bind:unit="'pts'"
2639
v-bind:name="'popularity'"
2740
v-on:save-filter="saveFilter"></FilterSliderDropdown>
2841
<MultipleFiltersDropdown
42+
v-if="recommendations.length > 1"
2943
v-bind:position="'right'"
3044
v-bind:options="recommendationsAnalysis.interests"
3145
v-bind:name="'interests'"
3246
v-on:save-filter-multiple="saveFilterMultiple"></MultipleFiltersDropdown>
3347
</div>
34-
<div v-if="recommendations.length && ready" ref="recommendationCards" class="grid grid-cols-1 md:grid-cols-2 gap-2">
35-
<RecommendationCard
36-
v-for="(recommendation, index) in recommendations" :key="index"
37-
v-bind:recommendation="recommendation"></RecommendationCard>
48+
<div v-if="recommendations.length" ref="recommendationCards" class="grid grid-cols-1 md:grid-cols-2 gap-2">
49+
<RecommendationCard
50+
v-for="(recommendation, index) in recommendations" :key="index"
51+
v-bind:recommendation="recommendation"></RecommendationCard>
3852
</div>
3953
</section>
4054
</template>

frontend/src/components/shared/DropdownDisplayChoiceHistory.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export default {
2525
select(option) {
2626
this.close();
2727
this.currentOption = option;
28-
console.log(option);
2928
this.$emit('save-single-choice', this.name, option);
3029
},
3130
toggle() {

frontend/src/views/app/History.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
v-bind:options="['People I viewed', 'People I liked', 'Who viewed me', 'Who liked me', 'Whom I blocked']"></DropdownDisplayChoiceHistory>
1616
</div>
1717
<HistoryRecommendations
18-
v-if="firstTimeAnalysisDone"
19-
v-bind:ready="recommendations.length"
18+
v-if="recommendationsAnalysisDone"
2019
v-bind:title="'Potential matches'"
2120
v-bind:recommendationsReceived="recommendations"
2221
v-bind:recommendationsAnalysis="recommendationsAnalysis"></HistoryRecommendations>
@@ -57,7 +56,6 @@ export default {
5756
interests: [],
5857
},
5958
recommendationsAnalysisDone: false,
60-
firstTimeAnalysisDone: false,
6159
}),
6260
methods: {
6361
async fetchUsers(request) {
@@ -111,7 +109,6 @@ export default {
111109
}
112110
}
113111
this.recommendationsAnalysisDone = true;
114-
this.firstTimeAnalysisDone = true;
115112
},
116113
browseAgain() {
117114
this.recommendations = [];
@@ -125,17 +122,18 @@ export default {
125122
this.recommendationsAnalysisDone = false;
126123
},
127124
updateHistory(...args) {
128-
const [request] = args;
129-
this.browseAgain();
130-
this.fetchUsers(request);
125+
const [key, value] = args;
126+
if (key === 'history') {
127+
this.browseAgain();
128+
this.fetchUsers(value);
129+
}
131130
},
132131
},
133132
async created() {
134133
await this.fetchUsers('People I viewed');
135134
},
136135
deactivated() {
137136
if (!this.$route.path.startsWith('/users')) {
138-
this.firstTimeAnalysisDone = false;
139137
this.browseAgain();
140138
this.fetchUsers('People I viewed');
141139
this.$el.scrollTop = 0;

0 commit comments

Comments
 (0)