diff --git a/resources/i18n/en.json b/resources/i18n/en.json
index 9714640287..c605d76961 100644
--- a/resources/i18n/en.json
+++ b/resources/i18n/en.json
@@ -69,5 +69,14 @@
"head": "Communities in DSpace",
"help": "Select a community to browse its collections."
}
+ },
+ "search": {
+ "form": {
+ "search": "Search",
+ "search_dspace": "Search DSpace"
+ },
+ "results": {
+ "title": "Search Results"
+ }
}
}
diff --git a/src/app/search-page/search-page.component.html b/src/app/search-page/search-page.component.html
index 97eb9360dd..45b7e70ed1 100644
--- a/src/app/search-page/search-page.component.html
+++ b/src/app/search-page/search-page.component.html
@@ -1,4 +1,4 @@
-
+
diff --git a/src/app/search-page/search-page.component.ts b/src/app/search-page/search-page.component.ts
index e601ab4d8c..bfabd1c0c6 100644
--- a/src/app/search-page/search-page.component.ts
+++ b/src/app/search-page/search-page.component.ts
@@ -6,6 +6,7 @@ import { SearchResult } from '../search/search-result.model';
import { DSpaceObject } from '../core/shared/dspace-object.model';
import { SortOptions } from '../core/cache/models/sort-options.model';
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
+import { SearchOptions } from '../search/search-options.model';
/**
* This component renders a simple item page.
@@ -20,11 +21,12 @@ import { PaginationComponentOptions } from '../shared/pagination/pagination-comp
})
export class SearchPageComponent implements OnInit, OnDestroy {
private sub;
- private query: string;
+ query: string;
private scope: string;
private page: number;
- private results: RemoteData>>;
+ results: RemoteData>>;
private currentParams = {};
+ searchOptions: SearchOptions;
constructor(private service: SearchService,
private route: ActivatedRoute,
@@ -40,13 +42,12 @@ export class SearchPageComponent implements OnInit, OnDestroy {
this.scope = params.scope;
this.page = +params.page || 1;
const pagination: PaginationComponentOptions = new PaginationComponentOptions();
- pagination.id = 'results-pagination';
+ pagination.id = 'search-results-pagination';
pagination.currentPage = this.page;
- pagination.pageSize = +params.pageSize;
- this.results = this.service.search(this.query, this.scope, {
- pagination: pagination,
- sort: new SortOptions(params.sortField, params.sortDirection)
- });
+ pagination.pageSize = +params.pageSize || 10;
+ const sort: SortOptions = new SortOptions(params.sortField, params.sortDirection);
+ this.searchOptions = {pagination: pagination, sort: sort};
+ this.results = this.service.search(this.query, this.scope, this.searchOptions);
}
);
}
diff --git a/src/app/search-page/search-results/search-results.component.html b/src/app/search-page/search-results/search-results.component.html
index 2f17c9a730..7d769dbeb0 100644
--- a/src/app/search-page/search-results/search-results.component.html
+++ b/src/app/search-page/search-results/search-results.component.html
@@ -1,2 +1,3 @@
+ 0">{{ 'search.results.title' | translate }}
\ No newline at end of file
diff --git a/src/app/search-page/search-results/search-results.compontent.ts b/src/app/search-page/search-results/search-results.compontent.ts
index e39c0323c9..8ca741a68d 100644
--- a/src/app/search-page/search-results/search-results.compontent.ts
+++ b/src/app/search-page/search-results/search-results.compontent.ts
@@ -17,16 +17,7 @@ import { SearchOptions } from '../../search/search-options.model';
templateUrl: './search-results.component.html',
})
-export class SearchResultsComponent implements OnInit {
+export class SearchResultsComponent {
@Input() searchResults: RemoteData>>;
-
@Input() searchConfig: SearchOptions;
-
- ngOnInit(): void {
- this.searchConfig = new SearchOptions();
- this.searchConfig.pagination = new PaginationComponentOptions();
- this.searchConfig.pagination.id = 'search-results-pagination';
- this.searchConfig.sort = new SortOptions();
- }
-
}
diff --git a/src/app/shared/pagination/pagination.component.ts b/src/app/shared/pagination/pagination.component.ts
index c0b8e4abd6..5cdefd8eed 100644
--- a/src/app/shared/pagination/pagination.component.ts
+++ b/src/app/shared/pagination/pagination.component.ts
@@ -199,8 +199,8 @@ export class PaginationComponent implements OnDestroy, OnInit {
this.sortDirection = this.sortOptions.direction;
this.sortField = this.sortOptions.field;
}
+ this.setShowingDetail();
}));
- this.setShowingDetail();
}
/**
@@ -246,6 +246,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
*/
public setPageSize(pageSize: number) {
this.pageSize = pageSize;
+ this.doPageChange(1);
this.updateRoute();
this.setShowingDetail();
this.pageSizeChange.emit(pageSize);
@@ -259,6 +260,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
*/
public setSortDirection(sortDirection: SortDirection) {
this.sortDirection = sortDirection;
+ this.doPageChange(1);
this.updateRoute();
this.setShowingDetail();
this.sortDirectionChange.emit(sortDirection);
@@ -272,6 +274,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
*/
public setSortField(field: string) {
this.sortField = field;
+ this.doPageChange(1);
this.updateRoute();
this.setShowingDetail();
this.sortFieldChange.emit(field);
@@ -298,11 +301,11 @@ export class PaginationComponent implements OnDestroy, OnInit {
private setShowingDetail() {
let firstItem;
let lastItem;
- const lastPage = Math.round(this.collectionSize / this.pageSize);
+ const pageMax = this.pageSize * this.currentPage;
firstItem = this.pageSize * (this.currentPage - 1) + 1;
- if (this.currentPage !== lastPage) {
- lastItem = this.pageSize * this.currentPage;
+ if (this.collectionSize > pageMax) {
+ lastItem = pageMax;
} else {
lastItem = this.collectionSize;
}
diff --git a/src/app/shared/search-form/search-form.component.html b/src/app/shared/search-form/search-form.component.html
index e83554ad9b..d636d3227a 100644
--- a/src/app/shared/search-form/search-form.component.html
+++ b/src/app/shared/search-form/search-form.component.html
@@ -1,16 +1,16 @@