Commit dd6738d0d6f4fbe66a731be0b5bb8e45781390e9
1 parent
2b3acb1761
Exists in
master
Asignando el precio total a una variable.
Showing
2 changed files
with
6 additions
and
7 deletions
 
Show diff stats
src/app/components/popover-promos/popover-promos.component.html
| 1 | <div class="card-body fade-left"> | 1 | <div class="card-body fade-left"> | 
| 2 | <div class="row"> | 2 | <div class="row"> | 
| 3 | <div class="col text-left"> | 3 | <div class="col text-left"> | 
| 4 | <p class="h5 card-title"> | 4 | <p class="h5 card-title"> | 
| 5 | Este producto forma parte<br> | 5 | Este producto forma parte<br> | 
| 6 | de Combos y Promociones | 6 | de Combos y Promociones | 
| 7 | </p> | 7 | </p> | 
| 8 | </div> | 8 | </div> | 
| 9 | </div> | 9 | </div> | 
| 10 | 10 | ||
| 11 | <div class="overflow-scroll popover-size pr-2"> | 11 | <div class="overflow-scroll popover-size pr-2"> | 
| 12 | <div | 12 | <div | 
| 13 | class="row my-2" | 13 | class="row my-2" | 
| 14 | *ngFor="let promo of popoverContent"> | 14 | *ngFor="let promo of popoverContent"> | 
| 15 | <div class="col text-dark"> | 15 | <div class="col text-dark"> | 
| 16 | <div | 16 | <div | 
| 17 | class="bg-white card-effect rounded-sm p-2 px-3" | 17 | class="bg-white card-effect rounded-sm p-2 px-3" | 
| 18 | (click)="seleccionarPromo(promo)"> | 18 | (click)="seleccionarPromo(promo)"> | 
| 19 | <div class="row justify-content-between"> | 19 | <div class="row justify-content-between"> | 
| 20 | <div class="col-12 text-left"> | 20 | <div class="col-12 text-left"> | 
| 21 | <p class="h5 mb-0"> | 21 | <p class="h5 mb-0"> | 
| 22 | <small class="font-weight-bold">{{promo.nombrePromo}}</small> | 22 | <small class="font-weight-bold">{{promo.nombrePromo}}</small> | 
| 23 | </p> | 23 | </p> | 
| 24 | </div> | 24 | </div> | 
| 25 | <div class="col-12 text-right mt-2"> | 25 | <div class="col-12 text-right mt-2"> | 
| 26 | <p class="h4 font-weight-bold mb-0"> | 26 | <p class="h4 font-weight-bold mb-0"> | 
| 27 | {{calcularPrecioDePromo(promo.productos) | currency}} | 27 | {{calcularPrecioDePromo(promo) | currency}} | 
| 28 | </p> | 28 | </p> | 
| 29 | </div> | 29 | </div> | 
| 30 | </div> | 30 | </div> | 
| 31 | </div> | 31 | </div> | 
| 32 | </div> | 32 | </div> | 
| 33 | </div> | 33 | </div> | 
| 34 | </div> | 34 | </div> | 
| 35 | 35 | ||
| 36 | <div class="row mt-3 justify-content-end"> | 36 | <div class="row mt-3 justify-content-end"> | 
| 37 | <div class="col-auto"> | 37 | <div class="col-auto"> | 
| 38 | <button | 38 | <button | 
| 39 | type="button" | 39 | type="button" | 
| 40 | class="btn btn-sm btn-light shadow" | 40 | class="btn btn-sm btn-light shadow" | 
| 41 | (click)="hide()"> | 41 | (click)="hide()"> | 
| 42 | <span class="pr-2">No, gracias</span> | 42 | <span class="pr-2">No, gracias</span> | 
| 43 | <i class="fa fa-times text-danger" aria-hidden="true"></i> | 43 | <i class="fa fa-times text-danger" aria-hidden="true"></i> | 
| 44 | </button> | 44 | </button> | 
| 45 | </div> | 45 | </div> | 
| 46 | </div> | 46 | </div> | 
| 47 | 47 | ||
| 48 | </div> | 48 | </div> | 
| 49 | 49 | 
src/app/components/popover-promos/popover-promos.component.ts
| 1 | import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; | 1 | import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; | 
| 2 | import { PopoverDirective } from 'ngx-bootstrap/popover'; | 2 | import { PopoverDirective } from 'ngx-bootstrap/popover'; | 
| 3 | import { Promocion } from 'src/app/wrappers/promocion'; | 3 | import { Promocion } from 'src/app/wrappers/promocion'; | 
| 4 | import { Producto } from 'src/app/wrappers/producto'; | 4 | import { Producto } from 'src/app/wrappers/producto'; | 
| 5 | 5 | ||
| 6 | @Component({ | 6 | @Component({ | 
| 7 | selector: 'app-popover-promos', | 7 | selector: 'app-popover-promos', | 
| 8 | templateUrl: './popover-promos.component.html', | 8 | templateUrl: './popover-promos.component.html', | 
| 9 | styleUrls: ['./popover-promos.component.scss'] | 9 | styleUrls: ['./popover-promos.component.scss'] | 
| 10 | }) | 10 | }) | 
| 11 | export class PopoverPromosComponent implements OnInit { | 11 | export class PopoverPromosComponent implements OnInit { | 
| 12 | 12 | ||
| 13 | @Input() popover: PopoverDirective; | 13 | @Input() popover: PopoverDirective; | 
| 14 | @Input() popoverContent: Promocion[]; | 14 | @Input() popoverContent: Promocion[]; | 
| 15 | @Output() promoSeleccionada = new EventEmitter<Promocion>(); | 15 | @Output() promoSeleccionada = new EventEmitter<Promocion>(); | 
| 16 | 16 | ||
| 17 | constructor() { } | 17 | constructor() { } | 
| 18 | 18 | ||
| 19 | ngOnInit() { | 19 | ngOnInit() { | 
| 20 | } | 20 | } | 
| 21 | 21 | ||
| 22 | hide() { | 22 | hide() { | 
| 23 | this.popover.hide(); | 23 | this.popover.hide(); | 
| 24 | } | 24 | } | 
| 25 | 25 | ||
| 26 | seleccionarPromo(promo: Promocion) { | 26 | seleccionarPromo(promo: Promocion) { | 
| 27 | 27 | ||
| 28 | this.promoSeleccionada.emit(promo); | 28 | this.promoSeleccionada.emit(promo); | 
| 29 | } | 29 | } | 
| 30 | 30 | ||
| 31 | calcularPrecioDePromo(productos: Producto[]) { | 31 | calcularPrecioDePromo(promo: Promocion) { | 
| 32 | 32 | ||
| 33 | var precio = 0; | 33 | promo.precioTotal = 0; | 
| 34 | productos.forEach(producto => { | 34 | promo.productos.forEach(producto => { | 
| 35 | precio += producto.PreVen; | 35 | promo.precioTotal += producto.PreVen; | 
| 36 | }) | 36 | }) | 
| 37 | 37 | return promo.precioTotal; | |
| 38 | return precio; | ||
| 39 | } | 38 | } | 
| 40 | 39 | ||
| 41 | } | 40 | } | 
| 42 | 41 |