Commit 8f0f532fa6a0fa21b242c3c15edeb1e0e773b124

Authored by Luis Suarez
1 parent 0ecd086403
Exists in develop

correcciones diff commits

src/app/modules/seleccion-articulos/filtro-categorias/filtro-categorias.component.html
1 <!-- FILTRO CATEGORIAS --> 1 <!-- FILTRO CATEGORIAS -->
2 <p class="h6 h-6 m-0 text-center"><small>CATEGORÍAS</small></p> 2 <p class="h6 h-6 m-0 text-center"><small>CATEGORÍAS</small></p>
3 <div class="row mx-0 h-94 justify-content-center align-items-center"> 3 <div class="row mx-0 h-94 justify-content-center align-items-center">
4 <div class="col-auto btn-effect h-5 cat-btn"> 4 <div class="col-auto btn-effect h-5 cat-btn">
5 <img 5 <img
6 draggable="false" 6 draggable="false"
7 ondragstart="return false;" 7 ondragstart="return false;"
8 (contextmenu)="false" 8 (contextmenu)="false"
9 class="h-100 d-block mx-auto rotate-90-neg" 9 class="h-100 d-block mx-auto rotate-90-neg"
10 src="assets/img/ir-color.svg" 10 src="assets/img/ir-color.svg"
11 (mousedown)="scrollY(templateCategorias, -100)" 11 (mousedown)="scrollY(templateCategorias, -100)"
12 (mouseup)="mouseup()" 12 (mouseup)="mouseup()"
13 (mouseleave)="mouseup()"> 13 (mouseleave)="mouseup()">
14 </div> 14 </div>
15 <!-- CATEGORIAS --> 15 <!-- CATEGORIAS -->
16 <div 16 <div
17 #templateCategorias 17 #templateCategorias
18 class="col-12 px-0 mx-0 box-categorias border border-primary py-1 18 class="col-12 px-0 mx-0 box-categorias border border-primary py-1
19 border-left-0 rounded-right scroll-y cat-box" 19 border-left-0 rounded-right scroll-y cat-box"
20 (scroll)="scrollEvent($event)"> 20 (scroll)="scrollEvent($event)">
21 <div 21 <div
22 class="row mx-2 mb-2 h-25 h-lg-30 justify-content-center tab cat-content" 22 class="row mx-2 mb-2 h-25 h-lg-30 justify-content-center tab cat-content"
23 [ngClass]="{ 'active rounded shadow px-2': allActive, 'border-bottom-effect': !allActive }" 23 [ngClass]="{ 'active rounded shadow px-2': allActive, 'border-bottom-effect': !allActive }"
24 (click)="selectCategoria(-1, 0)"> 24 (click)="selectCategoria(-1, 0)">
25 <img 25 <img
26 draggable="false" 26 draggable="false"
27 ondragstart="return false;" 27 ondragstart="return false;"
28 (contextmenu)="false" 28 (contextmenu)="false"
29 class="col-12 img-fluid align-self-end d-none 29 class="col-12 img-fluid align-self-end d-none
30 d-sm-block rounded-circle h-50" 30 d-sm-block rounded-circle h-50"
31 src="assets/img/logo-spot.svg"> 31 src="assets/img/logo-spot.svg">
32 <small class="col-12 px-0 my-1 h-100 h-md-25 align-self-end text-center text-truncate">Todos</small> 32 <small class="col-12 px-0 my-1 h-100 h-md-25 align-self-end text-center text-truncate">Todos</small>
33 </div> 33 </div>
34 <div *ngFor="let categoria of categorias; let i = index;"> 34 <div *ngFor="let categoria of categorias; let i = index;">
35 <div 35 <div
36 class="row mx-2 mb-2 h-25 h-lg-30 justify-content-center tab cat-content" 36 class="row mx-2 mb-2 h-25 h-lg-30 justify-content-center tab cat-content"
37 [ngClass]="{ 'active rounded shadow px-2': categoria.selected, 37 [ngClass]="{ 'active rounded shadow px-2': categoria.selected,
38 'border-bottom-effect': !categoria.selected, 38 'border-bottom-effect': !categoria.selected,
39 'media-pantalla': templateCategorias.classList.contains('media-pantalla')}" 39 'media-pantalla': templateCategorias.classList.contains('media-pantalla')}"
40 (click)="selectCategoria(i, categoria.id)" 40 (click)="selectCategoria(i, categoria.id)"
41 id="cat-content" 41 id="cat-content"
42 *ngIf="categoria.articulos > 0 42 *ngIf="categoria.articulos > 0
43 && validarFecha(categoria.vigencia_desde,categoria.vigencia_hasta)"> 43 && validarFecha(categoria.vigencia_desde, categoria.vigencia_hasta)">
44 <img 44 <img
45 draggable="false" 45 draggable="false"
46 ondragstart="return false;" 46 ondragstart="return false;"
47 (contextmenu)="false" 47 (contextmenu)="false"
48 class="d-none d-sm-block rounded-circle w-auto h-auto col-12" 48 class="d-none d-sm-block rounded-circle w-auto h-auto col-12"
49 src="{{urlImagenes}}{{categoria.path_imagen}}" 49 src="{{urlImagenes}}{{categoria.path_imagen}}"
50 onerror="this.src='assets/img/imagen-no-encontrada.jpg'"> 50 onerror="this.src='assets/img/imagen-no-encontrada.jpg'">
51 <small class="col-12 px-1 my-1 h-100 h-md-25 align-self-end text-center text-truncate">{{categoria.detalle}}</small> 51 <small class="col-12 px-1 my-1 h-100 h-md-25 align-self-end text-center text-truncate">{{categoria.detalle}}</small>
52 </div> 52 </div>
53 </div> 53 </div>
54 </div> 54 </div>
55 <div class="col-auto btn-effect h-5 cat-btn"> 55 <div class="col-auto btn-effect h-5 cat-btn">
56 <img 56 <img
57 draggable="false" 57 draggable="false"
58 ondragstart="return false;" 58 ondragstart="return false;"
59 (contextmenu)="false" 59 (contextmenu)="false"
60 class="h-100 d-block mx-auto rotate-90" 60 class="h-100 d-block mx-auto rotate-90"
61 src="assets/img/ir-color.svg" 61 src="assets/img/ir-color.svg"
62 (mousedown)="scrollY(templateCategorias, 100)" 62 (mousedown)="scrollY(templateCategorias, 100)"
63 (mouseup)="mouseup()" 63 (mouseup)="mouseup()"
64 (mouseleave)="mouseup()"> 64 (mouseleave)="mouseup()">
65 </div> 65 </div>
66 </div> 66 </div>
67 67
src/app/modules/seleccion-articulos/filtro-categorias/filtro-categorias.component.ts
1 import { Component, OnInit, HostListener, Output, EventEmitter } from '@angular/core'; 1 import { Component, OnInit, HostListener, Output, EventEmitter } from '@angular/core';
2 import { ICategoria } from 'src/app/interfaces/ICategoria'; 2 import { ICategoria } from 'src/app/interfaces/ICategoria';
3 import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; 3 import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service';
4 import { CategoriaService } from 'src/app/services/categoria/categoria.service'; 4 import { CategoriaService } from 'src/app/services/categoria/categoria.service';
5 import { APP_SETTINGS } from 'src/etc/AppSettings'; 5 import { APP_SETTINGS } from 'src/etc/AppSettings';
6 6
7 @Component({ 7 @Component({
8 selector: 'app-filtro-categorias', 8 selector: 'app-filtro-categorias',
9 templateUrl: './filtro-categorias.component.html', 9 templateUrl: './filtro-categorias.component.html',
10 styleUrls: ['./filtro-categorias.component.scss'] 10 styleUrls: ['./filtro-categorias.component.scss']
11 }) 11 })
12 export class FiltroCategoriasComponent implements OnInit { 12 export class FiltroCategoriasComponent implements OnInit {
13 @Output() getProductos = new EventEmitter<any>(); 13 @Output() getProductos = new EventEmitter<any>();
14 @Output() setProductos = new EventEmitter<any>(); 14 @Output() setProductos = new EventEmitter<any>();
15 @Output() filterItems = new EventEmitter<any>(); 15 @Output() filterItems = new EventEmitter<any>();
16 categorias: ICategoria[] = []; 16 categorias: ICategoria[] = [];
17 timeoutHandler: any; 17 timeoutHandler: any;
18 categoriaActive = null; 18 categoriaActive = null;
19 allActive = true; 19 allActive = true;
20 queMostrar = 'todos'; 20 queMostrar = 'todos';
21 urlImagenes = `${APP_SETTINGS.apiImagenes}/imagenes/`; 21 urlImagenes = `${APP_SETTINGS.apiImagenes}/imagenes/`;
22 22
23 constructor( 23 constructor(
24 private categoriaService: CategoriaService, 24 private categoriaService: CategoriaService,
25 private inactiveScreen: InactiveScreenService 25 private inactiveScreen: InactiveScreenService
26 ) { } 26 ) { }
27 27
28 ngOnInit() { 28 ngOnInit() {
29 this.mediaPantalla(); 29 this.mediaPantalla();
30 } 30 }
31 31
32 getCategorias() { 32 getCategorias() {
33 this.categoriaService.getAll() 33 this.categoriaService.getAll()
34 .subscribe((categorias: ICategoria[]) => { 34 .subscribe((categorias: ICategoria[]) => {
35 switch (this.queMostrar) { 35 switch (this.queMostrar) {
36 case 'todos': 36 case 'todos':
37 this.categorias = categorias; 37 this.categorias = categorias;
38 this.categoriaActive = 0; 38 this.categoriaActive = 0;
39 break; 39 break;
40 case 'promociones': 40 case 'promociones':
41 this.categorias = categorias; 41 this.categorias = categorias;
42 this.categoriaActive = 19; 42 this.categoriaActive = 19;
43 break; 43 break;
44 case 'ordenar': 44 case 'ordenar':
45 this.categorias = categorias.filter((categoria: ICategoria) => { 45 this.categorias = categorias.filter((categoria: ICategoria) => {
46 return categoria.ES_PEDIDO; 46 return categoria.ES_PEDIDO;
47 }); 47 });
48 this.categoriaActive = 4; 48 this.categoriaActive = 4;
49 break; 49 break;
50 default: 50 default:
51 this.categorias = categorias; 51 this.categorias = categorias;
52 this.categoriaActive = 0; 52 this.categoriaActive = 0;
53 break; 53 break;
54 } 54 }
55 !localStorage.getItem('articulos') ? 55 !localStorage.getItem('articulos') ?
56 this.getProductos.emit() : 56 this.getProductos.emit() :
57 this.setProductos.emit(); 57 this.setProductos.emit();
58 }); 58 });
59 this.mediaPantalla(); 59 this.mediaPantalla();
60 } 60 }
61 61
62 selectCategoria(index: number, idCategoria?: number) { 62 selectCategoria(index: number, idCategoria?: number) {
63 if (this.categoriaActive === idCategoria) return; 63 if (this.categoriaActive === idCategoria) return;
64 this.categoriaActive = idCategoria; 64 this.categoriaActive = idCategoria;
65 this.allActive = idCategoria === 0 ? true : false; 65 this.allActive = idCategoria === 0 ? true : false;
66 this.categorias.forEach((categoria, i) => { 66 this.categorias.forEach((categoria, i) => {
67 categoria.selected = index === i ? true : false; 67 categoria.selected = index === i ? true : false;
68 }); 68 });
69 this.filterItems.emit(); 69 this.filterItems.emit();
70 } 70 }
71 71
72 @HostListener('scroll', ['$event']) 72 @HostListener('scroll', ['$event'])
73 scrollEvent(event: Event) { 73 scrollEvent(event: Event) {
74 clearTimeout(this.inactiveScreen.timerReposo); 74 clearTimeout(this.inactiveScreen.timerReposo);
75 this.inactiveScreen.startTimeOutInactividad(); 75 this.inactiveScreen.startTimeOutInactividad();
76 } 76 }
77 77
78 mouseup() { 78 mouseup() {
79 if (!this.timeoutHandler) return; 79 if (!this.timeoutHandler) return;
80 clearInterval(this.timeoutHandler); 80 clearInterval(this.timeoutHandler);
81 } 81 }
82 82
83 scrollY(el: HTMLElement, value) { 83 scrollY(el: HTMLElement, value) {
84 el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); 84 el.scroll({ behavior: 'smooth', top: value + el.scrollTop });
85 this.timeoutHandler = setInterval(() => { 85 this.timeoutHandler = setInterval(() => {
86 el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); 86 el.scroll({ behavior: 'smooth', top: value + el.scrollTop });
87 }, 500); 87 }, 500);
88 } 88 }
89 89
90 validarFecha(fechaInicioString: string, fechaFinString: string) { 90 validarFecha(fechaInicioString: string, fechaFinString: string) {
91 const fechaInicio = new Date(fechaInicioString); 91 const fechaInicio = new Date(fechaInicioString);
92 const fechaFin = new Date(fechaFinString); 92 const fechaFin = new Date(fechaFinString);
93 const fechaAux = Date.now(); 93 const fechaAux = Date.now();
94 const fechaHoy = new Date(fechaAux); 94 const fechaHoy = new Date(fechaAux);
95 if (fechaHoy >= fechaInicio && fechaHoy <= fechaFin) { 95 return (fechaHoy >= fechaInicio && fechaHoy <= fechaFin) ? true : false;
96 return true;
97 } else {
98 return false;
99 }
100 } 96 }
101 97
102 mediaPantalla() { 98 mediaPantalla() {
103 if ($('body').hasClass('media-pantalla')) { 99 if ($('body').hasClass('media-pantalla')) {
104 $('.cat-content,#cat-content') 100 $('.cat-content,#cat-content')
105 .addClass('media-pantalla') 101 .addClass('media-pantalla')
106 .addBack('media-pantalla'); 102 .addBack('media-pantalla');
107 } 103 }
108 } 104 }
109 } 105 }
110 106