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:
@ -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(
|
||||
|
||||
Reference in New Issue
Block a user