Skip to content

Commit

Permalink
feat(dayView): allow the all day event template to be customised
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Lewis committed Apr 4, 2017
1 parent 149b605 commit d542d13
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/components/day/calendarAllDayEvent.component.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Component, Input, Output, EventEmitter, TemplateRef } from '@angular/core';
import { CalendarEvent } from 'calendar-utils';

@Component({
selector: 'mwl-calendar-all-day-event',
template: `
<div
class="cal-all-day-event"
[style.backgroundColor]="event.color.secondary"
[style.borderColor]="event.color.primary">
<mwl-calendar-event-title
[event]="event"
view="day"
(click)="eventClicked.emit()">
</mwl-calendar-event-title>
<mwl-calendar-event-actions [event]="event"></mwl-calendar-event-actions>
</div>
<ng-template #defaultTemplate>
<div
class="cal-all-day-event"
[style.backgroundColor]="event.color.secondary"
[style.borderColor]="event.color.primary">
<mwl-calendar-event-title
[event]="event"
view="day"
(click)="eventClicked.emit()">
</mwl-calendar-event-title>
<mwl-calendar-event-actions [event]="event"></mwl-calendar-event-actions>
</div>
</ng-template>
<ng-template
[ngTemplateOutlet]="customTemplate || defaultTemplate"
[ngTemplateOutletContext]="{
event: event,
eventClicked: eventClicked
}">
</ng-template>
`
})
export class CalendarAllDayEventComponent {

@Input() event: CalendarEvent;

@Input() customTemplate: TemplateRef<any>;

@Output() eventClicked: EventEmitter<any> = new EventEmitter();

}
6 changes: 6 additions & 0 deletions src/components/day/calendarDayView.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const SEGMENT_HEIGHT: number = 30;
<mwl-calendar-all-day-event
*ngFor="let event of view.allDayEvents"
[event]="event"
[customTemplate]="allDayEventTemplate"
(eventClicked)="eventClicked.emit({event: event})">
</mwl-calendar-all-day-event>
<div class="cal-hour-rows">
Expand Down Expand Up @@ -182,6 +183,11 @@ export class CalendarDayViewComponent implements OnChanges, OnInit, OnDestroy {
*/
@Input() hourSegmentTemplate: TemplateRef<any>;

/**
* A custom template to use for all day events
*/
@Input() allDayEventTemplate: TemplateRef<any>;

/**
* Called when an event title is clicked
*/
Expand Down

0 comments on commit d542d13

Please sign in to comment.