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
| 1 | import { Component, OnInit, OnDestroy, HostListener } from '@angular/core'; | 1 | import { Component, OnInit, OnDestroy, HostListener } from '@angular/core'; |
| 2 | import { Location } from '@angular/common'; | 2 | import { Location } from '@angular/common'; |
| 3 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 3 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
| 4 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 4 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
| 5 | import { trigger, state, style, transition, animate } from '@angular/animations'; | 5 | import { trigger, state, style, transition, animate } from '@angular/animations'; |
| 6 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | 6 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
| 7 | import { Router } from '@angular/router'; | 7 | import { Router } from '@angular/router'; |
| 8 | import { BsModalRef } from 'ngx-bootstrap/modal/public_api'; | 8 | import { BsModalRef } from 'ngx-bootstrap/modal/public_api'; |
| 9 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; | 9 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; |
| 10 | 10 | ||
| 11 | @Component({ | 11 | @Component({ |
| 12 | selector: 'app-carrito', | 12 | selector: 'app-carrito', |
| 13 | templateUrl: './carrito.component.html', | 13 | templateUrl: './carrito.component.html', |
| 14 | styleUrls: ['./carrito.component.scss'], | 14 | styleUrls: ['./carrito.component.scss'], |
| 15 | animations: [ | 15 | animations: [ |
| 16 | trigger('EnterLeave', [ | 16 | trigger('EnterLeave', [ |
| 17 | state('flyIn', style({ transform: 'translateX(0)' })), | 17 | state('flyIn', style({ transform: 'translateX(0)' })), |
| 18 | transition(':enter', [ | 18 | transition(':enter', [ |
| 19 | style({ transform: 'translateX(-100%)' }), | 19 | style({ transform: 'translateX(-100%)' }), |
| 20 | animate('1s ease-in') | 20 | animate('1s ease-in') |
| 21 | ]), | 21 | ]), |
| 22 | transition(':leave', [ | 22 | transition(':leave', [ |
| 23 | animate('1s ease-out', style({ transform: 'translateX(-100%)' })) | 23 | animate('1s ease-out', style({ transform: 'translateX(-100%)' })) |
| 24 | ]) | 24 | ]) |
| 25 | ]) | 25 | ]) |
| 26 | ] | 26 | ] |
| 27 | }) | 27 | }) |
| 28 | export class CarritoComponent implements OnInit, OnDestroy { | 28 | export class CarritoComponent implements OnInit, OnDestroy { |
| 29 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; | 29 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
| 30 | maxCantidad = 50; | 30 | maxCantidad = 50; |
| 31 | modalRef: BsModalRef; | 31 | modalRef: BsModalRef; |
| 32 | 32 | ||
| 33 | constructor( | 33 | constructor( |
| 34 | public articuloService: ArticuloService, | 34 | public articuloService: ArticuloService, |
| 35 | private location: Location, | 35 | private location: Location, |
| 36 | private router: Router, | 36 | private router: Router, |
| 37 | private inactiveScreen: InactiveScreenService, | 37 | private inactiveScreen: InactiveScreenService, |
| 38 | ) { } | 38 | ) { } |
| 39 | 39 | ||
| 40 | ngOnInit() { | 40 | ngOnInit() { |
| 41 | if (!this.articuloService.carrito.length) { | 41 | if (!this.articuloService.carrito.length) { |
| 42 | this.router.navigate(['']); | 42 | this.router.navigate(['']); |
| 43 | return; | 43 | return; |
| 44 | } | 44 | } |
| 45 | this.mediaPantallaP() | 45 | this.mediaPantallaP(); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | ngOnDestroy() { | 48 | ngOnDestroy() { |
| 49 | if (this.modalRef) this.modalRef.hide(); | 49 | if (this.modalRef) this.modalRef.hide(); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | deleteArticulo(index: number) { | 52 | deleteArticulo(index: number) { |
| 53 | this.articuloService.carrito.splice(index, 1); | 53 | this.articuloService.deleteArticulo(index); |
| 54 | this.articuloService.calcularTotal(); | ||
| 55 | } | 54 | } |
| 56 | 55 | ||
| 57 | substractCant(articulo: IArticulo) { | 56 | substractCant(articulo: IArticulo) { |
| 58 | if (articulo.cantidad === 1) return; | 57 | if (articulo.cantidad === 1) return; |
| 59 | articulo.cantidad--; | 58 | articulo.cantidad--; |
| 60 | this.articuloService.calcularTotal(); | 59 | this.articuloService.calcularTotal(); |
| 61 | } | 60 | } |
| 62 | 61 | ||
| 63 | addCant(articulo: IArticulo) { | 62 | addCant(articulo: IArticulo) { |
| 64 | if (articulo.cantidad >= this.maxCantidad) return; | 63 | if (articulo.cantidad >= this.maxCantidad) return; |
| 65 | articulo.cantidad++; | 64 | articulo.cantidad++; |
| 66 | this.articuloService.calcularTotal(); | 65 | this.articuloService.calcularTotal(); |
| 67 | } | 66 | } |
| 68 | 67 | ||
| 69 | goBack() { | 68 | goBack() { |
| 70 | this.location.back(); | 69 | this.location.back(); |
| 71 | } | 70 | } |
| 72 | 71 | ||
| 73 | @HostListener('document:click', ['$event']) | 72 | @HostListener('document:click', ['$event']) |
| 74 | eventListener(event: Event) { | 73 | eventListener(event: Event) { |
| 75 | clearTimeout(this.inactiveScreen.timerReposo); | 74 | clearTimeout(this.inactiveScreen.timerReposo); |
| 76 | this.inactiveScreen.startTimeOutInactividad(); | 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 | mediaPantallaP() { | 84 | mediaPantallaP() { |
| 80 | if ($('body').hasClass('media-pantalla')) { | 85 | if ($('body').hasClass('media-pantalla')) { |
| 81 | $('.carrito-content,.carrito-articulo').addClass('media-pantalla'); | 86 | $('.carrito-content,.carrito-articulo').addClass('media-pantalla'); |
| 82 | } | 87 | } |
| 83 | } | 88 | } |
| 84 | } | 89 | } |
src/app/modules/forma-pago/forma-pago.component.ts
| 1 | import { Component, OnInit } from "@angular/core"; | 1 | import { Component, OnInit } from '@angular/core'; |
| 2 | import { ArticuloService } from "src/app/services/articulo/articulo.service"; | 2 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
| 3 | import { Router } from "@angular/router"; | 3 | import { Router } from '@angular/router'; |
| 4 | 4 | ||
| 5 | @Component({ | 5 | @Component({ |
| 6 | selector: "app-forma-pago", | 6 | selector: 'app-forma-pago', |
| 7 | templateUrl: "./forma-pago.component.html", | 7 | templateUrl: './forma-pago.component.html', |
| 8 | styleUrls: ["./forma-pago.component.scss"] | 8 | styleUrls: ['./forma-pago.component.scss'] |
| 9 | }) | 9 | }) |
| 10 | export class FormaPagoComponent implements OnInit { | 10 | export class FormaPagoComponent implements OnInit { |
| 11 | constructor( | 11 | constructor( |
| 12 | private articuloService: ArticuloService, | 12 | private articuloService: ArticuloService, |
| 13 | private router: Router | 13 | private router: Router |
| 14 | ) {} | 14 | ) {} |
| 15 | 15 | ||
| 16 | ngOnInit() { | 16 | ngOnInit() { |
| 17 | if (!this.articuloService.carrito.length) { | 17 | if (!this.articuloService.carrito.length) { |
| 18 | this.router.navigate([""]); | 18 | this.router.navigate(['']); |
| 19 | return; | 19 | return; |
| 20 | } | 20 | } |
| 21 | this.mediaPantalla(); | 21 | this.mediaPantalla(); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | medioPago(medioPago: number) { | 24 | medioPago(medioPago: number) { |
| 25 | this.articuloService.medioPago = medioPago; | 25 | this.articuloService.medioPago = medioPago; |
| 26 | switch (medioPago) { | 26 | switch (medioPago) { |
| 27 | case 4: | 27 | case 4: |
| 28 | this.router.navigate(["pago-tarjeta"]); | 28 | this.router.navigate(['pago-tarjeta']); |
| 29 | break; | 29 | break; |
| 30 | case 9: | 30 | case 9: |
| 31 | this.router.navigate(["pago-electronico"]); | 31 | this.router.navigate(['pago-electronico']); |
| 32 | break; | 32 | break; |
| 33 | } | 33 | } |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | mediaPantalla() { | 36 | mediaPantalla() { |
| 37 | if ($('body').hasClass('media-pantalla')) { | 37 | if ($('body').hasClass('media-pantalla')) { |
| 38 | $('.reduce-card-1,.reduce-card-2').addClass('media-pantalla'); | 38 | $('.reduce-card-1,.reduce-card-2').addClass('media-pantalla'); |
| 39 | } | 39 | } |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| 42 | 42 |
src/app/modules/info-formas-pago/info-formas-pago.component.ts
| 1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
| 2 | 2 | ||
| 3 | @Component({ | 3 | @Component({ |
| 4 | selector: 'app-formas-pago', | 4 | selector: 'app-formas-pago', |
| 5 | templateUrl: './info-formas-pago.component.html', | 5 | templateUrl: './info-formas-pago.component.html', |
| 6 | styleUrls: ['./info-formas-pago.component.scss'] | 6 | styleUrls: ['./info-formas-pago.component.scss'] |
| 7 | }) | 7 | }) |
| 8 | export class InfoFormasPagoComponent implements OnInit { | 8 | export class InfoFormasPagoComponent implements OnInit { |
| 9 | mediaPantalla = false; | 9 | mediaPantalla = false; |
| 10 | 10 | ||
| 11 | constructor() {} | 11 | constructor() { } |
| 12 | 12 | ||
| 13 | ngOnInit() { | 13 | ngOnInit() { |
| 14 | this.reducirPantalla(); | 14 | this.reducirPantalla(); |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | reducirPantalla() { | 17 | reducirPantalla() { |
| 18 | if ($('body').hasClass('media-pantalla')) { | 18 | if ($('body').hasClass('media-pantalla')) { |
| 19 | $('.reduce-card-1,.reduce-card-2').addClass('media-pantalla'); | 19 | $('.reduce-card-1,.reduce-card-2').addClass('media-pantalla'); |
| 20 | } | 20 | } |
| 21 | } | 21 | } |
| 22 | } | 22 | } |
| 23 | 23 |
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
| 1 | import { Component, OnInit, TemplateRef, OnDestroy, HostListener } from '@angular/core'; | 1 | import { Component, OnInit, TemplateRef, OnDestroy, HostListener } from '@angular/core'; |
| 2 | import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; | 2 | import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; |
| 3 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 3 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
| 4 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | 4 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
| 5 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 5 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
| 6 | import { ICategoria } from 'src/app/interfaces/ICategoria'; | 6 | import { ICategoria } from 'src/app/interfaces/ICategoria'; |
| 7 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; | 7 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; |
| 8 | import { CategoriaService } from 'src/app/services/categoria/categoria.service'; | 8 | import { CategoriaService } from 'src/app/services/categoria/categoria.service'; |
| 9 | import { PromocionService } from 'src/app/services/promocion/promocion.service'; | 9 | import { PromocionService } from 'src/app/services/promocion/promocion.service'; |
| 10 | import { PromocionComponent } from 'src/app/shared/promocion/promocion.component'; | 10 | import { PromocionComponent } from 'src/app/shared/promocion/promocion.component'; |
| 11 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; | 11 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; |
| 12 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; | 12 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; |
| 13 | import { SinonimoComponent } from 'src/app/shared/sinonimo/sinonimo.component'; | 13 | import { SinonimoComponent } from 'src/app/shared/sinonimo/sinonimo.component'; |
| 14 | 14 | ||
| 15 | @Component({ | 15 | @Component({ |
| 16 | selector: 'app-seleccion-articulos', | 16 | selector: 'app-seleccion-articulos', |
| 17 | templateUrl: './seleccion-articulos.component.html', | 17 | templateUrl: './seleccion-articulos.component.html', |
| 18 | styleUrls: ['./seleccion-articulos.component.scss'] | 18 | styleUrls: ['./seleccion-articulos.component.scss'] |
| 19 | }) | 19 | }) |
| 20 | export class SeleccionArticulosComponent implements OnInit, OnDestroy { | 20 | export class SeleccionArticulosComponent implements OnInit, OnDestroy { |
| 21 | showSpinner = true; | 21 | showSpinner = true; |
| 22 | timeoutHandler: any; | 22 | timeoutHandler: any; |
| 23 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; | 23 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
| 24 | articulos: IArticulo[] = []; | 24 | articulos: IArticulo[] = []; |
| 25 | auxArticulos: IArticulo[] = []; | 25 | auxArticulos: IArticulo[] = []; |
| 26 | showQuantity = 100; | 26 | showQuantity = 100; |
| 27 | queMostrar = 'todos'; | 27 | queMostrar = 'todos'; |
| 28 | categoriaActive = null; | 28 | categoriaActive = null; |
| 29 | categorias: ICategoria[] = []; | 29 | categorias: ICategoria[] = []; |
| 30 | searchTerm = ''; | 30 | searchTerm = ''; |
| 31 | ordenandoByVendidos = true; | 31 | ordenandoByVendidos = true; |
| 32 | allActive = true; | 32 | allActive = true; |
| 33 | modalRef: BsModalRef; | 33 | modalRef: BsModalRef; |
| 34 | total = 0; | 34 | total = 0; |
| 35 | 35 | ||
| 36 | constructor( | 36 | constructor( |
| 37 | public articuloService: ArticuloService, | 37 | public articuloService: ArticuloService, |
| 38 | private categoriaService: CategoriaService, | 38 | private categoriaService: CategoriaService, |
| 39 | private sinonimoService: SinonimoService, | 39 | private sinonimoService: SinonimoService, |
| 40 | private modalService: BsModalService, | 40 | private modalService: BsModalService, |
| 41 | private inactiveScreen: InactiveScreenService, | 41 | private inactiveScreen: InactiveScreenService, |
| 42 | ) { } | 42 | ) { } |
| 43 | 43 | ||
| 44 | ngOnInit() { | 44 | ngOnInit() { |
| 45 | this.getCategorias(); | 45 | this.getCategorias(); |
| 46 | this.mediaPantalla(); | 46 | this.mediaPantalla(); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | ngOnDestroy() { | 49 | ngOnDestroy() { |
| 50 | if (this.modalRef) this.modalRef.hide(); | 50 | if (this.modalRef) this.modalRef.hide(); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | getCategorias() { | 53 | getCategorias() { |
| 54 | this.categoriaService.getAll() | 54 | this.categoriaService.getAll() |
| 55 | .subscribe((categorias: ICategoria[]) => { | 55 | .subscribe((categorias: ICategoria[]) => { |
| 56 | switch (this.queMostrar) { | 56 | switch (this.queMostrar) { |
| 57 | case 'todos': | 57 | case 'todos': |
| 58 | this.categorias = categorias; | 58 | this.categorias = categorias; |
| 59 | this.categoriaActive = 0; | 59 | this.categoriaActive = 0; |
| 60 | break; | 60 | break; |
| 61 | case 'promociones': | 61 | case 'promociones': |
| 62 | this.categorias = categorias; | 62 | this.categorias = categorias; |
| 63 | this.categoriaActive = 19; | 63 | this.categoriaActive = 19; |
| 64 | break; | 64 | break; |
| 65 | case 'ordenar': | 65 | case 'ordenar': |
| 66 | this.categorias = categorias.filter((categoria: ICategoria) => { | 66 | this.categorias = categorias.filter((categoria: ICategoria) => { |
| 67 | return categoria.ES_PEDIDO; | 67 | return categoria.ES_PEDIDO; |
| 68 | }); | 68 | }); |
| 69 | this.categoriaActive = 4; | 69 | this.categoriaActive = 4; |
| 70 | break; | 70 | break; |
| 71 | default: | 71 | default: |
| 72 | this.categorias = categorias; | 72 | this.categorias = categorias; |
| 73 | this.categoriaActive = 0; | 73 | this.categoriaActive = 0; |
| 74 | break; | 74 | break; |
| 75 | } | 75 | } |
| 76 | !localStorage.getItem('articulos') ? | 76 | !localStorage.getItem('articulos') ? |
| 77 | this.getProductos() : | 77 | this.getProductos() : |
| 78 | this.setProductos(); | 78 | this.setProductos(); |
| 79 | }); | 79 | }); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | getProductos() { | 82 | getProductos() { |
| 83 | this.articuloService.getAll() | 83 | this.articuloService.getAll() |
| 84 | .subscribe((result: IArticulo[]) => { | 84 | .subscribe((result: IArticulo[]) => { |
| 85 | this.articuloService.setArticulosSinImagen(result); | 85 | this.articuloService.setArticulosSinImagen(result); |
| 86 | if (this.queMostrar === 'ordenar') { | 86 | if (this.queMostrar === 'ordenar') { |
| 87 | this.categorias.forEach((categoria: ICategoria) => { | 87 | this.categorias.forEach((categoria: ICategoria) => { |
| 88 | const tempArticulos = result.filter((articulo: IArticulo) => { | 88 | const tempArticulos = result.filter((articulo: IArticulo) => { |
| 89 | return articulo.categoria_selfservice === categoria.id; | 89 | return articulo.categoria_selfservice === categoria.id; |
| 90 | }); | 90 | }); |
| 91 | result = tempArticulos; | 91 | result = tempArticulos; |
| 92 | }); | 92 | }); |
| 93 | } | 93 | } |
| 94 | localStorage.setItem('articulos', JSON.stringify(result)); | 94 | localStorage.setItem('articulos', JSON.stringify(result)); |
| 95 | this.setProductos(); | 95 | this.setProductos(); |
| 96 | }, (error) => { | 96 | }, (error) => { |
| 97 | this.showSpinner = false; | 97 | this.showSpinner = false; |
| 98 | console.error(error); | 98 | console.error(error); |
| 99 | }); | 99 | }); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | setProductos() { | 102 | setProductos() { |
| 103 | this.articulos = JSON.parse(localStorage.getItem('articulos')); | 103 | this.articulos = JSON.parse(localStorage.getItem('articulos')); |
| 104 | this.filterItems(); | 104 | this.filterItems(); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | filterItems() { | 107 | filterItems() { |
| 108 | if (this.categoriaActive === 0) { | 108 | if (this.categoriaActive === 0) { |
| 109 | this.auxArticulos = this.articulos; | 109 | this.auxArticulos = this.articulos; |
| 110 | return; | 110 | return; |
| 111 | } | 111 | } |
| 112 | this.auxArticulos = this.articulos.filter(x => { | 112 | this.auxArticulos = this.articulos.filter(x => { |
| 113 | return x.categoria_selfservice === this.categoriaActive; | 113 | return x.categoria_selfservice === this.categoriaActive; |
| 114 | }); | 114 | }); |
| 115 | this.ordenar(); | 115 | this.ordenar(); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | ordenar() { | 118 | ordenar() { |
| 119 | if (this.ordenandoByVendidos) { | 119 | if (this.ordenandoByVendidos) { |
| 120 | this.auxArticulos.sort((a, b) => { | 120 | this.auxArticulos.sort((a, b) => { |
| 121 | return b.cantidadVendida - a.cantidadVendida; | 121 | return b.cantidadVendida - a.cantidadVendida; |
| 122 | }); | 122 | }); |
| 123 | } | 123 | } |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | selectCategoria(index: number, idCategoria?: number) { | 126 | selectCategoria(index: number, idCategoria?: number) { |
| 127 | if (this.categoriaActive === idCategoria) return; | 127 | if (this.categoriaActive === idCategoria) return; |
| 128 | this.categoriaActive = idCategoria; | 128 | this.categoriaActive = idCategoria; |
| 129 | this.allActive = idCategoria === 0 ? true : false; | 129 | this.allActive = idCategoria === 0 ? true : false; |
| 130 | this.categorias.forEach((categoria, i) => { | 130 | this.categorias.forEach((categoria, i) => { |
| 131 | categoria.selected = index === i ? true : false; | 131 | categoria.selected = index === i ? true : false; |
| 132 | }); | 132 | }); |
| 133 | this.filterItems(); | 133 | this.filterItems(); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | selectArticulo(articulo: IArticulo) { | 136 | selectArticulo(articulo: IArticulo) { |
| 137 | this.getByID(articulo.id); | 137 | this.getByID(articulo.id); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | getByID(id: number) { | 140 | getByID(id: number) { |
| 141 | this.articuloService.getById(id) | 141 | this.articuloService.getById(id) |
| 142 | .subscribe((res: IArticulo) => { | 142 | .subscribe((res: IArticulo) => { |
| 143 | if (res.FPP) { | 143 | if (res.FPP) { |
| 144 | this.openModalPromos(res); | 144 | this.openModalPromos(res); |
| 145 | } else { | 145 | } else { |
| 146 | this.getSinonimos(res); | 146 | this.getSinonimos(res); |
| 147 | } | 147 | } |
| 148 | }, err => console.error(err)); | 148 | }, err => console.error(err)); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | getSinonimos(articulo: IArticulo) { | 151 | getSinonimos(articulo: IArticulo) { |
| 152 | this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) | 152 | this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) |
| 153 | .subscribe((res: ISinonimo[]) => { | 153 | .subscribe((res: ISinonimo[]) => { |
| 154 | if (res.length) { | 154 | if (res.length) { |
| 155 | this.openModalSinonimos(res); | 155 | this.openModalSinonimos(res); |
| 156 | } else { | 156 | } else { |
| 157 | articulo.cantidad = 1; | ||
| 158 | this.articuloService.setArticulo(articulo); | 157 | this.articuloService.setArticulo(articulo); |
| 159 | } | 158 | } |
| 160 | }) | 159 | }); |
| 161 | } | 160 | } |
| 162 | 161 | ||
| 163 | openModalPromos(articulo: IArticulo) { | 162 | openModalPromos(articulo: IArticulo) { |
| 164 | this.modalRef = this.modalService.show(PromocionComponent, { | 163 | this.modalRef = this.modalService.show(PromocionComponent, { |
| 165 | initialState: { articulosPromo: [articulo] }, | 164 | initialState: { articulosPromo: [articulo] }, |
| 166 | class: 'modal-promo modal-dialog-centered' | 165 | class: 'modal-promo modal-dialog-centered' |
| 167 | }); | 166 | }); |
| 168 | } | 167 | } |
| 169 | 168 | ||
| 170 | openModalSinonimos(sinonimosData: ISinonimo[]) { | 169 | openModalSinonimos(sinonimosData: ISinonimo[]) { |
| 171 | this.modalRef = this.modalService.show(SinonimoComponent, { | 170 | this.modalRef = this.modalService.show(SinonimoComponent, { |
| 172 | initialState: { sinonimos: sinonimosData }, | 171 | initialState: { sinonimos: sinonimosData }, |
| 173 | class: 'modal-promo modal-dialog-centered' | 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 | deleteArticulo(index: number) { | 181 | deleteArticulo(index: number) { |
| 178 | this.articuloService.carrito.splice(index, 1); | 182 | this.articuloService.deleteArticulo(index); |
| 179 | this.articuloService.calcularTotal(); | ||
| 180 | } | 183 | } |
| 181 | 184 | ||
| 182 | increaseShow() { | 185 | increaseShow() { |
| 183 | this.showQuantity += 100; | 186 | this.showQuantity += 100; |
| 184 | } | 187 | } |
| 185 | 188 | ||
| 186 | @HostListener('scroll', ['$event']) | 189 | @HostListener('scroll', ['$event']) |
| 187 | scrollEvent(event: Event) { | 190 | scrollEvent(event: Event) { |
| 188 | clearTimeout(this.inactiveScreen.timerReposo); | 191 | clearTimeout(this.inactiveScreen.timerReposo); |
| 189 | this.inactiveScreen.startTimeOutInactividad(); | 192 | this.inactiveScreen.startTimeOutInactividad(); |
| 190 | } | 193 | } |
| 191 | 194 | ||
| 192 | mouseup() { | 195 | mouseup() { |
| 193 | if (!this.timeoutHandler) return; | 196 | if (!this.timeoutHandler) return; |
| 194 | clearInterval(this.timeoutHandler); | 197 | clearInterval(this.timeoutHandler); |
| 195 | } | 198 | } |
| 196 | 199 | ||
| 197 | scrollY(el: HTMLElement, value) { | 200 | scrollY(el: HTMLElement, value) { |
| 198 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); | 201 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); |
| 199 | this.timeoutHandler = setInterval(() => { | 202 | this.timeoutHandler = setInterval(() => { |
| 200 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); | 203 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); |
| 201 | }, 500); | 204 | }, 500); |
| 202 | } | 205 | } |
| 203 | 206 | ||
| 204 | scrollX(el: HTMLElement, value) { | 207 | scrollX(el: HTMLElement, value) { |
| 205 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); | 208 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); |
| 206 | this.timeoutHandler = setInterval(() => { | 209 | this.timeoutHandler = setInterval(() => { |
| 207 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); | 210 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); |
| 208 | }, 500); | 211 | }, 500); |
| 209 | } | 212 | } |
| 210 | 213 | ||
| 211 | mediaPantalla() { | 214 | mediaPantalla() { |
| 212 | if ($('body').hasClass('media-pantalla')) { | 215 | if ($('body').hasClass('media-pantalla')) { |
| 213 | $('.cat-content,#content,.cat-btn,#boxCarrito,.cat-box,.img-categoria').addClass('media-pantalla').addBack('media-pantalla'); | 216 | $('.cat-content,#content,.cat-btn,#boxCarrito,.cat-box,.img-categoria').addClass('media-pantalla').addBack('media-pantalla'); |
| 214 | } | 217 | } |
| 215 | } | 218 | } |
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 | @Component({ | 3 | @Component({ |
| 4 | selector: "app-splash-screen", | 4 | selector: 'app-splash-screen', |
| 5 | templateUrl: "./splash-screen.component.html", | 5 | templateUrl: './splash-screen.component.html', |
| 6 | styleUrls: ["./splash-screen.component.scss"] | 6 | styleUrls: ['./splash-screen.component.scss'] |
| 7 | }) | 7 | }) |
| 8 | export class SplashScreenComponent implements OnInit { | 8 | export class SplashScreenComponent implements OnInit { |
| 9 | timerSplashScreen = 2000; | 9 | timerSplashScreen = 2000; |
| 10 | showSplashScreen = true; | 10 | showSplashScreen = true; |
| 11 | textWelcome = "BIENVENIDO A SPOT!"; | 11 | textWelcome = 'BIENVENIDO A SPOT!'; |
| 12 | textComoEstas = "¿cómo estás?"; | 12 | textComoEstas = '¿cómo estás?'; |
| 13 | textInvitamos = "TE INVITAMOS A HACER"; | 13 | textInvitamos = 'TE INVITAMOS A HACER'; |
| 14 | textTuPedido = "tu pedido acá"; | 14 | textTuPedido = 'tu pedido acá'; |
| 15 | 15 | ||
| 16 | constructor() {} | 16 | constructor() {} |
| 17 | 17 | ||
| 18 | ngOnInit() { | 18 | ngOnInit() { |
| 19 | localStorage.clear(); | 19 | localStorage.clear(); |
| 20 | setTimeout(() => { | 20 | setTimeout(() => { |
| 21 | this.showSplashScreen = false; | 21 | this.showSplashScreen = false; |
| 22 | }, this.timerSplashScreen); | 22 | }, this.timerSplashScreen); |
| 23 | $('body').removeClass('media-pantalla'); | 23 | $('body').removeClass('media-pantalla'); |
| 24 | } | 24 | } |
| 25 | } | 25 | } |
| 26 | 26 |
src/app/services/articulo/articulo.service.ts
| 1 | import { Injectable } from '@angular/core'; | 1 | import { Injectable } from '@angular/core'; |
| 2 | import { HttpClient } from '@angular/common/http'; | 2 | import { HttpClient } from '@angular/common/http'; |
| 3 | import { APP_SETTINGS } from '../../../etc/AppSettings'; | 3 | import { APP_SETTINGS } from '../../../etc/AppSettings'; |
| 4 | import { IArticulo } from '../../interfaces/IArticulo'; | 4 | import { IArticulo } from '../../interfaces/IArticulo'; |
| 5 | import { ClienteService } from '../cliente/cliente.service'; | 5 | import { ClienteService } from '../cliente/cliente.service'; |
| 6 | import { Observable } from 'rxjs'; | 6 | import { Observable } from 'rxjs'; |
| 7 | 7 | ||
| 8 | @Injectable() | 8 | @Injectable() |
| 9 | export class ArticuloService { | 9 | export class ArticuloService { |
| 10 | carrito: IArticulo[] = []; | 10 | carrito: IArticulo[] = []; |
| 11 | articuloAcargar: IArticulo; | 11 | articuloAcargar: IArticulo; |
| 12 | promoAcargar: IArticulo; | 12 | promoAcargar: IArticulo; |
| 13 | mostrar: string; | 13 | mostrar: string; |
| 14 | esPromoPersonalizada = false; | 14 | esPromoPersonalizada = false; |
| 15 | urlDeboSuite = APP_SETTINGS.apiDeboSuite; | 15 | urlDeboSuite = APP_SETTINGS.apiDeboSuite; |
| 16 | medioPago: number; | 16 | medioPago: number; |
| 17 | idComanda: number; | 17 | idComanda: number; |
| 18 | subTotal = 0; | 18 | subTotal = 0; |
| 19 | 19 | ||
| 20 | constructor( | 20 | constructor( |
| 21 | private http: HttpClient, | 21 | private http: HttpClient, |
| 22 | private clienteService: ClienteService, | 22 | private clienteService: ClienteService, |
| 23 | ) { } | 23 | ) { } |
| 24 | 24 | ||
| 25 | getById(id) { | 25 | getById(id) { |
| 26 | return this.http.get(`${this.urlDeboSuite}/articulos/${id}`); | 26 | return this.http.get(`${this.urlDeboSuite}/articulos/${id}`); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | getAll() { | 29 | getAll() { |
| 30 | return this.http.get(`${this.urlDeboSuite}/articulos/`); | 30 | return this.http.get(`${this.urlDeboSuite}/articulos/`); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | getAllWithPaginator(page: number = 1) { | 33 | getAllWithPaginator(page: number = 1) { |
| 34 | return this.http.get(`${this.urlDeboSuite}/articulos/${page}`); | 34 | return this.http.get(`${this.urlDeboSuite}/articulos/${page}`); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | calcularTotal() { | 37 | calcularTotal() { |
| 38 | this.subTotal = 0; | 38 | this.subTotal = 0; |
| 39 | this.carrito.forEach(articulo => { | 39 | this.carrito.forEach(articulo => { |
| 40 | this.subTotal += (articulo.PreVen * articulo.cantidad); | 40 | this.subTotal += (articulo.PreVen * articulo.cantidad); |
| 41 | }); | 41 | }); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | setArticulo(articulo: IArticulo) { | 44 | setArticulo(articulo: IArticulo) { |
| 45 | articulo.cantidad = 1; | ||
| 45 | for (const articuloCarrito of this.carrito) { | 46 | for (const articuloCarrito of this.carrito) { |
| 46 | if (articuloCarrito.id === articulo.id) { | 47 | if (articuloCarrito.id === articulo.id) { |
| 47 | articuloCarrito.cantidad++; | 48 | articuloCarrito.cantidad++; |
| 48 | this.calcularTotal(); | 49 | this.calcularTotal(); |
| 49 | return; | 50 | return; |
| 50 | } | 51 | } |
| 51 | } | 52 | } |
| 52 | this.setArticulosSinImagen([articulo]); | 53 | this.setArticulosSinImagen([articulo]); |
| 53 | this.carrito.unshift(articulo); | 54 | this.carrito.unshift(articulo); |
| 54 | this.calcularTotal(); | 55 | this.calcularTotal(); |
| 55 | } | 56 | } |
| 56 | 57 | ||
| 58 | deleteArticulo(index: number) { | ||
| 59 | this.carrito.splice(index, 1); | ||
| 60 | this.calcularTotal(); | ||
| 61 | } | ||
| 62 | |||
| 57 | pay(dataPago: any) { | 63 | pay(dataPago: any) { |
| 58 | return new Observable((observer) => { | 64 | return new Observable((observer) => { |
| 59 | this.clienteService.getById(-1) | 65 | this.clienteService.getById(-1) |
| 60 | .subscribe(cliente => { | 66 | .subscribe(cliente => { |
| 61 | this.markArticuloInPromoAsRemoved(); | 67 | this.markArticuloInPromoAsRemoved(); |
| 62 | this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${this.medioPago}`, { | 68 | this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${this.medioPago}`, { |
| 63 | productos: this.carrito, | 69 | productos: this.carrito, |
| 64 | cliente, | 70 | cliente, |
| 65 | origen: 'autoservicio', | 71 | origen: 'autoservicio', |
| 66 | codigoVendedor: 5, | 72 | codigoVendedor: 5, |
| 67 | puntoVenta: APP_SETTINGS.puntoVenta, | 73 | puntoVenta: APP_SETTINGS.puntoVenta, |
| 68 | pedidoAnombreDe: dataPago.pedidoAnombreDe, | 74 | pedidoAnombreDe: dataPago.pedidoAnombreDe, |
| 69 | numeroPlanilla: APP_SETTINGS.numeroPlanilla, | 75 | numeroPlanilla: APP_SETTINGS.numeroPlanilla, |
| 70 | }) | 76 | }) |
| 71 | .subscribe((data) => { | 77 | .subscribe((data) => { |
| 72 | observer.next(data); | 78 | observer.next(data); |
| 73 | observer.complete(); | 79 | observer.complete(); |
| 74 | }); | 80 | }); |
| 75 | }); | 81 | }); |
| 76 | }); | 82 | }); |
| 77 | } | 83 | } |
| 78 | 84 | ||
| 79 | cleanShoppingCar() { | 85 | cleanShoppingCar() { |
| 80 | this.articuloAcargar = undefined; | 86 | this.articuloAcargar = undefined; |
| 81 | this.promoAcargar = undefined; | 87 | this.promoAcargar = undefined; |
| 82 | this.carrito = []; | 88 | this.carrito = []; |
| 83 | } | 89 | } |
| 84 | 90 | ||
| 85 | setArticulosSinImagen(articulos: IArticulo[]) { | 91 | setArticulosSinImagen(articulos: IArticulo[]) { |
| 86 | articulos.forEach((articulo: IArticulo) => { | 92 | articulos.forEach((articulo: IArticulo) => { |
| 87 | articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] : | 93 | articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] : |
| 88 | !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes; | 94 | !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes; |
| 89 | }); | 95 | }); |
| 90 | } | 96 | } |
| 91 | 97 | ||
| 92 | markArticuloInPromoAsRemoved() { | 98 | markArticuloInPromoAsRemoved() { |
| 93 | this.carrito.forEach((articuloCarrito: IArticulo) => { | 99 | this.carrito.forEach((articuloCarrito: IArticulo) => { |
| 94 | if (articuloCarrito.PRO) { | 100 | if (articuloCarrito.PRO) { |
| 95 | articuloCarrito.productos.forEach((articulo: IArticulo) => { | 101 | articuloCarrito.productos.forEach((articulo: IArticulo) => { |
| 96 | if (articulo.cantidadAdicionada === 0) { | 102 | if (articulo.cantidadAdicionada === 0) { |
| 97 | articulo.cantidad = 0; | 103 | articulo.cantidad = 0; |
| 98 | articulo.importeValorExtra = 0; | 104 | articulo.importeValorExtra = 0; |
| 99 | } | 105 | } |
| 100 | }); | 106 | }); |
| 101 | } | 107 | } |
| 102 | }); | 108 | }); |
| 103 | } | 109 | } |
| 104 | } | 110 | } |
| 105 | 111 |
src/app/shared/footer/footer.component.ts
| 1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
| 2 | import { Location } from '@angular/common'; | 2 | import { Location } from '@angular/common'; |
| 3 | 3 | ||
| 4 | @Component({ | 4 | @Component({ |
| 5 | selector: 'app-footer', | 5 | selector: 'app-footer', |
| 6 | templateUrl: './footer.component.html', | 6 | templateUrl: './footer.component.html', |
| 7 | styleUrls: ['./footer.component.scss'] | 7 | styleUrls: ['./footer.component.scss'] |
| 8 | }) | 8 | }) |
| 9 | export class FooterComponent implements OnInit { | 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 | goBack() { | 14 | goBack() { |
| 15 | this.location.back(); | 15 | this.location.back(); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | reducirPantalla() { | 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 | } |
| 22 | 38 |
src/app/shared/header-publicidad/header-publicidad.component.ts
| 1 | import { Component, OnInit, TemplateRef } from '@angular/core'; | 1 | import { Component, OnInit, TemplateRef } from '@angular/core'; |
| 2 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 2 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
| 3 | import { IPublicidad } from 'src/app/interfaces/IPublicidad'; | 3 | import { IPublicidad } from 'src/app/interfaces/IPublicidad'; |
| 4 | import { PublicidadService } from 'src/app/services/publicidad/publicidad.service'; | 4 | import { PublicidadService } from 'src/app/services/publicidad/publicidad.service'; |
| 5 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | 5 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
| 6 | import { PromocionComponent } from '../promocion/promocion.component'; | 6 | import { PromocionComponent } from '../promocion/promocion.component'; |
| 7 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; | 7 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal'; |
| 8 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 8 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
| 9 | import { ConfirmacionComponent } from '../confirmacion/confirmacion.component'; | 9 | import { ConfirmacionComponent } from '../confirmacion/confirmacion.component'; |
| 10 | 10 | ||
| 11 | @Component({ | 11 | @Component({ |
| 12 | selector: 'app-header-publicidad', | 12 | selector: 'app-header-publicidad', |
| 13 | templateUrl: './header-publicidad.component.html', | 13 | templateUrl: './header-publicidad.component.html', |
| 14 | styleUrls: ['./header-publicidad.component.scss'] | 14 | styleUrls: ['./header-publicidad.component.scss'] |
| 15 | }) | 15 | }) |
| 16 | export class HeaderPublicidadComponent implements OnInit { | 16 | export class HeaderPublicidadComponent implements OnInit { |
| 17 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; | 17 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
| 18 | publicidades: IPublicidad[] = []; | 18 | publicidades: IPublicidad[] = []; |
| 19 | modalRef: BsModalRef; | 19 | modalRef: BsModalRef; |
| 20 | 20 | ||
| 21 | constructor( | 21 | constructor( |
| 22 | private publicidadService: PublicidadService, | 22 | private publicidadService: PublicidadService, |
| 23 | private articuloService: ArticuloService, | 23 | private articuloService: ArticuloService, |
| 24 | private modalService: BsModalService, | 24 | private modalService: BsModalService, |
| 25 | ) { } | 25 | ) { } |
| 26 | 26 | ||
| 27 | ngOnInit() { | 27 | ngOnInit() { |
| 28 | this.getPublicidades(); | 28 | this.getPublicidades(); |
| 29 | this.mediaPantalla(); | 29 | this.mediaPantalla(); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | getPublicidades() { | 32 | getPublicidades() { |
| 33 | this.publicidadService.getAll() | 33 | this.publicidadService.getAll() |
| 34 | .subscribe((res: IPublicidad[]) => { | 34 | .subscribe((res: IPublicidad[]) => { |
| 35 | this.publicidades = res; | 35 | this.publicidades = res; |
| 36 | }, err => console.error(err)); | 36 | }, err => console.error(err)); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | elegirArticulo(publicidad: IPublicidad) { | 39 | elegirArticulo(publicidad: IPublicidad) { |
| 40 | if (publicidad.id_articulo) this.getByID(publicidad.id_articulo); | 40 | if (publicidad.id_articulo) this.getByID(publicidad.id_articulo); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | getByID(id: number) { | 43 | getByID(id: number) { |
| 44 | this.articuloService.getById(id) | 44 | this.articuloService.getById(id) |
| 45 | .subscribe((res: IArticulo) => { | 45 | .subscribe((res: IArticulo) => { |
| 46 | if (res.FPP) { | 46 | if (res.FPP) { |
| 47 | this.openModalPromos(res); | 47 | this.openModalPromos(res); |
| 48 | return; | 48 | return; |
| 49 | } else { | 49 | } else { |
| 50 | this.openModalConfirmacion(res); | 50 | this.openModalConfirmacion(res); |
| 51 | return; | 51 | return; |
| 52 | } | 52 | } |
| 53 | }, err => console.error(err)); | 53 | }, err => console.error(err)); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | openModalPromos(articulo: IArticulo) { | 56 | openModalPromos(articulo: IArticulo) { |
| 57 | this.modalRef = this.modalService.show(PromocionComponent, | 57 | this.modalRef = this.modalService.show(PromocionComponent, |
| 58 | { | 58 | { |
| 59 | initialState: { | 59 | initialState: { |
| 60 | idArticulo: articulo.id | 60 | idArticulo: articulo.id |
| 61 | }, | 61 | }, |
| 62 | class: 'modal-promo modal-dialog-centered' | 62 | class: 'modal-promo modal-dialog-centered' |
| 63 | }); | 63 | }); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | openModalConfirmacion(articulo: IArticulo) { | 66 | openModalConfirmacion(articulo: IArticulo) { |
| 67 | this.modalRef = this.modalService.show(ConfirmacionComponent, | 67 | this.modalRef = this.modalService.show(ConfirmacionComponent, |
| 68 | { | 68 | { |
| 69 | initialState: { | 69 | initialState: { |
| 70 | titleMessage: articulo.DET_LAR, | 70 | titleMessage: articulo.DET_LAR, |
| 71 | imagenPath: articulo.imagenes, | 71 | imagenPath: articulo.imagenes, |
| 72 | footerMessageFirst: `¿DESEA AGREGAR ESTE ARTÍCULO`, | 72 | footerMessageFirst: `¿DESEA AGREGAR ESTE ARTÍCULO`, |
| 73 | footerMessageSecond: `a su carrito?`, | 73 | footerMessageSecond: `a su carrito?`, |
| 74 | footerConfirmation: articulo.PreVen, | 74 | footerConfirmation: articulo.PreVen, |
| 75 | footerClose: `volver` | 75 | footerClose: `volver` |
| 76 | }, | 76 | }, |
| 77 | class: 'modal-promo modal-dialog-centered' | 77 | class: 'modal-promo modal-dialog-centered' |
| 78 | }); | 78 | }); |
| 79 | this.modalRef.content.onClose.subscribe(() => { | 79 | this.modalRef.content.onClose.subscribe(() => { |
| 80 | articulo.cantidad = 1; | ||
| 81 | this.articuloService.setArticulo(articulo); | 80 | this.articuloService.setArticulo(articulo); |
| 82 | }); | 81 | }); |
| 83 | } | 82 | } |
| 84 | 83 | ||
| 85 | mediaPantalla() { | 84 | mediaPantalla() { |
| 86 | if ($('body').hasClass('media-pantalla')) { | 85 | if ($('body').hasClass('media-pantalla')) { |
| 87 | $('#headerPublicidad,#headerPad').addClass('media-pantalla'); | 86 | $('#headerPublicidad,#headerPad').addClass('media-pantalla'); |
| 88 | } | 87 | } |
| 89 | } | 88 | } |
| 90 | } | 89 | } |
| 91 | 90 |
src/app/shared/promocion/promocion.component.ts
| 1 | import { Component, OnInit, HostListener } from '@angular/core'; | 1 | import { Component, OnInit, HostListener } from '@angular/core'; |
| 2 | import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; | 2 | import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; |
| 3 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | 3 | import { IArticulo } from 'src/app/interfaces/IArticulo'; |
| 4 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; | 4 | import { ArticuloService } from 'src/app/services/articulo/articulo.service'; |
| 5 | import { PromocionService } from 'src/app/services/promocion/promocion.service'; | 5 | import { PromocionService } from 'src/app/services/promocion/promocion.service'; |
| 6 | import { Subject } from 'rxjs'; | 6 | import { Subject } from 'rxjs'; |
| 7 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 7 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
| 8 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; | 8 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; |
| 9 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; | 9 | import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; |
| 10 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; | 10 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; |
| 11 | import { SinonimoComponent } from '../sinonimo/sinonimo.component'; | 11 | import { SinonimoComponent } from '../sinonimo/sinonimo.component'; |
| 12 | 12 | ||
| 13 | @Component({ | 13 | @Component({ |
| 14 | selector: 'app-promocion', | 14 | selector: 'app-promocion', |
| 15 | templateUrl: './promocion.component.html', | 15 | templateUrl: './promocion.component.html', |
| 16 | styleUrls: ['./promocion.component.scss'] | 16 | styleUrls: ['./promocion.component.scss'] |
| 17 | }) | 17 | }) |
| 18 | export class PromocionComponent implements OnInit { | 18 | export class PromocionComponent implements OnInit { |
| 19 | articulosPromo: IArticulo[] = []; | 19 | articulosPromo: IArticulo[] = []; |
| 20 | promociones: IArticulo[] = []; | 20 | promociones: IArticulo[] = []; |
| 21 | onClose: Subject<any>; | 21 | onClose: Subject<any>; |
| 22 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; | 22 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
| 23 | 23 | ||
| 24 | constructor( | 24 | constructor( |
| 25 | public modalRef: BsModalRef, | 25 | public modalPromocion: BsModalRef, |
| 26 | private modalService: BsModalService, | 26 | private modalService: BsModalService, |
| 27 | private articuloService: ArticuloService, | 27 | private articuloService: ArticuloService, |
| 28 | private promocionService: PromocionService, | 28 | private promocionService: PromocionService, |
| 29 | private sinonimoService: SinonimoService, | 29 | private sinonimoService: SinonimoService, |
| 30 | private inactiveScreen: InactiveScreenService, | 30 | private inactiveScreen: InactiveScreenService, |
| 31 | ) { | 31 | ) { |
| 32 | this.onClose = new Subject(); | 32 | this.onClose = new Subject(); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | ngOnInit() { | 35 | ngOnInit() { |
| 36 | this.getPromociones(); | 36 | this.getPromociones(); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | selectPromo(promo: IArticulo) { | 39 | selectPromo(promo: IArticulo) { |
| 40 | this.sinonimoService.getSinonimos(promo.CodSec, promo.CodArt) | 40 | this.sinonimoService.getSinonimos(promo.CodSec, promo.CodArt) |
| 41 | .subscribe((res: ISinonimo[]) => { | 41 | .subscribe((res: ISinonimo[]) => { |
| 42 | if (res.length) { | 42 | if (res.length) { |
| 43 | this.openModalSinonimos(res); | 43 | this.openModalSinonimos(res); |
| 44 | } else { | 44 | } else { |
| 45 | promo.cantidad = 1; | 45 | promo.cantidad = 1; |
| 46 | this.articuloService.setArticulo(promo); | 46 | this.articuloService.setArticulo(promo); |
| 47 | this.modalRef.hide(); | 47 | this.modalPromocion.hide(); |
| 48 | } | 48 | } |
| 49 | }, err => console.error(err)); | 49 | }, err => console.error(err)); |
| 50 | this.mediaPantalla(); | 50 | this.mediaPantalla(); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | openModalSinonimos(sinonimosData: ISinonimo[]) { | 53 | openModalSinonimos(sinonimosData: ISinonimo[]) { |
| 54 | this.modalRef = this.modalService.show(SinonimoComponent, { | 54 | const modalSinonimo = this.modalService.show(SinonimoComponent, { |
| 55 | initialState: { sinonimos: sinonimosData }, | 55 | initialState: { sinonimos: sinonimosData }, |
| 56 | class: 'modal-promo modal-dialog-centered' | 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 | getPromociones() { | 66 | getPromociones() { |
| 61 | const sector = this.articulosPromo[0].CodSec; | 67 | const sector = this.articulosPromo[0].CodSec; |
| 62 | const codigo = this.articulosPromo[0].CodArt; | 68 | const codigo = this.articulosPromo[0].CodArt; |
| 63 | this.promocionService.getPromociones(sector, codigo) | 69 | this.promocionService.getPromociones(sector, codigo) |
| 64 | .subscribe((res: IArticulo[]) => { | 70 | .subscribe((res: IArticulo[]) => { |
| 65 | this.promociones = res; | 71 | this.promociones = res; |
| 66 | }, error => { console.error(error); }); | 72 | }, error => { console.error(error); }); |
| 67 | } | 73 | } |
| 68 | 74 | ||
| 69 | @HostListener('document:click', ['$event']) | 75 | @HostListener('document:click', ['$event']) |
| 70 | eventListener(event: Event) { | 76 | eventListener(event: Event) { |
| 71 | clearTimeout(this.inactiveScreen.timerReposo); | 77 | clearTimeout(this.inactiveScreen.timerReposo); |
| 72 | this.inactiveScreen.startTimeOutInactividad(); | 78 | this.inactiveScreen.startTimeOutInactividad(); |
| 73 | } | 79 | } |
| 74 | 80 | ||
| 75 | mediaPantalla() { | 81 | mediaPantalla() { |
| 76 | if ($('body').hasClass('media-pantalla')) { | 82 | if ($('body').hasClass('media-pantalla')) { |
| 77 | $('.modal-content').addClass('media-pantalla'); | 83 | $('.modal-content').addClass('media-pantalla'); |
| 78 | } | 84 | } |
| 79 | } | 85 | } |
| 80 | } | 86 | } |
| 81 | 87 |
src/app/shared/sinonimo/sinonimo.component.html
| 1 | <div class="bg-primary rounded text-white"> | 1 | <div class="bg-primary rounded text-white"> |
| 2 | <div class="modal-header"> | 2 | <div class="modal-header"> |
| 3 | <p class="h4">Seleccione sinonimos</p> | 3 | <p class="h4">Seleccione sinonimos</p> |
| 4 | </div> | 4 | </div> |
| 5 | 5 | ||
| 6 | <div class="modal-body"> | 6 | <div class="modal-body"> |
| 7 | <div | 7 | <div |
| 8 | class="lista-sinonimos scroll-y-visible" | 8 | class="lista-sinonimos scroll-y-visible" |
| 9 | *ngFor="let s of sinonimos"> | 9 | *ngFor="let s of sinonimos"> |
| 10 | <div *ngFor="let articulo of s.productos"> | 10 | <div *ngFor="let articulo of s.productos"> |
| 11 | <div class="custom-control custom-checkbox"> | 11 | <div class="custom-control custom-checkbox"> |
| 12 | <input | 12 | <input |
| 13 | type="checkbox" | 13 | type="checkbox" |
| 14 | class="custom-control-input" | 14 | class="custom-control-input" |
| 15 | [(ngModel)]="articulo.seleccionado" | 15 | [(ngModel)]="articulo.seleccionado" |
| 16 | (click)="selectArticulo(articulo)" | 16 | (click)="selectArticulo(articulo)" |
| 17 | [id]="articulo.id"> | 17 | [id]="articulo.id"> |
| 18 | <label | 18 | <label |
| 19 | class="custom-control-label" | 19 | class="custom-control-label" |
| 20 | [for]="articulo.id"> | 20 | [for]="articulo.id"> |
| 21 | {{articulo.DET_LAR}} | 21 | {{articulo.DET_LAR}} |
| 22 | </label> | 22 | </label> |
| 23 | </div> | 23 | </div> |
| 24 | </div> | 24 | </div> |
| 25 | </div> | 25 | </div> |
| 26 | </div> | 26 | </div> |
| 27 | 27 | ||
| 28 | <div class="modal-footer"> | 28 | <div class="modal-footer"> |
| 29 | <div | 29 | <div |
| 30 | [ngClass]="validate()" | 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 | CONTINUAR | 33 | CONTINUAR |
| 33 | <img | 34 | <img |
| 34 | draggable="false" | 35 | draggable="false" |
| 35 | ondragstart="return false;" | 36 | ondragstart="return false;" |
| 36 | (contextmenu)="false" | 37 | (contextmenu)="false" |
| 37 | class="icon-30" | 38 | class="icon-30" |
| 38 | src="assets/img/ir-color.svg"> | 39 | src="assets/img/ir-color.svg"> |
| 39 | </div> | 40 | </div> |
| 40 | </div> | 41 | </div> |
| 41 | </div> | 42 | </div> |
| 42 | 43 |
src/app/shared/sinonimo/sinonimo.component.ts
| 1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
| 2 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; | 2 | import { ISinonimo } from 'src/app/interfaces/ISinonimo'; |
| 3 | import { IArticulo } from 'src/app/interfaces/IArticulo'; | 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 | @Component({ | 8 | @Component({ |
| 6 | selector: 'app-sinonimo', | 9 | selector: 'app-sinonimo', |
| 7 | templateUrl: './sinonimo.component.html', | 10 | templateUrl: './sinonimo.component.html', |
| 8 | styleUrls: ['./sinonimo.component.scss'] | 11 | styleUrls: ['./sinonimo.component.scss'] |
| 9 | }) | 12 | }) |
| 10 | export class SinonimoComponent implements OnInit { | 13 | export class SinonimoComponent implements OnInit { |
| 11 | sinonimos: ISinonimo[] = []; | 14 | sinonimos: ISinonimo[] = []; |
| 12 | isValid: boolean; | 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 | ngOnInit() { | 26 | ngOnInit() { |
| 17 | } | 27 | } |
| 18 | 28 | ||
| 19 | selectArticulo(articulo: IArticulo) { | 29 | selectArticulo(articulo: IArticulo) { |
| 20 | for (const s of this.sinonimos) { | 30 | for (const s of this.sinonimos) { |
| 21 | for (const articulo of s.productos) { | 31 | for (const a of s.productos) { |
| 22 | articulo.seleccionado = false; | 32 | a.seleccionado = false; |
| 23 | } | 33 | } |
| 24 | } | 34 | } |
| 25 | articulo.seleccionado = true; | 35 | articulo.seleccionado = true; |
| 36 | this.articuloSelected = articulo; | ||
| 26 | } | 37 | } |
| 27 | 38 | ||
| 28 | validate() { | 39 | validate() { |
| 29 | this.isValid = false; | 40 | this.isValid = false; |
| 30 | for (const s of this.sinonimos) { | 41 | for (const s of this.sinonimos) { |
| 31 | for (const articulo of s.productos) { | 42 | for (const articulo of s.productos) { |
| 32 | if (articulo.seleccionado) { | 43 | if (articulo.seleccionado) { |
| 33 | this.isValid = true; | 44 | this.isValid = true; |
| 34 | } | 45 | } |
| 35 | } | 46 | } |
| 36 | } | 47 | } |
| 37 | return !this.isValid ? 'disabled' : ''; | 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 | } |
| 41 | 60 |