Skip to content

Commit c80a0e1

Browse files
committed
use /search/values for search sliders
1 parent 54f4651 commit c80a0e1

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

frontend/src/views/app/Search.vue

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212
v-bind:recommendationsAnalysis="filters"></Recommendations>
1313
</section>
1414
<section v-if="!recommendationsAnalysisDone" class="flex flex-col my-8 md:my-12">
15-
<div>
15+
<div v-if="sliderValuesFetched">
1616
<FilterSlider
17-
v-bind:min="18"
18-
v-bind:max="100"
17+
v-bind:min="sliders.age.min"
18+
v-bind:max="sliders.age.max"
1919
v-bind:name="'age'"
2020
v-on:saveFilter="saveFilter"></FilterSlider>
2121
<FilterSlider
2222
v-bind:min="0"
23-
v-bind:max="1000"
23+
v-bind:max="2000"
2424
v-bind:unit="'km'"
2525
v-bind:oneHandle="true"
2626
v-bind:name="'distance'"
2727
v-on:saveFilter="saveFilter"></FilterSlider>
2828
<FilterSlider
29-
v-bind:min="18"
30-
v-bind:max="100"
29+
v-bind:min="sliders.popularity.min"
30+
v-bind:max="sliders.popularity.max"
3131
v-bind:unit="'pts'"
3232
v-bind:name="'popularity'"
3333
v-on:saveFilter="saveFilter"></FilterSlider>
@@ -72,6 +72,17 @@ export default {
7272
},
7373
data: () => ({
7474
recommendations: [],
75+
sliders: {
76+
age: {
77+
min: null,
78+
max: null,
79+
},
80+
popularity: {
81+
min: null,
82+
max: null,
83+
},
84+
},
85+
sliderValuesFetched: false,
7586
filters: {
7687
age: {
7788
min: null,
@@ -144,6 +155,18 @@ export default {
144155
this.recommendationsAnalysisDone = false;
145156
},
146157
},
158+
async mounted() {
159+
const sliderRangesRequest = await this.$http.get('/search/values');
160+
const values = sliderRangesRequest.data.search_minmax;
161+
this.sliders.age.min = values.min_age;
162+
if (this.sliders.age.min < 18) {
163+
this.sliders.age.min = 18;
164+
}
165+
this.sliders.age.max = values.max_age;
166+
this.sliders.popularity.min = values.min_score;
167+
this.sliders.popularity.max = values.max_score;
168+
this.sliderValuesFetched = true;
169+
},
147170
};
148171
149172
</script>

0 commit comments

Comments
 (0)