import {Component, Input, Output, EventEmitter} from '@angular/core'; import {Observable} from 'rxjs/Observable'; import { Filter, Value, DateValue} from './searchHelperClasses.class'; import {IMyOptions, IMyDateModel} from '../../utils/my-date-picker/interfaces/index'; // import {IMyDateModel} from '../../../utils/my-date-picker/interfaces/my-date-model.interface'; import {Dates} from '../../utils/string-utils.class'; @Component({ selector: 'date-filter', template: `
From To
` }) export class DateFilterComponent { @Input() dateValue = new DateValue("any"); @Input() filterId; private myDatePickerOptions: IMyOptions = { // other options... dateFormat: 'yyyy-mm-dd', selectionTxtFontSize: '15px', height:'28px', width: '100%', editableDateField: false, showClearDateBtn: false }; // Initialized to specific date (09.10.2018). public from;//: Object = { date: { year: 2018, month: 10, day: 9 } }; public to;//: Object = { date: { year: 2018, month: 10, day: 9 } }; constructor() { this.updateDefaultRangeDates(this.dateValue.from,this.dateValue.to); } updateDefaultRangeDates(df:Date,dt:Date){ this.from = { date: { year: df.getFullYear(), month: (df.getMonth()+1), day: df.getDate() } }; this.to = { date: { year: dt.getFullYear(), month: (dt.getMonth()+1), day: dt.getDate() } }; } typeChanged(type:string){ this.dateValue.setDatesByType(type); this.updateDefaultRangeDates(this.dateValue.from, this.dateValue.to); } onFromDateChanged(event: IMyDateModel) { this.dateValue.from = Dates.getDateFromString(event.formatted); } onToDateChanged(event: IMyDateModel) { this.dateValue.to = Dates.getDateFromString(event.formatted); }}