diff --git a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts index 50c1b6abd..2f1013bf2 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts +++ b/dmp-frontend/src/app/ui/dataset/listing/criteria/dataset-criteria.component.ts @@ -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) diff --git a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts index e4afaf0c2..556b7c70a 100644 --- a/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts +++ b/dmp-frontend/src/app/ui/dataset/listing/dataset-listing.component.ts @@ -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 = new Array(); if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; } diff --git a/dmp-frontend/src/app/ui/dmp/listing/criteria/dmp-criteria.component.ts b/dmp-frontend/src/app/ui/dmp/listing/criteria/dmp-criteria.component.ts index 6a934ded3..ee56c2fc5 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/criteria/dmp-criteria.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/criteria/dmp-criteria.component.ts @@ -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)); } } diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts index fb1cce8f5..e08a3f97a 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts @@ -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 = new Array(); if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; } diff --git a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.ts b/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.ts index ed24ef189..f35879b75 100644 --- a/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.ts +++ b/dmp-frontend/src/app/ui/explore-dataset/explore-dataset-listing.component.ts @@ -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(); } diff --git a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.ts b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.ts index f6801edc3..9ce83cb22 100644 --- a/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.ts +++ b/dmp-frontend/src/app/ui/explore-dmp/explore-dmp-listing.component.ts @@ -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(); } diff --git a/dmp-frontend/src/app/ui/project/listing/criteria/project-criteria.component.ts b/dmp-frontend/src/app/ui/project/listing/criteria/project-criteria.component.ts index ca20e14fd..55b1019ab 100644 --- a/dmp-frontend/src/app/ui/project/listing/criteria/project-criteria.component.ts +++ b/dmp-frontend/src/app/ui/project/listing/criteria/project-criteria.component.ts @@ -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)); } -} \ No newline at end of file +} diff --git a/dmp-frontend/src/app/ui/project/listing/project-listing.component.html b/dmp-frontend/src/app/ui/project/listing/project-listing.component.html index cf58362fd..b1cd9f5b1 100644 --- a/dmp-frontend/src/app/ui/project/listing/project-listing.component.html +++ b/dmp-frontend/src/app/ui/project/listing/project-listing.component.html @@ -21,7 +21,7 @@
- + diff --git a/dmp-frontend/src/app/ui/project/listing/project-listing.component.ts b/dmp-frontend/src/app/ui/project/listing/project-listing.component.ts index 17c9b14cb..a33d34f54 100644 --- a/dmp-frontend/src/app/ui/project/listing/project-listing.component.ts +++ b/dmp-frontend/src/app/ui/project/listing/project-listing.component.ts @@ -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 = 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(); + } }