Ensure a valid sort is specified

This commit is contained in:
Tim Donohue
2022-06-03 11:13:00 -05:00
parent eb662fc156
commit f942eced3a

View File

@@ -28,6 +28,7 @@ import { SearchConfigurationService } from '../../../core/shared/search/search-c
import { SearchService } from '../../../core/shared/search/search.service'; import { SearchService } from '../../../core/shared/search/search.service';
import { NoContent } from '../../../core/shared/NoContent.model'; import { NoContent } from '../../../core/shared/NoContent.model';
import { getItemPageRoute } from '../../item-page-routing-paths'; import { getItemPageRoute } from '../../item-page-routing-paths';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
@Component({ @Component({
selector: 'ds-item-collection-mapper', selector: 'ds-item-collection-mapper',
@@ -73,6 +74,12 @@ export class ItemCollectionMapperComponent implements OnInit {
*/ */
mappedCollectionsRD$: Observable<RemoteData<PaginatedList<Collection>>>; mappedCollectionsRD$: Observable<RemoteData<PaginatedList<Collection>>>;
/**
* Sort on title ASC by default
* @type {SortOptions}
*/
defaultSortOptions: SortOptions = new SortOptions('dc.title', SortDirection.ASC);
/** /**
* Firing this observable (shouldUpdate$.next(true)) forces the two lists to reload themselves * Firing this observable (shouldUpdate$.next(true)) forces the two lists to reload themselves
* Usually fired after the lists their cache is cleared (to force a new request to the REST API) * Usually fired after the lists their cache is cleared (to force a new request to the REST API)
@@ -149,7 +156,8 @@ export class ItemCollectionMapperComponent implements OnInit {
switchMap(([itemCollectionsRD, owningCollectionRD, searchOptions]) => { switchMap(([itemCollectionsRD, owningCollectionRD, searchOptions]) => {
return this.searchService.search(Object.assign(new PaginatedSearchOptions(searchOptions), { return this.searchService.search(Object.assign(new PaginatedSearchOptions(searchOptions), {
query: this.buildQuery([...itemCollectionsRD.payload.page, owningCollectionRD.payload], searchOptions.query), query: this.buildQuery([...itemCollectionsRD.payload.page, owningCollectionRD.payload], searchOptions.query),
dsoTypes: [DSpaceObjectType.COLLECTION] dsoTypes: [DSpaceObjectType.COLLECTION],
sort: this.defaultSortOptions
}), 10000).pipe( }), 10000).pipe(
toDSpaceObjectListRD(), toDSpaceObjectListRD(),
startWith(undefined) startWith(undefined)