Commit ece306d2c2879276d73afa047a790536ba1f17a2
1 parent
1bdc4ea250
Exists in
develop
Add
Logica para validad fechas
Showing
4 changed files
with
20 additions
and
6 deletions
 
Show diff stats
src/app/modules/seleccion-articulos/filtro-categorias/filtro-categorias.component.ts
| ... | ... | @@ -3,6 +3,7 @@ import { ICategoria } from 'src/app/interfaces/ICategoria'; | 
| 3 | 3 | import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service'; | 
| 4 | 4 | import { CategoriaService } from 'src/app/services/categoria/categoria.service'; | 
| 5 | 5 | import { APP_SETTINGS } from 'src/etc/AppSettings'; | 
| 6 | +import { DateExtension } from 'src/app/utils/dateExtension'; | |
| 6 | 7 | |
| 7 | 8 | @Component({ | 
| 8 | 9 | selector: 'app-filtro-categorias', | 
| ... | ... | @@ -87,12 +88,8 @@ export class FiltroCategoriasComponent implements OnInit { | 
| 87 | 88 | }, 500); | 
| 88 | 89 | } | 
| 89 | 90 | |
| 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; | |
| 91 | + validarFecha(fechaInicio: string, fechaFin: string) { | |
| 92 | + return DateExtension.ValidateDateRange(fechaInicio, fechaFin); | |
| 96 | 93 | } | 
| 97 | 94 | |
| 98 | 95 | mediaPantalla() { | 
src/app/modules/seleccion-articulos/seleccion-articulos.component.html
| ... | ... | @@ -40,6 +40,7 @@ | 
| 40 | 40 | <!-- ARTICULO --> | 
| 41 | 41 | <div | 
| 42 | 42 | *ngFor="let articulo of auxArticulos | slice:0:showQuantity;" | 
| 43 | + [hidden]="validarFecha(articulo.FECHA_VIGENCIA_DESDE, articulo.FECHA_VIGENCIA_HASTA)" | |
| 43 | 44 | class="col px-2 my-1 my-md-3 h-auto"> | 
| 44 | 45 | <div | 
| 45 | 46 | class="swing-in-top-fwd btn-effect card h-auto" | 
src/app/modules/seleccion-articulos/seleccion-articulos.component.ts
| ... | ... | @@ -13,6 +13,7 @@ import { FiltroCategoriasComponent } from './filtro-categorias/filtro-categorias | 
| 13 | 13 | import * as _ from 'lodash'; | 
| 14 | 14 | import { ANIMATIONS } from 'src/app/utils/animations'; | 
| 15 | 15 | import { NoStockComponent } from './no-stock/no-stock.component'; | 
| 16 | +import { DateExtension } from 'src/app/utils/dateExtension'; | |
| 16 | 17 | |
| 17 | 18 | @Component({ | 
| 18 | 19 | selector: 'app-seleccion-articulos', | 
| ... | ... | @@ -188,6 +189,11 @@ export class SeleccionArticulosComponent implements OnInit, AfterViewInit, OnDes | 
| 188 | 189 | this.showQuantity += 100; | 
| 189 | 190 | } | 
| 190 | 191 | |
| 192 | + | |
| 193 | + validarFecha(fechaInicio: string, fechaFin: string) { | |
| 194 | + return DateExtension.ValidateDateRange(fechaInicio, fechaFin); | |
| 195 | + } | |
| 196 | + | |
| 191 | 197 | @HostListener('scroll', ['$event']) | 
| 192 | 198 | scrollEvent(event: Event) { | 
| 193 | 199 | clearTimeout(this.inactiveScreen.timerReposo); | 
src/app/utils/dateExtension.ts
| ... | ... | @@ -0,0 +1,10 @@ | 
| 1 | +export class DateExtension { | |
| 2 | + | |
| 3 | + public static ValidateDateRange(dateStart: string, dateEnd: string) { | |
| 4 | + if (dateEnd === null) return false; | |
| 5 | + const today = new Date(Date.now()); | |
| 6 | + return (new Date(dateStart) <= today && today <= new Date(dateEnd)) | |
| 7 | + ? true : false; | |
| 8 | + } | |
| 9 | + | |
| 10 | +} | |
| 0 | 11 | \ No newline at end of file |