Revize 41ab77d7
Přidáno uživatelem Václav Jirák před asi 6 roky(ů)
frontend/src/app/day-picker/day-picker.component.html | ||
---|---|---|
1 |
<div class="day-picker-container"> |
|
2 |
<div class="row text-center day-picker-month-selection"> |
|
3 |
<div class="col-4"></div> |
|
4 |
<div class="col-1"> |
|
5 |
<div class="btn btn-primary" |
|
6 |
mwlCalendarPreviousView |
|
7 |
[view]="view" |
|
8 |
[(viewDate)]="viewDate" |
|
9 |
> |
|
10 |
< |
|
11 |
</div> |
|
12 |
</div> |
|
13 |
<div class="col-2"> |
|
14 |
<span id="day-picker-date">{{ viewDate | calendarDate:(view + 'ViewTitle'):locale }}</span> |
|
15 |
</div> |
|
16 |
<div class="col-1"> |
|
17 |
<div class="btn btn-primary" |
|
18 |
mwlCalendarNextView |
|
19 |
[view]="view" |
|
20 |
[(viewDate)]="viewDate" |
|
21 |
> |
|
22 |
> |
|
23 |
</div> |
|
24 |
<div class="col-4"></div> |
|
25 |
</div> |
|
26 |
</div> |
|
27 |
|
|
28 |
<mwl-calendar-month-view |
|
29 |
[viewDate]="viewDate" |
|
30 |
(dayClicked)="dayClicked($event.day)" |
|
31 |
weekStartsOn="1" |
|
32 |
[locale]="locale" |
|
33 |
> |
|
34 |
</mwl-calendar-month-view> |
|
35 |
</div> |
frontend/src/app/day-picker/day-picker.component.sass | ||
---|---|---|
1 |
.day-picker-container |
|
2 |
background-color: white |
|
3 |
padding: 10px |
|
4 |
border: 1px solid gainsboro |
|
5 |
|
|
6 |
#day-picker-date |
|
7 |
font-weight: bold |
|
8 |
text-transform: uppercase |
|
9 |
|
|
10 |
.day-picker-month-selection |
|
11 |
margin-bottom: 10px |
frontend/src/app/day-picker/day-picker.component.ts | ||
---|---|---|
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 |
} |
frontend/src/app/day-picker/day-picker.module.ts | ||
---|---|---|
1 |
import { NgModule } from '@angular/core'; |
|
2 |
import { CommonModule } from '@angular/common'; |
|
3 |
import { FormsModule } from '@angular/forms'; |
|
4 |
import { FlatpickrModule } from 'angularx-flatpickr'; |
|
5 |
import { CalendarModule, DateAdapter } from 'angular-calendar'; |
|
6 |
import { adapterFactory } from 'angular-calendar/date-adapters/date-fns'; |
|
7 |
import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap'; |
|
8 |
import { DayPickerComponent } from './day-picker.component'; |
|
9 |
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; |
|
10 |
|
|
11 |
@NgModule({ |
|
12 |
imports: [ |
|
13 |
CommonModule, |
|
14 |
FormsModule, |
|
15 |
NgbModalModule, |
|
16 |
FlatpickrModule.forRoot(), |
|
17 |
CalendarModule.forRoot({ |
|
18 |
provide: DateAdapter, |
|
19 |
useFactory: adapterFactory |
|
20 |
}), |
|
21 |
BrowserAnimationsModule |
|
22 |
], |
|
23 |
declarations: [DayPickerComponent], |
|
24 |
exports: [DayPickerComponent] |
|
25 |
}) |
|
26 |
export class DayPickerModule {} |
Také k dispozici: Unified diff
Re #7263 Day picker component implemented