mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
44024: search service changes
This commit is contained in:
@@ -35,7 +35,6 @@
|
||||
<div *ngIf="(itemData.hasSucceeded | async)">
|
||||
<h2>{{'collection.page.browse.recent.head' | translate}}</h2>
|
||||
<ds-object-list [config]="paginationConfig" [sortConfig]="sortConfig"
|
||||
[objects]="itemData" [hideGear]="false"
|
||||
(paginationChange)="updatePage($event)"></ds-object-list>
|
||||
[objects]="itemData" [hideGear]="false"></ds-object-list>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -53,6 +53,15 @@ export class SearchService {
|
||||
if (isNotEmpty(searchOptions) && hasValue(searchOptions.pagination.currentPage)) {
|
||||
self += `&page=${searchOptions.pagination.currentPage}`;
|
||||
}
|
||||
if (isNotEmpty(searchOptions) && hasValue(searchOptions.pagination.pageSize)) {
|
||||
self += `&pageSize=${searchOptions.pagination.pageSize}`;
|
||||
}
|
||||
if (isNotEmpty(searchOptions) && hasValue(searchOptions.sort.direction)) {
|
||||
self += `&sortDirection=${searchOptions.sort.direction}`;
|
||||
}
|
||||
if (isNotEmpty(searchOptions) && hasValue(searchOptions.sort.field)) {
|
||||
self += `&sortField=${searchOptions.sort.field}`;
|
||||
}
|
||||
const requestPending = Observable.of(false);
|
||||
const responsePending = Observable.of(false);
|
||||
const errorMessage = Observable.of(undefined);
|
||||
@@ -66,11 +75,15 @@ export class SearchService {
|
||||
returningPageInfo.elementsPerPage = 10;
|
||||
returningPageInfo.currentPage = 1;
|
||||
}
|
||||
returningPageInfo.totalPages = this.totalPages;
|
||||
returningPageInfo.totalElements = returningPageInfo.elementsPerPage * returningPageInfo.totalPages;
|
||||
const pageInfo = Observable.of(returningPageInfo);
|
||||
|
||||
const itemsRD = this.itemDataService.findAll({ elementsPerPage: 10 });
|
||||
const itemsRD = this.itemDataService.findAll({
|
||||
scopeID: scopeId,
|
||||
currentPage: returningPageInfo.currentPage,
|
||||
elementsPerPage: returningPageInfo.elementsPerPage
|
||||
});
|
||||
|
||||
const pageInfo = itemsRD.pageInfo;
|
||||
|
||||
const payload = itemsRD.payload.map((items: Item[]) => {
|
||||
return shuffle(items)
|
||||
.map((item: Item, index: number) => {
|
||||
|
@@ -69,6 +69,7 @@ export class ObjectListComponent implements OnChanges, OnInit {
|
||||
|
||||
ngOnInit(): void {
|
||||
this.pageInfo = this.objects.pageInfo;
|
||||
this.pageInfo.subscribe((info) => console.log(info));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<div class="row">
|
||||
<div class="col pagination-info">
|
||||
<span class="align-middle hidden-xs-down">{{ 'pagination.showing.label' | translate }}</span>
|
||||
<span class="align-middle">{{ 'pagination.showing.detail' | translate:showingDetail }}</span>
|
||||
<span class="align-middle" *ngIf="collectionSize">{{ 'pagination.showing.detail' | translate:getShowingDetails(collectionSize)}}</span>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div ngbDropdown #paginationControls="ngbDropdown" class="d-inline-block float-right">
|
||||
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<ng-content></ng-content>
|
||||
|
||||
<div *ngIf="shouldShowBottomPager" class="pagination justify-content-center clearfix bottom">
|
||||
|
@@ -162,14 +162,6 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
||||
*/
|
||||
private subs: Subscription[] = [];
|
||||
|
||||
/**
|
||||
* An object that represents pagination details of the current viewed page
|
||||
*/
|
||||
public showingDetail: any = {
|
||||
range: null,
|
||||
total: null
|
||||
};
|
||||
|
||||
/**
|
||||
* Method provided by Angular. Invoked after the constructor.
|
||||
*/
|
||||
@@ -193,7 +185,6 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
||||
this.fixRoute(fixedProperties);
|
||||
}
|
||||
this.setFields();
|
||||
this.setShowingDetail();
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -228,7 +219,6 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
||||
sortDirection: this.sortDirection,
|
||||
sortField: this.sortField
|
||||
};
|
||||
this.setShowingDetail();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,23 +343,24 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set pagination details of the current viewed page.
|
||||
* Method to get pagination details of the current viewed page.
|
||||
*/
|
||||
private setShowingDetail() {
|
||||
public getShowingDetails(collectionSize: number): any {
|
||||
let showingDetails = { range: null + ' - ' + null, total: null };
|
||||
if (collectionSize) {
|
||||
let firstItem;
|
||||
let lastItem;
|
||||
const pageMax = this.pageSize * this.currentPage;
|
||||
|
||||
firstItem = this.pageSize * (this.currentPage - 1) + 1;
|
||||
if (this.collectionSize > pageMax) {
|
||||
if (collectionSize > pageMax) {
|
||||
lastItem = pageMax;
|
||||
} else {
|
||||
lastItem = this.collectionSize;
|
||||
lastItem = collectionSize;
|
||||
}
|
||||
this.showingDetail = {
|
||||
range: firstItem + ' - ' + lastItem,
|
||||
total: this.collectionSize
|
||||
showingDetails = { range: firstItem + ' - ' + lastItem, total: collectionSize };
|
||||
}
|
||||
return showingDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user