Commit 1bdc4ea25070c0b63ab28830878b13d2ef7d5172
Exists in
develop
Merge branch 'develop' into 'develop'
Solo se muestran categorias con fecha vigente See merge request !141
Showing
2 changed files
Show diff stats
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 | <img | 44 | <img |
44 | draggable="false" | 45 | draggable="false" |
45 | ondragstart="return false;" | 46 | ondragstart="return false;" |
46 | (contextmenu)="false" | 47 | (contextmenu)="false" |
47 | 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" |
48 | src="{{urlImagenes}}{{categoria.path_imagen}}" | 49 | src="{{urlImagenes}}{{categoria.path_imagen}}" |
49 | onerror="this.src='assets/img/imagen-no-encontrada.jpg'"> | 50 | onerror="this.src='assets/img/imagen-no-encontrada.jpg'"> |
50 | <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> |
51 | </div> | 52 | </div> |
52 | </div> | 53 | </div> |
53 | </div> | 54 | </div> |
54 | <div class="col-auto btn-effect h-5 cat-btn"> | 55 | <div class="col-auto btn-effect h-5 cat-btn"> |
55 | <img | 56 | <img |
56 | draggable="false" | 57 | draggable="false" |
57 | ondragstart="return false;" | 58 | ondragstart="return false;" |
58 | (contextmenu)="false" | 59 | (contextmenu)="false" |
59 | class="h-100 d-block mx-auto rotate-90" | 60 | class="h-100 d-block mx-auto rotate-90" |
60 | src="assets/img/ir-color.svg" | 61 | src="assets/img/ir-color.svg" |
61 | (mousedown)="scrollY(templateCategorias, 100)" | 62 | (mousedown)="scrollY(templateCategorias, 100)" |
62 | (mouseup)="mouseup()" | 63 | (mouseup)="mouseup()" |
63 | (mouseleave)="mouseup()"> | 64 | (mouseleave)="mouseup()"> |
64 | </div> | 65 | </div> |
65 | </div> | 66 | </div> |
66 | 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 | |||
71 | } | 70 | } |
72 | 71 | ||
73 | @HostListener('scroll', ['$event']) | 72 | @HostListener('scroll', ['$event']) |
74 | scrollEvent(event: Event) { | 73 | scrollEvent(event: Event) { |
75 | clearTimeout(this.inactiveScreen.timerReposo); | 74 | clearTimeout(this.inactiveScreen.timerReposo); |
76 | this.inactiveScreen.startTimeOutInactividad(); | 75 | this.inactiveScreen.startTimeOutInactividad(); |
77 | } | 76 | } |
78 | 77 | ||
79 | mouseup() { | 78 | mouseup() { |
80 | if (!this.timeoutHandler) return; | 79 | if (!this.timeoutHandler) return; |
81 | clearInterval(this.timeoutHandler); | 80 | clearInterval(this.timeoutHandler); |
82 | } | 81 | } |
83 | 82 | ||
84 | scrollY(el: HTMLElement, value) { | 83 | scrollY(el: HTMLElement, value) { |
85 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); | 84 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); |
86 | this.timeoutHandler = setInterval(() => { | 85 | this.timeoutHandler = setInterval(() => { |
87 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); | 86 | el.scroll({ behavior: 'smooth', top: value + el.scrollTop }); |
88 | }, 500); | 87 | }, 500); |
89 | } | 88 | } |
90 | 89 | ||
90 | validarFecha(fechaInicioString: string, fechaFinString: string) { | ||
91 | const fechaInicio = new Date(fechaInicioString); | ||
92 | const fechaFin = new Date(fechaFinString); | ||
93 | const fechaAux = Date.now(); | ||
94 | const fechaHoy = new Date(fechaAux); | ||
95 | return (fechaHoy >= fechaInicio && fechaHoy <= fechaFin) ? true : false; | ||
96 | } | ||
97 | |||
91 | mediaPantalla() { | 98 | mediaPantalla() { |
92 | if ($('body').hasClass('media-pantalla')) { | 99 | if ($('body').hasClass('media-pantalla')) { |
93 | $('.cat-content,#cat-content') | 100 | $('.cat-content,#cat-content') |
94 | .addClass('media-pantalla') | 101 | .addClass('media-pantalla') |
95 | .addBack('media-pantalla'); | 102 | .addBack('media-pantalla'); |
96 | } | 103 | } |
97 | } | 104 | } |
98 | } | 105 | } |