Feature: Table Booking in guestbook.
Feature: Guest book list shows the running cover count
This commit is contained in:
@ -13,6 +13,7 @@ export class GuestBookDetailResolver {
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<GuestBook> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.ser.get(id);
|
||||
const account = route.queryParamMap.get('t') || 'walk_in';
|
||||
return this.ser.get(id, account);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,10 +41,22 @@
|
||||
</div>
|
||||
<div class="flex flex-row justify-around content-start items-start">
|
||||
<mat-form-field class="flex-auto">
|
||||
<mat-label>Notes</mat-label>
|
||||
<textarea matInput formControlName="notes"></textarea>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="flex flex-row justify-around content-start items-start">
|
||||
<mat-form-field class="flex-auto basis-1/2 mr-5">
|
||||
<mat-label>Date</mat-label>
|
||||
<input matInput [matDatepicker]="date" (focus)="date.open()" formControlName="date" autocomplete="off" />
|
||||
<mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle>
|
||||
<mat-datepicker #date></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field class="flex-auto basis-1/4 mr-5">
|
||||
<mat-label>Hours</mat-label>
|
||||
<input matInput formControlName="hours" />
|
||||
</mat-form-field>
|
||||
<mat-form-field class="flex-auto">
|
||||
<mat-form-field class="flex-auto basis-1/4">
|
||||
<mat-label>Minutes</mat-label>
|
||||
<input matInput formControlName="minutes" />
|
||||
</mat-form-field>
|
||||
|
||||
@ -3,6 +3,7 @@ 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 * as moment from 'moment';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
import { debounceTime, distinctUntilChanged, map, startWith, switchMap } from 'rxjs/operators';
|
||||
|
||||
@ -25,6 +26,8 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
phone: FormControl<string | Customer>;
|
||||
pax: FormControl<number>;
|
||||
address: FormControl<string | null>;
|
||||
notes: FormControl<string | null>;
|
||||
date: FormControl<Date>;
|
||||
hours: FormControl<number>;
|
||||
minutes: FormControl<number>;
|
||||
}>;
|
||||
@ -49,6 +52,8 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
}),
|
||||
pax: new FormControl(0, { validators: Validators.required, nonNullable: true }),
|
||||
address: new FormControl<string | null>(null),
|
||||
notes: new FormControl<string | null>(null),
|
||||
date: new FormControl({ value: new Date(), disabled: false }, { nonNullable: true }),
|
||||
hours: new FormControl(0, { validators: [Validators.min(0), Validators.max(23)], nonNullable: true }),
|
||||
minutes: new FormControl(0, { validators: [Validators.min(0), Validators.max(59)], nonNullable: true }),
|
||||
});
|
||||
@ -79,13 +84,22 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
showItem(item: GuestBook) {
|
||||
this.item = item;
|
||||
const dt = (this.item.arrivalDate || this.item.bookingDate) as string;
|
||||
if (item.type === 'booking') {
|
||||
this.form.controls.date.enable();
|
||||
} else {
|
||||
this.form.controls.date.disable();
|
||||
}
|
||||
|
||||
this.form.setValue({
|
||||
name: item.name,
|
||||
phone: item.phone,
|
||||
pax: item.pax,
|
||||
address: item.address,
|
||||
hours: +item.date.substring(12, 14),
|
||||
minutes: +item.date.substring(15, 17),
|
||||
notes: item.notes,
|
||||
date: new Date(dt),
|
||||
hours: +dt.substring(12, 14),
|
||||
minutes: +dt.substring(15, 17),
|
||||
});
|
||||
}
|
||||
|
||||
@ -149,9 +163,16 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
this.item.pax = formModel.pax ?? 0;
|
||||
this.item.address = formModel.address ?? null;
|
||||
this.item.notes = formModel.notes ?? null;
|
||||
const hours = ('' + (formModel.hours as number)).padStart(2, '0');
|
||||
const minutes = ('' + (formModel.minutes as number)).padStart(2, '0');
|
||||
this.item.date = this.item.date.substring(0, 12) + hours + ':' + minutes;
|
||||
if (this.item.type === 'booking') {
|
||||
console.log(formModel.date);
|
||||
this.item.bookingDate = moment(formModel.date).format('DD-MMM-YYYY') + ' ' + hours + ':' + minutes;
|
||||
} else {
|
||||
this.item.arrivalDate = (this.item.arrivalDate as string).substring(0, 12) + hours + ':' + minutes;
|
||||
}
|
||||
|
||||
return this.item;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,13 @@
|
||||
<mat-card-header>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Guest List</mat-card-title>
|
||||
<a mat-button [routerLink]="['/guest-book', 'new']">
|
||||
<a mat-button [routerLink]="['/guest-book', 'new']" [queryParams]="{ t: 'booking' }">
|
||||
<mat-icon>add_box</mat-icon>
|
||||
Add
|
||||
Table Booking
|
||||
</a>
|
||||
<a mat-button [routerLink]="['/guest-book', 'new']" [queryParams]="{ t: 'walk_in' }">
|
||||
<mat-icon>add_box</mat-icon>
|
||||
Walk-in
|
||||
</a>
|
||||
</mat-card-title-group>
|
||||
</mat-card-header>
|
||||
@ -22,8 +26,8 @@
|
||||
<mat-table [dataSource]="dataSource" aria-label="Elements">
|
||||
<!-- SNo Column -->
|
||||
<ng-container matColumnDef="sno">
|
||||
<mat-header-cell *matHeaderCellDef>S. No</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.serial }}</mat-cell>
|
||||
<mat-header-cell *matHeaderCellDef>S. No / Total</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.serial }} / {{ row.count }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Name Column -->
|
||||
@ -49,7 +53,9 @@
|
||||
<!-- Time Column -->
|
||||
<ng-container matColumnDef="date">
|
||||
<mat-header-cell *matHeaderCellDef>Time</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.date | localTime }}</mat-cell>
|
||||
<mat-cell *matCellDef="let row"
|
||||
>{{ row.bookingDate | localTime }} // {{ row.arrivalDate | localTime }}</mat-cell
|
||||
>
|
||||
</ng-container>
|
||||
|
||||
<!-- Action Column -->
|
||||
@ -88,6 +94,7 @@
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row
|
||||
*matRowDef="let row; columns: displayedColumns"
|
||||
[class.grey300]="row.status === 'booking'"
|
||||
[class.accent]="row.status === 'running'"
|
||||
[class.strong-accent]="row.status === 'printed'"
|
||||
></mat-row>
|
||||
|
||||
@ -19,3 +19,7 @@ table
|
||||
/* Read the 700 hue from the primary color palete.*/
|
||||
color: mat.get-color-from-palette($my-accent, '700-contrast')
|
||||
background: mat.get-color-from-palette($my-accent, 700)
|
||||
|
||||
.grey300
|
||||
background-color: #ede7f6
|
||||
color: #000000
|
||||
|
||||
@ -22,10 +22,11 @@ export class GuestBookService {
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
|
||||
get(id: string | null): Observable<GuestBook> {
|
||||
get(id: string | null, type: string): Observable<GuestBook> {
|
||||
const options = { params: new HttpParams().set('t', type) };
|
||||
const getUrl: string = id === null ? url : `${url}/${id}`;
|
||||
return this.http
|
||||
.get<GuestBook>(getUrl)
|
||||
.get<GuestBook>(getUrl, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<GuestBook>;
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
export class GuestBook {
|
||||
id: string | undefined;
|
||||
serial: number;
|
||||
count: number;
|
||||
name: string;
|
||||
phone: string;
|
||||
pax: number;
|
||||
address: string | null;
|
||||
date: string;
|
||||
notes: string | null;
|
||||
bookingDate: string | null;
|
||||
arrivalDate: string | null;
|
||||
type: string | undefined;
|
||||
lastEditDate: string | undefined;
|
||||
status?: string;
|
||||
tableId?: string;
|
||||
voucherId?: string;
|
||||
@ -14,11 +19,15 @@ export class GuestBook {
|
||||
public constructor(init?: Partial<GuestBook>) {
|
||||
this.id = undefined;
|
||||
this.serial = 0;
|
||||
this.count = 0;
|
||||
this.name = '';
|
||||
this.phone = '';
|
||||
this.pax = 0;
|
||||
this.address = null;
|
||||
this.date = '';
|
||||
this.notes = null;
|
||||
this.bookingDate = null;
|
||||
this.arrivalDate = null;
|
||||
this.lastEditDate = '';
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import * as moment from 'moment';
|
||||
})
|
||||
export class LocalTimePipe implements PipeTransform {
|
||||
transform(value: string): string {
|
||||
if (value === undefined) {
|
||||
if (value === undefined || value === null) {
|
||||
return '';
|
||||
}
|
||||
if (value.length === 5) {
|
||||
|
||||
Reference in New Issue
Block a user