Chore: Changed the Section Printer from Menu Categories to Sale Categories. This is more logical, in the older software, there as no concept of sale categories so menu categories was used.
This should make the whole thing much easier to update and read.
This commit is contained in:
@ -1,13 +1,13 @@
|
||||
import { MenuCategory } from './menu-category';
|
||||
import { Printer } from './printer';
|
||||
import { SaleCategory } from './sale-category';
|
||||
|
||||
export class SectionPrinter {
|
||||
menuCategory: MenuCategory | null;
|
||||
saleCategory: SaleCategory | null;
|
||||
printer: Printer | null;
|
||||
copies: number;
|
||||
|
||||
public constructor(init?: Partial<SectionPrinter>) {
|
||||
this.menuCategory = null;
|
||||
this.saleCategory = null;
|
||||
this.printer = null;
|
||||
this.copies = 0;
|
||||
Object.assign(this, init);
|
||||
|
||||
@ -26,11 +26,11 @@
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<mat-divider></mat-divider>
|
||||
<mat-table #table [dataSource]="dataSource" formArrayName="menuCategories">
|
||||
<!-- Menu Category Column -->
|
||||
<ng-container matColumnDef="menuCategory">
|
||||
<mat-header-cell *matHeaderCellDef>Menu Category</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.menuCategory?.name || 'Default' }}</mat-cell>
|
||||
<mat-table #table [dataSource]="dataSource" formArrayName="saleCategories">
|
||||
<!-- Sale Category Column -->
|
||||
<ng-container matColumnDef="saleCategory">
|
||||
<mat-header-cell *matHeaderCellDef>Sale Category</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.saleCategory?.name || 'Default' }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Printer Column -->
|
||||
@ -53,7 +53,7 @@
|
||||
<ng-container matColumnDef="copies">
|
||||
<mat-header-cell *matHeaderCellDef>Copies</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row; let i = index" [formGroupName]="i" fxFlex>
|
||||
<mat-form-field *ngIf="!!$any(form.get('menuCategories')).at(i).value.printer">
|
||||
<mat-form-field *ngIf="!!$any(form.get('saleCategories')).at(i).value.printer">
|
||||
<mat-label>Copies</mat-label>
|
||||
<input matInput type="number" placeholder="Copies" formControlName="copies" />
|
||||
</mat-form-field>
|
||||
|
||||
@ -29,7 +29,7 @@ export class SectionPrinterComponent implements OnInit {
|
||||
sections: Section[] = [];
|
||||
printers: Printer[] = [];
|
||||
sectionId = '';
|
||||
displayedColumns = ['menuCategory', 'printer', 'copies'];
|
||||
displayedColumns = ['saleCategory', 'printer', 'copies'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
@ -42,7 +42,7 @@ export class SectionPrinterComponent implements OnInit {
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
section: '',
|
||||
menuCategories: this.fb.array([]),
|
||||
saleCategories: this.fb.array([]),
|
||||
});
|
||||
route.params.pipe(map((p) => p.id)).subscribe((x) => {
|
||||
this.sectionId = x;
|
||||
@ -64,11 +64,11 @@ export class SectionPrinterComponent implements OnInit {
|
||||
this.list = list;
|
||||
(this.form.get('section') as AbstractControl).setValue(this.sectionId);
|
||||
this.form.setControl(
|
||||
'menuCategories',
|
||||
'saleCategories',
|
||||
this.fb.array(
|
||||
this.list.map((x) =>
|
||||
this.fb.group({
|
||||
menuCategory: x.menuCategory?.name || 'Default',
|
||||
saleCategory: x.saleCategory?.name || 'Default',
|
||||
printer: x.printer?.id,
|
||||
copies: `${x.copies}`,
|
||||
}),
|
||||
@ -119,7 +119,7 @@ export class SectionPrinterComponent implements OnInit {
|
||||
getItem(): SectionPrinter[] {
|
||||
const formModel = this.form.value;
|
||||
this.sectionId = formModel.section;
|
||||
const array = this.form.get('menuCategories') as FormArray;
|
||||
const array = this.form.get('saleCategories') as FormArray;
|
||||
this.list.forEach((item, index) => {
|
||||
const cont = array.controls[index].value;
|
||||
if (cont.printer === null || cont.printer === undefined) {
|
||||
|
||||
@ -27,14 +27,6 @@ export class SectionPrinterService {
|
||||
>;
|
||||
}
|
||||
|
||||
// item(id: string, menuCategoryId: string): Observable<SectionPrinterItem> {
|
||||
// const options = {params: new HttpParams().set('m', menuCategoryId)};
|
||||
// return this.http.get<SectionPrinterItem>(`${url}/${id}`, options)
|
||||
// .pipe(
|
||||
// catchError(this.log.handleError(serviceName, 'list'))
|
||||
// ) as Observable<SectionPrinterItem>;
|
||||
// }
|
||||
|
||||
save(sectionId: string, list: SectionPrinter[]): Observable<SectionPrinter[]> {
|
||||
return this.http
|
||||
.post<SectionPrinter[]>(`${url}/${sectionId}`, list, httpOptions)
|
||||
|
||||
Reference in New Issue
Block a user