Blacked and isorted the python files
Prettied and eslinted the typescript/html files
This commit is contained in:
1 parent
b31db593c2
commit
d677cfb1ea
505 files changed
+7559
-5649
No files matched your search
@@ -1,61 +1,53 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { ModifierCategoryListResolver } from './modifier-category-list-resolver.service';
|
||||
import { ModifierCategoryResolver } from './modifier-category-resolver.service';
|
||||
import { ModifierCategoryListComponent } from './modifier-category-list/modifier-category-list.component';
|
||||
import { ModifierCategoryDetailComponent } from './modifier-category-detail/modifier-category-detail.component';
|
||||
|
||||
import { AuthGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { ModifierCategoryDetailComponent } from './modifier-category-detail/modifier-category-detail.component';
|
||||
import { ModifierCategoryListResolver } from './modifier-category-list-resolver.service';
|
||||
import { ModifierCategoryListComponent } from './modifier-category-list/modifier-category-list.component';
|
||||
import { ModifierCategoryResolver } from './modifier-category-resolver.service';
|
||||
|
||||
const modifierCategoriesRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: ModifierCategoryListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Modifiers'
|
||||
permission: 'Modifiers',
|
||||
},
|
||||
resolve: {
|
||||
list: ModifierCategoryListResolver
|
||||
}
|
||||
list: ModifierCategoryListResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
component: ModifierCategoryDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Modifiers'
|
||||
permission: 'Modifiers',
|
||||
},
|
||||
resolve: {
|
||||
item: ModifierCategoryResolver,
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: ModifierCategoryDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Modifiers'
|
||||
permission: 'Modifiers',
|
||||
},
|
||||
resolve: {
|
||||
item: ModifierCategoryResolver
|
||||
}
|
||||
}
|
||||
item: ModifierCategoryResolver,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(modifierCategoriesRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
ModifierCategoryListResolver,
|
||||
ModifierCategoryResolver
|
||||
]
|
||||
imports: [CommonModule, RouterModule.forChild(modifierCategoriesRoutes)],
|
||||
exports: [RouterModule],
|
||||
providers: [ModifierCategoryListResolver, ModifierCategoryResolver],
|
||||
})
|
||||
export class ModifierCategoriesRoutingModule {
|
||||
}
|
||||
export class ModifierCategoriesRoutingModule {}
|
||||
@@ -1,10 +1,9 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
|
||||
import {ModifierCategoryListComponent} from './modifier-category-list/modifier-category-list.component';
|
||||
import {ModifierCategoryDetailComponent} from './modifier-category-detail/modifier-category-detail.component';
|
||||
import {ModifierCategoriesRoutingModule} from './modifier-categories-routing.module';
|
||||
import {CdkTreeModule} from '@angular/cdk/tree';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { CdkTreeModule } from '@angular/cdk/tree';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
@@ -14,10 +13,12 @@ import { MatInputModule } from '@angular/material/input';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { MatTreeModule } from '@angular/material/tree';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import {ReactiveFormsModule} from '@angular/forms';
|
||||
import {SharedModule} from '../shared/shared.module';
|
||||
import {FlexLayoutModule} from '@angular/flex-layout';
|
||||
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
|
||||
import { ModifierCategoriesRoutingModule } from './modifier-categories-routing.module';
|
||||
import { ModifierCategoryDetailComponent } from './modifier-category-detail/modifier-category-detail.component';
|
||||
import { ModifierCategoryListComponent } from './modifier-category-list/modifier-category-list.component';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -36,12 +37,8 @@ import {FlexLayoutModule} from '@angular/flex-layout';
|
||||
MatTreeModule,
|
||||
ReactiveFormsModule,
|
||||
SharedModule,
|
||||
ModifierCategoriesRoutingModule
|
||||
ModifierCategoriesRoutingModule,
|
||||
],
|
||||
declarations: [
|
||||
ModifierCategoryListComponent,
|
||||
ModifierCategoryDetailComponent
|
||||
]
|
||||
declarations: [ModifierCategoryListComponent, ModifierCategoryDetailComponent],
|
||||
})
|
||||
export class ModifierCategoriesModule {
|
||||
}
|
||||
export class ModifierCategoriesModule {}
|
||||
+37
-17
@@ -5,26 +5,41 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput #nameElement placeholder="Name" formControlName="name">
|
||||
<input matInput #nameElement placeholder="Name" formControlName="name" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Minimum</mat-label>
|
||||
<input matInput placeholder="Minimum" type="number" formControlName="minimum">
|
||||
<input matInput placeholder="Minimum" type="number" formControlName="minimum" />
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Maximum</mat-label>
|
||||
<input matInput placeholder="Maximum" type="number" formControlName="maximum">
|
||||
<input matInput placeholder="Maximum" type="number" formControlName="maximum" />
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<div
|
||||
fxLayout="row"
|
||||
fxLayoutAlign="space-around start"
|
||||
fxLayout.lt-md="column"
|
||||
fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px"
|
||||
>
|
||||
<mat-checkbox formControlName="isActive">Is Active?</mat-checkbox>
|
||||
</div>
|
||||
<mat-divider></mat-divider>
|
||||
@@ -34,24 +49,29 @@
|
||||
<li class="mat-tree-node">
|
||||
<!-- use a disabled button to provide padding for tree leaf -->
|
||||
<button mat-icon-button disabled></button>
|
||||
<mat-checkbox class="checklist-leaf-node"
|
||||
[checked]="isProductSelected(node)"
|
||||
(change)="toggleProductSelection(node)">{{node.name}}</mat-checkbox>
|
||||
<mat-checkbox
|
||||
class="checklist-leaf-node"
|
||||
[checked]="isProductSelected(node)"
|
||||
(change)="toggleProductSelection(node)"
|
||||
>{{ node.name }}</mat-checkbox
|
||||
>
|
||||
</li>
|
||||
</mat-tree-node>
|
||||
<!-- This is the tree node template for expandable nodes -->
|
||||
<mat-nested-tree-node *matTreeNodeDef="let node; when: hasChild">
|
||||
<li>
|
||||
<div class="mat-tree-node">
|
||||
<button mat-icon-button matTreeNodeToggle
|
||||
[attr.aria-label]="'toggle ' + node.name">
|
||||
<button mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name">
|
||||
<mat-icon class="mat-icon-rtl-mirror">
|
||||
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
|
||||
{{ treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right' }}
|
||||
</mat-icon>
|
||||
</button>
|
||||
<mat-checkbox [checked]="isMenuCategorySelected(node)"
|
||||
<mat-checkbox
|
||||
[checked]="isMenuCategorySelected(node)"
|
||||
[indeterminate]="isMenuCategoryPartiallySelected(node)"
|
||||
(change)="toggleMenuCategorySelection(node)">{{node.name}}</mat-checkbox>
|
||||
(change)="toggleMenuCategorySelection(node)"
|
||||
>{{ node.name }}</mat-checkbox
|
||||
>
|
||||
</div>
|
||||
<ul [class.example-tree-invisible]="!treeControl.isExpanded(node)">
|
||||
<ng-container matTreeNodeOutlet></ng-container>
|
||||
|
||||
+4
-5
@@ -1,6 +1,6 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {ModifierCategoryDetailComponent} from './modifier-category-detail.component';
|
||||
import { ModifierCategoryDetailComponent } from './modifier-category-detail.component';
|
||||
|
||||
describe('ModifierCategoryDetailComponent', () => {
|
||||
let component: ModifierCategoryDetailComponent;
|
||||
@@ -8,9 +8,8 @@ describe('ModifierCategoryDetailComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ModifierCategoryDetailComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [ModifierCategoryDetailComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
+51
-47
@@ -1,26 +1,27 @@
|
||||
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ModifierCategoryService} from '../modifier-category.service';
|
||||
import {ModifierCategory} from '../../core/modifier-category';
|
||||
import {ToasterService} from '../../core/toaster.service';
|
||||
import {ConfirmDialogComponent} from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import {MatDialog} from '@angular/material/dialog';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
import {MenuCategory} from '../../core/menu-category';
|
||||
import {NestedTreeControl} from '@angular/cdk/tree';
|
||||
import { NestedTreeControl } from '@angular/cdk/tree';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatTreeNestedDataSource } from '@angular/material/tree';
|
||||
import {Product} from '../../core/product';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { MenuCategory } from '../../core/menu-category';
|
||||
import { ModifierCategory } from '../../core/modifier-category';
|
||||
import { Product } from '../../core/product';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { ModifierCategoryService } from '../modifier-category.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-role-detail',
|
||||
templateUrl: './modifier-category-detail.component.html',
|
||||
styleUrls: ['./modifier-category-detail.component.css']
|
||||
styleUrls: ['./modifier-category-detail.component.css'],
|
||||
})
|
||||
export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', {static: true}) nameElement: ElementRef;
|
||||
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
|
||||
form: FormGroup;
|
||||
item: ModifierCategory;
|
||||
treeControl = new NestedTreeControl<any>(node => node.products);
|
||||
treeControl = new NestedTreeControl<any>((node) => node.products);
|
||||
dataSource = new MatTreeNestedDataSource<any>();
|
||||
products: Map<string, Product>;
|
||||
productsOfMenuCategory: Map<string, Product[]>;
|
||||
@@ -31,7 +32,7 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
private fb: FormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private dialog: MatDialog,
|
||||
private ser: ModifierCategoryService
|
||||
private ser: ModifierCategoryService,
|
||||
) {
|
||||
this.createForm();
|
||||
this.dataSource.data = [];
|
||||
@@ -42,15 +43,14 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
name: '',
|
||||
minimum: '',
|
||||
maximum: '',
|
||||
isActive: ''
|
||||
isActive: '',
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { item: ModifierCategory }) => {
|
||||
this.showItem(data.item);
|
||||
});
|
||||
this.route.data.subscribe((data: { item: ModifierCategory }) => {
|
||||
this.showItem(data.item);
|
||||
});
|
||||
}
|
||||
|
||||
showItem(item: ModifierCategory) {
|
||||
@@ -58,9 +58,9 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
this.dataSource.data = item.menuCategories;
|
||||
this.form.patchValue({
|
||||
name: this.item.name || '',
|
||||
minimum: '' + this.item.minimum,
|
||||
maximum: '' + this.item.maximum,
|
||||
isActive: this.item.isActive
|
||||
minimum: `${this.item.minimum}`,
|
||||
maximum: `${this.item.maximum}`,
|
||||
isActive: this.item.isActive,
|
||||
});
|
||||
this.products = new Map();
|
||||
this.productsOfMenuCategory = new Map();
|
||||
@@ -82,40 +82,39 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,class-methods-use-this
|
||||
isExpanded(mc: MenuCategory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem())
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/modifier-categories');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
this.ser.saveOrUpdate(this.getItem()).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/modifier-categories');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.item.id)
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/modifier-categories');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
this.ser.delete(this.item.id).subscribe(
|
||||
() => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/modifier-categories');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
confirmDelete(): void {
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: {title: 'Delete Modifier Category?', content: 'Are you sure? This cannot be undone.'}
|
||||
data: { title: 'Delete Modifier Category?', content: 'Are you sure? This cannot be undone.' },
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result: boolean) => {
|
||||
@@ -141,13 +140,16 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
isMenuCategorySelected(node: MenuCategory) {
|
||||
return this.productsOfMenuCategory.get(node.id).reduce((acc, current) => acc && current.enabled, true);
|
||||
return this.productsOfMenuCategory
|
||||
.get(node.id)
|
||||
.reduce((acc, current) => acc && current.enabled, true);
|
||||
}
|
||||
|
||||
isMenuCategoryPartiallySelected(node: MenuCategory) {
|
||||
const total = this.productsOfMenuCategory.get(node.id).length;
|
||||
const ticked = this.productsOfMenuCategory.get(node.id).reduce((acc, current) => {
|
||||
if (current.enabled) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
acc += 1;
|
||||
}
|
||||
return acc;
|
||||
@@ -156,12 +158,14 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
toggleProductSelection(node: Product) {
|
||||
return this.products.get(node.id).enabled = !this.products.get(node.id).enabled;
|
||||
this.products.get(node.id).enabled = !this.products.get(node.id).enabled;
|
||||
}
|
||||
|
||||
toggleMenuCategorySelection(node: MenuCategory) {
|
||||
const sel = !this.isMenuCategorySelected(node);
|
||||
this.productsOfMenuCategory.get(node.id).forEach((p) => {p.enabled = sel; });
|
||||
this.productsOfMenuCategory.get(node.id).forEach((p) => {
|
||||
p.enabled = sel;
|
||||
});
|
||||
return sel;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,18 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {ModifierCategoryListResolver} from './modifier-category-list-resolver.service';
|
||||
import { ModifierCategoryListResolver } from './modifier-category-list-resolver.service';
|
||||
|
||||
describe('ModifierCategoryListResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [ModifierCategoryListResolver]
|
||||
providers: [ModifierCategoryListResolver],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([ModifierCategoryListResolver], (service: ModifierCategoryListResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
it('should be created', inject(
|
||||
[ModifierCategoryListResolver],
|
||||
(service: ModifierCategoryListResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
},
|
||||
));
|
||||
});
|
||||
@@ -1,18 +1,18 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {ModifierCategory} from '../core/modifier-category';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {ModifierCategoryService} from './modifier-category.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { ModifierCategory } from '../core/modifier-category';
|
||||
|
||||
import { ModifierCategoryService } from './modifier-category.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ModifierCategoryListResolver implements Resolve<ModifierCategory[]> {
|
||||
constructor(private ser: ModifierCategoryService) {}
|
||||
|
||||
constructor(private ser: ModifierCategoryService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<ModifierCategory[]> {
|
||||
resolve(): Observable<ModifierCategory[]> {
|
||||
return this.ser.list();
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -1,9 +1,9 @@
|
||||
import { DataSource } from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf } from 'rxjs';
|
||||
|
||||
import { ModifierCategory } from '../../core/modifier-category';
|
||||
|
||||
export class ModifierCategoryListDatasource extends DataSource<ModifierCategory> {
|
||||
|
||||
constructor(public data: ModifierCategory[]) {
|
||||
super();
|
||||
}
|
||||
@@ -12,6 +12,5 @@ export class ModifierCategoryListDatasource extends DataSource<ModifierCategory>
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
disconnect() {}
|
||||
}
|
||||
+11
-9
@@ -8,23 +8,24 @@
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="['/modifier-categories', row.id]">{{row.name}}</a></mat-cell>
|
||||
<mat-cell *matCellDef="let row"
|
||||
><a [routerLink]="['/modifier-categories', row.id]">{{ row.name }}</a></mat-cell
|
||||
>
|
||||
</ng-container>
|
||||
|
||||
<!-- Minimum Column -->
|
||||
<ng-container matColumnDef="minimum">
|
||||
<mat-header-cell *matHeaderCellDef>Minimum</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.minimum}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.minimum }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Maximum Column -->
|
||||
<ng-container matColumnDef="maximum">
|
||||
<mat-header-cell *matHeaderCellDef>Maximum</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.maximum}}</mat-cell>
|
||||
<mat-cell *matCellDef="let row">{{ row.maximum }}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Is Active Column -->
|
||||
@@ -32,9 +33,9 @@
|
||||
<mat-header-cell *matHeaderCellDef>Is Active</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">
|
||||
<mat-icon>
|
||||
{{ row.isActive ? "visibility" : "visibility_off" }}
|
||||
{{ row.isActive ? 'visibility' : 'visibility_off' }}
|
||||
</mat-icon>
|
||||
<b> {{ row.isActive ? "Active" : "Not Active" }}</b>
|
||||
<b> {{ row.isActive ? 'Active' : 'Not Active' }}</b>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
@@ -43,9 +44,10 @@
|
||||
<mat-header-cell *matHeaderCellDef>Products</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">
|
||||
<ul>
|
||||
<li *ngFor="let mc of row.menuCategories">{{mc.name}}
|
||||
<li *ngFor="let mc of row.menuCategories">
|
||||
{{ mc.name }}
|
||||
<ul *ngIf="!mc.enabled">
|
||||
<li *ngFor="let p of mc.products">{{p.name}}</li>
|
||||
<li *ngFor="let p of mc.products">{{ p.name }}</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -53,7 +55,7 @@
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||
</mat-table>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
+4
-5
@@ -1,6 +1,6 @@
|
||||
import {ComponentFixture, fakeAsync, TestBed} from '@angular/core/testing';
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {ModifierCategoryListComponent} from './modifier-category-list.component';
|
||||
import { ModifierCategoryListComponent } from './modifier-category-list.component';
|
||||
|
||||
describe('ModifierCategoryListComponent', () => {
|
||||
let component: ModifierCategoryListComponent;
|
||||
@@ -8,9 +8,8 @@ describe('ModifierCategoryListComponent', () => {
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ModifierCategoryListComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
declarations: [ModifierCategoryListComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ModifierCategoryListComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
+9
-9
@@ -1,12 +1,14 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ModifierCategoryListDatasource } from './modifier-category-list-datasource';
|
||||
import { ModifierCategory } from '../../core/modifier-category';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { ModifierCategory } from '../../core/modifier-category';
|
||||
|
||||
import { ModifierCategoryListDatasource } from './modifier-category-list-datasource';
|
||||
|
||||
@Component({
|
||||
selector: 'app-modifier-category-list',
|
||||
templateUrl: './modifier-category-list.component.html',
|
||||
styleUrls: ['./modifier-category-list.component.css']
|
||||
styleUrls: ['./modifier-category-list.component.css'],
|
||||
})
|
||||
export class ModifierCategoryListComponent implements OnInit {
|
||||
dataSource: ModifierCategoryListDatasource;
|
||||
@@ -14,14 +16,12 @@ export class ModifierCategoryListComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'minimum', 'maximum', 'products', 'isActive'];
|
||||
|
||||
constructor(private route: ActivatedRoute) {
|
||||
}
|
||||
constructor(private route: ActivatedRoute) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { list: ModifierCategory[] }) => {
|
||||
this.list = data.list;
|
||||
});
|
||||
this.route.data.subscribe((data: { list: ModifierCategory[] }) => {
|
||||
this.list = data.list;
|
||||
});
|
||||
this.dataSource = new ModifierCategoryListDatasource(this.list);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,18 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {ModifierCategoryResolver} from './modifier-category-resolver.service';
|
||||
import { ModifierCategoryResolver } from './modifier-category-resolver.service';
|
||||
|
||||
describe('ModifierCategoryResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [ModifierCategoryResolver]
|
||||
providers: [ModifierCategoryResolver],
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([ModifierCategoryResolver], (service: ModifierCategoryResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
it('should be created', inject(
|
||||
[ModifierCategoryResolver],
|
||||
(service: ModifierCategoryResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
},
|
||||
));
|
||||
});
|
||||
@@ -1,18 +1,18 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {ModifierCategory} from '../core/modifier-category';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {ModifierCategoryService} from './modifier-category.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
|
||||
import { ModifierCategory } from '../core/modifier-category';
|
||||
|
||||
import { ModifierCategoryService } from './modifier-category.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ModifierCategoryResolver implements Resolve<ModifierCategory> {
|
||||
constructor(private ser: ModifierCategoryService) {}
|
||||
|
||||
constructor(private ser: ModifierCategoryService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<ModifierCategory> {
|
||||
resolve(route: ActivatedRouteSnapshot): Observable<ModifierCategory> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.ser.get(id);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
|
||||
import {ModifierCategoryService} from './modifier-category.service';
|
||||
import { ModifierCategoryService } from './modifier-category.service';
|
||||
|
||||
describe('ModifierCategoryService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [ModifierCategoryService]
|
||||
providers: [ModifierCategoryService],
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,72 +1,76 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { ModifierCategory } from '../core/modifier-category';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
|
||||
};
|
||||
const url = '/api/modifier-categories';
|
||||
const serviceName = 'ModifierCategoryService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ModifierCategoryService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
|
||||
|
||||
get(id: string): Observable<ModifierCategory> {
|
||||
const getUrl: string = (id === null) ? url : `${url}/${id}`;
|
||||
return <Observable<ModifierCategory>>this.http.get<ModifierCategory>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`))
|
||||
);
|
||||
const getUrl: string = id === null ? url : `${url}/${id}`;
|
||||
return <Observable<ModifierCategory>>(
|
||||
this.http
|
||||
.get<ModifierCategory>(getUrl)
|
||||
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`)))
|
||||
);
|
||||
}
|
||||
|
||||
list(): Observable<ModifierCategory[]> {
|
||||
return <Observable<ModifierCategory[]>>this.http.get<ModifierCategory[]>(`${url}/list`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
return <Observable<ModifierCategory[]>>(
|
||||
this.http
|
||||
.get<ModifierCategory[]>(`${url}/list`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'list')))
|
||||
);
|
||||
}
|
||||
|
||||
listForProduct(id: string): Observable<ModifierCategory[]> {
|
||||
return <Observable<ModifierCategory[]>>this.http.get<ModifierCategory[]>(`${url}/for-product/${id}`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'listIsActiveOfProduct'))
|
||||
);
|
||||
return <Observable<ModifierCategory[]>>(
|
||||
this.http
|
||||
.get<ModifierCategory[]>(`${url}/for-product/${id}`)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'listIsActiveOfProduct')))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
save(modifierCategory: ModifierCategory): Observable<ModifierCategory> {
|
||||
return <Observable<ModifierCategory>>this.http.post<ModifierCategory>(url, modifierCategory, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
return <Observable<ModifierCategory>>(
|
||||
this.http
|
||||
.post<ModifierCategory>(url, modifierCategory, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'save')))
|
||||
);
|
||||
}
|
||||
|
||||
update(modifierCategory: ModifierCategory): Observable<ModifierCategory> {
|
||||
return <Observable<ModifierCategory>>this.http.put<ModifierCategory>(`${url}/${modifierCategory.id}`, modifierCategory, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'update'))
|
||||
);
|
||||
return <Observable<ModifierCategory>>(
|
||||
this.http
|
||||
.put<ModifierCategory>(`${url}/${modifierCategory.id}`, modifierCategory, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'update')))
|
||||
);
|
||||
}
|
||||
|
||||
saveOrUpdate(modifierCategory: ModifierCategory): Observable<ModifierCategory> {
|
||||
if (!modifierCategory.id) {
|
||||
return this.save(modifierCategory);
|
||||
} else {
|
||||
return this.update(modifierCategory);
|
||||
}
|
||||
return this.update(modifierCategory);
|
||||
}
|
||||
|
||||
delete(id: string): Observable<ModifierCategory> {
|
||||
return <Observable<ModifierCategory>>this.http.delete<ModifierCategory>(`${url}/${id}`, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'delete'))
|
||||
);
|
||||
return <Observable<ModifierCategory>>(
|
||||
this.http
|
||||
.delete<ModifierCategory>(`${url}/${id}`, httpOptions)
|
||||
.pipe(catchError(this.log.handleError(serviceName, 'delete')))
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user