Commit 7e604dd701068fe8cc7f7b726a927e70d1080406
1 parent
dd6738d0d6
Exists in
master
and in
1 other branch
Borradas banderas.
Showing
2 changed files
with
25 additions
and
17 deletions
Show diff stats
src/app/components/inicio/inicio.component.html
... | ... | @@ -63,16 +63,17 @@ |
63 | 63 | <!-- CARGAR PRODUCTOS --> |
64 | 64 | <ng-template #popTemplate> |
65 | 65 | <app-popover-promos |
66 | - *ngIf="productoAcargar && !productoEsPromo" | |
66 | + *ngIf="promociones.length > 0 && sinonimos.length === 0" | |
67 | 67 | [popover]="popoverDirective" |
68 | 68 | [popoverContent]="promociones" |
69 | 69 | (promoSeleccionada)="promoSeleccionada($event)" |
70 | 70 | class="text-white rounded-sm border-0"> |
71 | 71 | </app-popover-promos> |
72 | 72 | <app-popover-sinonimos |
73 | - *ngIf="promoAcargar && productoEsPromo" | |
73 | + *ngIf="sinonimos.length > 0" | |
74 | 74 | [popover]="popoverDirective" |
75 | 75 | [popoverContent]="sinonimos" |
76 | + (sinonimoSeleccionado)="sinonimoSeleccionado($event)" | |
76 | 77 | class="text-white rounded-sm border-0"> |
77 | 78 | </app-popover-sinonimos> |
78 | 79 | </ng-template> |
... | ... | @@ -106,7 +107,7 @@ |
106 | 107 | src="{{apiUrl}}/imagenes/escanner.jpg"> |
107 | 108 | |
108 | 109 | <!-- PRODUCTO A CARGAR --> |
109 | - <div class="fade-in m-0" *ngIf="productoAcargar && !productoEsPromo"> | |
110 | + <div class="fade-in m-0" *ngIf="productoAcargar && !promoAcargar"> | |
110 | 111 | <img |
111 | 112 | class="card-img-top d-block w-100 mx-auto rounded-sm" |
112 | 113 | src="{{apiUrl}}/imagenes/testImg3.jpg"> |
... | ... | @@ -122,7 +123,7 @@ |
122 | 123 | </div> |
123 | 124 | |
124 | 125 | <!-- PROMO A CARGAR --> |
125 | - <div class="fade-in m-0" *ngIf="promoAcargar && productoEsPromo"> | |
126 | + <div class="fade-in m-0" *ngIf="promoAcargar"> | |
126 | 127 | <img |
127 | 128 | class="card-img-top d-block w-100 mx-auto rounded-sm" |
128 | 129 | src="{{apiUrl}}/imagenes/testImg3.jpg"> |
... | ... | @@ -132,7 +133,7 @@ |
132 | 133 | <p class="h6 font-weight-bold mb-0">{{promoAcargar.nombrePromo}}</p> |
133 | 134 | </div> |
134 | 135 | <div class="col-12 text-right mt-2 align-self-end"> |
135 | - <p class="h5 font-weight-bold mb-0">{{productoAcargar.PreVen | currency}}</p> | |
136 | + <p class="h5 font-weight-bold mb-0">{{promoAcargar.precioTotal | currency}}</p> | |
136 | 137 | </div> |
137 | 138 | </div> |
138 | 139 | </div> |
... | ... | @@ -141,9 +142,9 @@ |
141 | 142 | <!-- BOTONES DE CARGAR PRODUCTOS--> |
142 | 143 | <div |
143 | 144 | class="col-5 pr-0" |
144 | - *ngIf="productoAcargar && tienePromo"> | |
145 | + *ngIf="promociones.length > 0"> | |
145 | 146 | <button |
146 | - *ngIf="productoEsPromo && promoAcargar.sinonimos" | |
147 | + *ngIf="sinonimos.length > 0" | |
147 | 148 | type="button" |
148 | 149 | class="btn btn-light btn-block shadow-sm" |
149 | 150 | (click)="pop.show()"> |
... | ... | @@ -151,7 +152,7 @@ |
151 | 152 | <i class="fa fa-hand-o-up text-purple" aria-hidden="true"></i> |
152 | 153 | </button> |
153 | 154 | <button |
154 | - *ngIf="!productoEsPromo" | |
155 | + *ngIf="!promoAcargar" | |
155 | 156 | type="button" |
156 | 157 | class="btn btn-primary btn-block shadow-sm" |
157 | 158 | (click)="pop.show()"> |
src/app/components/inicio/inicio.component.ts
... | ... | @@ -18,8 +18,7 @@ export class InicioComponent implements OnInit { |
18 | 18 | @ViewChild('pop', { static: false }) popoverDirective: PopoverDirective; |
19 | 19 | private productoAcargar: Producto; |
20 | 20 | private promoAcargar: Promocion; |
21 | - private tienePromo = false; | |
22 | - private productoEsPromo = false; | |
21 | + private sinonimoAcargar: Sinonimo; | |
23 | 22 | |
24 | 23 | promociones: Promocion[] = []; |
25 | 24 | sinonimos: Sinonimo[] = []; |
... | ... | @@ -43,12 +42,10 @@ export class InicioComponent implements OnInit { |
43 | 42 | setTimeout(() => { |
44 | 43 | this.productoService.productos.push(this.productoAcargar); |
45 | 44 | this.productoAcargar = undefined; |
46 | - this.tienePromo = false; | |
47 | 45 | }, 2000) |
48 | 46 | } else { |
49 | 47 | |
50 | 48 | this.promociones = res; |
51 | - this.tienePromo = true; | |
52 | 49 | this.popoverDirective.show(); |
53 | 50 | } |
54 | 51 | }, error => { console.error(error); }) |
... | ... | @@ -66,27 +63,32 @@ export class InicioComponent implements OnInit { |
66 | 63 | } |
67 | 64 | |
68 | 65 | deshacerCarga() { |
69 | - if (this.productoEsPromo) { | |
66 | + | |
67 | + if (this.sinonimoAcargar || this.sinonimos.length > 0) { | |
68 | + this.sinonimos = []; | |
69 | + this.sinonimoAcargar = undefined; | |
70 | + this.popoverDirective.hide(); | |
71 | + } | |
72 | + | |
73 | + if (this.promoAcargar) { | |
70 | 74 | this.promoAcargar = undefined; |
71 | - this.productoEsPromo = false; | |
72 | 75 | this.popoverDirective.show(); |
73 | 76 | } else { |
74 | 77 | this.productoAcargar = undefined; |
75 | - this.tienePromo = false; | |
78 | + this.promociones = []; | |
76 | 79 | this.popoverDirective.hide(); |
77 | 80 | } |
78 | 81 | } |
79 | 82 | |
80 | 83 | promoSeleccionada($event: Promocion) { |
81 | 84 | |
82 | - this.productoEsPromo = true; | |
83 | 85 | this.promoAcargar = $event; |
84 | 86 | this.popoverDirective.hide(); |
85 | 87 | if (this.promoAcargar.sinonimos) { |
86 | 88 | var sector = this.promoAcargar.sector; |
87 | 89 | var codigo = this.promoAcargar.codigo; |
88 | 90 | this.productoService.getPromocionSinonimos(sector, codigo) |
89 | - .subscribe((res : Sinonimo[]) => { | |
91 | + .subscribe((res: Sinonimo[]) => { | |
90 | 92 | |
91 | 93 | this.sinonimos = res; |
92 | 94 | this.showPopover(); |
... | ... | @@ -94,4 +96,9 @@ export class InicioComponent implements OnInit { |
94 | 96 | } |
95 | 97 | } |
96 | 98 | |
99 | + sinonimoSeleccionado($event: Sinonimo) { | |
100 | + | |
101 | + this.sinonimoAcargar = $event; | |
102 | + } | |
103 | + | |
97 | 104 | } |