Commit e1bda7ef4ce3046d488c0c764aed4eb62a546b22
1 parent
e6c4e964d4
Exists in
develop
agrego modal sinonimos al header publicidad
Showing
1 changed file
with
37 additions
and
1 deletions
 
Show diff stats
src/app/shared/header-publicidad/header-publicidad.component.ts
| ... | ... | @@ -7,6 +7,9 @@ import { PromocionComponent } from '../promocion/promocion.component'; | 
| 7 | 7 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; | 
| 8 | 8 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 
| 9 | 9 | import { ConfirmacionComponent } from '../confirmacion/confirmacion.component'; | 
| 10 | +import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; | |
| 11 | +import { ISinonimo } from 'src/app/interfaces/ISinonimo'; | |
| 12 | +import { SinonimoComponent } from '../sinonimo/sinonimo.component'; | |
| 10 | 13 | |
| 11 | 14 | @Component({ | 
| 12 | 15 | selector: 'app-header-publicidad', | 
| ... | ... | @@ -22,6 +25,7 @@ export class HeaderPublicidadComponent implements OnInit { | 
| 22 | 25 | private publicidadService: PublicidadService, | 
| 23 | 26 | private articuloService: ArticuloService, | 
| 24 | 27 | private modalService: BsModalService, | 
| 28 | + private sinonimoService: SinonimoService | |
| 25 | 29 | ) { } | 
| 26 | 30 | |
| 27 | 31 | ngOnInit() { | 
| ... | ... | @@ -77,10 +81,42 @@ export class HeaderPublicidadComponent implements OnInit { | 
| 77 | 81 | class: 'modal-promo modal-dialog-centered' | 
| 78 | 82 | }); | 
| 79 | 83 | this.modalRef.content.onClose.subscribe(() => { | 
| 80 | - this.articuloService.setArticulo(articulo); | |
| 84 | + this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) | |
| 85 | + .subscribe((res: ISinonimo[]) => { | |
| 86 | + if (res.length) { | |
| 87 | + this.openModalSinonimos(res, articulo); | |
| 88 | + } else { | |
| 89 | + articulo.cantidad = 1; | |
| 90 | + this.articuloService.setArticulo(articulo); | |
| 91 | + } | |
| 92 | + }, err => console.error(err)); | |
| 81 | 93 | }); | 
| 94 | + this.mediaPantalla(); | |
| 82 | 95 | } | 
| 83 | 96 | |
| 97 | + openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { | |
| 98 | + const modalSinonimo = this.modalService.show(SinonimoComponent, { | |
| 99 | + initialState: { sinonimos: sinonimosData }, | |
| 100 | + class: 'modal-promo modal-dialog-centered' | |
| 101 | + }); | |
| 102 | + modalSinonimo.content.onClose | |
| 103 | + .subscribe((res: any) => { | |
| 104 | + for (const a of articulo.productos) { | |
| 105 | + if (a.idSinonimo === res.ID_SIN) { | |
| 106 | + a.CODA = res.articulo.CodArt; | |
| 107 | + a.CodArt = res.articulo.CodArt; | |
| 108 | + a.SECA = res.articulo.CodSec; | |
| 109 | + a.CodSec = res.articulo.CodSec; | |
| 110 | + a.PreVen = res.articulo.PreVen; | |
| 111 | + a.id = res.articulo.id; | |
| 112 | + a.DET_LAR = res.articulo.DET_LAR; | |
| 113 | + a.DetArt = res.articulo.DetArt; | |
| 114 | + } | |
| 115 | + } | |
| 116 | + this.articuloService.setArticulo(articulo); | |
| 117 | + }); | |
| 118 | +} | |
| 119 | + | |
| 84 | 120 | mediaPantalla() { | 
| 85 | 121 | if ($('body').hasClass('media-pantalla')) { | 
| 86 | 122 | $('#headerPublicidad,#headerPad').addClass('media-pantalla'); |