1
- import { Component , Input , Output , EventEmitter } from '@angular/core' ;
1
+ import { Component , Input , Output , EventEmitter , TemplateRef } from '@angular/core' ;
2
2
import { MonthViewDay , CalendarEvent } from 'calendar-utils' ;
3
3
4
4
@Component ( {
5
5
selector : 'mwl-calendar-month-cell' ,
6
6
template : `
7
- <div class="cal-cell-top">
8
- <span class="cal-day-badge" *ngIf="day.badgeTotal > 0">{{ day.badgeTotal }}</span>
9
- <span class="cal-day-number">{{ day.date | calendarDate:'monthViewDayNumber':locale }}</span>
10
- </div>
11
- <div class="cal-events">
12
- <div
13
- class="cal-event"
14
- *ngFor="let event of day.events"
15
- [style.backgroundColor]="event.color.primary"
16
- [ngClass]="event?.cssClass"
17
- (mouseenter)="highlightDay.emit({event: event})"
18
- (mouseleave)="unhighlightDay.emit({event: event})"
19
- [mwlCalendarTooltip]="event.title | calendarEventTitle:'monthTooltip':event"
20
- [tooltipPlacement]="tooltipPlacement"
21
- mwlDraggable
22
- [dropData]="{event: event}"
23
- [dragAxis]="{x: event.draggable, y: event.draggable}"
24
- (click)="$event.stopPropagation(); eventClicked.emit({event: event})">
7
+ <template #defaultTemplate>
8
+ <div class="cal-cell-top">
9
+ <span class="cal-day-badge" *ngIf="day.badgeTotal > 0">{{ day.badgeTotal }}</span>
10
+ <span class="cal-day-number">{{ day.date | calendarDate:'monthViewDayNumber':locale }}</span>
25
11
</div>
26
- </div>
12
+ <div class="cal-events">
13
+ <div
14
+ class="cal-event"
15
+ *ngFor="let event of day.events"
16
+ [style.backgroundColor]="event.color.primary"
17
+ [ngClass]="event?.cssClass"
18
+ (mouseenter)="highlightDay.emit({event: event})"
19
+ (mouseleave)="unhighlightDay.emit({event: event})"
20
+ [mwlCalendarTooltip]="event.title | calendarEventTitle:'monthTooltip':event"
21
+ [tooltipPlacement]="tooltipPlacement"
22
+ mwlDraggable
23
+ [dropData]="{event: event}"
24
+ [dragAxis]="{x: event.draggable, y: event.draggable}"
25
+ (click)="$event.stopPropagation(); eventClicked.emit({event: event})">
26
+ </div>
27
+ </div>
28
+ </template>
29
+ <template
30
+ [ngTemplateOutlet]="customTemplate || defaultTemplate"
31
+ [ngOutletContext]="{
32
+ day: day,
33
+ openDay: openDay,
34
+ locale: locale,
35
+ tooltipPlacement: tooltipPlacement,
36
+ highlightDay: highlightDay,
37
+ unhighlightDay: unhighlightDay,
38
+ eventClicked: eventClicked
39
+ }">
40
+ </template>
27
41
` ,
28
42
host : {
29
43
'[class]' : '"cal-cell cal-day-cell " + day?.cssClass' ,
@@ -48,6 +62,8 @@ export class CalendarMonthCellComponent {
48
62
49
63
@Input ( ) tooltipPlacement : string ;
50
64
65
+ @Input ( ) customTemplate : TemplateRef < any > ;
66
+
51
67
@Output ( ) highlightDay : EventEmitter < any > = new EventEmitter ( ) ;
52
68
53
69
@Output ( ) unhighlightDay : EventEmitter < any > = new EventEmitter ( ) ;
0 commit comments