Commit c6ead4054f1718e23814a5d8044b30b78f15be51
1 parent
d292db89d5
Exists in
master
and in
2 other branches
Agregado metodo para agregar/restar cantidad de articulos
Showing
2 changed files
with
16 additions
and
2 deletions
Show diff stats
src/app/modules/carrito/carrito.component.html
... | ... | @@ -53,7 +53,8 @@ |
53 | 53 | ondragstart="return false;" |
54 | 54 | (contextmenu)="false" |
55 | 55 | class="d-block ml-auto py-2 icon-20 btn-effect" |
56 | - src="assets/img/menos-blanco.svg"> | |
56 | + src="assets/img/menos-blanco.svg" | |
57 | + (click)="substractCant(articulo)"> | |
57 | 58 | </div> |
58 | 59 | <!-- CANTIDAD --> |
59 | 60 | <div class="col px-0 align-self-center text-white"> |
... | ... | @@ -66,7 +67,8 @@ |
66 | 67 | ondragstart="return false;" |
67 | 68 | (contextmenu)="false" |
68 | 69 | class="d-block ml-auto py-2 icon-20 btn-effect" |
69 | - src="assets/img/mas-blanco.svg"> | |
70 | + src="assets/img/mas-blanco.svg" | |
71 | + (click)="addCant(articulo)"> | |
70 | 72 | </div> |
71 | 73 | </div> |
72 | 74 | </div> |
src/app/modules/carrito/carrito.component.ts
... | ... | @@ -3,6 +3,7 @@ import { Location } from '@angular/common'; |
3 | 3 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
4 | 4 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
5 | 5 | import { trigger, state, style, transition, animate } from '@angular/animations'; |
6 | +import { IArticulo } from 'src/app/interfaces/IArticulo'; | |
6 | 7 | |
7 | 8 | @Component({ |
8 | 9 | selector: 'app-carrito', |
... | ... | @@ -23,6 +24,7 @@ import { trigger, state, style, transition, animate } from '@angular/animations' |
23 | 24 | }) |
24 | 25 | export class CarritoComponent implements OnInit { |
25 | 26 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
27 | + maxCantidad = 50; | |
26 | 28 | |
27 | 29 | constructor( |
28 | 30 | private location: Location, |
... | ... | @@ -35,6 +37,16 @@ export class CarritoComponent implements OnInit { |
35 | 37 | this.articuloService.carrito.splice(index, 1); |
36 | 38 | } |
37 | 39 | |
40 | + substractCant(articulo: IArticulo) { | |
41 | + if (articulo.cantidad === 1) return; | |
42 | + articulo.cantidad--; | |
43 | + } | |
44 | + | |
45 | + addCant(articulo: IArticulo) { | |
46 | + if (articulo.cantidad >= this.maxCantidad) return; | |
47 | + articulo.cantidad++; | |
48 | + } | |
49 | + | |
38 | 50 | goBack() { |
39 | 51 | this.location.back(); |
40 | 52 | } |