Fixes bug on paginator control on all listing views. (Ticket #84)
This commit is contained in:
parent
4b47ce75e1
commit
682bebfc60
|
@ -158,7 +158,7 @@ export class DatasetCriteriaComponent extends BaseCriteriaComponent implements O
|
|||
if (this.refreshCallback != null &&
|
||||
(this.formGroup.get('like').value == null || this.formGroup.get('like').value.length === 0 || this.formGroup.get('like').value.length > 2)
|
||||
) {
|
||||
setTimeout(() => this.refreshCallback());
|
||||
setTimeout(() => this.refreshCallback(true));
|
||||
}
|
||||
// if (this.refreshCallback != null &&
|
||||
// (this.criteria.like == null || this.criteria.like.length === 0 || this.criteria.like.length > 2)
|
||||
|
|
|
@ -55,6 +55,7 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
|
|||
const dmp = await this.dmpService.getSingle(this.dmpId).toPromise();
|
||||
this.criteria.setCriteria(this.getDefaultCriteria(dmp));
|
||||
this.refresh();
|
||||
this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages));
|
||||
this.breadCrumbs = Observable.of([{ parentComponentName: 'DmpEditorComponent', label: dmp.label, url: 'plans/edit/' + this.dmpId }]);
|
||||
if (params['dmpLabel'] !== undefined) {
|
||||
this.titlePrefix = 'for ' + params['dmpLabel'];
|
||||
|
@ -62,18 +63,21 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
|
|||
} else {
|
||||
this.criteria.setCriteria(this.getDefaultCriteria());
|
||||
this.refresh();
|
||||
this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages));
|
||||
this.breadCrumbs = Observable.of([]);
|
||||
}
|
||||
|
||||
if (this.status != null && this.status == 0) {
|
||||
this.criteria.setCriteria(this.getDraftCriteria());
|
||||
this.refresh();
|
||||
this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
refresh() {
|
||||
refresh(resetPages = false) {
|
||||
if (this._paginator.pageSize === undefined) this._paginator.pageSize = 10;
|
||||
if (resetPages) this._paginator.pageIndex = 0;
|
||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||
let fields: Array<string> = new Array();
|
||||
if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; }
|
||||
|
|
|
@ -114,7 +114,7 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
|
|||
if (this.refreshCallback != null &&
|
||||
(this.formGroup.get('like').value == null || this.formGroup.get('like').value.length === 0 || this.formGroup.get('like').value.length > 2)
|
||||
) {
|
||||
setTimeout(() => this.refreshCallback());
|
||||
setTimeout(() => this.refreshCallback(true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
|
|||
this.refresh();
|
||||
projectLabel = this.route.snapshot.queryParams.projectLabel;
|
||||
this.breadCrumbs = Observable.of([{ parentComponentName: 'ProjectEditorComponent', label: projectLabel, url: '/projects/edit/' + this.projectId }]);
|
||||
this.criteria.setRefreshCallback(() => this.refresh());
|
||||
this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages));
|
||||
} else {
|
||||
this.itemId = params['groupId'];
|
||||
this.showProject = true;
|
||||
|
@ -76,7 +76,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
|
|||
|
||||
this.criteria.setCriteria(this.getDefaultCriteria());
|
||||
this.refresh();
|
||||
this.criteria.setRefreshCallback(() => this.refresh());
|
||||
this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages));
|
||||
}
|
||||
|
||||
if (this.projectId != null) {
|
||||
|
@ -87,8 +87,9 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
|
|||
});
|
||||
}
|
||||
|
||||
refresh() {
|
||||
refresh(resetPages = false) {
|
||||
if (this._paginator.pageSize === undefined) this._paginator.pageSize = 10;
|
||||
if (resetPages) this._paginator.pageIndex = 0;
|
||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||
let fields: Array<string> = new Array();
|
||||
if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; }
|
||||
|
|
|
@ -61,8 +61,8 @@ export class ExploreDatasetListingComponent extends BaseComponent implements OnI
|
|||
}
|
||||
|
||||
onCriteriaChange(event: ExploreDatasetCriteriaModel) {
|
||||
console.log(event)
|
||||
this.exploreDatasetCriteriaModel = event;
|
||||
this._paginator.pageIndex = 0;
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ export class ExploreDmpListingComponent extends BaseComponent implements OnInit,
|
|||
onCriteriaChange(event: ExploreDmpCriteriaModel) {
|
||||
//console.log(event)
|
||||
this.exploreDmpCriteriaModel = event;
|
||||
this._paginator.pageIndex = 0;
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ export class ProjectCriteriaComponent extends BaseCriteriaComponent implements O
|
|||
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
if (this.criteria == null) {
|
||||
this.criteria = new ProjectCriteria();
|
||||
if (this.criteria == null) {
|
||||
this.criteria = new ProjectCriteria();
|
||||
this.criteria.projectStateType = ProjectStateType.OnGoing;
|
||||
}
|
||||
}
|
||||
|
@ -47,13 +47,13 @@ export class ProjectCriteriaComponent extends BaseCriteriaComponent implements O
|
|||
if (this.refreshCallback != null &&
|
||||
(this.criteria.like == null || this.criteria.like.length === 0 || this.criteria.like.length > 2)
|
||||
) {
|
||||
this.refreshCallback();
|
||||
setTimeout(() => this.refreshCallback(true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
||||
const isSubmitted = form && form.submitted;
|
||||
const isDateInvalid = this.criteria.periodStart != null && this.criteria.periodEnd != null && this.criteria.periodStart > this.criteria.periodEnd
|
||||
return !!(control && isDateInvalid && (control.dirty || control.touched || isSubmitted));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<div class="row" *ngFor="let item of listingItems; let i = index">
|
||||
<app-project-listing-item-component class="col-12" [showDivider]="i !== (listingItems.length - 1)" [project]="item" (onClick)="rowClicked($event)"></app-project-listing-item-component>
|
||||
</div>
|
||||
<mat-paginator #paginator [length]="totalCount" [pageSizeOptions]="[10, 25, 100]" class="mt-2"></mat-paginator>
|
||||
<mat-paginator #paginator [length]="totalCount" [pageSizeOptions]="[10, 25, 100]" (page)="pageThisEvent($event)" class="mt-2"></mat-paginator>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -42,10 +42,12 @@ export class ProjectListingComponent extends BaseComponent implements OnInit, IB
|
|||
|
||||
this.criteria.setCriteria(this.getDefaultCriteria());
|
||||
this.refresh();
|
||||
this.criteria.setRefreshCallback(() => this.refresh());
|
||||
this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages));
|
||||
}
|
||||
|
||||
refresh() {
|
||||
refresh(resetPages = false) {
|
||||
if (this._paginator.pageSize === undefined) this._paginator.pageSize = 10;
|
||||
if (resetPages) this._paginator.pageIndex = 0;
|
||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||
let fields: Array<string> = new Array();
|
||||
if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; }
|
||||
|
@ -66,6 +68,10 @@ export class ProjectListingComponent extends BaseComponent implements OnInit, IB
|
|||
const defaultCriteria = new ProjectCriteria();
|
||||
return defaultCriteria;
|
||||
}
|
||||
|
||||
pageThisEvent(event) {
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue