From 149b6058bff38d60844d31d98b4919650ec21469 Mon Sep 17 00:00:00 2001 From: Matt Lewis Date: Tue, 4 Apr 2017 19:58:14 +0100 Subject: [PATCH] feat(dayView): allow the hour segment template to be customised Closes #172 --- .../day/calendarDayView.component.ts | 19 +++++++++++++++-- .../calendarDayViewHourSegment.component.ts | 21 ++++++++++++++----- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/components/day/calendarDayView.component.ts b/src/components/day/calendarDayView.component.ts index 57e91eb0f..f0d095e01 100644 --- a/src/components/day/calendarDayView.component.ts +++ b/src/components/day/calendarDayView.component.ts @@ -8,9 +8,18 @@ import { LOCALE_ID, Inject, OnInit, - OnDestroy + OnDestroy, + TemplateRef } from '@angular/core'; -import { getDayView, getDayViewHourGrid, CalendarEvent, DayView, DayViewHour, DayViewHourSegment, DayViewEvent } from 'calendar-utils'; +import { + getDayView, + getDayViewHourGrid, + CalendarEvent, + DayView, + DayViewHour, + DayViewHourSegment, + DayViewEvent +} from 'calendar-utils'; import { Subject } from 'rxjs/Subject'; import { Subscription } from 'rxjs/Subscription'; import { ResizeEvent } from 'angular-resizable-element'; @@ -87,6 +96,7 @@ const SEGMENT_HEIGHT: number = 30; *ngFor="let segment of hour.segments" [segment]="segment" [locale]="locale" + [customTemplate]="hourSegmentTemplate" (click)="hourSegmentClicked.emit({date: segment.date})" [class.cal-drag-over]="segment.dragOver" mwlDroppable @@ -167,6 +177,11 @@ export class CalendarDayViewComponent implements OnChanges, OnInit, OnDestroy { */ @Input() tooltipPlacement: string = 'top'; + /** + * A custom template to use to replace the hour segment + */ + @Input() hourSegmentTemplate: TemplateRef; + /** * Called when an event title is clicked */ diff --git a/src/components/day/calendarDayViewHourSegment.component.ts b/src/components/day/calendarDayViewHourSegment.component.ts index 9750a4e97..6560ac6a2 100644 --- a/src/components/day/calendarDayViewHourSegment.component.ts +++ b/src/components/day/calendarDayViewHourSegment.component.ts @@ -1,14 +1,23 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, TemplateRef } from '@angular/core'; import { DayViewHourSegment } from 'calendar-utils'; @Component({ selector: 'mwl-calendar-day-view-hour-segment', template: ` -
-
- {{ segment.date | calendarDate:'dayViewHour':locale }} + +
+
+ {{ segment.date | calendarDate:'dayViewHour':locale }} +
-
+ + + ` }) export class CalendarDayViewHourSegmentComponent { @@ -17,4 +26,6 @@ export class CalendarDayViewHourSegmentComponent { @Input() locale: string; + @Input() customTemplate: TemplateRef; + } \ No newline at end of file