Product Error on *ngIf, new a dealbreaker, but not sure.
This commit is contained in:
@ -26,34 +26,18 @@
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Fraction</mat-label>
|
||||
<input matInput type="number" placeholder="Fraction" formControlName="fraction">
|
||||
<mat-label>Price</mat-label>
|
||||
<input matInput type="number" placeholder="Price" formControlName="price">
|
||||
</mat-form-field>
|
||||
<mat-form-field cdk-overlay-origin="">
|
||||
<mat-label>Fraction Units</mat-label>
|
||||
<input matInput placeholder="Fraction Units" formControlName="fractionUnits">
|
||||
</mat-form-field>
|
||||
<mat-form-field cdk-overlay-origin="">
|
||||
<mat-label>Yield</mat-label>
|
||||
<input matInput type="number" placeholder="Tield" formControlName="productYield">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>{{item.isPurchased ? 'Purchase Price' : 'Cost Price' }}</mat-label>
|
||||
<input matInput type="number" placeholder="{{item.isPurchased ? 'Purchase Price' : 'Cost Price' }}"
|
||||
formControlName="price">
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex [hidden]="!item.isSold">
|
||||
<mat-label>Sale Price</mat-label>
|
||||
<input matInput type="number" placeholder="Sale Price" formControlName="salePrice">
|
||||
<mat-label>Quantity</mat-label>
|
||||
<input matInput type="number" placeholder="Quantity" formControlName="quantity">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<mat-checkbox formControlName="isPurchased">Is Purchased?</mat-checkbox>
|
||||
<mat-checkbox formControlName="isSold">Is Sold?</mat-checkbox>
|
||||
<mat-checkbox formControlName="hasHappyHour">Has Happy Hour?</mat-checkbox>
|
||||
<mat-checkbox formControlName="isNotAvailable">Is Not Available?</mat-checkbox>
|
||||
<mat-checkbox formControlName="isActive">Is Active?</mat-checkbox>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
@ -66,6 +50,14 @@
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Tax</mat-label>
|
||||
<mat-select placeholder="Tax" formControlName="tax">
|
||||
<mat-option *ngFor="let t of taxes" [value]="t.id">
|
||||
{{ t.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
import {AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
||||
import {ToasterService} from '../../core/toaster.service';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ProductService} from '../product.service';
|
||||
import {Product} from '../../core/product';
|
||||
import {ProductGroup} from '../../core/product-group';
|
||||
import {ConfirmDialogComponent} from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ProductService } from '../product.service';
|
||||
import { Product } from '../../core/product';
|
||||
import { ProductGroup } from '../../core/product-group';
|
||||
import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dialog.component';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import {FormBuilder, FormGroup} from '@angular/forms';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { Tax } from "../../core/tax";
|
||||
|
||||
@Component({
|
||||
selector: 'app-product-detail',
|
||||
@ -17,6 +18,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
|
||||
form: FormGroup;
|
||||
productGroups: ProductGroup[];
|
||||
taxes: Tax[];
|
||||
item: Product;
|
||||
|
||||
constructor(
|
||||
@ -35,22 +37,21 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
code: {value: '', disabled: true},
|
||||
name: '',
|
||||
units: '',
|
||||
fraction: '',
|
||||
fractionUnits: '',
|
||||
productYield: '',
|
||||
productGroup: '',
|
||||
tax: '',
|
||||
price: '',
|
||||
salePrice: '',
|
||||
isPurchased: '',
|
||||
isSold: '',
|
||||
isActive: '',
|
||||
productGroup: ''
|
||||
hasHappyHour: '',
|
||||
isNotAvailable: '',
|
||||
quantity: '',
|
||||
isActive: ''
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { item: Product, productGroups: ProductGroup[] }) => {
|
||||
.subscribe((data: { item: Product, productGroups: ProductGroup[], taxes: Tax[] }) => {
|
||||
this.productGroups = data.productGroups;
|
||||
this.taxes = data.taxes;
|
||||
this.showItem(data.item);
|
||||
});
|
||||
}
|
||||
@ -64,7 +65,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
productGroup: this.item.tax.id ? this.item.tax.id : '',
|
||||
tax: this.item.productGroup.id ? this.item.productGroup.id : '',
|
||||
price: this.item.price || '',
|
||||
hadHappyHour: this.item.hasHappyHour,
|
||||
hasHappyHour: this.item.hasHappyHour,
|
||||
isNotAvailable: this.item.isNotAvailable,
|
||||
quantity: this.item.quantity || '',
|
||||
isActive: this.item.isActive,
|
||||
|
||||
Reference in New Issue
Block a user