Chore: Moved edit and delete in guestbook to the details from list.
This will give more space. Also removed the old table button
This commit is contained in:
@ -1,13 +1,11 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as moment from 'moment';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { GuestBook } from '../guest-book';
|
||||
import { GuestBookList } from '../guest-book-list';
|
||||
import { GuestBookService } from '../guest-book.service';
|
||||
@ -32,7 +30,6 @@ export class GuestBookListComponent implements OnInit {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private toaster: ToasterService,
|
||||
private ser: GuestBookService,
|
||||
) {
|
||||
@ -59,29 +56,4 @@ export class GuestBookListComponent implements OnInit {
|
||||
});
|
||||
this.dataSource = new GuestBookListDataSource(this.data);
|
||||
}
|
||||
|
||||
delete(id: string) {
|
||||
this.ser.delete(id).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/guest-book');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Error', error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
confirmDelete(id: string): void {
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: { title: 'Delete Guest Book Entry?', content: 'Are you sure? This cannot be undone.' },
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result: boolean) => {
|
||||
if (result) {
|
||||
this.delete(id);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user