From a2a3f542e60b8ebd755e20e2785afb603df9f763 Mon Sep 17 00:00:00 2001 From: piotrpekala7 <31202938+piotrpekala7@users.noreply.github.com> Date: Wed, 16 Jun 2021 19:19:39 +0200 Subject: [PATCH] Changing style for links added --- .../link-style-editor.component.html | 8 +++---- .../link-style-editor.component.ts | 24 ++++++++++++++----- src/app/services/link.service.ts | 4 ++++ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/app/components/project-map/drawings-editors/link-style-editor/link-style-editor.component.html b/src/app/components/project-map/drawings-editors/link-style-editor/link-style-editor.component.html index aa761fbb..8c947b08 100644 --- a/src/app/components/project-map/drawings-editors/link-style-editor/link-style-editor.component.html +++ b/src/app/components/project-map/drawings-editors/link-style-editor/link-style-editor.component.html @@ -20,11 +20,9 @@ - + + {{ type }} + diff --git a/src/app/components/project-map/drawings-editors/link-style-editor/link-style-editor.component.ts b/src/app/components/project-map/drawings-editors/link-style-editor/link-style-editor.component.ts index 51fd2bac..25134039 100644 --- a/src/app/components/project-map/drawings-editors/link-style-editor/link-style-editor.component.ts +++ b/src/app/components/project-map/drawings-editors/link-style-editor/link-style-editor.component.ts @@ -28,16 +28,26 @@ export class LinkStyleEditorDialogComponent implements OnInit { private nonNegativeValidator: NonNegativeValidator ) { this.formGroup = this.formBuilder.group({ - color: new FormControl('', [Validators.required, nonNegativeValidator.get]), + color: new FormControl('', [Validators.required]), width: new FormControl('', [Validators.required, nonNegativeValidator.get]), - type: new FormControl('', [Validators.required, nonNegativeValidator.get]) + type: new FormControl('', [Validators.required]) }); } ngOnInit() { - this.formGroup.controls['color'].setValue(this.link.link_style.color); + if (!this.link.link_style?.color) { + this.formGroup.controls['color'].setValue("#000000"); + } else { + this.formGroup.controls['color'].setValue(this.link.link_style.color); + } + this.formGroup.controls['width'].setValue(this.link.link_style.width); - this.formGroup.controls['type'].setValue(this.link.link_style.width); + + let type = this.borderTypes[0]; + if (this.link.link_style?.type) { + type = this.borderTypes[this.link.link_style.type]; + } + this.formGroup.controls['type'].setValue(type); } onNoClick() { @@ -48,9 +58,11 @@ export class LinkStyleEditorDialogComponent implements OnInit { if (this.formGroup.valid) { this.link.link_style.color = this.formGroup.get('color').value; this.link.link_style.width = this.formGroup.get('width').value; - this.link.link_style.type = this.formGroup.get('type').value; - this.linkService.updateLink(this.server, this.link).subscribe(() => { + let type = this.borderTypes.indexOf(this.formGroup.get('type').value); + this.link.link_style.type = type; + + this.linkService.updateLinkStyle(this.server, this.link).subscribe((link) => { this.toasterService.success("Link updated"); this.dialogRef.close(); }); diff --git a/src/app/services/link.service.ts b/src/app/services/link.service.ts index 27b8f88a..2599acb7 100644 --- a/src/app/services/link.service.ts +++ b/src/app/services/link.service.ts @@ -69,6 +69,10 @@ export class LinkService { return this.httpServer.put(server, `/projects/${link.project_id}/links/${link.link_id}`, link); } + updateLinkStyle(server: Server, link: Link) { + return this.httpServer.put(server, `/projects/${link.project_id}/links/${link.link_id}`, link); + } + getAvailableFilters(server: Server, link: Link) { return this.httpServer.get( server,