1
|
import { Component, ChangeDetectionStrategy, Output, EventEmitter } from '@angular/core';
|
2
|
import { CalendarView } from 'angular-calendar';
|
3
|
|
4
|
@Component({
|
5
|
selector: 'app-day-picker',
|
6
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
7
|
styleUrls: ['day-picker.component.sass'],
|
8
|
templateUrl: 'day-picker.component.html'
|
9
|
})
|
10
|
export class DayPickerComponent {
|
11
|
|
12
|
// TODO Move to language service
|
13
|
locale = 'cs';
|
14
|
|
15
|
// Type of calendar (constant)
|
16
|
view: CalendarView = CalendarView.Month;
|
17
|
|
18
|
// Selected date for this component's purpose
|
19
|
private viewDate: Date = new Date();
|
20
|
|
21
|
// EventEmitter informing about changes of selected date
|
22
|
@Output() selectedDate = new EventEmitter<Date>();
|
23
|
|
24
|
/**
|
25
|
* Method that is invoked when user clicks on a day.
|
26
|
* Sets selected date and emits event informing about new selected date.
|
27
|
*
|
28
|
* @param date Selected date
|
29
|
*/
|
30
|
private dayClicked({ date }: { date: Date }): void {
|
31
|
this.viewDate = date;
|
32
|
this.selectedDate.emit(date);
|
33
|
}
|
34
|
}
|