Commit 7f8d72ac14c07037bf1b6021082c594ba7cfdfff

Authored by Marcelo Puebla
1 parent d684bd32d2
Exists in master

Cambio de tipo en objeto sinonimo,

Showing 1 changed file with 15 additions and 7 deletions   Show diff stats
src/app/components/inicio/inicio.component.ts
... ... @@ -5,8 +5,6 @@ import { Producto } from 'src/app/wrappers/producto';
5 5 import { ProductoService } from 'src/app/services/producto.service';
6 6 import { Router } from '@angular/router';
7 7 import { Promocion } from 'src/app/wrappers/promocion';
8   -import { Sinonimo } from 'src/app/wrappers/sinonimo';
9   -
10 8  
11 9 @Component({
12 10 selector: 'app-inicio',
... ... @@ -18,10 +16,10 @@ export class InicioComponent implements OnInit {
18 16 @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective;
19 17 private productoAcargar: Producto;
20 18 private promoAcargar: Promocion;
21   - private sinonimoAcargar: Sinonimo;
  19 + private sinonimoAcargar: Producto;
22 20  
23 21 promociones: Promocion[] = [];
24   - sinonimos: Sinonimo[] = [];
  22 + sinonimos: Producto[] = [];
25 23 apiUrl: string = appSettings.apiUrl
26 24  
27 25 constructor(
... ... @@ -31,6 +29,10 @@ export class InicioComponent implements OnInit {
31 29 ngOnInit() {
32 30  
33 31 this.productoAcargar = this.productoService.productoAcargar;
  32 + this.getPromociones();
  33 + }
  34 +
  35 + getPromociones() {
34 36 if (this.productoAcargar) {
35 37 var sector = this.productoAcargar.CodSec;
36 38 var codigo = this.productoAcargar.CodArt;
... ... @@ -88,15 +90,21 @@ export class InicioComponent implements OnInit {
88 90 var sector = this.promoAcargar.sector;
89 91 var codigo = this.promoAcargar.codigo;
90 92 this.productoService.getPromocionSinonimos(sector, codigo)
91   - .subscribe((res: Sinonimo[]) => {
92   -
  93 + .subscribe((res: Producto[]) => {
  94 + res.forEach(resSinonimo => {
  95 + this.promoAcargar.productos.forEach(producto => {
  96 + if (producto.id === resSinonimo.id) {
  97 + resSinonimo.esPadre = true;
  98 + }
  99 + });
  100 + })
93 101 this.sinonimos = res;
94 102 this.showPopover();
95 103 })
96 104 }
97 105 }
98 106  
99   - sinonimoSeleccionado($event: Sinonimo) {
  107 + sinonimoSeleccionado($event: Producto) {
100 108  
101 109 this.sinonimoAcargar = $event;
102 110 }