Skip to content

Commit

Permalink
fix: handle aggregation funct on FE
Browse files Browse the repository at this point in the history
  • Loading branch information
FrantisekMichalSebestyen committed Aug 23, 2023
1 parent 1dc169c commit bb4f08c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getParsedFilterFromUrl() {
}
function stringifyUrl({ url, params }) {
const { filter, size, terms, page } = params
const { filter, size, terms, page, min, max } = params
const {
yearRange,
author,
Expand Down Expand Up @@ -63,6 +63,8 @@ function stringifyUrl({ url, params }) {
sort: {
[sort]: SORT_DIRECTIONS[sort],
},
min,
max,
page,
terms,
size,
Expand Down Expand Up @@ -254,6 +256,8 @@ export default {
filter: this.query,
terms: AGGREGATIONS_TERMS,
size: AGGREGATIONS_SIZE,
min: { date_earliest: 'date_earliest' },
max: { date_latest: 'date_latest' },
},
}),
{ headers: this.apiHeaders }
Expand Down
17 changes: 13 additions & 4 deletions resources/js/components/catalog-new/SearchOptionsController.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@ export default {
filteredOptions() {
// TODO better matching algorithm?
const query = this.search.toLowerCase()
return this.options
.filter((option) => option.value.toLowerCase().includes(query))
.map((option) => ({
const optionsWithSelected = [
...this.options.map((option) => ({
...option,
checked: this.selected.includes(option.value),
}))
})),
...this.selected
.filter((queryItem) =>
this.options.every((option) => option.value !== queryItem)
)
.map((selected) => ({ value: selected, count: 0, checked: true })),
]
return optionsWithSelected.filter((option) =>
option.value.toLowerCase().includes(query)
)
},
},
render() {
Expand Down

0 comments on commit bb4f08c

Please sign in to comment.