No automatic signout
Voucher basic working running tables shifted to cards from buttons, this gives us immense styling oportunities
This commit is contained in:
@ -1,19 +1,21 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {TableService} from '../../tables/table.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { VoucherService } from "./voucher.service";
|
||||
import { Bill } from "./bill";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class BillResolver implements Resolve<any[]> {
|
||||
export class BillResolver implements Resolve<Bill> {
|
||||
|
||||
constructor(private ser: TableService, private router: Router) {
|
||||
constructor(private ser: VoucherService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any[]> {
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Bill> {
|
||||
const tableId = route.queryParamMap.get('table');
|
||||
const guestId = route.queryParamMap.get('guest');
|
||||
return this.ser.list();
|
||||
const voucherId = route.queryParamMap.get('voucher');
|
||||
return this.ser.getFromTable(tableId, voucherId, guestId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ export class Inventory {
|
||||
taxRate: number;
|
||||
tax: Tax;
|
||||
discount: number;
|
||||
modifiers: Modifier;
|
||||
modifiers: Modifier[];
|
||||
}
|
||||
|
||||
export class Kot {
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
.kot {
|
||||
background-color: red;
|
||||
font-weight: bold;
|
||||
background-color: hotpink;
|
||||
}
|
||||
.printed {
|
||||
background-color: lightpink;
|
||||
}
|
||||
.new-kot {
|
||||
background-color: lightblue;
|
||||
}
|
||||
|
||||
.square-button {
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||
<!-- Info Column -->
|
||||
<ng-container matColumnDef="info">
|
||||
<mat-cell *matCellDef="let row" fxLayout="column" fxLayoutAlign="space-around start" [class.kot]="row.isKot">
|
||||
<mat-cell *matCellDef="let row" fxLayout="column" fxLayoutAlign="start space-between end">
|
||||
<span>
|
||||
{{row.info}}
|
||||
</span>
|
||||
@ -19,26 +19,27 @@
|
||||
<ng-container matColumnDef="quantity">
|
||||
<mat-header-cell *matHeaderCellDef>Quantity</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">
|
||||
<button mat-icon-button (click)="subtractOne(row)">
|
||||
<button mat-icon-button (click)="subtractOne(row)" [disabled]="row.isPrinted" *ngIf="!row.isKot">
|
||||
<mat-icon class="del">indeterminate_check_box</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button (click)="quantity(row)">
|
||||
<button mat-icon-button (click)="quantity(row)" [disabled]="row.isPrinted" *ngIf="!row.isKot">
|
||||
{{row.quantity}}
|
||||
</button>
|
||||
<button mat-icon-button (click)="addOne(row)">
|
||||
<button mat-icon-button (click)="addOne(row)" [disabled]="row.isPrinted" *ngIf="!row.isKot">
|
||||
<mat-icon class="del">control_point</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button (click)="removeItem(row)">
|
||||
<button mat-icon-button (click)="removeItem(row)" [disabled]="row.isPrinted" *ngIf="!row.isKot">
|
||||
<mat-icon class="del">cancel</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button (click)="modifier(row)">
|
||||
<button mat-icon-button (click)="modifier(row)" [disabled]="row.isPrinted" *ngIf="!row.isKot">
|
||||
<mat-icon class="del">assignment</mat-icon>
|
||||
</button>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;" [class.kot]="row.isKot" [class.new-kot]="row.newKot"
|
||||
[class.printed]="row.isPrinted"></mat-row>
|
||||
</mat-table>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import {Bill, Inventory, Kot} from './bill';
|
||||
import {ModifierCategoryListDatasource} from '../../modifier-categories/modifier-category-list/modifier-category-list-datasource';
|
||||
import {BillsDataSource} from './bills-datasource';
|
||||
import {BillService} from "../bill.service";
|
||||
|
||||
@ -13,7 +12,6 @@ import {BillService} from "../bill.service";
|
||||
export class BillsComponent implements OnInit {
|
||||
dataSource: BillsDataSource;
|
||||
item: Bill;
|
||||
view: any[];
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns: string[] = ['info', 'quantity'];
|
||||
|
||||
@ -24,18 +22,35 @@ export class BillsComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
console.log("ds set")
|
||||
this.dataSource = new BillsDataSource(this.bs.dataObs);
|
||||
this.route.data
|
||||
.subscribe((data: { item: Bill }) => {
|
||||
this.updateView(data.item);
|
||||
});
|
||||
this.dataSource = new BillsDataSource(this.bs.dataObs);
|
||||
}
|
||||
|
||||
updateView(item) {
|
||||
this.item = item;
|
||||
// this.view = item.kots.reduce((p: Kot, c:Kot) => {
|
||||
//
|
||||
// }, [])
|
||||
let view = item.kots.map(k => {
|
||||
return [{
|
||||
isKot: true,
|
||||
}, ...k.inventories.map(i => {
|
||||
return {
|
||||
id: i.id,
|
||||
isKot: false,
|
||||
product: i.product,
|
||||
productId: i.product.id,
|
||||
isHappyHour: i.isHappyHour,
|
||||
isPrinted: true,
|
||||
info: `${i.product.name} (${i.product.units}) @ ${i.price}`,
|
||||
quantity: 1,
|
||||
modifiers: i.modifiers
|
||||
}
|
||||
})]
|
||||
});
|
||||
view = view.reduce((a, c) => {return a.concat(c)} , []);
|
||||
this.bs.loadData(view);
|
||||
}
|
||||
|
||||
addOne(item: any): void {
|
||||
|
||||
70
bookie/src/app/sales/bills/voucher.service.ts
Normal file
70
bookie/src/app/sales/bills/voucher.service.ts
Normal file
@ -0,0 +1,70 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { ErrorLoggerService } from '../../core/error-logger.service';
|
||||
import {Bill} from "./bill";
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
|
||||
const url = '/v1/vouchers';
|
||||
const serviceName = 'VoucherService';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class VoucherService {
|
||||
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
|
||||
get(id: string): Observable<Bill> {
|
||||
return <Observable<Bill>>this.http.get<Bill>(`${url}/${id}`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`))
|
||||
);
|
||||
}
|
||||
|
||||
getFromTable(tableId: string, voucherId: string, guestId: string): Observable<Bill> {
|
||||
let params = new HttpParams();
|
||||
if (tableId !== null) {
|
||||
params = params.set('t', tableId);
|
||||
}
|
||||
if (voucherId !== null) {
|
||||
params = params.set('v', voucherId);
|
||||
}
|
||||
if (guestId !== null) {
|
||||
params = params.set('g', guestId);
|
||||
}
|
||||
|
||||
return <Observable<Bill>>this.http.get<Bill>(`${url}/new`, {params: params})
|
||||
.pipe(
|
||||
catchError(this.log.handleError(
|
||||
serviceName,
|
||||
`getFromTable tableId=${tableId} voucherId=${voucherId} guestId=${guestId}`
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
save(voucher: Bill): Observable<Bill> {
|
||||
return <Observable<Bill>>this.http.post<Bill>(`${url}/new`, voucher, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
}
|
||||
|
||||
update(voucher: Bill): Observable<Bill> {
|
||||
return <Observable<Bill>>this.http.put<Bill>(`${url}/${voucher.id}`, voucher, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'update'))
|
||||
);
|
||||
}
|
||||
|
||||
saveOrUpdate(voucher: Bill): Observable<Bill> {
|
||||
if (!voucher.id) {
|
||||
return this.save(voucher);
|
||||
} else {
|
||||
return this.update(voucher);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user