Commit f67ec934988cd9655d9adb0cd46f035713d0aa60
1 parent
75e1d0e078
Exists in
develop
and in
1 other branch
Arreglos de reglas de tslint
Showing
16 changed files
with
57 additions
and
55 deletions
Show diff stats
src/app/modules/admin/admin.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-admin', | 4 | selector: 'app-admin', |
5 | templateUrl: './admin.component.html', | 5 | templateUrl: './admin.component.html', |
6 | styleUrls: ['./admin.component.scss'] | 6 | styleUrls: ['./admin.component.scss'] |
7 | }) | 7 | }) |
8 | export class AdminComponent implements OnInit { | 8 | export class AdminComponent implements OnInit { |
9 | 9 | ||
10 | constructor() { } | 10 | constructor() { } |
11 | 11 | ||
12 | ngOnInit() { | 12 | ngOnInit() { } |
13 | console.log(""); | ||
14 | } | ||
15 | 13 | ||
16 | } | 14 | } |
17 | 15 |
src/app/modules/carrito/carrito.module.ts
1 | import { NgModule } from "@angular/core"; | 1 | import { NgModule } from '@angular/core'; |
2 | import { CommonModule } from "@angular/common"; | 2 | import { CommonModule } from '@angular/common'; |
3 | 3 | ||
4 | import { CarritoRoutingModule } from "./carrito-routing.module"; | 4 | import { CarritoRoutingModule } from './carrito-routing.module'; |
5 | import { CarritoComponent } from "./carrito.component"; | 5 | import { CarritoComponent } from './carrito.component'; |
6 | import { SeleccionArticulosModule } from '../seleccion-articulos/seleccion-articulos.module'; | 6 | import { SeleccionArticulosModule } from '../seleccion-articulos/seleccion-articulos.module'; |
7 | import { SharedModule } from '../shared/shared.module'; | 7 | import { SharedModule } from '../shared/shared.module'; |
8 | 8 | ||
9 | @NgModule({ | 9 | @NgModule({ |
10 | declarations: [CarritoComponent], | 10 | declarations: [CarritoComponent], |
11 | imports: [ | 11 | imports: [ |
12 | CommonModule, | 12 | CommonModule, |
13 | CarritoRoutingModule, | 13 | CarritoRoutingModule, |
14 | SeleccionArticulosModule, | 14 | SeleccionArticulosModule, |
15 | SharedModule, | 15 | SharedModule, |
16 | ] | 16 | ] |
17 | }) | 17 | }) |
18 | export class CarritoModule { } | 18 | export class CarritoModule { } |
19 | 19 |
src/app/modules/info-formas-pago/info-formas-pago-routing.module.ts
1 | import { NgModule } from "@angular/core"; | 1 | import { NgModule } from '@angular/core'; |
2 | import { Routes, RouterModule } from "@angular/router"; | 2 | import { Routes, RouterModule } from '@angular/router'; |
3 | import { InfoFormasPagoComponent } from "./info-formas-pago.component"; | 3 | import { InfoFormasPagoComponent } from './info-formas-pago.component'; |
4 | 4 | ||
5 | const routes: Routes = [{ path: "", component: InfoFormasPagoComponent }]; | 5 | const routes: Routes = [{ path: '', component: InfoFormasPagoComponent }]; |
6 | 6 | ||
7 | @NgModule({ | 7 | @NgModule({ |
8 | imports: [RouterModule.forChild(routes)], | 8 | imports: [RouterModule.forChild(routes)], |
9 | exports: [RouterModule] | 9 | exports: [RouterModule] |
10 | }) | 10 | }) |
11 | export class InfoFormasPagoRoutingModule {} | 11 | export class InfoFormasPagoRoutingModule {} |
12 | 12 |
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 | constructor() {} | 9 | constructor() {} |
10 | 10 | ||
11 | ngOnInit() {} | 11 | ngOnInit() {} |
12 | } | 12 | } |
13 | 13 |
src/app/modules/mensaje-final/mensaje-final.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-mensaje-final', | 6 | selector: 'app-mensaje-final', |
7 | templateUrl: './mensaje-final.component.html', | 7 | templateUrl: './mensaje-final.component.html', |
8 | styleUrls: ['./mensaje-final.component.scss'] | 8 | styleUrls: ['./mensaje-final.component.scss'] |
9 | }) | 9 | }) |
10 | export class MensajeFinalComponent implements OnInit { | 10 | export class MensajeFinalComponent implements OnInit { |
11 | 11 | ||
12 | constructor( | 12 | constructor( |
13 | public articuloService: ArticuloService, | 13 | public articuloService: ArticuloService, |
14 | private router: Router, | 14 | private router: Router, |
15 | ) { } | 15 | ) { } |
16 | 16 | ||
17 | ngOnInit() { | 17 | ngOnInit() { |
18 | setTimeout(() => { | 18 | setTimeout(() => { |
19 | this.goToSplash(); | 19 | this.goToSplash(); |
20 | }, 10000) | 20 | }, 10000); |
21 | } | 21 | } |
22 | 22 | ||
23 | goToSplash() { | 23 | goToSplash() { |
24 | this.articuloService.cleanShoppingCar(); | 24 | this.articuloService.cleanShoppingCar(); |
25 | this.router.navigate(['']); | 25 | this.router.navigate(['']); |
26 | } | 26 | } |
27 | 27 | ||
28 | } | 28 | } |
29 | 29 |
src/app/modules/opcion-pedido/opcion-pedido-routing.module.ts
1 | import { NgModule } from "@angular/core"; | 1 | import { NgModule } from '@angular/core'; |
2 | import { Routes, RouterModule } from "@angular/router"; | 2 | import { Routes, RouterModule } from '@angular/router'; |
3 | import { OpcionPedidoComponent } from './opcion-pedido.component'; | 3 | import { OpcionPedidoComponent } from './opcion-pedido.component'; |
4 | 4 | ||
5 | const routes: Routes = [{ path: "", component: OpcionPedidoComponent }]; | 5 | const routes: Routes = [{ path: '', component: OpcionPedidoComponent }]; |
6 | 6 | ||
7 | @NgModule({ | 7 | @NgModule({ |
8 | imports: [RouterModule.forChild(routes)], | 8 | imports: [RouterModule.forChild(routes)], |
9 | exports: [RouterModule] | 9 | exports: [RouterModule] |
10 | }) | 10 | }) |
11 | export class OpcionPedidoRoutingModule {} | 11 | export class OpcionPedidoRoutingModule {} |
12 | 12 |
src/app/modules/opcion-pedido/opcion-pedido.component.ts
1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
2 | import { Router } from '@angular/router'; | 2 | import { Router } from '@angular/router'; |
3 | 3 | ||
4 | @Component({ | 4 | @Component({ |
5 | selector: 'app-opcion-pedido', | 5 | selector: 'app-opcion-pedido', |
6 | templateUrl: './opcion-pedido.component.html', | 6 | templateUrl: './opcion-pedido.component.html', |
7 | styleUrls: ['./opcion-pedido.component.scss'] | 7 | styleUrls: ['./opcion-pedido.component.scss'] |
8 | }) | 8 | }) |
9 | export class OpcionPedidoComponent implements OnInit { | 9 | export class OpcionPedidoComponent implements OnInit { |
10 | 10 | ||
11 | constructor( | 11 | constructor( |
12 | private router: Router, | 12 | private router: Router, |
13 | ) { } | 13 | ) { } |
14 | 14 | ||
15 | ngOnInit() { | 15 | ngOnInit() { |
16 | } | 16 | } |
17 | 17 | ||
18 | goTo(path) { | 18 | goTo(path) { |
19 | this.router.navigate([path]); | 19 | this.router.navigate([path]); |
20 | } | 20 | } |
21 | 21 | ||
22 | seleccionPedido(lugar) { | 22 | seleccionPedido(lugar) { |
23 | localStorage.setItem('pedidoPara', lugar) | 23 | localStorage.setItem('pedidoPara', lugar); |
24 | } | 24 | } |
25 | } | 25 | } |
26 | 26 |
src/app/modules/opcion-pedido/opcion-pedido.module.ts
1 | import { NgModule } from "@angular/core"; | 1 | import { NgModule } from '@angular/core'; |
2 | import { CommonModule } from "@angular/common"; | 2 | import { CommonModule } from '@angular/common'; |
3 | import { OpcionPedidoRoutingModule } from "./opcion-pedido-routing.module"; | 3 | import { OpcionPedidoRoutingModule } from './opcion-pedido-routing.module'; |
4 | import { OpcionPedidoComponent } from "./opcion-pedido.component"; | 4 | import { OpcionPedidoComponent } from './opcion-pedido.component'; |
5 | 5 | ||
6 | @NgModule({ | 6 | @NgModule({ |
7 | declarations: [OpcionPedidoComponent], | 7 | declarations: [OpcionPedidoComponent], |
8 | imports: [CommonModule, OpcionPedidoRoutingModule] | 8 | imports: [CommonModule, OpcionPedidoRoutingModule] |
9 | }) | 9 | }) |
10 | export class OpcionPedidoModule {} | 10 | export class OpcionPedidoModule {} |
11 | 11 |
src/app/modules/pago-electronico/pago-electronico.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 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 4 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
5 | 5 | ||
6 | @Component({ | 6 | @Component({ |
7 | selector: 'app-pago-electronico', | 7 | selector: 'app-pago-electronico', |
8 | templateUrl: './pago-electronico.component.html', | 8 | templateUrl: './pago-electronico.component.html', |
9 | styleUrls: ['./pago-electronico.component.scss'] | 9 | styleUrls: ['./pago-electronico.component.scss'] |
10 | }) | 10 | }) |
11 | export class PagoElectronicoComponent implements OnInit { | 11 | export class PagoElectronicoComponent implements OnInit { |
12 | urlQr = `${APP_SETTINGS.apiDeboSuite}/qr/dev/${APP_SETTINGS.codigoP}/tienda/${APP_SETTINGS.terminal}`; | 12 | urlQr = `${APP_SETTINGS.apiDeboSuite}/qr/dev/${APP_SETTINGS.codigoP}/tienda/${APP_SETTINGS.terminal}`; |
13 | 13 | ||
14 | constructor( | 14 | constructor( |
15 | private articuloService: ArticuloService, | 15 | private articuloService: ArticuloService, |
16 | private router: Router, | 16 | private router: Router, |
17 | ) { } | 17 | ) { } |
18 | 18 | ||
19 | ngOnInit() { | 19 | ngOnInit() { |
20 | if (!this.articuloService.carrito.length) { | 20 | if (!this.articuloService.carrito.length) { |
21 | this.router.navigate(['']); | 21 | this.router.navigate(['']); |
22 | return; | 22 | return; |
23 | } | 23 | } |
24 | let dataPago = { | 24 | const dataPago = { |
25 | pedidoAnombreDe: '' | 25 | pedidoAnombreDe: '' |
26 | } | 26 | }; |
27 | dataPago.pedidoAnombreDe = ''; | ||
27 | this.articuloService.pay(dataPago) | 28 | this.articuloService.pay(dataPago) |
28 | .subscribe((res: any) => { | 29 | .subscribe((res: any) => { |
29 | this.articuloService.idComanda = res.data; | 30 | this.articuloService.idComanda = res.data; |
30 | this.router.navigate(['mensaje-final']); | 31 | this.router.navigate(['mensaje-final']); |
31 | }, err => console.error(err)); | 32 | }, err => console.error(err)); |
32 | } | 33 | } |
33 | 34 | ||
34 | } | 35 | } |
35 | 36 |
src/app/modules/pago-tarjeta/pago-tarjeta.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-pago-tarjeta', | 6 | selector: 'app-pago-tarjeta', |
7 | templateUrl: './pago-tarjeta.component.html', | 7 | templateUrl: './pago-tarjeta.component.html', |
8 | styleUrls: ['./pago-tarjeta.component.scss'] | 8 | styleUrls: ['./pago-tarjeta.component.scss'] |
9 | }) | 9 | }) |
10 | export class PagoTarjetaComponent implements OnInit { | 10 | export class PagoTarjetaComponent implements OnInit { |
11 | 11 | ||
12 | constructor( | 12 | constructor( |
13 | private articuloService: ArticuloService, | 13 | private articuloService: ArticuloService, |
14 | private router: Router, | 14 | private router: Router, |
15 | ) { } | 15 | ) { } |
16 | 16 | ||
17 | ngOnInit() { | 17 | ngOnInit() { |
18 | if (!this.articuloService.carrito.length) { | 18 | if (!this.articuloService.carrito.length) { |
19 | this.router.navigate(['']); | 19 | this.router.navigate(['']); |
20 | return; | 20 | return; |
21 | } | 21 | } |
22 | let dataPago = { | 22 | const dataPago = { |
23 | pedidoAnombreDe: '' | 23 | pedidoAnombreDe: '' |
24 | } | 24 | }; |
25 | this.articuloService.pay(dataPago) | 25 | this.articuloService.pay(dataPago) |
26 | .subscribe((res: any) => { | 26 | .subscribe((res: any) => { |
27 | this.articuloService.idComanda = res.data; | 27 | this.articuloService.idComanda = res.data; |
28 | this.router.navigate(['mensaje-final']); | 28 | this.router.navigate(['mensaje-final']); |
29 | }, err => console.error(err)); | 29 | }, err => console.error(err)); |
30 | } | 30 | } |
31 | 31 | ||
32 | } | 32 | } |
33 | 33 |
src/app/modules/pedidos-salientes/pedidos-salientes.component.ts
1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
2 | import { ComandaService } from 'src/app/services/comanda/comanda.service'; | 2 | import { ComandaService } from 'src/app/services/comanda/comanda.service'; |
3 | 3 | ||
4 | @Component({ | 4 | @Component({ |
5 | selector: 'app-pedidos-salientes', | 5 | selector: 'app-pedidos-salientes', |
6 | templateUrl: './pedidos-salientes.component.html', | 6 | templateUrl: './pedidos-salientes.component.html', |
7 | styleUrls: ['./pedidos-salientes.component.scss'] | 7 | styleUrls: ['./pedidos-salientes.component.scss'] |
8 | }) | 8 | }) |
9 | export class PedidosSalientesComponent implements OnInit { | 9 | export class PedidosSalientesComponent implements OnInit { |
10 | pedidoFinalizado = []; | 10 | pedidoFinalizado = []; |
11 | cicloTime; | 11 | cicloTime; |
12 | pedidosPendientes = []; | 12 | pedidosPendientes = []; |
13 | 13 | ||
14 | constructor( | 14 | constructor( |
15 | private comandaServices: ComandaService | 15 | private comandaServices: ComandaService |
16 | ) { } | 16 | ) { } |
17 | 17 | ||
18 | ngOnInit() { | 18 | ngOnInit() { |
19 | this.buscarPedidosFinalizados(); | 19 | this.buscarPedidosFinalizados(); |
20 | this.buscarPedidosPendientes(); | 20 | this.buscarPedidosPendientes(); |
21 | this.ciclo(); | 21 | this.ciclo(); |
22 | } | 22 | } |
23 | 23 | ||
24 | ngOnDestroy() { | 24 | OnDestroy() { |
25 | clearTimeout(this.cicloTime); | 25 | clearTimeout(this.cicloTime); |
26 | } | 26 | } |
27 | 27 | ||
28 | buscarPedidosFinalizados() { | 28 | buscarPedidosFinalizados() { |
29 | this.comandaServices.getPendientesEntrega() | 29 | this.comandaServices.getPendientesEntrega() |
30 | .subscribe((pedidos: []) => { | 30 | .subscribe((pedidos: []) => { |
31 | this.pedidoFinalizado = pedidos; | 31 | this.pedidoFinalizado = pedidos; |
32 | }); | 32 | }); |
33 | } | 33 | } |
34 | 34 | ||
35 | buscarPedidosPendientes() { | 35 | buscarPedidosPendientes() { |
36 | this.comandaServices.getAll() | 36 | this.comandaServices.getAll() |
37 | .subscribe((resComandas: []) => { | 37 | .subscribe((resComandas: []) => { |
38 | this.pedidosPendientes = resComandas; | 38 | this.pedidosPendientes = resComandas; |
39 | }, e => console.error(e)); | 39 | }, e => console.error(e)); |
40 | } | 40 | } |
41 | 41 | ||
42 | ciclo() { | 42 | ciclo() { |
43 | this.cicloTime = setTimeout(() => { | 43 | this.cicloTime = setTimeout(() => { |
44 | this.buscarPedidosFinalizados(); | 44 | this.buscarPedidosFinalizados(); |
45 | this.buscarPedidosPendientes(); | 45 | this.buscarPedidosPendientes(); |
46 | this.ciclo(); | 46 | this.ciclo(); |
47 | }, 5000); | 47 | }, 5000); |
48 | } | 48 | } |
49 | 49 | ||
50 | rellenar(relleno, longitud) { | 50 | rellenar(relleno, longitud) { |
51 | relleno = '' + relleno; | 51 | relleno = '' + relleno; |
52 | while (relleno.length < longitud) { | 52 | while (relleno.length < longitud) { |
53 | relleno = '0' + relleno; | 53 | relleno = '0' + relleno; |
54 | } | 54 | } |
55 | return relleno; | 55 | return relleno; |
56 | } | 56 | } |
57 | 57 | ||
58 | } | 58 | } |
59 | 59 |
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
1 | import { Component, OnInit } from "@angular/core"; | 1 | import { Component, OnInit } from '@angular/core'; |
2 | import { BsModalRef } from 'ngx-bootstrap/modal'; | 2 | import { BsModalRef } 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 { CategoriaService } from 'src/app/services/categoria/categoria.service'; | 7 | import { CategoriaService } from 'src/app/services/categoria/categoria.service'; |
8 | 8 | ||
9 | @Component({ | 9 | @Component({ |
10 | selector: "app-seleccion-articulos", | 10 | selector: 'app-seleccion-articulos', |
11 | templateUrl: "./seleccion-articulos.component.html", | 11 | templateUrl: './seleccion-articulos.component.html', |
12 | styleUrls: ["./seleccion-articulos.component.scss"] | 12 | styleUrls: ['./seleccion-articulos.component.scss'] |
13 | }) | 13 | }) |
14 | export class SeleccionArticulosComponent implements OnInit { | 14 | export class SeleccionArticulosComponent implements OnInit { |
15 | showSpinner = true; | 15 | showSpinner = true; |
16 | timeoutHandler: any; | 16 | timeoutHandler: any; |
17 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; | 17 | urlImagenes = `${APP_SETTINGS.apiDeboSuite}/imagenes/`; |
18 | articulos: IArticulo[] = []; | 18 | articulos: IArticulo[] = []; |
19 | auxArticulos: IArticulo[] = []; | 19 | auxArticulos: IArticulo[] = []; |
20 | showQuantity = 100; | 20 | showQuantity = 100; |
21 | queMostrar = 'todos'; | 21 | queMostrar = 'todos'; |
22 | categoriaActive: number = null; | 22 | categoriaActive: number = null; |
23 | categorias: ICategoria[] = []; | 23 | categorias: ICategoria[] = []; |
24 | searchTerm = ''; | 24 | searchTerm = ''; |
25 | ordenandoByVendidos = true; | 25 | ordenandoByVendidos = true; |
26 | allActive = true; | 26 | allActive = true; |
27 | modalRef: BsModalRef; | 27 | modalRef: BsModalRef; |
28 | 28 | ||
29 | constructor( | 29 | constructor( |
30 | public articuloService: ArticuloService, | 30 | public articuloService: ArticuloService, |
31 | private categoriaService: CategoriaService, | 31 | private categoriaService: CategoriaService, |
32 | ) { } | 32 | ) { } |
33 | 33 | ||
34 | ngOnInit() { | 34 | ngOnInit() { |
35 | this.getCategorias(); | 35 | this.getCategorias(); |
36 | } | 36 | } |
37 | 37 | ||
38 | getCategorias() { | 38 | getCategorias() { |
39 | this.categoriaService.getCategorias() | 39 | this.categoriaService.getCategorias() |
40 | .subscribe((categorias: ICategoria[]) => { | 40 | .subscribe((categorias: ICategoria[]) => { |
41 | switch (this.queMostrar) { | 41 | switch (this.queMostrar) { |
42 | case 'todos': | 42 | case 'todos': |
43 | this.categorias = categorias; | 43 | this.categorias = categorias; |
44 | this.categoriaActive = 0; | 44 | this.categoriaActive = 0; |
45 | break; | 45 | break; |
46 | case 'promociones': | 46 | case 'promociones': |
47 | this.categorias = categorias; | 47 | this.categorias = categorias; |
48 | this.categoriaActive = 19; | 48 | this.categoriaActive = 19; |
49 | break; | 49 | break; |
50 | case 'ordenar': | 50 | case 'ordenar': |
51 | this.categorias = categorias.filter((categoria: ICategoria) => { | 51 | this.categorias = categorias.filter((categoria: ICategoria) => { |
52 | return categoria.ES_PEDIDO; | 52 | return categoria.ES_PEDIDO; |
53 | }); | 53 | }); |
54 | this.categoriaActive = 4; | 54 | this.categoriaActive = 4; |
55 | break; | 55 | break; |
56 | default: | 56 | default: |
57 | this.categorias = categorias; | 57 | this.categorias = categorias; |
58 | this.categoriaActive = 0; | 58 | this.categoriaActive = 0; |
59 | break; | 59 | break; |
60 | } | 60 | } |
61 | !localStorage.getItem('articulos') ? | 61 | !localStorage.getItem('articulos') ? |
62 | this.getProductos() : | 62 | this.getProductos() : |
63 | this.setProductos(); | 63 | this.setProductos(); |
64 | }); | 64 | }); |
65 | } | 65 | } |
66 | 66 | ||
67 | getProductos() { | 67 | getProductos() { |
68 | this.articuloService.getAll() | 68 | this.articuloService.getAll() |
69 | .subscribe((result: IArticulo[]) => { | 69 | .subscribe((result: IArticulo[]) => { |
70 | this.articuloService.setArticulosSinImagen(result); | 70 | this.articuloService.setArticulosSinImagen(result); |
71 | if (this.queMostrar == 'ordenar') { | 71 | if (this.queMostrar === 'ordenar') { |
72 | this.categorias.forEach((categoria: ICategoria) => { | 72 | this.categorias.forEach((categoria: ICategoria) => { |
73 | let tempArticulos = result.filter((articulo: IArticulo) => { | 73 | const tempArticulos = result.filter((articulo: IArticulo) => { |
74 | return articulo.categoria_selfservice == categoria.id; | 74 | return articulo.categoria_selfservice === categoria.id; |
75 | }); | 75 | }); |
76 | result = tempArticulos; | 76 | result = tempArticulos; |
77 | }); | 77 | }); |
78 | } | 78 | } |
79 | localStorage.setItem('articulos', JSON.stringify(result)); | 79 | localStorage.setItem('articulos', JSON.stringify(result)); |
80 | this.setProductos(); | 80 | this.setProductos(); |
81 | }, (error) => { | 81 | }, (error) => { |
82 | this.showSpinner = false; | 82 | this.showSpinner = false; |
83 | console.error(error); | 83 | console.error(error); |
84 | }); | 84 | }); |
85 | } | 85 | } |
86 | 86 | ||
87 | setProductos() { | 87 | setProductos() { |
88 | this.articulos = JSON.parse(localStorage.getItem('articulos')); | 88 | this.articulos = JSON.parse(localStorage.getItem('articulos')); |
89 | this.filterItems(); | 89 | this.filterItems(); |
90 | } | 90 | } |
91 | 91 | ||
92 | filterItems() { | 92 | filterItems() { |
93 | if (this.categoriaActive == 0) { | 93 | if (this.categoriaActive === 0) { |
94 | this.auxArticulos = this.articulos; | 94 | this.auxArticulos = this.articulos; |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | this.auxArticulos = this.articulos.filter(x => { | 97 | this.auxArticulos = this.articulos.filter(x => { |
98 | return x.categoria_selfservice === this.categoriaActive; | 98 | return x.categoria_selfservice === this.categoriaActive; |
99 | }); | 99 | }); |
100 | this.ordenar(); | 100 | this.ordenar(); |
101 | } | 101 | } |
102 | 102 | ||
103 | ordenar() { | 103 | ordenar() { |
104 | if (this.ordenandoByVendidos) { | 104 | if (this.ordenandoByVendidos) { |
105 | this.auxArticulos.sort((a, b) => { | 105 | this.auxArticulos.sort((a, b) => { |
106 | return b.cantidadVendida - a.cantidadVendida; | 106 | return b.cantidadVendida - a.cantidadVendida; |
107 | }); | 107 | }); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | selectCategoria(index: number, idCategoria?: number) { | 111 | selectCategoria(index: number, idCategoria?: number) { |
112 | if (this.categoriaActive == idCategoria) return; | 112 | if (this.categoriaActive === idCategoria) return; |
113 | this.categoriaActive = idCategoria; | 113 | this.categoriaActive = idCategoria; |
114 | this.allActive = idCategoria === 0 ? true : false; | 114 | this.allActive = idCategoria === 0 ? true : false; |
115 | this.categorias.forEach((categoria, i) => { | 115 | this.categorias.forEach((categoria, i) => { |
116 | categoria.selected = index === i ? true : false; | 116 | categoria.selected = index === i ? true : false; |
117 | }); | 117 | }); |
118 | this.filterItems(); | 118 | this.filterItems(); |
119 | } | 119 | } |
120 | 120 | ||
121 | elegirArticulo(articulo: IArticulo) { | 121 | elegirArticulo(articulo: IArticulo) { |
122 | this.articuloService.getById(articulo.id) | 122 | this.articuloService.getById(articulo.id) |
123 | .subscribe((res: IArticulo) => { | 123 | .subscribe((res: IArticulo) => { |
124 | res.cantidad = 1; | 124 | res.cantidad = 1; |
125 | this.articuloService.setArticulo(res); | 125 | this.articuloService.setArticulo(res); |
126 | }, err => console.error(err)); | 126 | }, err => console.error(err)); |
127 | } | 127 | } |
128 | 128 | ||
129 | increaseShow() { | 129 | increaseShow() { |
130 | this.showQuantity += 100; | 130 | this.showQuantity += 100; |
131 | } | 131 | } |
132 | 132 | ||
133 | mouseup() { | 133 | mouseup() { |
134 | if (!this.timeoutHandler) return; | 134 | if (!this.timeoutHandler) return; |
135 | clearInterval(this.timeoutHandler); | 135 | clearInterval(this.timeoutHandler); |
136 | } | 136 | } |
137 | 137 | ||
138 | scrollY(el: HTMLElement, value) { | 138 | scrollY(el: HTMLElement, value) { |
139 | el.scroll({ behavior: "smooth", top: value + el.scrollTop }); | 139 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); |
140 | this.timeoutHandler = setInterval(() => { | 140 | this.timeoutHandler = setInterval(() => { |
141 | el.scroll({ behavior: "smooth", top: value + el.scrollTop }); | 141 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); |
142 | }, 500); | 142 | }, 500); |
143 | } | 143 | } |
144 | 144 | ||
145 | scrollX(el: HTMLElement, value) { | 145 | scrollX(el: HTMLElement, value) { |
146 | el.scroll({ behavior: "smooth", left: value + el.scrollLeft }); | 146 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); |
147 | this.timeoutHandler = setInterval(() => { | 147 | this.timeoutHandler = setInterval(() => { |
148 | el.scroll({ behavior: "smooth", left: value + el.scrollLeft }); | 148 | el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); |
149 | }, 500); | 149 | }, 500); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 |
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: boolean = 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 | 18 | ||
19 | constructor( | 19 | constructor( |
20 | private http: HttpClient, | 20 | private http: HttpClient, |
21 | private clienteService: ClienteService, | 21 | private clienteService: ClienteService, |
22 | ) { } | 22 | ) { } |
23 | 23 | ||
24 | getById(id) { | 24 | getById(id) { |
25 | return this.http.get(`${this.urlDeboSuite}/articulos/${id}`); | 25 | return this.http.get(`${this.urlDeboSuite}/articulos/${id}`); |
26 | } | 26 | } |
27 | 27 | ||
28 | getAll() { | 28 | getAll() { |
29 | return this.http.get(`${this.urlDeboSuite}/articulos/`); | 29 | return this.http.get(`${this.urlDeboSuite}/articulos/`); |
30 | } | 30 | } |
31 | 31 | ||
32 | getAllWithPaginator(page: number = 1) { | 32 | getAllWithPaginator(page: number = 1) { |
33 | return this.http.get(`${this.urlDeboSuite}/articulos/${page}`); | 33 | return this.http.get(`${this.urlDeboSuite}/articulos/${page}`); |
34 | } | 34 | } |
35 | 35 | ||
36 | setArticulo(articulo: IArticulo) { | 36 | setArticulo(articulo: IArticulo) { |
37 | for (let i = 0; i < this.carrito.length; i++) { | 37 | for (const articuloCarrito of this.carrito) { |
38 | if (this.carrito[i].id === articulo.id) { | 38 | if (articuloCarrito.id === articulo.id) { |
39 | if (articulo.PRO) break; | 39 | if (articulo.PRO) break; |
40 | this.carrito[i].cantidad++; | 40 | articuloCarrito.cantidad++; |
41 | return; | 41 | return; |
42 | } | 42 | } |
43 | } | 43 | } |
44 | this.setArticulosSinImagen([articulo]); | 44 | this.setArticulosSinImagen([articulo]); |
45 | this.carrito.unshift(articulo); | 45 | this.carrito.unshift(articulo); |
46 | } | 46 | } |
47 | 47 | ||
48 | pay(dataPago: any) { | 48 | pay(dataPago: any) { |
49 | return new Observable((observer) => { | 49 | return new Observable((observer) => { |
50 | this.clienteService.getById(-1) | 50 | this.clienteService.getById(-1) |
51 | .subscribe(cliente => { | 51 | .subscribe(cliente => { |
52 | let puntoVenta = APP_SETTINGS.puntoVenta; | ||
53 | this.markArticuloInPromoAsRemoved(); | 52 | this.markArticuloInPromoAsRemoved(); |
54 | this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${this.medioPago}`, { | 53 | this.http.post(`${this.urlDeboSuite}/comprobante/guardar/${this.medioPago}`, { |
55 | productos: this.carrito, | 54 | productos: this.carrito, |
56 | cliente: cliente, | 55 | cliente, |
57 | origen: 'autoservicio', | 56 | origen: 'autoservicio', |
58 | codigoVendedor: 5, | 57 | codigoVendedor: 5, |
59 | puntoVenta: puntoVenta, | 58 | puntoVenta: APP_SETTINGS.puntoVenta, |
60 | pedidoAnombreDe: dataPago.pedidoAnombreDe, | 59 | pedidoAnombreDe: dataPago.pedidoAnombreDe, |
61 | numeroPlanilla: APP_SETTINGS.numeroPlanilla, | 60 | numeroPlanilla: APP_SETTINGS.numeroPlanilla, |
62 | }) | 61 | }) |
63 | .subscribe((data) => { | 62 | .subscribe((data) => { |
64 | observer.next(data); | 63 | observer.next(data); |
65 | observer.complete(); | 64 | observer.complete(); |
66 | }); | 65 | }); |
67 | }); | 66 | }); |
68 | }); | 67 | }); |
69 | } | 68 | } |
70 | 69 | ||
71 | cleanShoppingCar() { | 70 | cleanShoppingCar() { |
72 | this.articuloAcargar = undefined; | 71 | this.articuloAcargar = undefined; |
73 | this.promoAcargar = undefined; | 72 | this.promoAcargar = undefined; |
74 | this.carrito = []; | 73 | this.carrito = []; |
75 | } | 74 | } |
76 | 75 | ||
77 | setArticulosSinImagen(articulos: IArticulo[]) { | 76 | setArticulosSinImagen(articulos: IArticulo[]) { |
78 | articulos.forEach((articulo: IArticulo) => { | 77 | articulos.forEach((articulo: IArticulo) => { |
79 | articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] : | 78 | articulo.imagenes = !articulo.imagenes ? [{ imagen: 'noImage.jpg' }] : |
80 | !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes; | 79 | !articulo.imagenes.length ? [{ imagen: 'noImage.jpg' }] : articulo.imagenes; |
81 | }); | 80 | }); |
82 | } | 81 | } |
83 | 82 | ||
84 | markArticuloInPromoAsRemoved() { | 83 | markArticuloInPromoAsRemoved() { |
85 | this.carrito.forEach((articulo: IArticulo) => { | 84 | this.carrito.forEach((articuloCarrito: IArticulo) => { |
86 | if (articulo.PRO) { | 85 | if (articuloCarrito.PRO) { |
87 | articulo.productos.forEach((articulo: IArticulo) => { | 86 | articuloCarrito.productos.forEach((articulo: IArticulo) => { |
88 | if (articulo.cantidadAdicionada === 0) { | 87 | if (articulo.cantidadAdicionada === 0) { |
89 | articulo.cantidad = 0; | 88 | articulo.cantidad = 0; |
90 | articulo.importeValorExtra = 0; | 89 | articulo.importeValorExtra = 0; |
91 | } | 90 | } |
92 | }); | 91 | }); |
93 | } | 92 | } |
94 | }); | 93 | }); |
95 | } | 94 | } |
96 | } | 95 | } |
97 | 96 |
src/app/services/cliente/cliente.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 "src/etc/AppSettings"; | 3 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
4 | 4 | ||
5 | @Injectable({ | 5 | @Injectable({ |
6 | providedIn: 'root' | 6 | providedIn: 'root' |
7 | }) | 7 | }) |
8 | export class ClienteService { | 8 | export class ClienteService { |
9 | urlClientes = `${APP_SETTINGS.apiDeboSuite}/clientes`; | 9 | urlClientes = `${APP_SETTINGS.apiDeboSuite}/clientes`; |
10 | 10 | ||
11 | constructor(private http: HttpClient) { } | 11 | constructor(private http: HttpClient) { } |
12 | 12 | ||
13 | getById(id: number) { | 13 | getById(id: number) { |
14 | return this.http.get(`${this.urlClientes}/get/${id}`); | 14 | return this.http.get(`${this.urlClientes}/get/${id}`); |
15 | } | 15 | } |
16 | } | 16 | } |
17 | 17 |
src/app/services/comanda/comanda.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 "src/etc/AppSettings"; | 3 | import { APP_SETTINGS } from 'src/etc/AppSettings'; |
4 | 4 | ||
5 | @Injectable({ | 5 | @Injectable({ |
6 | providedIn: 'root' | 6 | providedIn: 'root' |
7 | }) | 7 | }) |
8 | export class ComandaService { | 8 | export class ComandaService { |
9 | urlDeboSuite = APP_SETTINGS.apiDeboSuite; | 9 | urlDeboSuite = APP_SETTINGS.apiDeboSuite; |
10 | 10 | ||
11 | constructor( | 11 | constructor( |
12 | private http: HttpClient, | 12 | private http: HttpClient, |
13 | ) { } | 13 | ) { } |
14 | 14 | ||
15 | getPendientesEntrega() { | 15 | getPendientesEntrega() { |
16 | return this.http.get(`${this.urlDeboSuite}/comandas/pendientes-entrega`); | 16 | return this.http.get(`${this.urlDeboSuite}/comandas/pendientes-entrega`); |
17 | } | 17 | } |
18 | 18 | ||
19 | getAll() { | 19 | getAll() { |
20 | return this.http.get(`${this.urlDeboSuite}/comandas`); | 20 | return this.http.get(`${this.urlDeboSuite}/comandas`); |
21 | } | 21 | } |
22 | 22 | ||
23 | } | 23 | } |
24 | 24 |
tslint.json
1 | { | 1 | { |
2 | "extends": "tslint:recommended", | 2 | "extends": "tslint:recommended", |
3 | "rules": { | 3 | "rules": { |
4 | "array-type": false, | 4 | "array-type": false, |
5 | "arrow-parens": false, | 5 | "arrow-parens": false, |
6 | "deprecation": { | 6 | "deprecation": { |
7 | "severity": "warning" | 7 | "severity": "warning" |
8 | }, | 8 | }, |
9 | "component-class-suffix": true, | 9 | "component-class-suffix": true, |
10 | "contextual-lifecycle": true, | 10 | "contextual-lifecycle": true, |
11 | "curly": [ | ||
12 | true, | ||
13 | "ignore-same-line" | ||
14 | ], | ||
11 | "directive-class-suffix": true, | 15 | "directive-class-suffix": true, |
12 | "directive-selector": [ | 16 | "directive-selector": [ |
13 | true, | 17 | true, |
14 | "attribute", | 18 | "attribute", |
15 | "app", | 19 | "app", |
16 | "camelCase" | 20 | "camelCase" |
17 | ], | 21 | ], |
18 | "component-selector": [ | 22 | "component-selector": [ |
19 | true, | 23 | true, |
20 | "element", | 24 | "element", |
21 | "app", | 25 | "app", |
22 | "kebab-case" | 26 | "kebab-case" |
23 | ], | 27 | ], |
24 | "import-blacklist": [ | 28 | "import-blacklist": [ |
25 | true, | 29 | true, |
26 | "rxjs/Rx" | 30 | "rxjs/Rx" |
27 | ], | 31 | ], |
28 | "interface-name": false, | 32 | "interface-name": false, |
29 | "max-classes-per-file": false, | 33 | "max-classes-per-file": false, |
30 | "max-line-length": [ | 34 | "max-line-length": [ |
31 | true, | 35 | true, |
32 | 140 | 36 | 140 |
33 | ], | 37 | ], |
34 | "member-access": false, | 38 | "member-access": false, |
35 | "member-ordering": [ | 39 | "member-ordering": [ |
36 | true, | 40 | true, |
37 | { | 41 | { |
38 | "order": [ | 42 | "order": [ |
39 | "static-field", | 43 | "static-field", |
40 | "instance-field", | 44 | "instance-field", |
41 | "static-method", | 45 | "static-method", |
42 | "instance-method" | 46 | "instance-method" |
43 | ] | 47 | ] |
44 | } | 48 | } |
45 | ], | 49 | ], |
46 | "no-consecutive-blank-lines": false, | 50 | "no-consecutive-blank-lines": false, |
47 | "no-console": [ | 51 | "no-console": [ |
48 | true, | 52 | true, |
49 | "debug", | 53 | "debug", |
50 | "info", | 54 | "info", |
51 | "time", | 55 | "time", |
52 | "timeEnd", | 56 | "timeEnd", |
53 | "trace", | 57 | "trace", |
54 | "log" | 58 | "log" |
55 | ], | 59 | ], |
56 | "no-empty": false, | 60 | "no-empty": false, |
57 | "no-inferrable-types": [ | 61 | "no-inferrable-types": [ |
58 | true, | 62 | true, |
59 | "ignore-params" | 63 | "ignore-params" |
60 | ], | 64 | ], |
61 | "no-non-null-assertion": true, | 65 | "no-non-null-assertion": true, |
62 | "no-redundant-jsdoc": true, | 66 | "no-redundant-jsdoc": true, |
63 | "no-switch-case-fall-through": true, | 67 | "no-switch-case-fall-through": true, |
64 | "no-var-requires": false, | 68 | "no-var-requires": false, |
65 | "object-literal-key-quotes": [ | 69 | "object-literal-key-quotes": [ |
66 | true, | 70 | true, |
67 | "as-needed" | 71 | "as-needed" |
68 | ], | 72 | ], |
69 | "object-literal-sort-keys": false, | 73 | "object-literal-sort-keys": false, |
70 | "ordered-imports": false, | 74 | "ordered-imports": false, |
71 | "quotemark": [ | 75 | "quotemark": [ |
72 | true, | 76 | true, |
73 | "single" | 77 | "single" |
74 | ], | 78 | ], |
75 | "trailing-comma": false, | 79 | "trailing-comma": false, |
76 | "no-conflicting-lifecycle": true, | 80 | "no-conflicting-lifecycle": true, |
77 | "no-host-metadata-property": true, | 81 | "no-host-metadata-property": true, |
78 | "no-input-rename": true, | 82 | "no-input-rename": true, |
79 | "no-inputs-metadata-property": true, | 83 | "no-inputs-metadata-property": true, |
80 | "no-output-native": true, | 84 | "no-output-native": true, |
81 | "no-output-on-prefix": true, | 85 | "no-output-on-prefix": true, |
82 | "no-output-rename": true, | 86 | "no-output-rename": true, |
83 | "no-outputs-metadata-property": true, | 87 | "no-outputs-metadata-property": true, |
84 | "template-banana-in-box": true, | 88 | "template-banana-in-box": true, |
85 | "template-no-negated-async": true, | 89 | "template-no-negated-async": true, |
86 | "use-lifecycle-interface": true, | 90 | "use-lifecycle-interface": true, |
87 | "use-pipe-transform-interface": true | 91 | "use-pipe-transform-interface": true |
88 | }, | 92 | }, |
89 | "rulesDirectory": [ | 93 | "rulesDirectory": [ |
90 | "codelyzer" | 94 | "codelyzer" |
91 | ] | 95 | ] |
92 | } | 96 | } |