diff --git a/resources/i18n/en.json b/resources/i18n/en.json index 5c750b2397..53ae9015f6 100644 --- a/resources/i18n/en.json +++ b/resources/i18n/en.json @@ -56,6 +56,10 @@ "detail": "{{ range }} of {{ total }}" } }, + "sorting": { + "ASC": "Ascending", + "DESC": "Descending" + }, "title": "DSpace", "404": { "help": "We can't find the page you're looking for. The page may have been moved or deleted. You can use the button below to get back to the home page. ", diff --git a/src/app/+search-page/search-filters/search-filter/search-filter.service.ts b/src/app/+search-page/search-filters/search-filter/search-filter.service.ts index 1ba8182d33..62f906c004 100644 --- a/src/app/+search-page/search-filters/search-filter/search-filter.service.ts +++ b/src/app/+search-page/search-filters/search-filter/search-filter.service.ts @@ -10,7 +10,7 @@ import { SearchFilterInitialExpandAction, SearchFilterResetPageAction, SearchFilterToggleAction } from './search-filter.actions'; -import { hasValue, } from '../../../shared/empty.util'; +import { hasValue, isEmpty, isNotEmpty, } from '../../../shared/empty.util'; import { SearchFilterConfig } from '../../search-service/search-filter-config.model'; import { SearchService } from '../../search-service/search.service'; import { RouteService } from '../../../shared/route.service'; @@ -59,7 +59,9 @@ export class SearchFilterService { getCurrentSort(): Observable { const sortDirection$ = this.routeService.getQueryParameterValue('sortDirection'); const sortField$ = this.routeService.getQueryParameterValue('sortField'); - return Observable.combineLatest(sortDirection$, sortField$, (sortDirection, sortField) => new SortOptions(sortField || undefined, SortDirection[sortDirection])); + return Observable.combineLatest(sortDirection$, sortField$, (sortDirection, sortField) => + new SortOptions(isNotEmpty(sortField) ? sortField : undefined, SortDirection[sortDirection]) + ); } getCurrentFilters() { diff --git a/src/app/+search-page/search-settings/search-settings.component.html b/src/app/+search-page/search-settings/search-settings.component.html index b0d3294e30..18fd45caed 100644 --- a/src/app/+search-page/search-settings/search-settings.component.html +++ b/src/app/+search-page/search-settings/search-settings.component.html @@ -5,7 +5,7 @@ diff --git a/src/app/core/cache/models/sort-options.model.ts b/src/app/core/cache/models/sort-options.model.ts index 751b72b399..b2380cbaf3 100644 --- a/src/app/core/cache/models/sort-options.model.ts +++ b/src/app/core/cache/models/sort-options.model.ts @@ -1,10 +1,10 @@ export enum SortDirection { - Ascending = 'ASC', - Descending = 'DESC' + ASC = 'ASC', + DESC = 'DESC' } export class SortOptions { - constructor(public field: string = 'dc.title', public direction: SortDirection = SortDirection.Ascending) { + constructor(public field: string = 'dc.title', public direction: SortDirection = SortDirection.ASC) { } } diff --git a/src/app/shared/pagination/pagination.component.html b/src/app/shared/pagination/pagination.component.html index 0ad812a6b6..e974bb6eb0 100644 --- a/src/app/shared/pagination/pagination.component.html +++ b/src/app/shared/pagination/pagination.component.html @@ -12,7 +12,7 @@ - + diff --git a/src/app/shared/pagination/pagination.component.ts b/src/app/shared/pagination/pagination.component.ts index 6ab0e2a567..faaf20ec79 100644 --- a/src/app/shared/pagination/pagination.component.ts +++ b/src/app/shared/pagination/pagination.component.ts @@ -144,7 +144,7 @@ export class PaginationComponent implements OnDestroy, OnInit { /** * Direction in which to sort: ascending or descending */ - public sortDirection: SortDirection = SortDirection.Ascending; + public sortDirection: SortDirection = SortDirection.ASC; /** * Name of the field that's used to sort by diff --git a/src/app/shared/route.service.ts b/src/app/shared/route.service.ts index 10a7eaecb9..9c2b64ede1 100644 --- a/src/app/shared/route.service.ts +++ b/src/app/shared/route.service.ts @@ -13,19 +13,19 @@ export class RouteService { } getQueryParameterValues(paramName: string): Observable { - return this.route.queryParamMap.map((map) => [...map.getAll(paramName)]); + return this.route.queryParamMap.map((map) => [...map.getAll(paramName)]).distinctUntilChanged(); } getQueryParameterValue(paramName: string): Observable { - return this.route.queryParamMap.map((map) => map.get(paramName)); + return this.route.queryParamMap.map((map) => map.get(paramName)).distinctUntilChanged(); } hasQueryParam(paramName: string): Observable { - return this.route.queryParamMap.map((map) => map.has(paramName)); + return this.route.queryParamMap.map((map) => map.has(paramName)).distinctUntilChanged(); } hasQueryParamWithValue(paramName: string, paramValue: string): Observable { - return this.route.queryParamMap.map((map) => map.getAll(paramName).indexOf(paramValue) > -1); + return this.route.queryParamMap.map((map) => map.getAll(paramName).indexOf(paramValue) > -1).distinctUntilChanged(); } getQueryParamsWithPrefix(prefix: string): Observable { @@ -38,6 +38,6 @@ export class RouteService { params[key] = [...map.getAll(key)]; }); return params; - }); + }).distinctUntilChanged(); } }