diff --git a/dmp-frontend/src/app/dmps/dmp.component.ts b/dmp-frontend/src/app/dmps/dmp.component.ts index 370954597..b19f776a1 100644 --- a/dmp-frontend/src/app/dmps/dmp.component.ts +++ b/dmp-frontend/src/app/dmps/dmp.component.ts @@ -112,6 +112,12 @@ export class DmpComponent implements OnInit{ this.tableData = response; if(muted && muted!=true) simple_notifier("success",null,"Refreshed DMPs"); + + this.tableData.forEach( dmp => { + if(dmp.previous!=null) + this.serverService.getDmp(dmp.previous).subscribe( previous => {dmp.previous = previous;}); + }); + }, (err: HttpErrorResponse) => { simple_notifier("danger",null,"Could not refresh DMPs"); @@ -141,6 +147,8 @@ export class DmpComponent implements OnInit{ this.dmp.project = {"id":this.dmp.project}; this.dmp.creator = {"id": this.dmp.creator}; + if(this.dmp.previous!=null) + this.dmp.previous = this.dmp.previous.id; this.serverService.updateDmp(this.dmp) .subscribe( @@ -185,7 +193,7 @@ export class DmpComponent implements OnInit{ $("#newDmpModal").modal("show"); } - editDmpVersion(item){ + cloneDmp(item){ this.dmp = Object.assign({}, item); this.dmp.project = item.project.id; $("#newVersionDmpModal").modal("show"); @@ -210,8 +218,9 @@ export class DmpComponent implements OnInit{ deleteRow(dmp){ this.dmp = {"id": this.dmp.id}; //only id is needed to delete + - this.serverService.deleteDmp(dmp).subscribe( + this.serverService.deleteDmp(this.dmp).subscribe( response => { simple_notifier("success",null,"Successfully deleted the DMP"); this.getDmps(); @@ -264,13 +273,11 @@ export class DmpComponent implements OnInit{ } viewDetailedDMP(dmp){ - console.log(dmp) let random = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5); this.router.navigate(['/dmps/dmp'], { queryParams: { "dmpid":dmp.id, "label":dmp.label, random: random}}); } viewDetailedProject(dmp){ - console.log(dmp) let random = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5); this.router.navigate(['/dmps/project'], { queryParams: { "projectid":dmp.project.id, "label":dmp.project.label, random: random }}); } diff --git a/dmp-frontend/src/app/dmps/dmps.html b/dmp-frontend/src/app/dmps/dmps.html index d2d9dffef..2c334aa15 100644 --- a/dmp-frontend/src/app/dmps/dmps.html +++ b/dmp-frontend/src/app/dmps/dmps.html @@ -76,7 +76,7 @@