Big Chunk of updates on way to making the sales portion working
This commit is contained in:
@ -0,0 +1,12 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProductsResolver } from './products-resolver.service';
|
||||
|
||||
describe('ProductsResolver', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
|
||||
it('should be created', () => {
|
||||
const service: ProductsResolver = TestBed.get(ProductsResolver);
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
19
bookie/src/app/sales/products/products-resolver.service.ts
Normal file
19
bookie/src/app/sales/products/products-resolver.service.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from "@angular/router";
|
||||
import { Observable } from "rxjs";
|
||||
import { Product } from "../../core/product";
|
||||
import { ProductService } from "../../product/product.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ProductsResolver implements Resolve<Product[]> {
|
||||
|
||||
constructor(private ser: ProductService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Product[]> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.ser.listIsActiveOfCategory(id);
|
||||
}
|
||||
}
|
||||
5
bookie/src/app/sales/products/products.component.css
Normal file
5
bookie/src/app/sales/products/products.component.css
Normal file
@ -0,0 +1,5 @@
|
||||
.square-button {
|
||||
min-width: 150px;
|
||||
max-width: 150px;
|
||||
min-height: 150px;
|
||||
}
|
||||
6
bookie/src/app/sales/products/products.component.html
Normal file
6
bookie/src/app/sales/products/products.component.html
Normal file
@ -0,0 +1,6 @@
|
||||
<mat-card>
|
||||
<mat-card-content fxLayout="row wrap" fxLayoutGap="grid 20px">
|
||||
<button mat-raised-button class="square-button"
|
||||
*ngFor="let item of list" (click)="showModifier(item)">{{item.name}}</button>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
25
bookie/src/app/sales/products/products.component.spec.ts
Normal file
25
bookie/src/app/sales/products/products.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProductsComponent } from './products.component';
|
||||
|
||||
describe('ProductsComponent', () => {
|
||||
let component: ProductsComponent;
|
||||
let fixture: ComponentFixture<ProductsComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ProductsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ProductsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
39
bookie/src/app/sales/products/products.component.ts
Normal file
39
bookie/src/app/sales/products/products.component.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { MatDialog } from "@angular/material";
|
||||
import { Product } from "../../core/product";
|
||||
import {ModifiersComponent} from "../modifiers/modifiers.component";
|
||||
import {ModifierCategoryService} from "../../modifier-categories/modifier-category.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-products',
|
||||
templateUrl: './products.component.html',
|
||||
styleUrls: ['./products.component.css']
|
||||
})
|
||||
export class ProductsComponent implements OnInit {
|
||||
list: Product[];
|
||||
|
||||
constructor(private route: ActivatedRoute, private dialog: MatDialog, private modifierCategoryService: ModifierCategoryService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { list: Product[] }) => {
|
||||
this.list = data.list;
|
||||
});
|
||||
}
|
||||
|
||||
showModifier(product: Product): void {
|
||||
// [routerLink]="['/sales', 'modifiers', item.id]"
|
||||
let dialogRef = this.dialog.open(ModifiersComponent, {
|
||||
position: {
|
||||
top: '10vh'
|
||||
},
|
||||
data: this.modifierCategoryService.listIsActiveOfProduct(product.id)
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
console.log('The dialog was closed');
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user