edit dashboard and text widgets

This commit is contained in:
2023-03-11 10:39:28 +01:00
parent cb5b160d3c
commit e3945a4d33
10 changed files with 99 additions and 23 deletions

View File

@@ -1,4 +1,7 @@
import { Component, Input } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { TextWidget } from 'src/app/dashboard.service';
import { AddTextDialogComponent } from '../add-text-dialog/add-text-dialog.component';
@Component({
selector: 'app-text-widget',
@@ -6,9 +9,22 @@ import { Component, Input } from '@angular/core';
})
export class TextWidgetComponent {
@Input()
text = "";
data! : TextWidget;
constructor(private dialog: MatDialog){}
lines(): string[]{
return typeof this.text == 'string' ? this.text.split(/\r?\n/) : [];
return typeof this.data.text == 'string' ? this.data.text.split(/\r?\n/) : [];
}
edit() {
this.dialog.open(AddTextDialogComponent,{
data: {text : this.data.text},
width: '600px'
}).afterClosed().subscribe((text?: string) => {
if (text !== undefined) {
this.data.text = text;
}
});
}
}