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