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:
parent
e8a33cd80e
commit
1cb2677ad1
|
@ -52,6 +52,7 @@
|
||||||
</form>
|
</form>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
<mat-card-actions>
|
<mat-card-actions>
|
||||||
<button mat-raised-button color="primary" (click)="save()">Save</button>
|
<button mat-raised-button color="primary" class="mr-5" (click)="save()">Save</button>
|
||||||
|
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">Delete</button>
|
||||||
</mat-card-actions>
|
</mat-card-actions>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
|
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 { Customer } from '../../core/customer';
|
||||||
import { ToasterService } from '../../core/toaster.service';
|
import { ToasterService } from '../../core/toaster.service';
|
||||||
import { CustomerService } from '../../customers/customer.service';
|
import { CustomerService } from '../../customers/customer.service';
|
||||||
|
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||||
import { GuestBook } from '../guest-book';
|
import { GuestBook } from '../guest-book';
|
||||||
import { GuestBookService } from '../guest-book.service';
|
import { GuestBookService } from '../guest-book.service';
|
||||||
|
|
||||||
|
@ -33,6 +35,7 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
private dialog: MatDialog,
|
||||||
private toaster: ToasterService,
|
private toaster: ToasterService,
|
||||||
private ser: GuestBookService,
|
private ser: GuestBookService,
|
||||||
private customerService: CustomerService,
|
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 {
|
getItem(): GuestBook {
|
||||||
const formModel = this.form.value;
|
const formModel = this.form.value;
|
||||||
this.item.name = formModel.name ?? '';
|
this.item.name = formModel.name ?? '';
|
||||||
|
|
|
@ -29,7 +29,9 @@
|
||||||
<!-- Name Column -->
|
<!-- Name Column -->
|
||||||
<ng-container matColumnDef="name">
|
<ng-container matColumnDef="name">
|
||||||
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
|
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
|
||||||
<mat-cell *matCellDef="let row">{{ row.name }}</mat-cell>
|
<mat-cell *matCellDef="let row"
|
||||||
|
><a [routerLink]="['/guest-book/', row.id]">{{ row.name }}</a></mat-cell
|
||||||
|
>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
<!-- Phone Column -->
|
<!-- Phone Column -->
|
||||||
|
@ -71,7 +73,7 @@
|
||||||
>
|
>
|
||||||
{{ row.tableName }}
|
{{ row.tableName }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<!-- <button
|
||||||
mat-stroked-button
|
mat-stroked-button
|
||||||
color="primary"
|
color="primary"
|
||||||
[routerLink]="['/sales', 'bill']"
|
[routerLink]="['/sales', 'bill']"
|
||||||
|
@ -79,13 +81,7 @@
|
||||||
*ngIf="!row.tableId && row.voucherId"
|
*ngIf="!row.tableId && row.voucherId"
|
||||||
>
|
>
|
||||||
{{ row.tableName }}
|
{{ row.tableName }}
|
||||||
</button>
|
</button> -->
|
||||||
<button mat-icon-button [routerLink]="['/guest-book/', row.id]">
|
|
||||||
<mat-icon>edit</mat-icon>
|
|
||||||
</button>
|
|
||||||
<button mat-icon-button color="warn" (click)="confirmDelete(row.id)">
|
|
||||||
<mat-icon>delete</mat-icon>
|
|
||||||
</button>
|
|
||||||
</mat-cell>
|
</mat-cell>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FormControl, FormGroup } from '@angular/forms';
|
import { FormControl, FormGroup } from '@angular/forms';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
import { ToasterService } from '../../core/toaster.service';
|
import { ToasterService } from '../../core/toaster.service';
|
||||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
|
||||||
import { GuestBook } from '../guest-book';
|
import { GuestBook } from '../guest-book';
|
||||||
import { GuestBookList } from '../guest-book-list';
|
import { GuestBookList } from '../guest-book-list';
|
||||||
import { GuestBookService } from '../guest-book.service';
|
import { GuestBookService } from '../guest-book.service';
|
||||||
|
@ -32,7 +30,6 @@ export class GuestBookListComponent implements OnInit {
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private dialog: MatDialog,
|
|
||||||
private toaster: ToasterService,
|
private toaster: ToasterService,
|
||||||
private ser: GuestBookService,
|
private ser: GuestBookService,
|
||||||
) {
|
) {
|
||||||
|
@ -59,29 +56,4 @@ export class GuestBookListComponent implements OnInit {
|
||||||
});
|
});
|
||||||
this.dataSource = new GuestBookListDataSource(this.data);
|
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue