[frontend] Add warning dialog to telegram delete
This commit is contained in:
parent
d8ae3ff693
commit
c8d439f019
|
@ -4,6 +4,7 @@ import { Observer, Observable } from 'rxjs';
|
||||||
import { TelegramInfoDialogComponent } from '../telegram-info-dialog/telegram-info-dialog.component';
|
import { TelegramInfoDialogComponent } from '../telegram-info-dialog/telegram-info-dialog.component';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { TelegramDialogComponent } from '../telegram-dialog/telegram-dialog.component';
|
import { TelegramDialogComponent } from '../telegram-dialog/telegram-dialog.component';
|
||||||
|
import { YesNoDialogComponent } from 'src/app/shared/yes-no-dialog/yes-no-dialog.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-telegram-settings',
|
selector: 'app-telegram-settings',
|
||||||
|
@ -32,11 +33,23 @@ export class TelegramSettingsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
onDelete(telegramId) {
|
onDelete(telegramId) {
|
||||||
this.telegramService
|
const dialogRef = this.dialog.open(YesNoDialogComponent, {
|
||||||
.deleteTelegram(telegramId, this.hoodId)
|
data: {
|
||||||
.subscribe(() => {
|
title: 'Warning',
|
||||||
this.reload();
|
content:
|
||||||
});
|
'This will also delete the list of subscribers of the telegram bot.',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogRef.afterClosed().subscribe((response) => {
|
||||||
|
if (response) {
|
||||||
|
this.telegramService
|
||||||
|
.deleteTelegram(telegramId, this.hoodId)
|
||||||
|
.subscribe(() => {
|
||||||
|
this.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onCreate() {
|
onCreate() {
|
||||||
|
|
|
@ -6,9 +6,10 @@ import { ReactiveFormsModule, FormsModule } from '@angular/forms';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Ng2SearchPipeModule } from 'ng2-search-filter';
|
import { Ng2SearchPipeModule } from 'ng2-search-filter';
|
||||||
|
import { YesNoDialogComponent } from './yes-no-dialog/yes-no-dialog.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [ToolbarComponent, NotFoundComponent],
|
declarations: [ToolbarComponent, NotFoundComponent, YesNoDialogComponent],
|
||||||
imports: [
|
imports: [
|
||||||
MaterialModule,
|
MaterialModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<h2 mat-dialog-title>{{ data.title }}</h2>
|
||||||
|
<mat-dialog-content>{{ data.content }}</mat-dialog-content>
|
||||||
|
<mat-dialog-actions align="end">
|
||||||
|
<button mat-button mat-dialog-close>Back</button>
|
||||||
|
<button mat-button [mat-dialog-close]="true" cdkFocusInitial>
|
||||||
|
I understand, delete
|
||||||
|
</button>
|
||||||
|
</mat-dialog-actions>
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { YesNoDialogComponent } from './yes-no-dialog.component';
|
||||||
|
|
||||||
|
describe('YesNoDialogComponent', () => {
|
||||||
|
let component: YesNoDialogComponent;
|
||||||
|
let fixture: ComponentFixture<YesNoDialogComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [YesNoDialogComponent],
|
||||||
|
}).compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(YesNoDialogComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { Component, OnInit, Inject } from '@angular/core';
|
||||||
|
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-yes-no-dialog',
|
||||||
|
templateUrl: './yes-no-dialog.component.html',
|
||||||
|
styleUrls: ['./yes-no-dialog.component.scss'],
|
||||||
|
})
|
||||||
|
export class YesNoDialogComponent implements OnInit {
|
||||||
|
constructor(@Inject(MAT_DIALOG_DATA) public data) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {}
|
||||||
|
}
|
Loading…
Reference in a new issue