Commit 2674b526a0ce91458dff6a66c1126c03e0c909bb
1 parent
be87ffca1a
Exists in
develop
Fix - Add
Refactor aplicadas reglas de lint Seleccion de sinonimos
Showing
11 changed files
with
93 additions
and
38 deletions
Show diff stats
src/app/modules/carrito/carrito.component.ts
... | ... | @@ -42,7 +42,7 @@ export class CarritoComponent implements OnInit, OnDestroy { |
42 | 42 | this.router.navigate(['']); |
43 | 43 | return; |
44 | 44 | } |
45 | - this.mediaPantallaP() | |
45 | + this.mediaPantallaP(); | |
46 | 46 | } |
47 | 47 | |
48 | 48 | ngOnDestroy() { |
... | ... | @@ -50,8 +50,7 @@ export class CarritoComponent implements OnInit, OnDestroy { |
50 | 50 | } |
51 | 51 | |
52 | 52 | deleteArticulo(index: number) { |
53 | - this.articuloService.carrito.splice(index, 1); | |
54 | - this.articuloService.calcularTotal(); | |
53 | + this.articuloService.deleteArticulo(index); | |
55 | 54 | } |
56 | 55 | |
57 | 56 | substractCant(articulo: IArticulo) { |
... | ... | @@ -76,6 +75,12 @@ export class CarritoComponent implements OnInit, OnDestroy { |
76 | 75 | this.inactiveScreen.startTimeOutInactividad(); |
77 | 76 | } |
78 | 77 | |
78 | + @HostListener('scroll', ['$event']) | |
79 | + scrollEvent(event: Event) { | |
80 | + clearTimeout(this.inactiveScreen.timerReposo); | |
81 | + this.inactiveScreen.startTimeOutInactividad(); | |
82 | + } | |
83 | + | |
79 | 84 | mediaPantallaP() { |
80 | 85 | if ($('body').hasClass('media-pantalla')) { |
81 | 86 | $('.carrito-content,.carrito-articulo').addClass('media-pantalla'); |
src/app/modules/forma-pago/forma-pago.component.ts
1 | -import { Component, OnInit } from "@angular/core"; | |
2 | -import { ArticuloService } from "src/app/services/articulo/articulo.service"; | |
3 | -import { Router } from "@angular/router"; | |
1 | +import { Component, OnInit } from '@angular/core'; | |
2 | +import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | |
3 | +import { Router } from '@angular/router'; | |
4 | 4 | |
5 | 5 | @Component({ |
6 | - selector: "app-forma-pago", | |
7 | - templateUrl: "./forma-pago.component.html", | |
8 | - styleUrls: ["./forma-pago.component.scss"] | |
6 | + selector: 'app-forma-pago', | |
7 | + templateUrl: './forma-pago.component.html', | |
8 | + styleUrls: ['./forma-pago.component.scss'] | |
9 | 9 | }) |
10 | 10 | export class FormaPagoComponent implements OnInit { |
11 | 11 | constructor( |
... | ... | @@ -15,7 +15,7 @@ export class FormaPagoComponent implements OnInit { |
15 | 15 | |
16 | 16 | ngOnInit() { |
17 | 17 | if (!this.articuloService.carrito.length) { |
18 | - this.router.navigate([""]); | |
18 | + this.router.navigate(['']); | |
19 | 19 | return; |
20 | 20 | } |
21 | 21 | this.mediaPantalla(); |
... | ... | @@ -25,10 +25,10 @@ export class FormaPagoComponent implements OnInit { |
25 | 25 | this.articuloService.medioPago = medioPago; |
26 | 26 | switch (medioPago) { |
27 | 27 | case 4: |
28 | - this.router.navigate(["pago-tarjeta"]); | |
28 | + this.router.navigate(['pago-tarjeta']); | |
29 | 29 | break; |
30 | 30 | case 9: |
31 | - this.router.navigate(["pago-electronico"]); | |
31 | + this.router.navigate(['pago-electronico']); | |
32 | 32 | break; |
33 | 33 | } |
34 | 34 | } |
src/app/modules/info-formas-pago/info-formas-pago.component.ts
... | ... | @@ -7,13 +7,13 @@ import { Component, OnInit } from '@angular/core'; |
7 | 7 | }) |
8 | 8 | export class InfoFormasPagoComponent implements OnInit { |
9 | 9 | mediaPantalla = false; |
10 | - | |
11 | - constructor() {} | |
10 | + | |
11 | + constructor() { } | |
12 | 12 | |
13 | 13 | ngOnInit() { |
14 | 14 | this.reducirPantalla(); |
15 | 15 | } |
16 | - | |
16 | + | |
17 | 17 | reducirPantalla() { |
18 | 18 | if ($('body').hasClass('media-pantalla')) { |
19 | 19 | $('.reduce-card-1,.reduce-card-2').addClass('media-pantalla'); |
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
... | ... | @@ -154,10 +154,9 @@ export class SeleccionArticulosComponent implements OnInit, OnDestroy { |
154 | 154 | if (res.length) { |
155 | 155 | this.openModalSinonimos(res); |
156 | 156 | } else { |
157 | - articulo.cantidad = 1; | |
158 | 157 | this.articuloService.setArticulo(articulo); |
159 | 158 | } |
160 | - }) | |
159 | + }); | |
161 | 160 | } |
162 | 161 | |
163 | 162 | openModalPromos(articulo: IArticulo) { |
... | ... | @@ -172,11 +171,15 @@ export class SeleccionArticulosComponent implements OnInit, OnDestroy { |
172 | 171 | initialState: { sinonimos: sinonimosData }, |
173 | 172 | class: 'modal-promo modal-dialog-centered' |
174 | 173 | }); |
174 | + | |
175 | + this.modalRef.content.onClose | |
176 | + .subscribe((articulo: IArticulo) => { | |
177 | + this.articuloService.setArticulo(articulo); | |
178 | + }); | |
175 | 179 | } |
176 | 180 | |
177 | 181 | deleteArticulo(index: number) { |
178 | - this.articuloService.carrito.splice(index, 1); | |
179 | - this.articuloService.calcularTotal(); | |
182 | + this.articuloService.deleteArticulo(index); | |
180 | 183 | } |
181 | 184 | |
182 | 185 | increaseShow() { |
src/app/modules/splash-screen/splash-screen.component.ts
1 | -import { Component, OnInit } from "@angular/core"; | |
1 | +import { Component, OnInit } from '@angular/core'; | |
2 | 2 | |
3 | 3 | @Component({ |
4 | - selector: "app-splash-screen", | |
5 | - templateUrl: "./splash-screen.component.html", | |
6 | - styleUrls: ["./splash-screen.component.scss"] | |
4 | + selector: 'app-splash-screen', | |
5 | + templateUrl: './splash-screen.component.html', | |
6 | + styleUrls: ['./splash-screen.component.scss'] | |
7 | 7 | }) |
8 | 8 | export class SplashScreenComponent implements OnInit { |
9 | 9 | timerSplashScreen = 2000; |
10 | 10 | showSplashScreen = true; |
11 | - textWelcome = "BIENVENIDO A SPOT!"; | |
12 | - textComoEstas = "ยฟcรณmo estรกs?"; | |
13 | - textInvitamos = "TE INVITAMOS A HACER"; | |
14 | - textTuPedido = "tu pedido acรก"; | |
11 | + textWelcome = 'BIENVENIDO A SPOT!'; | |
12 | + textComoEstas = 'ยฟcรณmo estรกs?'; | |
13 | + textInvitamos = 'TE INVITAMOS A HACER'; | |
14 | + textTuPedido = 'tu pedido acรก'; | |
15 | 15 | |
16 | 16 | constructor() {} |
17 | 17 |
src/app/services/articulo/articulo.service.ts
... | ... | @@ -42,6 +42,7 @@ export class ArticuloService { |
42 | 42 | } |
43 | 43 | |
44 | 44 | setArticulo(articulo: IArticulo) { |
45 | + articulo.cantidad = 1; | |
45 | 46 | for (const articuloCarrito of this.carrito) { |
46 | 47 | if (articuloCarrito.id === articulo.id) { |
47 | 48 | articuloCarrito.cantidad++; |
... | ... | @@ -54,6 +55,11 @@ export class ArticuloService { |
54 | 55 | this.calcularTotal(); |
55 | 56 | } |
56 | 57 | |
58 | + deleteArticulo(index: number) { | |
59 | + this.carrito.splice(index, 1); | |
60 | + this.calcularTotal(); | |
61 | + } | |
62 | + | |
57 | 63 | pay(dataPago: any) { |
58 | 64 | return new Observable((observer) => { |
59 | 65 | this.clienteService.getById(-1) |
src/app/shared/footer/footer.component.ts
... | ... | @@ -7,15 +7,31 @@ import { Location } from '@angular/common'; |
7 | 7 | styleUrls: ['./footer.component.scss'] |
8 | 8 | }) |
9 | 9 | export class FooterComponent implements OnInit { |
10 | - constructor(private location: Location) {} | |
10 | + constructor(private location: Location) { } | |
11 | 11 | |
12 | - ngOnInit() {} | |
12 | + ngOnInit() { } | |
13 | 13 | |
14 | 14 | goBack() { |
15 | 15 | this.location.back(); |
16 | 16 | } |
17 | 17 | |
18 | 18 | reducirPantalla() { |
19 | - $('body,.reduce-card-1,.reduce-card-2,#content,.cat-content,.cat-btn,.cat-box,#boxCarrito,#headerPublicidad,#headerPad,.img-categoria,.carrito-articulo,.carrito-content,.pago-tarjeta,.modal-promo').toggleClass('media-pantalla'); | |
19 | + $(` | |
20 | + body, | |
21 | + .reduce-card-1, | |
22 | + .reduce-card-2, | |
23 | + #content, | |
24 | + .cat-content, | |
25 | + .cat-btn, | |
26 | + .cat-box, | |
27 | + #boxCarrito, | |
28 | + #headerPublicidad, | |
29 | + #headerPad, | |
30 | + .img-categoria, | |
31 | + .carrito-articulo, | |
32 | + .carrito-content, | |
33 | + .pago-tarjeta, | |
34 | + .modal-promo`) | |
35 | + .toggleClass('media-pantalla'); | |
20 | 36 | } |
21 | 37 | } |
src/app/shared/header-publicidad/header-publicidad.component.ts
src/app/shared/promocion/promocion.component.ts
... | ... | @@ -22,7 +22,7 @@ export class PromocionComponent implements OnInit { |
22 | 22 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
23 | 23 | |
24 | 24 | constructor( |
25 | - public modalRef: BsModalRef, | |
25 | + public modalPromocion: BsModalRef, | |
26 | 26 | private modalService: BsModalService, |
27 | 27 | private articuloService: ArticuloService, |
28 | 28 | private promocionService: PromocionService, |
... | ... | @@ -44,17 +44,23 @@ export class PromocionComponent implements OnInit { |
44 | 44 | } else { |
45 | 45 | promo.cantidad = 1; |
46 | 46 | this.articuloService.setArticulo(promo); |
47 | - this.modalRef.hide(); | |
47 | + this.modalPromocion.hide(); | |
48 | 48 | } |
49 | 49 | }, err => console.error(err)); |
50 | 50 | this.mediaPantalla(); |
51 | 51 | } |
52 | 52 | |
53 | 53 | openModalSinonimos(sinonimosData: ISinonimo[]) { |
54 | - this.modalRef = this.modalService.show(SinonimoComponent, { | |
54 | + const modalSinonimo = this.modalService.show(SinonimoComponent, { | |
55 | 55 | initialState: { sinonimos: sinonimosData }, |
56 | 56 | class: 'modal-promo modal-dialog-centered' |
57 | 57 | }); |
58 | + | |
59 | + modalSinonimo.content.onClose | |
60 | + .subscribe((articulo: IArticulo) => { | |
61 | + this.articuloService.setArticulo(articulo); | |
62 | + this.modalPromocion.hide(); | |
63 | + }); | |
58 | 64 | } |
59 | 65 | |
60 | 66 | getPromociones() { |
src/app/shared/sinonimo/sinonimo.component.html
... | ... | @@ -28,7 +28,8 @@ |
28 | 28 | <div class="modal-footer"> |
29 | 29 | <div |
30 | 30 | [ngClass]="validate()" |
31 | - class="d-inline-block py-1 btn-effect bg-white badge-pill text-primary"> | |
31 | + class="d-inline-block py-1 btn-effect bg-white badge-pill text-primary" | |
32 | + (click)="continue()"> | |
32 | 33 | CONTINUAR |
33 | 34 | <img |
34 | 35 | draggable="false" |
src/app/shared/sinonimo/sinonimo.component.ts
1 | 1 | import { Component, OnInit } from '@angular/core'; |
2 | 2 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; |
3 | 3 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
4 | +import { BsModalRef } from 'ngx-bootstrap/modal'; | |
5 | +import { Subject } from 'rxjs'; | |
6 | +import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | |
4 | 7 | |
5 | 8 | @Component({ |
6 | 9 | selector: 'app-sinonimo', |
... | ... | @@ -10,19 +13,27 @@ import { IArticulo } from 'src/app/interfaces/IArticulo'; |
10 | 13 | export class SinonimoComponent implements OnInit { |
11 | 14 | sinonimos: ISinonimo[] = []; |
12 | 15 | isValid: boolean; |
16 | + onClose: Subject<any>; | |
17 | + articuloSelected: IArticulo; | |
13 | 18 | |
14 | - constructor() { } | |
19 | + constructor( | |
20 | + private modalRef: BsModalRef, | |
21 | + private articuloService: ArticuloService, | |
22 | + ) { | |
23 | + this.onClose = new Subject(); | |
24 | + } | |
15 | 25 | |
16 | 26 | ngOnInit() { |
17 | 27 | } |
18 | 28 | |
19 | 29 | selectArticulo(articulo: IArticulo) { |
20 | 30 | for (const s of this.sinonimos) { |
21 | - for (const articulo of s.productos) { | |
22 | - articulo.seleccionado = false; | |
31 | + for (const a of s.productos) { | |
32 | + a.seleccionado = false; | |
23 | 33 | } |
24 | 34 | } |
25 | 35 | articulo.seleccionado = true; |
36 | + this.articuloSelected = articulo; | |
26 | 37 | } |
27 | 38 | |
28 | 39 | validate() { |
... | ... | @@ -37,4 +48,12 @@ export class SinonimoComponent implements OnInit { |
37 | 48 | return !this.isValid ? 'disabled' : ''; |
38 | 49 | } |
39 | 50 | |
51 | + continue() { | |
52 | + this.articuloService.getById(this.articuloSelected.id) | |
53 | + .subscribe((res: IArticulo) => { | |
54 | + this.modalRef.hide(); | |
55 | + this.onClose.next(res); | |
56 | + }); | |
57 | + } | |
58 | + | |
40 | 59 | } |