mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
changed default sort options
This commit is contained in:
@@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { SortOptions } from '../core/cache/models/sort-options.model';
|
||||
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
|
||||
import { CollectionDataService } from '../core/data/collection-data.service';
|
||||
import { ItemDataService } from '../core/data/item-data.service';
|
||||
import { PaginatedList } from '../core/data/paginated-list';
|
||||
@@ -48,7 +48,7 @@ export class CollectionPageComponent implements OnInit, OnDestroy {
|
||||
this.paginationConfig.id = 'collection-page-pagination';
|
||||
this.paginationConfig.pageSize = 5;
|
||||
this.paginationConfig.currentPage = 1;
|
||||
this.sortConfig = new SortOptions();
|
||||
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { CommunityDataService } from '../../core/data/community-data.service';
|
||||
import { PaginatedList } from '../../core/data/paginated-list';
|
||||
|
||||
@@ -27,7 +27,7 @@ export class TopLevelCommunityListComponent {
|
||||
this.config.id = 'top-level-pagination';
|
||||
this.config.pageSize = 5;
|
||||
this.config.currentPage = 1;
|
||||
this.sortConfig = new SortOptions();
|
||||
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
||||
|
||||
this.updatePage({
|
||||
page: this.config.currentPage,
|
||||
|
@@ -60,8 +60,12 @@ export class SearchFilterService {
|
||||
getCurrentSort(): Observable<SortOptions> {
|
||||
const sortDirection$ = this.routeService.getQueryParameterValue('sortDirection');
|
||||
const sortField$ = this.routeService.getQueryParameterValue('sortField');
|
||||
return Observable.combineLatest(sortDirection$, sortField$, (sortDirection, sortField) =>
|
||||
new SortOptions(isNotEmpty(sortField) ? sortField : undefined, SortDirection[sortDirection])
|
||||
return Observable.combineLatest(sortDirection$, sortField$, (sortDirection, sortField) => {
|
||||
if (isNotEmpty(sortField)) {
|
||||
const direction = SortDirection[sortDirection];
|
||||
return new SortOptions(sortField, direction ? direction : SortDirection.ASC)
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,7 +91,7 @@ export class SearchFilterService {
|
||||
defaults,
|
||||
{
|
||||
pagination: pagination,
|
||||
sort: sort,
|
||||
sort: sort || defaults.sort,
|
||||
view: view,
|
||||
scope: scope || defaults.scope,
|
||||
query: query,
|
||||
@@ -108,7 +112,7 @@ export class SearchFilterService {
|
||||
defaults,
|
||||
{
|
||||
view: view,
|
||||
scope: scope,
|
||||
scope: scope || defaults.scope,
|
||||
query: query,
|
||||
filters: filters
|
||||
})
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { flatMap, } from 'rxjs/operators';
|
||||
import { SortOptions } from '../core/cache/models/sort-options.model';
|
||||
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
|
||||
import { CommunityDataService } from '../core/data/community-data.service';
|
||||
import { PaginatedList } from '../core/data/paginated-list';
|
||||
import { RemoteData } from '../core/data/remote-data';
|
||||
@@ -42,6 +42,7 @@ export class SearchPageComponent implements OnInit {
|
||||
id: 'search-results-pagination',
|
||||
pageSize: 10
|
||||
},
|
||||
sort: new SortOptions('score', SortDirection.DESC),
|
||||
query: '',
|
||||
scope: ''
|
||||
};
|
||||
|
@@ -7,7 +7,7 @@ import { Observable } from 'rxjs/Observable';
|
||||
import { flatMap, map, tap } from 'rxjs/operators';
|
||||
import { ViewMode } from '../../+search-page/search-options.model';
|
||||
import { RemoteDataBuildService } from '../../core/cache/builders/remote-data-build.service';
|
||||
import { SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import {
|
||||
FacetConfigSuccessResponse,
|
||||
FacetValueSuccessResponse,
|
||||
@@ -61,7 +61,7 @@ export class SearchService implements OnDestroy {
|
||||
pagination.id = 'search-results-pagination';
|
||||
pagination.currentPage = 1;
|
||||
pagination.pageSize = 10;
|
||||
const sort: SortOptions = new SortOptions();
|
||||
const sort: SortOptions = new SortOptions('score', SortDirection.DESC);
|
||||
this.searchOptions = Object.assign(new SearchOptions(), { pagination: pagination, sort: sort });
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@ export enum SortDirection {
|
||||
}
|
||||
|
||||
export class SortOptions {
|
||||
constructor(public field: string = 'dc.title', public direction: SortDirection = SortDirection.ASC) {
|
||||
constructor(public field: string, public direction: SortDirection) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ import { MockRouter } from '../mocks/mock-router';
|
||||
|
||||
import { HostWindowService } from '../host-window.service';
|
||||
import { EnumKeysPipe } from '../utils/enum-keys-pipe';
|
||||
import { SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
|
||||
import { GLOBAL_CONFIG, ENV_CONFIG } from '../../../config';
|
||||
|
||||
@@ -349,7 +349,7 @@ class TestComponent {
|
||||
collection: string[] = [];
|
||||
collectionSize: number;
|
||||
paginationOptions = new PaginationComponentOptions();
|
||||
sortOptions = new SortOptions();
|
||||
sortOptions = new SortOptions('dc.title', SortDirection.ASC);
|
||||
|
||||
constructor() {
|
||||
this.collection = Array.from(new Array(100), (x, i) => `item ${i + 1}`);
|
||||
|
Reference in New Issue
Block a user