diff --git a/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.html b/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.html
index bf64cac..96effa4 100644
--- a/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.html
+++ b/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.html
@@ -52,6 +52,7 @@
-
+
+
diff --git a/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.ts b/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.ts
index e21698d..d7ac127 100644
--- a/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.ts
+++ b/bookie/src/app/guest-book/guest-book-detail/guest-book-detail.component.ts
@@ -1,6 +1,7 @@
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
+import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable, of as observableOf } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
@@ -8,6 +9,7 @@ import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'r
import { Customer } from '../../core/customer';
import { ToasterService } from '../../core/toaster.service';
import { CustomerService } from '../../customers/customer.service';
+import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
import { GuestBook } from '../guest-book';
import { GuestBookService } from '../guest-book.service';
@@ -33,6 +35,7 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
constructor(
private route: ActivatedRoute,
private router: Router,
+ private dialog: MatDialog,
private toaster: ToasterService,
private ser: GuestBookService,
private customerService: CustomerService,
@@ -111,6 +114,31 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
});
}
+ confirmDelete(): 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(this.item.id ?? '');
+ }
+ });
+ }
+
+ delete(id: string) {
+ this.ser.delete(id).subscribe({
+ complete: () => {
+ this.toaster.show('Success', '');
+ this.router.navigateByUrl('/guest-book');
+ },
+ error: (error) => {
+ this.toaster.show('Error', error);
+ },
+ });
+ }
+
getItem(): GuestBook {
const formModel = this.form.value;
this.item.name = formModel.name ?? '';
diff --git a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.html b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.html
index d4189fe..dad4b5e 100644
--- a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.html
+++ b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.html
@@ -29,7 +29,9 @@
Name
- {{ row.name }}
+ {{ row.name }}
@@ -71,7 +73,7 @@
>
{{ row.tableName }}
-
-
-
+ -->
diff --git a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.ts b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.ts
index 52473a3..0732a5e 100644
--- a/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.ts
+++ b/bookie/src/app/guest-book/guest-book-list/guest-book-list.component.ts
@@ -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);
- }
- });
- }
}