edit dashboard and text widgets
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user