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; }) }) }