Simplified some permissions
Renamed Accounts Audit to Audit Renamed Machines to Devices as it made sense Sections and Tables are now under Sections Permission Guest Book is now under Customers Permission Renamed Beer Consumption Report to Beer Sale Report Fix: Move Kot and Table to check what the final effect is
This commit is contained in:
@ -7,11 +7,9 @@ import { HomeComponent } from './home/home.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'beer-consumption-report',
|
||||
path: 'beer-sale-report',
|
||||
loadChildren: () =>
|
||||
import('./beer-consumption-report/beer-consumption-report.module').then(
|
||||
(mod) => mod.BeerConsumptionReportModule,
|
||||
),
|
||||
import('./beer-sale-report/beer-sale-report.module').then((mod) => mod.BeerSaleReportModule),
|
||||
},
|
||||
{
|
||||
path: 'bill-settlement-report',
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
|
||||
import { BeerConsumptionReportItem } from './beer-consumption-report-item';
|
||||
|
||||
export class BeerConsumptionReportDataSource extends DataSource<BeerConsumptionReportItem> {
|
||||
constructor(public data: BeerConsumptionReportItem[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<BeerConsumptionReportItem[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { BeerConsumptionReportResolver } from './beer-consumption-report-resolver.service';
|
||||
|
||||
describe('BeerConsumptionReportResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [BeerConsumptionReportResolver],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject(
|
||||
[BeerConsumptionReportResolver],
|
||||
(service: BeerConsumptionReportResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
},
|
||||
));
|
||||
});
|
||||
@ -1,13 +0,0 @@
|
||||
import { BeerConsumptionReportRoutingModule } from './beer-consumption-report-routing.module';
|
||||
|
||||
describe('BeerConsumptionReportRoutingModule', () => {
|
||||
let pbeerConsumptionReportRoutingModule: BeerConsumptionReportRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
pbeerConsumptionReportRoutingModule = new BeerConsumptionReportRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(pbeerConsumptionReportRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -1,30 +0,0 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { BeerConsumptionReportResolver } from './beer-consumption-report-resolver.service';
|
||||
import { BeerConsumptionReportComponent } from './beer-consumption-report.component';
|
||||
|
||||
const beerConsumptionReportRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: BeerConsumptionReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Beer Consumption Report',
|
||||
},
|
||||
resolve: {
|
||||
info: BeerConsumptionReportResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, RouterModule.forChild(beerConsumptionReportRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [BeerConsumptionReportResolver],
|
||||
})
|
||||
export class BeerConsumptionReportRoutingModule {}
|
||||
@ -1,24 +0,0 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { BeerConsumptionReportComponent } from './beer-consumption-report.component';
|
||||
|
||||
describe('BeerConsumptionReportComponent', () => {
|
||||
let component: BeerConsumptionReportComponent;
|
||||
let fixture: ComponentFixture<BeerConsumptionReportComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [BeerConsumptionReportComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(BeerConsumptionReportComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -1,13 +0,0 @@
|
||||
import { BeerConsumptionReportModule } from './beer-consumption-report.module';
|
||||
|
||||
describe('BeerConsumptionReportModule', () => {
|
||||
let pbeerConsumptionReportModule: BeerConsumptionReportModule;
|
||||
|
||||
beforeEach(() => {
|
||||
pbeerConsumptionReportModule = new BeerConsumptionReportModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(pbeerConsumptionReportModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -1,18 +0,0 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { BeerConsumptionReportService } from './beer-consumption-report.service';
|
||||
|
||||
describe('BeerConsumptionReportService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [BeerConsumptionReportService],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject(
|
||||
[BeerConsumptionReportService],
|
||||
(service: BeerConsumptionReportService) => {
|
||||
expect(service).toBeTruthy();
|
||||
},
|
||||
));
|
||||
});
|
||||
@ -1,8 +0,0 @@
|
||||
import { BeerConsumptionReportItem } from './beer-consumption-report-item';
|
||||
|
||||
export class BeerConsumptionReport {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
headers?: string[];
|
||||
data?: BeerConsumptionReportItem[];
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
|
||||
import { BeerSaleReportItem } from './beer-sale-report-item';
|
||||
|
||||
export class BeerSaleReportDataSource extends DataSource<BeerSaleReportItem> {
|
||||
constructor(public data: BeerSaleReportItem[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<BeerSaleReportItem[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
export class BeerConsumptionReportItem {
|
||||
export class BeerSaleReportItem {
|
||||
date: string;
|
||||
name: string;
|
||||
quantity: number;
|
||||
@ -0,0 +1,15 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { BeerSaleReportResolver } from './beer-sale-report-resolver.service';
|
||||
|
||||
describe('BeerSaleReportResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [BeerSaleReportResolver],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([BeerSaleReportResolver], (service: BeerSaleReportResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@ -2,16 +2,16 @@ import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { BeerConsumptionReport } from './beer-consumption-report';
|
||||
import { BeerConsumptionReportService } from './beer-consumption-report.service';
|
||||
import { BeerSaleReport } from './beer-sale-report';
|
||||
import { BeerSaleReportService } from './beer-sale-report.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class BeerConsumptionReportResolver implements Resolve<BeerConsumptionReport> {
|
||||
constructor(private ser: BeerConsumptionReportService) {}
|
||||
export class BeerSaleReportResolver implements Resolve<BeerSaleReport> {
|
||||
constructor(private ser: BeerSaleReportService) {}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<BeerConsumptionReport> {
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<BeerSaleReport> {
|
||||
const startDate = route.queryParamMap.get('startDate') || null;
|
||||
const finishDate = route.queryParamMap.get('finishDate') || null;
|
||||
return this.ser.get(startDate, finishDate);
|
||||
@ -0,0 +1,13 @@
|
||||
import { BeerSaleReportRoutingModule } from './beer-sale-report-routing.module';
|
||||
|
||||
describe('BeerSaleReportRoutingModule', () => {
|
||||
let beerSaleReportRoutingModule: BeerSaleReportRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
beerSaleReportRoutingModule = new BeerSaleReportRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(beerSaleReportRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,30 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { BeerSaleReportResolver } from './beer-sale-report-resolver.service';
|
||||
import { BeerSaleReportComponent } from './beer-sale-report.component';
|
||||
|
||||
const beerSaleReportRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: BeerSaleReportComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Beer Sale Report',
|
||||
},
|
||||
resolve: {
|
||||
info: BeerSaleReportResolver,
|
||||
},
|
||||
runGuardsAndResolvers: 'always',
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, RouterModule.forChild(beerSaleReportRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [BeerSaleReportResolver],
|
||||
})
|
||||
export class BeerSaleReportRoutingModule {}
|
||||
@ -1,6 +1,6 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Beer Consumption Report</mat-card-title>
|
||||
<mat-card-title>Beer Sale Report</mat-card-title>
|
||||
<button mat-button mat-icon-button (click)="exportCsv()">
|
||||
<mat-icon>save_alt</mat-icon>
|
||||
</button>
|
||||
@ -0,0 +1,24 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { BeerSaleReportComponent } from './beer-sale-report.component';
|
||||
|
||||
describe('BeerSaleReportComponent', () => {
|
||||
let component: BeerSaleReportComponent;
|
||||
let fixture: ComponentFixture<BeerSaleReportComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [BeerSaleReportComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(BeerSaleReportComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -5,18 +5,18 @@ import * as moment from 'moment';
|
||||
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { BeerConsumptionReport } from './beer-consumption-report';
|
||||
import { BeerConsumptionReportDataSource } from './beer-consumption-report-datasource';
|
||||
import { BeerSaleReport } from './beer-sale-report';
|
||||
import { BeerSaleReportDataSource } from './beer-sale-report-datasource';
|
||||
|
||||
@Component({
|
||||
selector: 'app-beer-consumption-report',
|
||||
templateUrl: './beer-consumption-report.component.html',
|
||||
styleUrls: ['./beer-consumption-report.component.css'],
|
||||
selector: 'app-beer-sale-report',
|
||||
templateUrl: './beer-sale-report.component.html',
|
||||
styleUrls: ['./beer-sale-report.component.css'],
|
||||
})
|
||||
export class BeerConsumptionReportComponent implements OnInit {
|
||||
dataSource: BeerConsumptionReportDataSource;
|
||||
export class BeerSaleReportComponent implements OnInit {
|
||||
dataSource: BeerSaleReportDataSource;
|
||||
form: FormGroup;
|
||||
info: BeerConsumptionReport;
|
||||
info: BeerSaleReport;
|
||||
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns: string[] = ['date'];
|
||||
@ -31,20 +31,20 @@ export class BeerConsumptionReportComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((data: { info: BeerConsumptionReport }) => {
|
||||
this.route.data.subscribe((data: { info: BeerSaleReport }) => {
|
||||
this.info = data.info;
|
||||
this.displayedColumns = ['date'].concat(this.info.headers);
|
||||
this.form.setValue({
|
||||
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
|
||||
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate(),
|
||||
});
|
||||
this.dataSource = new BeerConsumptionReportDataSource(this.info.data);
|
||||
this.dataSource = new BeerSaleReportDataSource(this.info.data);
|
||||
});
|
||||
}
|
||||
|
||||
show() {
|
||||
const info = this.getInfo();
|
||||
this.router.navigate(['beer-consumption-report'], {
|
||||
this.router.navigate(['beer-sale-report'], {
|
||||
queryParams: {
|
||||
startDate: info.startDate,
|
||||
finishDate: info.finishDate,
|
||||
@ -59,7 +59,7 @@ export class BeerConsumptionReportComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
getInfo(): BeerConsumptionReport {
|
||||
getInfo(): BeerSaleReport {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return {
|
||||
@ -83,7 +83,7 @@ export class BeerConsumptionReportComponent implements OnInit {
|
||||
});
|
||||
const link = document.createElement('a');
|
||||
link.href = window.URL.createObjectURL(csvData);
|
||||
link.setAttribute('download', 'beer-consumption-report.csv');
|
||||
link.setAttribute('download', 'beer-sale-report.csv');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
@ -0,0 +1,13 @@
|
||||
import { BeerSaleReportModule } from './beer-sale-report.module';
|
||||
|
||||
describe('BeerSaleReportModule', () => {
|
||||
let beerSaleReportModule: BeerSaleReportModule;
|
||||
|
||||
beforeEach(() => {
|
||||
beerSaleReportModule = new BeerSaleReportModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(beerSaleReportModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -22,8 +22,8 @@ import { MatTableModule } from '@angular/material/table';
|
||||
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
|
||||
import { BeerConsumptionReportRoutingModule } from './beer-consumption-report-routing.module';
|
||||
import { BeerConsumptionReportComponent } from './beer-consumption-report.component';
|
||||
import { BeerSaleReportRoutingModule } from './beer-sale-report-routing.module';
|
||||
import { BeerSaleReportComponent } from './beer-sale-report.component';
|
||||
|
||||
export const MY_FORMATS = {
|
||||
parse: {
|
||||
@ -54,12 +54,12 @@ export const MY_FORMATS = {
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
SharedModule,
|
||||
BeerConsumptionReportRoutingModule,
|
||||
BeerSaleReportRoutingModule,
|
||||
],
|
||||
declarations: [BeerConsumptionReportComponent],
|
||||
declarations: [BeerSaleReportComponent],
|
||||
providers: [
|
||||
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
|
||||
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
|
||||
],
|
||||
})
|
||||
export class BeerConsumptionReportModule {}
|
||||
export class BeerSaleReportModule {}
|
||||
@ -0,0 +1,15 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { BeerSaleReportService } from './beer-sale-report.service';
|
||||
|
||||
describe('BeerSaleReportService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [BeerSaleReportService],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([BeerSaleReportService], (service: BeerSaleReportService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@ -5,18 +5,18 @@ import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { BeerConsumptionReport } from './beer-consumption-report';
|
||||
import { BeerSaleReport } from './beer-sale-report';
|
||||
|
||||
const url = '/api/beer-consumption-report';
|
||||
const serviceName = 'BeerConsumptionReportService';
|
||||
const url = '/api/beer-sale-report';
|
||||
const serviceName = 'BeerSaleReportService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class BeerConsumptionReportService {
|
||||
export class BeerSaleReportService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
get(startDate: string, finishDate): Observable<BeerConsumptionReport> {
|
||||
get(startDate: string, finishDate): Observable<BeerSaleReport> {
|
||||
const options = { params: new HttpParams() };
|
||||
if (startDate !== null) {
|
||||
options.params = options.params.set('s', startDate);
|
||||
@ -24,9 +24,9 @@ export class BeerConsumptionReportService {
|
||||
if (finishDate !== null) {
|
||||
options.params = options.params.set('f', finishDate);
|
||||
}
|
||||
return <Observable<BeerConsumptionReport>>(
|
||||
return <Observable<BeerSaleReport>>(
|
||||
this.http
|
||||
.get<BeerConsumptionReport>(url, options)
|
||||
.get<BeerSaleReport>(url, options)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'get')))
|
||||
);
|
||||
}
|
||||
8
bookie/src/app/beer-sale-report/beer-sale-report.ts
Normal file
8
bookie/src/app/beer-sale-report/beer-sale-report.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { BeerSaleReportItem } from './beer-sale-report-item';
|
||||
|
||||
export class BeerSaleReport {
|
||||
startDate: string;
|
||||
finishDate: string;
|
||||
headers?: string[];
|
||||
data?: BeerSaleReportItem[];
|
||||
}
|
||||
@ -14,7 +14,7 @@ const routes: Routes = [
|
||||
component: GuestBookListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book',
|
||||
permission: 'Customers',
|
||||
},
|
||||
resolve: {
|
||||
list: GuestBookListResolver,
|
||||
@ -26,7 +26,7 @@ const routes: Routes = [
|
||||
component: GuestBookDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book',
|
||||
permission: 'Customers',
|
||||
},
|
||||
resolve: {
|
||||
item: GuestBookDetailResolver,
|
||||
@ -37,7 +37,7 @@ const routes: Routes = [
|
||||
component: GuestBookDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book',
|
||||
permission: 'Customers',
|
||||
},
|
||||
resolve: {
|
||||
item: GuestBookDetailResolver,
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
*ngIf="auth.user && auth.user.perms.indexOf('guest-book') !== -1"
|
||||
*ngIf="auth.user && auth.user.perms.indexOf('customers') !== -1"
|
||||
[routerLink]="['/', 'guest-book']"
|
||||
>
|
||||
<h3 class="item-name">Guest Book</h3>
|
||||
@ -66,10 +66,10 @@
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
*ngIf="auth.user && auth.user.perms.indexOf('beer-consumption-report') !== -1"
|
||||
[routerLink]="['/', 'beer-consumption-report']"
|
||||
*ngIf="auth.user && auth.user.perms.indexOf('beer-sale-report') !== -1"
|
||||
[routerLink]="['/', 'beer-sale-report']"
|
||||
>
|
||||
<h3 class="item-name">Beer Consumption Report</h3>
|
||||
<h3 class="item-name">Beer Sale Report</h3>
|
||||
</mat-card>
|
||||
<mat-card
|
||||
fxLayout="column"
|
||||
@ -84,7 +84,7 @@
|
||||
fxLayout="column"
|
||||
class="square-button"
|
||||
matRipple
|
||||
*ngIf="auth.user && auth.user.perms.indexOf('tables') !== -1"
|
||||
*ngIf="auth.user && auth.user.perms.indexOf('sections') !== -1"
|
||||
[routerLink]="['/', 'tables']"
|
||||
>
|
||||
<h3 class="item-name">Tables</h3>
|
||||
|
||||
@ -134,43 +134,45 @@ export class BillsComponent implements OnInit {
|
||||
this.bs.modifier(item);
|
||||
}
|
||||
|
||||
confirmMoveKotDialog(table: Table): Observable<{ table: Table; confirmed: boolean }> {
|
||||
confirmMoveKotDialog(table: Table): Observable<Table | Observable<never>> {
|
||||
return this.dialog
|
||||
.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: { title: 'Move KOT?', content: 'Are you sure?' },
|
||||
})
|
||||
.afterClosed()
|
||||
.pipe(map((x: boolean) => ({ table, confirmed: x })));
|
||||
.pipe(map((x: boolean) => (x ? table : throwError('Please confirm move'))));
|
||||
}
|
||||
|
||||
moveKot(kot: Kot) {
|
||||
const canMergeTables = this.auth.user.perms.indexOf('merge-tables') !== -1;
|
||||
this.dialog
|
||||
chooseTable(allowMerge: boolean): Observable<Table> {
|
||||
return this.dialog
|
||||
.open(TablesDialogComponent, {
|
||||
// width: '750px',
|
||||
data: {
|
||||
list: this.tSer.running(),
|
||||
canChooseRunning: canMergeTables,
|
||||
canChooseRunning: allowMerge,
|
||||
},
|
||||
})
|
||||
.afterClosed()
|
||||
.pipe(map((x) => x || throwError('Please choose a table')));
|
||||
}
|
||||
|
||||
moveKot(kot: Kot) {
|
||||
const canMergeTables = this.auth.user.perms.indexOf('merge-tables') !== -1;
|
||||
this.chooseTable(canMergeTables)
|
||||
.pipe(
|
||||
switchMap((x: boolean | Table) => {
|
||||
if (x) {
|
||||
return this.confirmMoveKotDialog(x as Table);
|
||||
switchMap((table: Table) => this.confirmMoveKotDialog(table)),
|
||||
switchMap((table: Table) => {
|
||||
if (this.bs.bill.kots.length === 1 && table.status) {
|
||||
return this.bs.mergeTable(table);
|
||||
}
|
||||
return throwError('Please choose a table');
|
||||
}),
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
switchMap((value: { table: Table; confirmed: boolean }, index: number) => {
|
||||
if (!value.confirmed) {
|
||||
return throwError('Please confirm move');
|
||||
if (this.bs.bill.kots.length === 1 && !table.status) {
|
||||
return this.bs.moveTable(table);
|
||||
}
|
||||
if (value.table.status) {
|
||||
return this.bs.mergeKot(kot.id, value.table);
|
||||
if (table.status) {
|
||||
return this.bs.mergeKot(kot.id, table);
|
||||
}
|
||||
return this.bs.moveKot(kot.id, value.table);
|
||||
return this.bs.moveKot(kot.id, table);
|
||||
}),
|
||||
)
|
||||
.subscribe(
|
||||
|
||||
@ -16,7 +16,7 @@ const tablesRoutes: Routes = [
|
||||
component: TableListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Tables',
|
||||
permission: 'Sections',
|
||||
},
|
||||
resolve: {
|
||||
list: TableListResolver,
|
||||
@ -27,7 +27,7 @@ const tablesRoutes: Routes = [
|
||||
component: TableDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Tables',
|
||||
permission: 'Sections',
|
||||
},
|
||||
resolve: {
|
||||
item: TableResolver,
|
||||
@ -39,7 +39,7 @@ const tablesRoutes: Routes = [
|
||||
component: TableDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Tables',
|
||||
permission: 'Sections',
|
||||
},
|
||||
resolve: {
|
||||
item: TableResolver,
|
||||
|
||||
Reference in New Issue
Block a user