Guest User

Untitled

a guest
Sep 25th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. component.ts
  2.  
  3. import { Component, OnInit } from '@angular/core';
  4. import { Quote } from '../../1-model/quote.model';
  5. import { QuoteService } from '../../quote.service';
  6. import * as $ from 'jquery'
  7.  
  8. @Component({
  9. selector: 'app-quotes-abertas',
  10. templateUrl: './quotes-abertas.component.html',
  11. styleUrls: ['./quotes-abertas.component.css']
  12. })
  13. export class QuotesAbertasComponent implements OnInit {
  14.  
  15. public quotes: Quote[];
  16. public daysInLine: Date = new Date();
  17.  
  18. constructor(private quoteService: QuoteService) { }
  19.  
  20. ngOnInit() {
  21. $(document).ready(function () {
  22. $("#pesquisar").on("keyup", function () {
  23. var value = $(this).val().toLowerCase();
  24. $("#quote-table tr").filter(function () {
  25. $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
  26. });
  27. });
  28. });
  29.  
  30. this.getQuotes()
  31. }
  32.  
  33. getQuotes() {
  34. return this.quoteService.getQuotes()
  35. .subscribe(
  36. quotes => {
  37. console.log(quotes);
  38. this.quotes = quotes
  39. }
  40. )
  41. }
  42. }
  43.  
  44. import { Component, OnInit } from '@angular/core';
  45. import { QuoteService } from '../../quote.service';
  46.  
  47. import { ActivatedRoute, Router } from "@angular/router";
  48. import { FormGroup, FormBuilder, Validators } from '@angular/forms';
  49. import { Observable } from 'rxjs';
  50. import { tap } from 'rxjs/operators';
  51. import { QuoteValue } from '../../1-model/QuoteValue.model';
  52.  
  53. @Component({
  54. selector: 'app-quotes-abertas-detalhes',
  55. templateUrl: './quotes-abertas-detalhes.component.html',
  56. styleUrls: ['./quotes-abertas-detalhes.component.css']
  57. })
  58. export class QuotesAbertasDetalhesComponent implements OnInit {
  59.  
  60. public quoteValue: Observable<QuoteValue>;
  61. public detailsForm: FormGroup;
  62. public quote: QuoteValue
  63.  
  64. constructor(
  65. private quoteService: QuoteService,
  66. private activatedRoute: ActivatedRoute,
  67. private route: Router,
  68. private formBuilder: FormBuilder
  69. ) { }
  70.  
  71. ngOnInit() {
  72. const id = + this.activatedRoute.snapshot.paramMap.get('id');
  73.  
  74. this.quoteService.getQuote(id)
  75. .subscribe(
  76. quote => {
  77. this.quote = quote
  78. }
  79. );
  80.  
  81. this.quoteValue = this.quoteService.getQuote(id)
  82. .pipe(
  83. tap(quoteValue => this.detailsForm.patchValue(quoteValue))
  84. )
  85.  
  86. this.detailsForm = this.formBuilder.group({
  87. id: [id],
  88. QuoteType: [null],
  89. AccountOwner: [null, Validators.required],
  90. AccountContactName: [null, Validators.required],
  91. AccountContactEmail: [null, [Validators.required, Validators.email]],
  92. AccountContactTel: [null, Validators.required],
  93. AccountNumber: [null, Validators.required],
  94. IdOportunity: [null, Validators.required],
  95. IBX: [null, Validators.required],
  96. ProjectStatus: ['In Progress', Validators.required],
  97. InitialTerm: [0, [Validators.max(60), Validators.min(1)]],
  98. RenewalTerm: [0, [Validators.max(60), Validators.min(1)]],
  99. PriceIncrease: [null],
  100. EffectiveDate: [null],
  101. NonStandardTerm: [null],
  102. FreeMonths: [0],
  103. RampMonths: [0],
  104. RampPerCent: [null],
  105. RampStartDate: [null],
  106. RampEndDate: [null],
  107. })
  108. }
  109.  
  110. update(): void {
  111. const updateQuote = this.detailsForm.getRawValue() as QuoteValue
  112. this.quoteService.updateQuote(updateQuote).subscribe()
  113. this.goBack()
  114. }
  115.  
  116. delete(): void {
  117. this.quoteService.deleteQuote(this.quote.id).subscribe();
  118. this.goBack()
  119. }
  120.  
  121. goBack(): void {
  122. this.route.navigate(['homepage', 'quotes-abertas'])
  123. }
  124. }
Add Comment
Please, Sign In to add comment