From 5ac6311e7693067fd84c617228e5193a38b173d1 Mon Sep 17 00:00:00 2001 From: Nikolaos Laskaris Date: Wed, 15 Nov 2017 12:59:08 +0200 Subject: [PATCH] cleaned a bit the code --- dmp-frontend/src/app/app.component.html | 27 +- dmp-frontend/src/app/dmps/dmp.component.css | 5 + dmp-frontend/src/app/dmps/dmp.component.ts | 40 +-- dmp-frontend/src/app/dmps/dmps.html | 38 +-- .../src/app/form/dynamic-form.component.html | 243 +++++++++--------- .../src/app/form/dynamic-form.component.ts | 4 +- dmp-frontend/src/app/services/rest-base.ts | 22 +- 7 files changed, 195 insertions(+), 184 deletions(-) diff --git a/dmp-frontend/src/app/app.component.html b/dmp-frontend/src/app/app.component.html index c765eeeb1..d9b7e651f 100644 --- a/dmp-frontend/src/app/app.component.html +++ b/dmp-frontend/src/app/app.component.html @@ -8,13 +8,26 @@ --> diff --git a/dmp-frontend/src/app/dmps/dmp.component.css b/dmp-frontend/src/app/dmps/dmp.component.css index 0bcb42a63..0e7b1daa7 100644 --- a/dmp-frontend/src/app/dmps/dmp.component.css +++ b/dmp-frontend/src/app/dmps/dmp.component.css @@ -56,4 +56,9 @@ tr.hover:hover > * { .table-button { font-size: 1em; padding: 2px; +} + + +.centered-text{ + text-align: center; } \ No newline at end of file diff --git a/dmp-frontend/src/app/dmps/dmp.component.ts b/dmp-frontend/src/app/dmps/dmp.component.ts index 2e53648f3..f7f8395a2 100644 --- a/dmp-frontend/src/app/dmps/dmp.component.ts +++ b/dmp-frontend/src/app/dmps/dmp.component.ts @@ -64,7 +64,7 @@ export class DmpComponent implements OnInit{ breadcrumbData: MenuItem[] = new Array(); - dmp : any; + dmp : any = null; @Input() projectsDropDown:DropdownField; @Input() statusDropDown: DropdownField; @@ -83,14 +83,22 @@ export class DmpComponent implements OnInit{ this.statusDropDown.options= [{key:'', value:null},{key:'0', value:"Active"},{key:'1', value:"Inactive"}, {key:'2', value:"Submitted"}, {key:'3', value:"Cancel"}] //this.projects = []; - this.dmp = { - id: null, - label: '', - previous:'', - version:'', - profileData:'' - //profile:{} - } + this.dmp = this.clearDmp(); + } + + + clearDmp() { + + this.dmp = { + id: null, + label: '', + previous:'', + version:'', + profileData:'', + //project: '', + //profile:{} + } + } ngOnInit() { @@ -151,11 +159,9 @@ export class DmpComponent implements OnInit{ } newDMP(){ - console.log(this.dmp, this.dmp.projectsDropDownKey); this.dmp.project = {"id" : this.dmp.project}; this.dmp["version"] = 1; - //this.dmp.profile = {}; this.serverService.createDmpForCurrentUser(this.dmp) .subscribe( @@ -241,13 +247,9 @@ export class DmpComponent implements OnInit{ $("#newVersionDmpModal").modal("show"); } - newDmp(item){ - this.dmp.label = ""; - this.dmp.id = null; - this.dmp.version = ""; - // this.dmp.profile = ""; - this.dmp.profileData = ""; - this.dmp.project = ""; + newDmpForm(item){ + + this.dmp = this.clearDmp(); $("#newDmpModal").modal("show"); } @@ -263,6 +265,8 @@ export class DmpComponent implements OnInit{ deleteRow(dmp){ + this.dmp = {"id": this.dmp.id}; //only id is needed to delete + this.serverService.deleteDmp(dmp).subscribe( response => { simple_notifier("success",null,"Successfully deleted the DMP"); diff --git a/dmp-frontend/src/app/dmps/dmps.html b/dmp-frontend/src/app/dmps/dmps.html index 00f8d484d..32869b670 100644 --- a/dmp-frontend/src/app/dmps/dmps.html +++ b/dmp-frontend/src/app/dmps/dmps.html @@ -66,10 +66,10 @@ {{dmp?.id}} {{dmp?.label}} - {{dmp?.version}} - {{dmp?.previous}} + {{dmp?.version}} + {{dmp?.previous}} {{dmp?.project?.label}} - {{dmp?.description}} + {{(dmp?.description?.length > 20) ? (dmp?.description | slice:0:20)+'...':(dmp?.description) }} {{dmp?.created | date:'yyyy-MM-dd HH:mm:ss Z'}} {{dmp?.status | statusToString }} @@ -92,7 +92,7 @@ - + @@ -104,8 +104,8 @@