[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,12 +33,24 @@ export class TelegramSettingsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
onDelete(telegramId) {
|
onDelete(telegramId) {
|
||||||
|
const dialogRef = this.dialog.open(YesNoDialogComponent, {
|
||||||
|
data: {
|
||||||
|
title: 'Warning',
|
||||||
|
content:
|
||||||
|
'This will also delete the list of subscribers of the telegram bot.',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogRef.afterClosed().subscribe((response) => {
|
||||||
|
if (response) {
|
||||||
this.telegramService
|
this.telegramService
|
||||||
.deleteTelegram(telegramId, this.hoodId)
|
.deleteTelegram(telegramId, this.hoodId)
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.reload();
|
this.reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onCreate() {
|
onCreate() {
|
||||||
const dialogRef = this.dialog.open(TelegramDialogComponent, {
|
const dialogRef = this.dialog.open(TelegramDialogComponent, {
|
||||||
|
|
|
@ -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