Commit e89398eb9e98b56ef0a02997e315657d54924f39
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master(benjamin) See merge request !120
Showing
6 changed files
Show diff stats
src/app/components/confirmacion-carrito/confirmacion-carrito.component.html
src/app/components/home/home.component.html
1 | 1 | <div class="container-fluid p-0"> |
2 | 2 | <img |
3 | - src="{{apiImagenes}}/imagenes/homeBackground.jpg" | |
3 | + src="../../../assets/img/homeBackground.jpg" | |
4 | 4 | class="background-image vh-100 w-100"> |
5 | 5 | <div |
6 | 6 | class="fade-in vh-100 d-flex align-content-between flex-wrap disable-user-select" |
... | ... | @@ -28,7 +28,7 @@ |
28 | 28 | <!-- FOOTER --> |
29 | 29 | <div class="vh-15 row m-0 flex-row-reverse w-100 bg-gray"> |
30 | 30 | <div class="h-100 w-50 bg-white rounded-top-left"> |
31 | - <img class="h-100 p-2 m-auto d-block" src="{{apiImagenes}}/imagenes/logodebo.png"> | |
31 | + <img class="h-100 p-2 m-auto d-block" src="../../../assets/img/logodebo.png"> | |
32 | 32 | </div> |
33 | 33 | </div> |
34 | 34 |
src/app/components/inicio/inicio.component.ts
... | ... | @@ -33,7 +33,6 @@ export class InicioComponent implements OnInit, AfterViewInit { |
33 | 33 | } else { |
34 | 34 | this.busqueda += e.key; |
35 | 35 | } |
36 | - | |
37 | 36 | }; |
38 | 37 | |
39 | 38 | constructor( |
... | ... | @@ -90,11 +89,15 @@ export class InicioComponent implements OnInit, AfterViewInit { |
90 | 89 | }, error => { console.error(error); }) |
91 | 90 | } |
92 | 91 | |
93 | - confirmarProducto() { | |
92 | + confirmarProducto(cantidad?: number) { | |
94 | 93 | |
95 | 94 | let producto = this.promoAcargar ? this.promoAcargar : this.productoAcargar; |
96 | 95 | |
97 | - producto.cantidad = producto.cantidad ? producto.cantidad : 1; | |
96 | + if (cantidad) { | |
97 | + producto.cantidad = cantidad; | |
98 | + } else { | |
99 | + producto.cantidad = producto.cantidad ? producto.cantidad : 1; | |
100 | + } | |
98 | 101 | |
99 | 102 | this.productoService.setProductos(producto); |
100 | 103 | this.productoService.productoAcargar = this.promoAcargar = this.productoAcargar = undefined; |
... | ... | @@ -147,9 +150,9 @@ export class InicioComponent implements OnInit, AfterViewInit { |
147 | 150 | }) |
148 | 151 | } |
149 | 152 | |
150 | - productosPersonalizados($event: Producto[]) { | |
153 | + productosPersonalizados($event: any) { | |
151 | 154 | |
152 | - let productosPersonalizados = $event; | |
155 | + let productosPersonalizados = $event.productosAenviar; | |
153 | 156 | |
154 | 157 | productosPersonalizados.forEach(productoElegido => { |
155 | 158 | |
... | ... | @@ -159,8 +162,7 @@ export class InicioComponent implements OnInit, AfterViewInit { |
159 | 162 | }); |
160 | 163 | |
161 | 164 | this.promoAcargar.productos = this.promoAcargar.productos.concat(productosPersonalizados); |
162 | - | |
163 | - this.confirmarProducto(); | |
165 | + this.confirmarProducto($event.cantidadPromo); | |
164 | 166 | } |
165 | 167 | |
166 | 168 | buscarByCodigoBarras(busqueda) { |
src/app/components/popover-sinonimos/popover-sinonimos.component.html
... | ... | @@ -13,6 +13,32 @@ |
13 | 13 | <div class="row mb-2" *ngFor="let sinonimo of popoverContent; let i = index"> |
14 | 14 | <div class="col p-0"> |
15 | 15 | |
16 | + <div class="row py-2 mb-3"> | |
17 | + <div class="col-12"> | |
18 | + <div class="btn-group float-right my-auto" role="group"> | |
19 | + <button | |
20 | + type="button" | |
21 | + class="btn btn-light my-auto border shadow" | |
22 | + (click)="sumarCantidadPromo()"> | |
23 | + <i class="fa fa-plus" aria-hidden="true"></i> | |
24 | + </button> | |
25 | + <div class="bg-white border border-white px-3 py-1 my-auto text-dark h5"> | |
26 | + <small | |
27 | + class="font-weight-bold"> | |
28 | + {{cantidadPromo}} | |
29 | + </small> | |
30 | + </div> | |
31 | + <button | |
32 | + type="button" | |
33 | + class="btn btn-light my-auto border shadow" | |
34 | + (click)="restarCantidadPromo()" | |
35 | + [disabled]="cantidadRestanteSinonimos < cantidadOriginal || cantidadPromo === 1"> | |
36 | + <i class="fa fa-minus" aria-hidden="true"></i> | |
37 | + </button> | |
38 | + </div> | |
39 | + </div> | |
40 | + </div> | |
41 | + | |
16 | 42 | <div class="row bg-white text-dark m-0 py-1 shadow"> |
17 | 43 | <div class="col text-left"> |
18 | 44 | <p class="h5 m-0 card-title"> |
... | ... | @@ -36,6 +62,7 @@ |
36 | 62 | {{producto.DetArt}} |
37 | 63 | </p> |
38 | 64 | </div> |
65 | + <!-- SUMA -RESTA CANTIDAD DE PRODUCTOS --> | |
39 | 66 | <div class="col-5 pr-0"> |
40 | 67 | <div class="btn-group float-right my-auto" role="group"> |
41 | 68 | <button |
src/app/components/popover-sinonimos/popover-sinonimos.component.ts
... | ... | @@ -14,10 +14,12 @@ export class PopoverSinonimosComponent implements OnInit { |
14 | 14 | //Directiva del popover, para poder cerrarlo desde este componente |
15 | 15 | @Input() popover: PopoverDirective; |
16 | 16 | @Input() popoverContent: Sinonimo[]; |
17 | - @Output() productosPersonalizados = new EventEmitter<Producto[]>(); | |
18 | - // sinonimo: Sinonimo; | |
19 | - | |
17 | + @Output() productosPersonalizados = new EventEmitter<any>(); | |
18 | + private cantMin: number = 1; | |
19 | + private cantMax: number = 50; | |
20 | 20 | private cantidadRestanteSinonimos: number = 0; |
21 | + private cantidadOriginal: number = 0; | |
22 | + private cantidadPromo: number = 1; | |
21 | 23 | |
22 | 24 | constructor(private productoService: ProductoService) { } |
23 | 25 | |
... | ... | @@ -30,8 +32,10 @@ export class PopoverSinonimosComponent implements OnInit { |
30 | 32 | if (this.productoService.esPromoPersonalizada) { |
31 | 33 | producto.cantidad = producto.cantidad ? producto.cantidad : 0; |
32 | 34 | this.cantidadRestanteSinonimos = 0; |
35 | + this.cantidadOriginal = 0; | |
33 | 36 | } else { |
34 | 37 | this.cantidadRestanteSinonimos += producto.cantidad ? producto.cantidad : 0; |
38 | + this.cantidadOriginal += producto.cantidad ? producto.cantidad : 0; | |
35 | 39 | producto.cantidad = 0; |
36 | 40 | } |
37 | 41 | |
... | ... | @@ -43,7 +47,6 @@ export class PopoverSinonimosComponent implements OnInit { |
43 | 47 | |
44 | 48 | //Si aún quedan articulos que agregar no deja continuar. |
45 | 49 | if (this.cantidadRestanteSinonimos > 0) return; |
46 | - | |
47 | 50 | var productosAenviar: Producto[] = []; |
48 | 51 | |
49 | 52 | this.popoverContent.forEach(sinonimo => { |
... | ... | @@ -52,13 +55,13 @@ export class PopoverSinonimosComponent implements OnInit { |
52 | 55 | |
53 | 56 | if (producto.cantidad > 0) { |
54 | 57 | producto.idSinonimo = sinonimo.ID_SIN; |
58 | + | |
55 | 59 | productosAenviar.push(producto); |
56 | 60 | } |
57 | 61 | }) |
58 | - | |
59 | 62 | }) |
60 | 63 | |
61 | - this.productosPersonalizados.emit(productosAenviar); | |
64 | + this.productosPersonalizados.emit({productosAenviar: productosAenviar, cantidadPromo: this.cantidadPromo}); | |
62 | 65 | this.popover.hide(); |
63 | 66 | } |
64 | 67 | |
... | ... | @@ -77,4 +80,20 @@ export class PopoverSinonimosComponent implements OnInit { |
77 | 80 | this.cantidadRestanteSinonimos++; |
78 | 81 | } |
79 | 82 | |
83 | + sumarCantidadPromo() { | |
84 | + | |
85 | + if (this.cantidadPromo < this.cantMax) { | |
86 | + this.cantidadPromo++; | |
87 | + this.cantidadRestanteSinonimos += this.cantidadOriginal; | |
88 | + } | |
89 | + } | |
90 | + | |
91 | + restarCantidadPromo() { | |
92 | + | |
93 | + if (this.cantidadPromo > this.cantMin) { | |
94 | + this.cantidadPromo--; | |
95 | + this.cantidadRestanteSinonimos -= this.cantidadOriginal; | |
96 | + } | |
97 | + } | |
98 | + | |
80 | 99 | } |
src/app/components/sidebar/sidebar.component.html
... | ... | @@ -28,7 +28,8 @@ |
28 | 28 | <button |
29 | 29 | type="button" |
30 | 30 | class="btn btn-light btn-sm border shadow" |
31 | - (click)="aumentarCantidad(producto)"> | |
31 | + (click)="aumentarCantidad(producto)" | |
32 | + [hidden]="producto.PRO"> | |
32 | 33 | <i class="fa fa-plus" aria-hidden="true"></i> |
33 | 34 | </button> |
34 | 35 | <div class="bg-white border border-white my-auto px-2 text-dark h5 shadow"> |
... | ... | @@ -37,7 +38,8 @@ |
37 | 38 | <button |
38 | 39 | type="button" |
39 | 40 | class="btn btn-light btn-sm border shadow" |
40 | - (click)="restarCantidad(producto)"> | |
41 | + (click)="restarCantidad(producto)" | |
42 | + [hidden]="producto.PRO"> | |
41 | 43 | <i class="fa fa-minus" aria-hidden="true"></i> |
42 | 44 | </button> |
43 | 45 | </div> |