#8148 - [Bug fix] drafts.component.ts & recent-edited-activity.component.ts & recent-edited-dataset-activity.component.ts & recent-edited-dmp-activity.component.ts: Updated check to redirect to first page, if page parameter is bigger than the latest page.

This commit is contained in:
Konstantina Galouni 2023-05-15 00:43:45 +03:00
parent 0d9b6f9622
commit b435994c51
4 changed files with 30 additions and 11 deletions

View File

@ -122,7 +122,7 @@ export class DraftsComponent extends BaseComponent implements OnInit {
this.datasetDrafts = response.data;
this.totalCount = response.totalCount;
this.totalCountDraftDatasets.emit(this.datasetDrafts.length);
if(this.totalCount > 0 && this.totalCount < this.page*this.pageSize && this.page > 1) {
if(this.totalCount > 0 && this.totalCount <= (this.page-1)*this.pageSize && this.page > 1) {
let queryParams = { type: "drafts", page: 1, order: this.formGroup.get("order").value };
if(this.formGroup.get("like").value) {
queryParams['keyword'] = this.formGroup.get("like").value;

View File

@ -123,6 +123,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
let keyword = (params['keyword'] === undefined || params['keyword'].length <= 0) ? "" : params['keyword'];
this.formGroup.get("like").setValue(keyword);
console.log("init");
this.updateUrl();
}
});
@ -151,20 +152,27 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
}
});
this.totalCountRecentEdited.emit(this.allRecentActivities.length);
if(this.allRecentActivities.length > 0 && this.allRecentActivities.length < this.page*this.pageSize && this.page > 1) {
if(this.allRecentActivities.length == 0 && this.page > 1) {
let queryParams = { type: "recent", page: 1, order: this.formGroup.get("order").value };
if(this.formGroup.get("like").value) {
queryParams['keyword'] = this.formGroup.get("like").value;
}
console.log(queryParams);
this.router.navigate(["/home"], { queryParams: queryParams })
}
});
this.formGroup.get('like').valueChanges
.pipe(takeUntil(this._destroyed), debounceTime(500))
.subscribe(x => this.refresh());
.subscribe(x => {
console.log("like changed");
this.refresh()
});
this.formGroup.get('order').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => this.refresh());
.subscribe(x => {
console.log("order changed");
this.refresh()
});
} else {
this.publicMode = true;
if(!this.formGroup.get('order').value) {
@ -186,25 +194,33 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
}
});
this.totalCountRecentEdited.emit(this.allRecentActivities.length);
if(this.allRecentActivities.length > 0 && this.allRecentActivities.length < this.page*this.pageSize && this.page > 1) {
if(this.allRecentActivities.length == 0 && this.page > 1) {
let queryParams = { type: "recent", page: 1, order: this.formGroup.get("order").value };
if(this.formGroup.get("like").value) {
queryParams['keyword'] = this.formGroup.get("like").value;
}
console.log(queryParams);
this.router.navigate(["/home"], { queryParams: queryParams })
}
});
this.formGroup.get('like').valueChanges
.pipe(takeUntil(this._destroyed), debounceTime(500))
.subscribe(x => this.refresh());
.subscribe(x => {
console.log("like changed 1");
this.refresh()
});
this.formGroup.get('order').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => this.refresh());
.subscribe(x => {
console.log("order changed 1");
this.refresh()
});
}
}
ngOnChanges() {
if(this.isActive) {
console.log("active");
this.updateUrl();
}
}
@ -217,6 +233,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
if(parameters) {
parameters = "?type=recent" + parameters;
}
console.log(parameters);
this.location.go(this.router.url.split('?')[0]+parameters);
}
@ -693,6 +710,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
this.datasetOffset = 0;
this.dmpOffset = 0;
this.page = 1;
console.log("refresh");
this.updateUrl();
const fields: Array<string> = [((this.formGroup.get('order').value === 'status') || (this.formGroup.get('order').value === 'label') ? '+' : "-") + this.formGroup.get('order').value];
@ -745,6 +763,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn
// return [];
} else {
this.page = this.page + (more ? 1 : -1);
console.log("loadNextOrPrevious");
this.updateUrl();
// if(more) {
// result.forEach(recentActivity => {

View File

@ -122,7 +122,7 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen
this.datasetActivities = response.data;
this.totalCount = response.totalCount;
this.totalCountDatasets.emit(this.datasetActivities.length)
if(this.totalCount > 0 && this.totalCount < this.page*this.pageSize && this.page > 1) {
if(this.totalCount > 0 && this.totalCount <= (this.page-1)*this.pageSize && this.page > 1) {
let queryParams = { type: "datasets", page: 1, order: this.formGroup.get("order").value };
if(this.formGroup.get("like").value) {
queryParams['keyword'] = this.formGroup.get("like").value;
@ -146,7 +146,7 @@ export class RecentEditedDatasetActivityComponent extends BaseComponent implemen
this.datasetActivities = response.data;
this.totalCount = response.totalCount;
this.totalCountDatasets.emit(this.datasetActivities.length);
if(this.totalCount > 0 && this.totalCount < this.page*this.pageSize && this.page > 1) {
if(this.totalCount > 0 && this.totalCount <= (this.page-1)*this.pageSize && this.page > 1) {
let queryParams = { type: "datasets", page: 1, order: this.formGroup.get("order").value };
if(this.formGroup.get("like").value) {
queryParams['keyword'] = this.formGroup.get("like").value;

View File

@ -133,7 +133,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
this.dmpActivities = response.data;
this.totalCount = response.totalCount;
this.totalCountDmps.emit(this.dmpActivities.length);
if(this.totalCount > 0 && this.totalCount < this.page*this.pageSize && this.page > 1) {
if(this.totalCount > 0 && this.totalCount <= (this.page-1)*this.pageSize && this.page > 1) {
let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value };
if(this.formGroup.get("like").value) {
queryParams['keyword'] = this.formGroup.get("like").value;
@ -182,7 +182,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O
this.dmpActivities = response.data;
this.totalCount = response.totalCount;
this.totalCountDmps.emit(this.dmpActivities.length);
if(this.totalCount > 0 && this.totalCount < this.page*this.pageSize && this.page > 1) {
if(this.totalCount > 0 && this.totalCount <= (this.page-1)*this.pageSize && this.page > 1) {
let queryParams = { type: "dmps", page: 1, order: this.formGroup.get("order").value };
if(this.formGroup.get("like").value) {
queryParams['keyword'] = this.formGroup.get("like").value;