From 7809cdfb0c1591095075d90f3a78d837b7a75a20 Mon Sep 17 00:00:00 2001 From: mpuebla Date: Wed, 21 Aug 2019 12:04:18 -0300 Subject: [PATCH] Muestreo el sinonimo padre al prinicipio. --- .../popover-sinonimos/popover-sinonimos.component.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/components/popover-sinonimos/popover-sinonimos.component.ts b/src/app/components/popover-sinonimos/popover-sinonimos.component.ts index 2349d76..8e1c0de 100644 --- a/src/app/components/popover-sinonimos/popover-sinonimos.component.ts +++ b/src/app/components/popover-sinonimos/popover-sinonimos.component.ts @@ -23,15 +23,20 @@ export class PopoverSinonimosComponent implements OnInit { ngOnInit() { - //Seteo en la variable a emitir el sinonimo que sea padre this.popoverContent.forEach(sinonimo => { this.cantidadRestanteSinonimos.push(0); - // this.sinonimo = sinonimo.productoPadre ? sinonimo : undefined; - sinonimo.productos.forEach(producto => { + sinonimo.productos.forEach((producto, index) => { + + if (producto.id === sinonimo.productoPadre) { + sinonimo.productos.splice(index, 1); + sinonimo.productos.splice(0, 0, producto); + producto.cantidad = sinonimo.cantidad; + } else { + producto.cantidad = 0; + } - producto.cantidad = (producto.id === sinonimo.productoPadre) ? sinonimo.cantidad : 0; }) }) } -- 1.9.1