Skip to content

Commit

Permalink
feat: make sort param optionnal
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier committed Sep 20, 2023
1 parent db74690 commit b3c719c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions apps/datahub/src/app/home/home-header/home-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { map } from 'rxjs/operators'
import { ROUTER_ROUTE_NEWS } from '../../router/constants'

Check warning on line 22 in apps/datahub/src/app/home/home-header/home-header.component.ts

View workflow job for this annotation

GitHub Actions / Format check, lint, unit tests

'firstValueFrom' is defined but never used
import { firstValueFrom, lastValueFrom } from 'rxjs'
import { CatalogRecord } from '@geonetwork-ui/common/domain/record'
import { sortByToString } from '@geonetwork-ui/util/shared'
import { sortByFromString } from '@geonetwork-ui/util/shared'

marker('datahub.header.myfavorites')
marker('datahub.header.lastRecords')
Expand Down Expand Up @@ -84,7 +84,11 @@ export class HomeHeaderComponent {
customSearchParameters.filters
)
)
const sortBy = await firstValueFrom(this.searchFacade.sortBy$)
this.searchService.setSortAndFilters(searchFilters, sortBy)
if (customSearchParameters.sort) {
const sortBy = sortByFromString(customSearchParameters.sort[0])
this.searchService.setSortAndFilters(searchFilters, sortBy)
} else {
this.searchService.setFilters(searchFilters)
}
}
}
3 changes: 2 additions & 1 deletion conf/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ background_color = "#fdfbff"

# One or several search presets can be defined here; every search preset is composed of:
# - a name (which can be a translation key)
# - a sort criteria: either `createDate`, `userSavedCount` or `_score` (prepend with `-` for descending sort)
# - a sort criteria: either `createDate`, `userSavedCount` or `_score` (prepend with `-` for descending sort) (optionnal)
# - filters which can be expressed like so:
# [[search_preset]]
# name = 'filterByName'
Expand All @@ -88,6 +88,7 @@ background_color = "#fdfbff"
# filters.publicationYear = ['2023', '2022']
# filters.isSpatial = ['yes']
# filters.license = ['unknown']
# sort = ['createDate']
# [[search_preset]]
# name = 'otherFilterName'
# filters.q = 'Other Full text search'
Expand Down

0 comments on commit b3c719c

Please sign in to comment.