mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
Merge pull request #377 from atmire/home-pagination-issue-fix
Home pagination issue fix
This commit is contained in:
@@ -289,7 +289,7 @@
|
|||||||
"results-per-page": "Results Per Page",
|
"results-per-page": "Results Per Page",
|
||||||
"sort-direction": "Sort Options",
|
"sort-direction": "Sort Options",
|
||||||
"showing": {
|
"showing": {
|
||||||
"label": "Now showing items ",
|
"label": "Now showing ",
|
||||||
"detail": "{{ range }} of {{ total }}"
|
"detail": "{{ range }} of {{ total }}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -54,8 +54,8 @@
|
|||||||
"results-per-page": "Resultaten per pagina",
|
"results-per-page": "Resultaten per pagina",
|
||||||
"sort-direction": "Sorteermogelijkheden",
|
"sort-direction": "Sorteermogelijkheden",
|
||||||
"showing": {
|
"showing": {
|
||||||
"label": "Getoonde items ",
|
"label": "Resultaten ",
|
||||||
"detail": "{{ range }} tot {{ total }}"
|
"detail": "{{ range }} van {{ total }}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sorting": {
|
"sorting": {
|
||||||
@@ -229,7 +229,7 @@
|
|||||||
"validation": {
|
"validation": {
|
||||||
"pattern": "Deze invoer is niet toegelaten volgens dit patroon: {{ pattern }}.",
|
"pattern": "Deze invoer is niet toegelaten volgens dit patroon: {{ pattern }}.",
|
||||||
"license": {
|
"license": {
|
||||||
"notgranted": "U moet de invoerlicentie goedkeuren om de invoer af te werken. Indien u deze licentie momenteel niet kan of mag goedkeuren, kan u uw werk opslaan en de invoer later afwerken. U kan dit nieuwe item ook verwijderen indien u niet voldoet aan de vereisten van de invoer licentie."
|
"notgranted": "U moet de invoerlicentie goedkeuren om de invoer af te werken. Indien u deze licentie momenteel niet kan of mag goedkeuren, kan u uw werk opslaan en de invoer later afwerken. U kunt dit nieuwe item ook verwijderen indien u niet voldoet aan de vereisten van de invoerlicentie."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -271,7 +271,7 @@
|
|||||||
"expired": "Uw sessie is vervallen. Gelieve opnieuw aan te melden."
|
"expired": "Uw sessie is vervallen. Gelieve opnieuw aan te melden."
|
||||||
},
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
"invalid-user": "Ongeldig email adres of wachtwoord."
|
"invalid-user": "Ongeldig e-mailadres of wachtwoord."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,13 @@
|
|||||||
<ng-container *ngVar="(communitiesRDObs | async) as communitiesRD">
|
<ng-container *ngVar="(communitiesRD$ | async) as communitiesRD">
|
||||||
<div *ngIf="communitiesRD?.hasSucceeded " @fadeInOut>
|
<div *ngIf="communitiesRD?.hasSucceeded ">
|
||||||
<h2>{{'home.top-level-communities.head' | translate}}</h2>
|
<h2>{{'home.top-level-communities.head' | translate}}</h2>
|
||||||
<p class="lead">{{'home.top-level-communities.help' | translate}}</p>
|
<p class="lead">{{'home.top-level-communities.help' | translate}}</p>
|
||||||
<ds-viewable-collection
|
<ds-viewable-collection
|
||||||
[config]="config"
|
[config]="config"
|
||||||
[sortConfig]="sortConfig"
|
[sortConfig]="sortConfig"
|
||||||
[objects]="communitiesRD"
|
[objects]="communitiesRD$ | async"
|
||||||
(paginationChange)="updatePage($event)">
|
[hideGear]="true"
|
||||||
|
(paginationChange)="onPaginationChange($event)">
|
||||||
</ds-viewable-collection>
|
</ds-viewable-collection>
|
||||||
</div>
|
</div>
|
||||||
<ds-error *ngIf="communitiesRD?.hasFailed " message="{{'error.top-level-communites' | translate}}"></ds-error>
|
<ds-error *ngIf="communitiesRD?.hasFailed " message="{{'error.top-level-communites' | translate}}"></ds-error>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
import { SortDirection, 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';
|
||||||
@@ -9,7 +9,11 @@ import { Community } from '../../core/shared/community.model';
|
|||||||
|
|
||||||
import { fadeInOut } from '../../shared/animations/fade';
|
import { fadeInOut } from '../../shared/animations/fade';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
|
import { take } from 'rxjs/operators';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this component renders the Top-Level Community list
|
||||||
|
*/
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-top-level-community-list',
|
selector: 'ds-top-level-community-list',
|
||||||
styleUrls: ['./top-level-community-list.component.scss'],
|
styleUrls: ['./top-level-community-list.component.scss'],
|
||||||
@@ -18,9 +22,20 @@ import { PaginationComponentOptions } from '../../shared/pagination/pagination-c
|
|||||||
animations: [fadeInOut]
|
animations: [fadeInOut]
|
||||||
})
|
})
|
||||||
|
|
||||||
export class TopLevelCommunityListComponent {
|
export class TopLevelCommunityListComponent implements OnInit {
|
||||||
communitiesRDObs: Observable<RemoteData<PaginatedList<Community>>>;
|
/**
|
||||||
|
* A list of remote data objects of all top communities
|
||||||
|
*/
|
||||||
|
communitiesRD$: BehaviorSubject<RemoteData<PaginatedList<Community>>> = new BehaviorSubject<RemoteData<PaginatedList<Community>>>({} as any);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The pagination configuration
|
||||||
|
*/
|
||||||
config: PaginationComponentOptions;
|
config: PaginationComponentOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sorting configuration
|
||||||
|
*/
|
||||||
sortConfig: SortOptions;
|
sortConfig: SortOptions;
|
||||||
|
|
||||||
constructor(private cds: CommunityDataService) {
|
constructor(private cds: CommunityDataService) {
|
||||||
@@ -29,20 +44,34 @@ export class TopLevelCommunityListComponent {
|
|||||||
this.config.pageSize = 5;
|
this.config.pageSize = 5;
|
||||||
this.config.currentPage = 1;
|
this.config.currentPage = 1;
|
||||||
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
||||||
|
|
||||||
this.updatePage({
|
|
||||||
page: this.config.currentPage,
|
|
||||||
pageSize: this.config.pageSize,
|
|
||||||
sortField: this.sortConfig.field,
|
|
||||||
direction: this.sortConfig.direction
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePage(data) {
|
ngOnInit() {
|
||||||
this.communitiesRDObs = this.cds.findTop({
|
this.updatePage();
|
||||||
currentPage: data.page,
|
}
|
||||||
elementsPerPage: data.pageSize,
|
|
||||||
sort: { field: data.sortField, direction: data.sortDirection }
|
/**
|
||||||
|
* Called when one of the pagination settings is changed
|
||||||
|
* @param event The new pagination data
|
||||||
|
*/
|
||||||
|
onPaginationChange(event) {
|
||||||
|
this.config.currentPage = event.page;
|
||||||
|
this.config.pageSize = event.pageSize;
|
||||||
|
this.sortConfig.field = event.sortField;
|
||||||
|
this.sortConfig.direction = event.sortDirection;
|
||||||
|
this.updatePage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the list of top communities
|
||||||
|
*/
|
||||||
|
updatePage() {
|
||||||
|
this.cds.findTop({
|
||||||
|
currentPage: this.config.currentPage,
|
||||||
|
elementsPerPage: this.config.pageSize,
|
||||||
|
sort: { field: this.sortConfig.field, direction: this.sortConfig.direction }
|
||||||
|
}).pipe(take(1)).subscribe((results) => {
|
||||||
|
this.communitiesRD$.next(results);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,11 @@
|
|||||||
[sortConfig]="sortConfig"
|
[sortConfig]="sortConfig"
|
||||||
[objects]="objects"
|
[objects]="objects"
|
||||||
[hideGear]="hideGear"
|
[hideGear]="hideGear"
|
||||||
|
(paginationChange)="onPaginationChange($event)"
|
||||||
|
(pageChange)="onPageChange($event)"
|
||||||
|
(pageSizeChange)="onPageSizeChange($event)"
|
||||||
|
(sortDirectionChange)="onSortDirectionChange($event)"
|
||||||
|
(sortFieldChange)="onSortFieldChange($event)"
|
||||||
*ngIf="getViewMode()===viewModeEnum.List">
|
*ngIf="getViewMode()===viewModeEnum.List">
|
||||||
</ds-object-list>
|
</ds-object-list>
|
||||||
|
|
||||||
@@ -9,6 +14,11 @@
|
|||||||
[sortConfig]="sortConfig"
|
[sortConfig]="sortConfig"
|
||||||
[objects]="objects"
|
[objects]="objects"
|
||||||
[hideGear]="hideGear"
|
[hideGear]="hideGear"
|
||||||
|
(paginationChange)="onPaginationChange($event)"
|
||||||
|
(pageChange)="onPageChange($event)"
|
||||||
|
(pageSizeChange)="onPageSizeChange($event)"
|
||||||
|
(sortDirectionChange)="onSortDirectionChange($event)"
|
||||||
|
(sortFieldChange)="onSortFieldChange($event)"
|
||||||
*ngIf="getViewMode()===viewModeEnum.Grid">
|
*ngIf="getViewMode()===viewModeEnum.Grid">
|
||||||
</ds-object-grid>
|
</ds-object-grid>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user