Save Bill Works
This commit is contained in:
17
bookie/src/app/sales/quantity/quantity.component.html
Normal file
17
bookie/src/app/sales/quantity/quantity.component.html
Normal file
@ -0,0 +1,17 @@
|
||||
<div mat-dialog-content>
|
||||
<form [formGroup]="form">
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Quantity</mat-label>
|
||||
<input type="text" matInput #quantity placeholder="Quantity" formControlName="quantity" autocomplete="off"
|
||||
(focus)="quantity.select()" cdkFocusInitial>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div mat-dialog-actions>
|
||||
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
||||
<button mat-button (click)="accept()" color="primary">Ok</button>
|
||||
</div>
|
||||
|
||||
25
bookie/src/app/sales/quantity/quantity.component.spec.ts
Normal file
25
bookie/src/app/sales/quantity/quantity.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { QuantityComponent } from './quantity.component';
|
||||
|
||||
describe('QuantityComponent', () => {
|
||||
let component: QuantityComponent;
|
||||
let fixture: ComponentFixture<QuantityComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ QuantityComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(QuantityComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
37
bookie/src/app/sales/quantity/quantity.component.ts
Normal file
37
bookie/src/app/sales/quantity/quantity.component.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-quantity',
|
||||
templateUrl: './quantity.component.html',
|
||||
styleUrls: ['./quantity.component.css']
|
||||
})
|
||||
export class QuantityComponent implements OnInit {
|
||||
form: FormGroup;
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<QuantityComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: number,
|
||||
private fb: FormBuilder,
|
||||
) {
|
||||
this.createForm();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.form.setValue({
|
||||
quantity: this.data
|
||||
});
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
quantity: ''
|
||||
});
|
||||
}
|
||||
|
||||
accept(): void {
|
||||
const quantity = this.form.value.quantity;
|
||||
this.dialogRef.close(quantity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user