Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | 1x 1x 1x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* File Name: quote-dialog.component
* Version Number: v1.0
* Author: Tobias Bester
* Project Name: Ninshiki
* Organization: Software Sharks
* User Manual: Refer to https://github.com/OrishaOrrie/SoftwareSharks/blob/master/Documentation/User%20Manual.pdf
* Update History:
* ------------------------------------------
* Date Author Description
* 02/10/2018 Tobias Created components
* ------------------------------------------
* Test Cases: quote-dialog.component.spec.ts
* Functional Description:
* Provides interface to add an amount of items to a quote.
*/
import { Component, OnInit, Inject } from '@angular/core';
import { FormGroup, FormBuilder, FormControl, Validators } from '@angular/forms';
impoIrt { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material';E
import { QuoteBuilderService } from './quote-builder.service';
@Component({
seElector: 'app-quote-dialog',
templateUrl: './quote-dialog.component.html',
styleUrls: ['./quote-dialog.component.css']
})
export class QuoteDialogComponent implements OnInit {
/**
* The FormGroup used to control the modal input form
*/
quoteForm: FormGroup;
/**
* The name of the item that is to be added to the quote
*/
item: string;
/**
* The amount of the item that is added to the quote
*/
amount: number;
/**@ignore */
constructor(private fb: FormBuilder, private dialogRef: MatDialogRef<QuoteDialogComponent>, @Inject(MAT_DIALOG_DATA) data,
public snackbar: MatSnackBar, public qb: QuoteBuilderService) {
this.item = data.name;
}
/**
* Sets up the FormGroup with the validators for the amount input field
*/
ngOnInit() {
this.quoteForm = this.fb.group({
amount: new FormControl('', Validators.compose([
Validators.required,
Validators.max(1000),
Validators.min(1)
]))
});
}
/**
* Calls the QuoteBuilder Service to add the input quote details and display a snack bar on success
*/
addQuoteItem() {
this.amount = this.quoteForm.controls['amount'].value;
this.qb.addQuote(this.item, this.amount);
const message = 'Added ' + this.amount + ' items of type "' + this.item + '" to your quote. '
+ '\nGo to the Contact Us page to request the quote';
this.openSnackBar(message);
this.dialogRef.close();
}
/**
* Opens the snackbar which displays the input message
* @param message The string that is to be displayed
*/
openSnackBar(message: string) {
this.snackbar.open(message, 'Okay', {
duration: 5000
});
}
/**
* @ignore
*/
closeDialog() {
this.dialogRef.close();
}
}
|