delete text from dashboard

This commit is contained in:
2023-03-12 09:11:49 +01:00
parent 44aed2883d
commit 02c748c286
4 changed files with 28 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import { Component, Input } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ConfirmationDialogComponent } from 'src/app/confirmation-dialog/confirmation-dialog.component';
import { TextWidget } from 'src/app/dashboard.service';
import { AddTextDialogComponent } from '../add-text-dialog/add-text-dialog.component';
@@ -11,11 +12,26 @@ export class TextWidgetComponent {
@Input()
data! : TextWidget;
@Output()
deleted : EventEmitter<string> = new EventEmitter<string>();
constructor(private dialog: MatDialog){}
lines(): string[]{
return typeof this.data.text == 'string' ? this.data.text.split(/\r?\n/) : [];
}
delete() {
this.dialog
.open(ConfirmationDialogComponent, {
data: {title: "", text: "Delete text?", btnOkLabel: "Delete", btnCancelLabel: "Cancel"}
})
.afterClosed()
.subscribe((result: boolean) => {
if (result === true) {
this.deleted.emit(this.data.id);
}
});
}
edit() {
this.dialog.open(AddTextDialogComponent,{