Changing style for links added

This commit is contained in:
piotrpekala7 2021-06-16 19:19:39 +02:00
parent f7e07851f7
commit a2a3f542e6
3 changed files with 25 additions and 11 deletions

View File

@ -20,11 +20,9 @@
</mat-form-field>
<mat-form-field class="form-field">
<input
matInput
formControlName="type"
placeholder="Type"
type="text" />
<mat-select placeholder="Type" formControlName="type">
<mat-option *ngFor="let type of borderTypes" [value]="type"> {{ type }} </mat-option>
</mat-select>
</mat-form-field>
</form>
</div>

View File

@ -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();
});

View File

@ -69,6 +69,10 @@ export class LinkService {
return this.httpServer.put<Link>(server, `/projects/${link.project_id}/links/${link.link_id}`, link);
}
updateLinkStyle(server: Server, link: Link) {
return this.httpServer.put<Link>(server, `/projects/${link.project_id}/links/${link.link_id}`, link);
}
getAvailableFilters(server: Server, link: Link) {
return this.httpServer.get<FilterDescription[]>(
server,