Fixes bug on public dmp / datasets listing

This commit is contained in:
apapachristou 2020-07-08 18:28:34 +03:00
parent 3d51b6bd3c
commit ff532c56fb
2 changed files with 19 additions and 10 deletions

View File

@ -137,6 +137,7 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
fields.push('-modified'); fields.push('-modified');
//if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; } //if (this.sort && this.sort.active) { fields = this.sort.direction === 'asc' ? ['+' + this.sort.active] : ['-' + this.sort.active]; }
const request = new DataTableRequest<DatasetCriteria>(this.startIndex, this.pageSize, { fields: fields }); const request = new DataTableRequest<DatasetCriteria>(this.startIndex, this.pageSize, { fields: fields });
this.criteria.isPublic = this.isPublic;
request.criteria = this.criteria; request.criteria = this.criteria;
this.datasetService.getPaged(request).pipe(takeUntil(this._destroyed)).subscribe(result => { this.datasetService.getPaged(request).pipe(takeUntil(this._destroyed)).subscribe(result => {
@ -151,6 +152,7 @@ export class DatasetListingComponent extends BaseComponent implements OnInit, IB
this.startIndex = this.startIndex + this.pageSize; this.startIndex = this.startIndex + this.pageSize;
const fields: Array<string> = ["-modified"]; const fields: Array<string> = ["-modified"];
const request = new DataTableRequest<DatasetCriteria>(this.startIndex, this.pageSize, { fields: fields }); const request = new DataTableRequest<DatasetCriteria>(this.startIndex, this.pageSize, { fields: fields });
this.criteria.isPublic = this.isPublic;
request.criteria = this.criteria; request.criteria = this.criteria;
this.datasetService.getPaged(request).pipe(takeUntil(this._destroyed)).subscribe(result => { this.datasetService.getPaged(request).pipe(takeUntil(this._destroyed)).subscribe(result => {

View File

@ -174,6 +174,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
fields.push('-modified'); fields.push('-modified');
const request = new DataTableRequest<DmpCriteria>(this.startIndex, this.pageSize, { fields: fields }); const request = new DataTableRequest<DmpCriteria>(this.startIndex, this.pageSize, { fields: fields });
this.setPublicCriteria();
request.criteria = this.criteria; request.criteria = this.criteria;
this.dmpService.getPaged(request, "listing").pipe(takeUntil(this._destroyed)).subscribe(result => { this.dmpService.getPaged(request, "listing").pipe(takeUntil(this._destroyed)).subscribe(result => {
@ -195,6 +196,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
this.startIndex = this.startIndex + this.pageSize; this.startIndex = this.startIndex + this.pageSize;
const fields: Array<string> = ["-modified"]; const fields: Array<string> = ["-modified"];
const request = new DataTableRequest<DmpCriteria>(this.startIndex, this.pageSize, { fields: fields }); const request = new DataTableRequest<DmpCriteria>(this.startIndex, this.pageSize, { fields: fields });
this.setPublicCriteria();
request.criteria = this.criteria; request.criteria = this.criteria;
this.dmpService.getPaged(request, "listing").pipe(takeUntil(this._destroyed)).subscribe(result => { this.dmpService.getPaged(request, "listing").pipe(takeUntil(this._destroyed)).subscribe(result => {
@ -321,15 +323,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
role: formGroup.get('role').value role: formGroup.get('role').value
} }
this.criteria.status = formGroup.get('status').value; this.criteria.status = formGroup.get('status').value;
if (formGroup.get('status').value == 2) { this.setPublicCriteria(formGroup);
this.criteria.isPublic = true;
} else {
this.criteria.isPublic = false;
}
this.criteria.onlyPublic = this.isPublic;
if (this.isPublic) {
this.criteria.isPublic = true;
}
if (formGroup.get('datasetTemplates').value) if (formGroup.get('datasetTemplates').value)
this.criteria.datasetTemplates = formGroup.get('datasetTemplates').value.map(x => x.id); this.criteria.datasetTemplates = formGroup.get('datasetTemplates').value.map(x => x.id);
if (formGroup.get('collaborators').value) if (formGroup.get('collaborators').value)
@ -343,8 +337,21 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
this.criteria.grantStatus = formGroup.get('grantStatus').value; this.criteria.grantStatus = formGroup.get('grantStatus').value;
} }
setPublicCriteria(formGroup?: FormGroup): void {
if (formGroup && formGroup.get('status').value == 2) {
this.criteria.isPublic = true;
}
this.criteria.onlyPublic = this.isPublic;
if (this.isPublic) {
this.criteria.isPublic = true;
} else {
this.criteria.isPublic = false;
}
}
hasScrollbar(): boolean { hasScrollbar(): boolean {
return document.getElementById("main-page").scrollHeight > document.documentElement.clientHeight return document.getElementById("main-page").scrollHeight > document.documentElement.clientHeight
} }
} }