From d51f024a16513e65552d7a58e5f19805a741b9f7 Mon Sep 17 00:00:00 2001 From: Piotr Pekala Date: Mon, 28 Oct 2019 03:39:36 -0700 Subject: [PATCH] Support for global variables added --- .../edit-project-dialog.component.html | 27 +++++++++++- .../edit-project-dialog.component.scss | 12 ++++++ .../edit-project-dialog.component.ts | 41 ++++++++++++++----- 3 files changed, 68 insertions(+), 12 deletions(-) diff --git a/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.html b/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.html index 52550f0c..94d562cf 100644 --- a/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.html +++ b/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.html @@ -42,16 +42,39 @@ -
+ - +
+ + + + + + + + + + + + + + + + + + +
Name{{element.name}} Value{{element.value}}Actions + +
diff --git a/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.scss b/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.scss index 9c2173c2..00dc4971 100644 --- a/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.scss +++ b/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.scss @@ -1,3 +1,15 @@ .form-field { width: 100%; } + +th { + border: 0px!important; +} + +th.mat-header-cell { + padding-bottom: 15px; +} + +td.mat-cell { + padding-top: 15px; +} diff --git a/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.ts b/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.ts index acc8ed3f..2493bf0c 100644 --- a/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.ts +++ b/src/app/components/projects/edit-project-dialog/edit-project-dialog.component.ts @@ -19,6 +19,9 @@ export class EditProjectDialogComponent implements OnInit { variableFormGroup: FormGroup; projectVariables: ProjectVariable[]; + displayedColumns: string[] = ['name', 'value', 'actions']; + variables: ProjectVariable[] = []; + constructor( public dialogRef: MatDialogRef, private formBuilder: FormBuilder, @@ -46,6 +49,23 @@ export class EditProjectDialogComponent implements OnInit { this.formGroup.controls['height'].setValue(this.project.scene_height); this.formGroup.controls['nodeGridSize'].setValue(this.project.grid_size); this.formGroup.controls['drawingGridSize'].setValue(this.project.drawing_grid_size); + this.project.variables.forEach(n => this.variables.push(n)); + } + + addVariable() { + if (this.variableFormGroup.valid) { + let variable: ProjectVariable = { + name: this.variableFormGroup.get('name').value, + value: this.variableFormGroup.get('value').value + }; + this.variables = this.variables.concat([variable]); + } else { + this.toasterService.error(`Fill all required fields with correct values.`); + } + } + + deleteVariable(variable: ProjectVariable) { + this.variables = this.variables.filter(elem => elem!== variable); } onNoClick() { @@ -54,18 +74,19 @@ export class EditProjectDialogComponent implements OnInit { onYesClick() { if (this.formGroup.valid) { - this.project.name = this.formGroup.get('projectName').value; - this.project.scene_width = this.formGroup.get('width').value; - this.project.scene_height = this.formGroup.get('height').value; - this.project.drawing_grid_size = this.formGroup.get('drawingGridSize').value; - this.project.grid_size = this.formGroup.get('nodeGridSize').value; + this.project.name = this.formGroup.get('projectName').value; + this.project.scene_width = this.formGroup.get('width').value; + this.project.scene_height = this.formGroup.get('height').value; + this.project.drawing_grid_size = this.formGroup.get('drawingGridSize').value; + this.project.grid_size = this.formGroup.get('nodeGridSize').value; + this.project.variables = this.variables; - this.projectService.update(this.server, this.project).subscribe((project: Project) => { - this.toasterService.success(`Project ${project.name} updated.`); - this.onNoClick(); - }) + this.projectService.update(this.server, this.project).subscribe((project: Project) => { + this.toasterService.success(`Project ${project.name} updated.`); + this.onNoClick(); + }) } else { - this.toasterService.error(`Fill all required fields with correct values.`); + this.toasterService.error(`Fill all required fields with correct values.`); } } }