Commit bc753a27efb30d2250f653c8fbec7baa3c85b2ef

Authored by Benjamin Rodriguez
1 parent 540f91d409
Exists in develop

agrego spinner en seleccion-articulos

src/app/modules/seleccion-articulos/seleccion-articulos.component.html
1 <div class="h-92 bg-white fade-in-left"> 1 <div class="h-92 bg-white fade-in-left">
2 <!-- PUBLICIDADES --> 2 <!-- PUBLICIDADES -->
3 <app-header-publicidad></app-header-publicidad> 3 <app-header-publicidad></app-header-publicidad>
4 4
5 <div class="row mx-0 align-items-end" 5 <div class="row mx-0 align-items-end"
6 [ngClass]="boxCarrito.classList.contains('media-pantalla') 6 [ngClass]="boxCarrito.classList.contains('media-pantalla')
7 ? 'h-68' : 'h-80'"> 7 ? 'h-68' : 'h-80'">
8 <!-- CABECERA --> 8 <!-- CABECERA -->
9 <div class="row w-100 mx-3 h-auto border border-primary rounded-sm"> 9 <div class="row w-100 mx-3 h-auto border border-primary rounded-sm">
10 <div class="col-12 p-2 align-self-center"> 10 <div class="col-12 p-2 align-self-center">
11 <div class="px-3"> 11 <div class="px-3">
12 <p class="h6 text-truncate">SELECCIONÁ TÚ COMIDA Y/O BEBIDA</p> 12 <p class="h6 text-truncate">SELECCIONÁ TÚ COMIDA Y/O BEBIDA</p>
13 </div> 13 </div>
14 </div> 14 </div>
15 </div> 15 </div>
16 <!-- CUERPO --> 16 <!-- CUERPO -->
17 <div class="row w-100 mr-4 h-50 h-md-70" id="content"> 17 <div class="row w-100 mr-4 h-50 h-md-70" id="content">
18 <div class="col-12 h-100 px-0 py-3"> 18 <div class="col-12 h-100 px-0 py-3">
19 <div class="row mx-0 h-100"> 19 <div class="row mx-0 h-100">
20 <app-filtro-categorias 20 <app-filtro-categorias
21 class="col-5 col-sm-3 col-xl-2 h-100" 21 class="col-5 col-sm-3 col-xl-2 h-100"
22 #filtroCategorias 22 #filtroCategorias
23 (getProductos)="getProductos()" 23 (getProductos)="getProductos()"
24 (setProductos)="setProductos()" 24 (setProductos)="setProductos()"
25 (filterItems)="filterItems()"> 25 (filterItems)="filterItems()">
26 </app-filtro-categorias> 26 </app-filtro-categorias>
27 <!-- LISTA DE ARTICULOS --> 27 <!-- LISTA DE ARTICULOS -->
28 <div 28 <div
29 class="col-7 col-sm-9 col-xl-10 pb-3 h-100 align-self-center scroll-y-visible" 29 class="col-7 col-sm-9 col-xl-10 pb-3 h-100 align-self-center scroll-y-visible"
30 (scroll)="scrollEvent($event)"> 30 (scroll)="scrollEvent($event)">
31 <!-- SPINNER -->
32 <div
33 class="d-flex justify-content-center"
34 *ngIf="loading">
35 <div class="spinner-border text-primary mt-5" role="status">
36 <span class="sr-only">Loading...</span>
37 </div>
38 </div>
31 <div class="row row-cols-1 row-cols-sm-3 row-cols-xl-6"> 39 <div class="row row-cols-1 row-cols-sm-3 row-cols-xl-6">
32 <!-- ARTICULO --> 40 <!-- ARTICULO -->
33 <div 41 <div
34 *ngFor="let articulo of auxArticulos | slice:0:showQuantity;" 42 *ngFor="let articulo of auxArticulos | slice:0:showQuantity;"
35 class="col px-2 my-1 my-md-3 h-auto"> 43 class="col px-2 my-1 my-md-3 h-auto">
36 <div 44 <div
37 class="swing-in-top-fwd btn-effect card h-auto" 45 class="swing-in-top-fwd btn-effect card h-auto"
38 (click)="selectArticulo(articulo)"> 46 (click)="selectArticulo(articulo)">
39 <img 47 <img
40 draggable="false" 48 draggable="false"
41 ondragstart="return false;" 49 ondragstart="return false;"
42 (contextmenu)="false" 50 (contextmenu)="false"
43 src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}" 51 src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}"
44 onerror="this.src='assets/img/imagen-no-encontrada.jpg'" 52 onerror="this.src='assets/img/imagen-no-encontrada.jpg'"
45 class="card-img-top w-100 h-auto h-md-55 rounded-sm"> 53 class="card-img-top w-100 h-auto h-md-55 rounded-sm">
46 <div class="row mx-0 py-1 h-auto justify-content-center"> 54 <div class="row mx-0 py-1 h-auto justify-content-center">
47 <p class="col-12 px-1 h6 h-auto text-primary text-center min-h-60"> 55 <p class="col-12 px-1 h6 h-auto text-primary text-center min-h-60">
48 {{articulo.MKT_DESC ? articulo.MKT_DESC.toUpperCase() : articulo.DetArt.toUpperCase()}} 56 {{articulo.MKT_DESC ? articulo.MKT_DESC.toUpperCase() : articulo.DetArt.toUpperCase()}}
49 </p> 57 </p>
50 <div class="col-12 px-1 align-self-end h-auto"> 58 <div class="col-12 px-1 align-self-end h-auto">
51 <div class="row mx-0 justify-content-between bg-primary badge-pill"> 59 <div class="row mx-0 justify-content-between bg-primary badge-pill">
52 <div class="col px-0 align-self-center text-white text-right"> 60 <div class="col px-0 align-self-center text-white text-right">
53 {{articulo.PreVen | currency}} 61 {{articulo.PreVen | currency}}
54 </div> 62 </div>
55 <div class="col-5 px-0"> 63 <div class="col-5 px-0">
56 <img 64 <img
57 draggable="false" 65 draggable="false"
58 ondragstart="return false;" 66 ondragstart="return false;"
59 (contextmenu)="false" 67 (contextmenu)="false"
60 class="d-block ml-auto py-1 icon-30" 68 class="d-block ml-auto py-1 icon-30"
61 src="assets/img/ir.svg"> 69 src="assets/img/ir.svg">
62 </div> 70 </div>
63 </div> 71 </div>
64 </div> 72 </div>
65 </div> 73 </div>
66 </div> 74 </div>
67 </div> 75 </div>
68 </div> 76 </div>
69 <!-- BOTON VER MAS --> 77 <!-- BOTON VER MAS -->
70 <div class="row mx-0"> 78 <div class="row mx-0">
71 <div 79 <div
72 *ngIf="showQuantity <= auxArticulos.slice(0, showQuantity).length" 80 *ngIf="showQuantity <= auxArticulos.slice(0, showQuantity).length"
73 class="col-12 px-0 mb-2"> 81 class="col-12 px-0 mb-2">
74 <button 82 <button
75 (click)="increaseShow()" 83 (click)="increaseShow()"
76 class="btn btn-block btn-outline-primary"> 84 class="btn btn-block btn-outline-primary">
77 Ver Más 85 Ver Más
78 </button> 86 </button>
79 </div> 87 </div>
80 </div> 88 </div>
81 </div> 89 </div>
82 </div> 90 </div>
83 </div> 91 </div>
84 </div> 92 </div>
85 <!-- FOOTER CARRITO DE COMPRAS --> 93 <!-- FOOTER CARRITO DE COMPRAS -->
86 <div class="row w-90 mx-auto h-auto justify-content-center"> 94 <div class="row w-90 mx-auto h-auto justify-content-center">
87 <div class="h-75 px-0 border border-primary rounded" #boxCarrito 95 <div class="h-75 px-0 border border-primary rounded" #boxCarrito
88 [ngClass]="boxCarrito.classList.contains('media-pantalla') 96 [ngClass]="boxCarrito.classList.contains('media-pantalla')
89 ? 'col-8' : 'col-12'" id="boxCarrito"> 97 ? 'col-8' : 'col-12'" id="boxCarrito">
90 <!-- CABECERA --> 98 <!-- CABECERA -->
91 <div class="row mx-0 h-15 border-bottom border-primary"> 99 <div class="row mx-0 h-15 border-bottom border-primary">
92 <p class="col align-self-center text-truncate"><small>ARTÍCULOS EN TÚ CARRITO DE COMPRAS</small></p> 100 <p class="col align-self-center text-truncate"><small>ARTÍCULOS EN TÚ CARRITO DE COMPRAS</small></p>
93 </div> 101 </div>
94 <!-- CUERPO --> 102 <!-- CUERPO -->
95 <div class="row h-85 mx-0 justify-content-around"> 103 <div class="row h-85 mx-0 justify-content-around">
96 <!-- BOTON SCROLL IZQUIERDA --> 104 <!-- BOTON SCROLL IZQUIERDA -->
97 <div *ngIf="articuloService.carrito.length" class="col-auto btn-effect h-20 align-self-center"> 105 <div *ngIf="articuloService.carrito.length" class="col-auto btn-effect h-20 align-self-center">
98 <img 106 <img
99 draggable="false" 107 draggable="false"
100 ondragstart="return false;" 108 ondragstart="return false;"
101 (contextmenu)="false" 109 (contextmenu)="false"
102 class="icon-30 rotate-180-neg" 110 class="icon-30 rotate-180-neg"
103 src="assets/img/ir-fondo-color.svg" 111 src="assets/img/ir-fondo-color.svg"
104 (mousedown)="scrollX(templateCarrito, -100)" 112 (mousedown)="scrollX(templateCarrito, -100)"
105 (mouseup)="mouseup()" 113 (mouseup)="mouseup()"
106 (mouseleave)="mouseup()"> 114 (mouseleave)="mouseup()">
107 </div> 115 </div>
108 <!-- CARRITO --> 116 <!-- CARRITO -->
109 <div class="col-6 col-sm-8 col-lg-10 h-100"> 117 <div class="col-6 col-sm-8 col-lg-10 h-100">
110 <div 118 <div
111 #templateCarrito 119 #templateCarrito
112 class="row flex-row flex-nowrap h-100 mx-0 my-2 scroll-x" 120 class="row flex-row flex-nowrap h-100 mx-0 my-2 scroll-x"
113 (scroll)="scrollEvent($event)"> 121 (scroll)="scrollEvent($event)">
114 <!-- ARTICULOS --> 122 <!-- ARTICULOS -->
115 <div 123 <div
116 class="col-10 col-sm-4 col-lg-2 px-2 px-xl-4 align-self-center border-right border-primary" 124 class="col-10 col-sm-4 col-lg-2 px-2 px-xl-4 align-self-center border-right border-primary"
117 *ngFor="let articulo of articuloService.carrito; let i = index;" 125 *ngFor="let articulo of articuloService.carrito; let i = index;"
118 @EnterLeaveY> 126 @EnterLeaveY>
119 <img 127 <img
120 class="btn-effect icon-20 mr-2 position-absolute right-0" 128 class="btn-effect icon-20 mr-2 position-absolute right-0"
121 src="assets/img/icono-cancelar-color.svg" 129 src="assets/img/icono-cancelar-color.svg"
122 (click)="deleteArticulo(i)"> 130 (click)="deleteArticulo(i)">
123 <img 131 <img
124 draggable="false" 132 draggable="false"
125 ondragstart="return false;" 133 ondragstart="return false;"
126 (contextmenu)="false" 134 (contextmenu)="false"
127 class="d-block img-fluid p-2 mx-auto rounded w-100 h-auto" 135 class="d-block img-fluid p-2 mx-auto rounded w-100 h-auto"
128 src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}" 136 src="{{urlImagenes}}{{articulo.imagenes[0].imagen}}"
129 onerror="this.src='assets/img/imagen-no-encontrada.jpg'"> 137 onerror="this.src='assets/img/imagen-no-encontrada.jpg'">
130 <p class="d-block mt-auto text-center text-primary text-truncate"> 138 <p class="d-block mt-auto text-center text-primary text-truncate">
131 <small>{{articulo.MKT_DESC ? articulo.MKT_DESC.toUpperCase() : articulo.DetArt.toUpperCase()}}</small> 139 <small>{{articulo.MKT_DESC ? articulo.MKT_DESC.toUpperCase() : articulo.DetArt.toUpperCase()}}</small>
132 </p> 140 </p>
133 <app-articulo-cantidad [articulo]="articulo"></app-articulo-cantidad> 141 <app-articulo-cantidad [articulo]="articulo"></app-articulo-cantidad>
134 </div> 142 </div>
135 <!-- MENSAJE DE ADVERTENCIA --> 143 <!-- MENSAJE DE ADVERTENCIA -->
136 <div *ngIf="!articuloService.carrito.length" class="col h-100"> 144 <div *ngIf="!articuloService.carrito.length" class="col h-100">
137 <p class="text-center py-5">No hay articulos en el carrito</p> 145 <p class="text-center py-5">No hay articulos en el carrito</p>
138 </div> 146 </div>
139 </div> 147 </div>
140 </div> 148 </div>
141 <!-- BOTON SCROLL DERECHA --> 149 <!-- BOTON SCROLL DERECHA -->
142 <div *ngIf="articuloService.carrito.length" 150 <div *ngIf="articuloService.carrito.length"
143 class="col-auto btn-effect h-20 align-self-center d-contents"> 151 class="col-auto btn-effect h-20 align-self-center d-contents">
144 <img 152 <img
145 draggable="false" 153 draggable="false"
146 ondragstart="return false;" 154 ondragstart="return false;"
147 (contextmenu)="false" 155 (contextmenu)="false"
148 class="icon-30" 156 class="icon-30"
149 src="assets/img/ir-fondo-color.svg" 157 src="assets/img/ir-fondo-color.svg"
150 (mousedown)="scrollX(templateCarrito, 100)" 158 (mousedown)="scrollX(templateCarrito, 100)"
151 (mouseup)="mouseup()" 159 (mouseup)="mouseup()"
152 (mouseleave)="mouseup()"> 160 (mouseleave)="mouseup()">
153 </div> 161 </div>
154 </div> 162 </div>
155 </div> 163 </div>
156 <!-- TOTAL--> 164 <!-- TOTAL-->
157 <div 165 <div
158 class="col-auto mt-2 ml-auto h-20"> 166 class="col-auto mt-2 ml-auto h-20">
159 <div class="row mx-0"> 167 <div class="row mx-0">
160 <div class="col-auto font-weight-bold align-self-center text-primary py-2 h3">TOTAL</div> 168 <div class="col-auto font-weight-bold align-self-center text-primary py-2 h3">TOTAL</div>
161 <div class="col-auto align-self-center bg-primary badge-pill"> 169 <div class="col-auto align-self-center bg-primary badge-pill">
162 <p class="text-center font-weight-bold text-white py-2 h3 px-2">{{articuloService.subTotal | currency}}</p> 170 <p class="text-center font-weight-bold text-white py-2 h3 px-2">{{articuloService.subTotal | currency}}</p>
163 </div> 171 </div>
164 </div> 172 </div>
165 </div> 173 </div>
166 174
167 <!-- VER CARRITO --> 175 <!-- VER CARRITO -->
168 <div 176 <div
169 class="col-auto px-0 h-20" 177 class="col-auto px-0 h-20"
170 *ngIf="articuloService.carrito.length" 178 *ngIf="articuloService.carrito.length"
171 [ngClass]="boxCarrito.classList.contains('media-pantalla') ? 'ml-auto' : 'mt-3'"> 179 [ngClass]="boxCarrito.classList.contains('media-pantalla') ? 'ml-auto' : 'mt-3'">
172 <div 180 <div
173 class="btn-effect col-auto px-0 align-self-center bg-white" 181 class="btn-effect col-auto px-0 align-self-center bg-white"
174 [routerLink]="['/carrito']"> 182 [routerLink]="['/carrito']">
175 <div class="row mx-0 bg-light"> 183 <div class="row mx-0 bg-light">
176 <div class="col-auto p-0 bg-primary"> 184 <div class="col-auto p-0 bg-primary">
177 <img 185 <img
178 draggable="false" 186 draggable="false"
179 ondragstart="return false;" 187 ondragstart="return false;"
180 (contextmenu)="false" 188 (contextmenu)="false"
181 class="p-2 icon-40" 189 class="p-2 icon-40"
182 src="assets/img/carrito.svg"> 190 src="assets/img/carrito.svg">
183 </div> 191 </div>
184 <div class="col-auto align-self-center text-primary d-none d-sm-block">IR AL CARRITO</div> 192 <div class="col-auto align-self-center text-primary d-none d-sm-block">IR AL CARRITO</div>
185 </div> 193 </div>
186 </div> 194 </div>
187 </div> 195 </div>
188 196
189 </div> 197 </div>
190 </div> 198 </div>
191 199
192 </div> 200 </div>
193 201
src/app/modules/seleccion-articulos/seleccion-articulos.component.scss
1 #content.media-pantalla, 1 #content.media-pantalla,
2 #cat-content.media-pantalla, 2 #cat-content.media-pantalla,
3 #boxCarrito.media-pantalla { 3 #boxCarrito.media-pantalla {
4 max-height: 60% !important; 4 max-height: 60% !important;
5 } 5 }
6 6
7 .modal-content.media-pantalla { 7 .modal-content.media-pantalla {
8 margin-top: auto !important; 8 margin-top: auto !important;
9 } 9 }
10 10
11 .d-contents { 11 .d-contents {
12 display: contents !important; 12 display: contents !important;
13 } 13 }
14
15 .spinner-border {
16 width: 10rem;
17 height: 10rem;
18 }
14 19
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
1 import { Component, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit } from '@angular/core'; 1 import { Component, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit } 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 { PromocionComponent } from 'src/app/shared/promocion/promocion.component'; 8 import { PromocionComponent } from 'src/app/shared/promocion/promocion.component';
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 import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service'; 10 import { SinonimoService } from 'src/app/services/sinonimo/sinonimo.service';
11 import { SinonimoComponent } from 'src/app/shared/sinonimo/sinonimo.component'; 11 import { SinonimoComponent } from 'src/app/shared/sinonimo/sinonimo.component';
12 import { FiltroCategoriasComponent } from './filtro-categorias/filtro-categorias.component'; 12 import { FiltroCategoriasComponent } from './filtro-categorias/filtro-categorias.component';
13 import * as _ from 'lodash'; 13 import * as _ from 'lodash';
14 import { ANIMATIONS } from 'src/app/utils/animations'; 14 import { ANIMATIONS } from 'src/app/utils/animations';
15 15
16 @Component({ 16 @Component({
17 selector: 'app-seleccion-articulos', 17 selector: 'app-seleccion-articulos',
18 templateUrl: './seleccion-articulos.component.html', 18 templateUrl: './seleccion-articulos.component.html',
19 styleUrls: ['./seleccion-articulos.component.scss'], 19 styleUrls: ['./seleccion-articulos.component.scss'],
20 animations: [ANIMATIONS.EnterLeaveY] 20 animations: [ANIMATIONS.EnterLeaveY]
21 }) 21 })
22 export class SeleccionArticulosComponent implements OnInit, AfterViewInit, OnDestroy { 22 export class SeleccionArticulosComponent implements OnInit, AfterViewInit, OnDestroy {
23 showSpinner = true; 23 loading = true;
24 timeoutHandler: any; 24 timeoutHandler: any;
25 urlImagenes = `${APP_SETTINGS.apiImagenes}/imagenes/`; 25 urlImagenes = `${APP_SETTINGS.apiImagenes}/imagenes/`;
26 articulos: IArticulo[] = []; 26 articulos: IArticulo[] = [];
27 auxArticulos: IArticulo[] = []; 27 auxArticulos: IArticulo[] = [];
28 showQuantity = 100; 28 showQuantity = 100;
29 searchTerm = ''; 29 searchTerm = '';
30 ordenandoByVendidos = true; 30 ordenandoByVendidos = true;
31 modalRef: BsModalRef; 31 modalRef: BsModalRef;
32 total = 0; 32 total = 0;
33 @ViewChild(FiltroCategoriasComponent, { static: false }) filtroCategorias: FiltroCategoriasComponent; 33 @ViewChild(FiltroCategoriasComponent, { static: false }) filtroCategorias: FiltroCategoriasComponent;
34 34
35 constructor( 35 constructor(
36 public articuloService: ArticuloService, 36 public articuloService: ArticuloService,
37 private sinonimoService: SinonimoService, 37 private sinonimoService: SinonimoService,
38 private modalService: BsModalService, 38 private modalService: BsModalService,
39 private inactiveScreen: InactiveScreenService, 39 private inactiveScreen: InactiveScreenService,
40 ) { } 40 ) { }
41 41
42 ngOnInit() { } 42 ngOnInit() { }
43 43
44 ngAfterViewInit(): void { 44 ngAfterViewInit(): void {
45 this.filtroCategorias.getCategorias(); 45 this.filtroCategorias.getCategorias();
46 this.mediaPantalla(); 46 this.mediaPantalla();
47 } 47 }
48 48
49 ngOnDestroy() { 49 ngOnDestroy() {
50 for (let i = 1; i <= this.modalService.getModalsCount(); i++) { 50 for (let i = 1; i <= this.modalService.getModalsCount(); i++) {
51 this.modalService.hide(i); 51 this.modalService.hide(i);
52 } 52 }
53 } 53 }
54 54
55 getProductos() { 55 getProductos() {
56 this.articuloService.getAll() 56 this.articuloService.getAll()
57 .subscribe((result: IArticulo[]) => { 57 .subscribe((result: IArticulo[]) => {
58 this.articuloService.setArticulosSinImagen(result); 58 this.articuloService.setArticulosSinImagen(result);
59 if (this.filtroCategorias.queMostrar === 'ordenar') { 59 if (this.filtroCategorias.queMostrar === 'ordenar') {
60 this.filtroCategorias.categorias.forEach((categoria: ICategoria) => { 60 this.filtroCategorias.categorias.forEach((categoria: ICategoria) => {
61 const tempArticulos = result.filter((articulo: IArticulo) => { 61 const tempArticulos = result.filter((articulo: IArticulo) => {
62 return articulo.categoria_selfservice === categoria.id; 62 return articulo.categoria_selfservice === categoria.id;
63 }); 63 });
64 result = tempArticulos; 64 result = tempArticulos;
65 }); 65 });
66 } 66 }
67 localStorage.setItem('articulos', JSON.stringify(result)); 67 localStorage.setItem('articulos', JSON.stringify(result));
68 this.setProductos(); 68 this.setProductos();
69 }, (error) => { 69 }, (error) => {
70 this.showSpinner = false;
71 console.error(error); 70 console.error(error);
72 }); 71 });
73 } 72 }
74 73
75 setProductos() { 74 setProductos() {
76 this.articulos = JSON.parse(localStorage.getItem('articulos')); 75 this.articulos = JSON.parse(localStorage.getItem('articulos'));
77 this.filterItems(); 76 this.filterItems();
77 this.loading = false;
78 } 78 }
79 79
80 filterItems() { 80 filterItems() {
81 if (this.filtroCategorias.categoriaActive === 0) { 81 if (this.filtroCategorias.categoriaActive === 0) {
82 this.auxArticulos = this.articulos; 82 this.auxArticulos = this.articulos;
83 return; 83 return;
84 } 84 }
85 this.auxArticulos = this.articulos.filter(x => { 85 this.auxArticulos = this.articulos.filter(x => {
86 return x.categoria_selfservice === this.filtroCategorias.categoriaActive; 86 return x.categoria_selfservice === this.filtroCategorias.categoriaActive;
87 }); 87 });
88 this.ordenar(); 88 this.ordenar();
89 } 89 }
90 90
91 ordenar() { 91 ordenar() {
92 if (this.ordenandoByVendidos) { 92 if (this.ordenandoByVendidos) {
93 this.auxArticulos.sort((a, b) => { 93 this.auxArticulos.sort((a, b) => {
94 return b.cantidadVendida - a.cantidadVendida; 94 return b.cantidadVendida - a.cantidadVendida;
95 }); 95 });
96 } 96 }
97 } 97 }
98 98
99 selectArticulo(articulo: IArticulo) { 99 selectArticulo(articulo: IArticulo) {
100 this.getByID(articulo.id); 100 this.getByID(articulo.id);
101 } 101 }
102 102
103 getByID(id: number) { 103 getByID(id: number) {
104 this.articuloService.getById(id) 104 this.articuloService.getById(id)
105 .subscribe((res: IArticulo) => { 105 .subscribe((res: IArticulo) => {
106 if (res.FPP) { 106 if (res.FPP) {
107 this.openModalPromos(res); 107 this.openModalPromos(res);
108 } else { 108 } else {
109 this.getSinonimos(res); 109 this.getSinonimos(res);
110 } 110 }
111 }, err => console.error(err)); 111 }, err => console.error(err));
112 } 112 }
113 113
114 getSinonimos(articulo: IArticulo) { 114 getSinonimos(articulo: IArticulo) {
115 this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt) 115 this.sinonimoService.getSinonimos(articulo.CodSec, articulo.CodArt)
116 .subscribe((res: any[]) => { 116 .subscribe((res: any[]) => {
117 if (res.length) { 117 if (res.length) {
118 const sinonimos = []; 118 const sinonimos = [];
119 const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN'); 119 const gruposArticulos = _.groupBy(res[0].productos, 'ID_SIN');
120 Object.keys(gruposArticulos).forEach(key => { 120 Object.keys(gruposArticulos).forEach(key => {
121 sinonimos.push({ productos: gruposArticulos[key] }); 121 sinonimos.push({ productos: gruposArticulos[key] });
122 }); 122 });
123 res = sinonimos; 123 res = sinonimos;
124 this.openModalSinonimos(res, articulo); 124 this.openModalSinonimos(res, articulo);
125 } else { 125 } else {
126 this.articuloService.setArticulo(articulo); 126 this.articuloService.setArticulo(articulo);
127 } 127 }
128 }); 128 });
129 } 129 }
130 130
131 openModalPromos(articulo: IArticulo) { 131 openModalPromos(articulo: IArticulo) {
132 this.modalRef = this.modalService.show(PromocionComponent, { 132 this.modalRef = this.modalService.show(PromocionComponent, {
133 initialState: { articulosPromo: [articulo] }, 133 initialState: { articulosPromo: [articulo] },
134 class: 'modal-dialog-centered' 134 class: 'modal-dialog-centered'
135 }); 135 });
136 this.mediaPantalla(); 136 this.mediaPantalla();
137 } 137 }
138 138
139 openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) { 139 openModalSinonimos(sinonimosData: ISinonimo[], articulo: IArticulo) {
140 this.modalRef = this.modalService.show(SinonimoComponent, { 140 this.modalRef = this.modalService.show(SinonimoComponent, {
141 initialState: { 141 initialState: {
142 sinonimos: sinonimosData, 142 sinonimos: sinonimosData,
143 articulo 143 articulo
144 }, 144 },
145 class: 'modal-dialog-centered' 145 class: 'modal-dialog-centered'
146 }); 146 });
147 147
148 this.modalRef.content.onClose 148 this.modalRef.content.onClose
149 .subscribe((res: any) => { 149 .subscribe((res: any) => {
150 for (const a of articulo.productos) { 150 for (const a of articulo.productos) {
151 for (const aRes of res.articulos) { 151 for (const aRes of res.articulos) {
152 if (a.idSinonimo === aRes.ID_SIN) { 152 if (a.idSinonimo === aRes.ID_SIN) {
153 a.CODA = aRes.CodArt; 153 a.CODA = aRes.CodArt;
154 a.CodArt = aRes.CodArt; 154 a.CodArt = aRes.CodArt;
155 a.SECA = aRes.CodSec; 155 a.SECA = aRes.CodSec;
156 aRes.CodSec = aRes.CodSec; 156 aRes.CodSec = aRes.CodSec;
157 a.PreVen = aRes.PreVen; 157 a.PreVen = aRes.PreVen;
158 a.id = aRes.id; 158 a.id = aRes.id;
159 a.DET_LAR = aRes.DET_LAR; 159 a.DET_LAR = aRes.DET_LAR;
160 a.DetArt = aRes.DetArt; 160 a.DetArt = aRes.DetArt;
161 } 161 }
162 } 162 }
163 } 163 }
164 this.articuloService.setArticulo(articulo); 164 this.articuloService.setArticulo(articulo);
165 }); 165 });
166 this.mediaPantalla(); 166 this.mediaPantalla();
167 } 167 }
168 168
169 deleteArticulo(index: number) { 169 deleteArticulo(index: number) {
170 this.articuloService.deleteArticulo(index); 170 this.articuloService.deleteArticulo(index);
171 } 171 }
172 172
173 increaseShow() { 173 increaseShow() {
174 this.showQuantity += 100; 174 this.showQuantity += 100;
175 } 175 }
176 176
177 @HostListener('scroll', ['$event']) 177 @HostListener('scroll', ['$event'])
178 scrollEvent(event: Event) { 178 scrollEvent(event: Event) {
179 clearTimeout(this.inactiveScreen.timerReposo); 179 clearTimeout(this.inactiveScreen.timerReposo);
180 this.inactiveScreen.startTimeOutInactividad(); 180 this.inactiveScreen.startTimeOutInactividad();
181 } 181 }
182 182
183 mouseup() { 183 mouseup() {
184 if (!this.timeoutHandler) return; 184 if (!this.timeoutHandler) return;
185 clearInterval(this.timeoutHandler); 185 clearInterval(this.timeoutHandler);
186 } 186 }
187 187
188 scrollY(el: HTMLElement, value) { 188 scrollY(el: HTMLElement, value) {
189 el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); 189 el.scroll({ behavior: 'smooth', top: value + el.scrollTop });
190 this.timeoutHandler = setInterval(() => { 190 this.timeoutHandler = setInterval(() => {
191 el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); 191 el.scroll({ behavior: 'smooth', top: value + el.scrollTop });
192 }, 500); 192 }, 500);
193 } 193 }
194 194
195 scrollX(el: HTMLElement, value) { 195 scrollX(el: HTMLElement, value) {
196 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); 196 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft });
197 this.timeoutHandler = setInterval(() => { 197 this.timeoutHandler = setInterval(() => {
198 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft }); 198 el.scroll({ behavior: 'smooth', left: value + el.scrollLeft });
199 }, 500); 199 }, 500);
200 } 200 }
201 201
202 mediaPantalla() { 202 mediaPantalla() {
203 if ($('body').hasClass('media-pantalla')) { 203 if ($('body').hasClass('media-pantalla')) {
204 $(`.cat-content,#cat-content,#content,.cat-btn,#boxCarrito, 204 $(`.cat-content,#cat-content,#content,.cat-btn,#boxCarrito,
205 .cat-box,.img-categoria, .modal-content`) 205 .cat-box,.img-categoria, .modal-content`)
206 .addClass('media-pantalla') 206 .addClass('media-pantalla')
207 .addBack('media-pantalla'); 207 .addBack('media-pantalla');
208 } 208 }
209 } 209 }
210 } 210 }