UNPKG

@progress/kendo-angular-scheduler

Version:

Kendo UI Scheduler Angular - Outlook or Google-style angular scheduler calendar. Full-featured and customizable embedded scheduling from the creator developers trust for professional UI components.

200 lines (199 loc) 10.4 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Component, forwardRef, Input, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; import { LocalizationService } from '@progress/kendo-angular-l10n'; import { SchedulerView } from '../../types'; import { TimelineBase } from './timeline-base'; import { ViewContextService } from '../view-context.service'; import { ViewStateService } from '../view-state.service'; import { firstDayOfMonth, getDate, addMonths } from '@progress/kendo-date-math'; import { WorkHoursFooterDirective } from '../common/work-hours-footer.directive'; import { ViewFooterComponent } from '../common/view-footer.component'; import { TimelineMultiDayViewComponent } from './timeline-multi-day-view.component'; import { NgIf } from '@angular/common'; import * as i0 from "@angular/core"; import * as i1 from "@progress/kendo-angular-l10n"; import * as i2 from "../view-context.service"; import * as i3 from "../view-state.service"; /** * The component for rendering the **Month** timeline view. */ export class TimelineMonthViewComponent extends TimelineBase { /** * @hidden */ get title() { return this.localization.get('timelineMonthViewTitle'); } /** * The long-date format for displaying the * selected date in the Scheduler toolbar. * ([more information]({% slug parsingandformatting_intl %}#toc-date-formatting)). * > Note: If [numberOfMonths](#toc-numberofmonths) > 1, the default format value shows a range - `'{0:Y} - {1:Y}'`, where `0` is the start and `1` is the end date. * @default '{0:Y}' */ set selectedDateFormat(format) { this._selectedDateFormat = format; } get selectedDateFormat() { if (this._selectedDateFormat) { return this._selectedDateFormat; } return this.numberOfMonths && this.numberOfMonths > 1 ? '{0:Y} - {1:Y}' : '{0:Y}'; } _selectedDateFormat; /** * The short-date format for displaying the * selected date in the Scheduler toolbar. * ([more information]({% slug parsingandformatting_intl %}#toc-date-formatting)). * > Note: If [numberOfMonths](#toc-numberofmonths) > 1, the default format value shows a range - `'{0:y} - {1:y}'`, where `0` is the start and `1` is the end date. * @default '{0:y}' */ set selectedShortDateFormat(format) { this._selectedShortDateFormat = format; } get selectedShortDateFormat() { if (this._selectedShortDateFormat) { return this._selectedShortDateFormat; } return this.numberOfMonths && this.numberOfMonths > 1 ? '{0:y} - {1:y}' : '{0:y}'; } _selectedShortDateFormat; /** * Specifies the number of months that the view will render. * > Normalized to `1` if the provided value is <= 0. * @default 1 */ set numberOfMonths(months) { this._numberOfMonths = months > 0 ? months : 1; } get numberOfMonths() { return this._numberOfMonths; } _numberOfMonths = 1; /** * The invariant name for this view. * @default 'timelineMonth' */ name = 'timelineMonth'; /** * @hidden */ getStartDate = (selectedDate) => { return firstDayOfMonth(getDate(selectedDate)); }; /** * @hidden */ getEndDate = (selectedDate) => { return addMonths(this.getStartDate(selectedDate), this.numberOfMonths); }; /** * @hidden */ getNextDate = (date, count) => { return addMonths(date, count); }; constructor(localization, changeDetector, viewContext, viewState) { super(localization, changeDetector, viewContext, viewState); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TimelineMonthViewComponent, deps: [{ token: i1.LocalizationService }, { token: i0.ChangeDetectorRef }, { token: i2.ViewContextService }, { token: i3.ViewStateService }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: TimelineMonthViewComponent, isStandalone: true, selector: "kendo-scheduler-timeline-month-view", inputs: { selectedDateFormat: "selectedDateFormat", selectedShortDateFormat: "selectedShortDateFormat", numberOfMonths: "numberOfMonths" }, providers: [{ provide: SchedulerView, useExisting: forwardRef(() => TimelineMonthViewComponent) }], usesInheritance: true, ngImport: i0, template: ` <ng-template #content> <timeline-multi-day-view viewName="timeline-month" [name]="name" [getNextDate]="getNextDate" [getStartDate]="getStartDate" [getEndDate]="getEndDate" [eventHeight]="viewEventHeight" [columnWidth]="viewColumnWidth" [currentTimeMarker]="viewCurrentTimeMarker" [highlightOngoingEvents]="viewHighlightOngoingEvents" [showWorkHours]="shouldShowWorkHours" [scrollTime]="viewScrollTime" [startTime]="viewStartTime" [endTime]="viewEndTime" [workDayStart]="viewWorkDayStart" [workDayEnd]="viewWorkDayEnd" [workWeekStart]="viewWorkWeekStart" [workWeekEnd]="viewWorkWeekEnd" [slotDuration]="viewSlotDuration" [slotDivisions]="viewSlotDivisions" [slotClass]="viewSlotClass" [eventClass]="viewEventClass" [eventStyles]="viewEventStyles" [eventTemplate]="eventTemplate?.templateRef" [groupHeaderTemplate]="groupHeaderTemplate?.templateRef" [timeSlotTemplate]="timeSlotTemplate?.templateRef" [dateHeaderTemplate]="dateHeaderTemplate?.templateRef" [majorTimeHeaderTemplate]="majorTimeHeaderTemplate?.templateRef" [minorTimeHeaderTemplate]="minorTimeHeaderTemplate?.templateRef" [selectedDateFormat]="selectedDateFormat" [selectedShortDateFormat]="selectedShortDateFormat"> </timeline-multi-day-view> <div *ngIf="viewShowFooter" viewFooter kendoWorkHoursFooter [showWorkHours]="shouldShowWorkHours" (itemClick)="showWorkHours = !shouldShowWorkHours"></div> </ng-template> `, isInline: true, dependencies: [{ kind: "component", type: TimelineMultiDayViewComponent, selector: "timeline-multi-day-view", inputs: ["name", "columnWidth", "viewName"] }, { kind: "component", type: ViewFooterComponent, selector: "[viewFooter]", inputs: ["items"], outputs: ["itemClick"] }, { kind: "directive", type: WorkHoursFooterDirective, selector: "[kendoWorkHoursFooter]", inputs: ["showWorkHours"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TimelineMonthViewComponent, decorators: [{ type: Component, args: [{ changeDetection: ChangeDetectionStrategy.OnPush, selector: 'kendo-scheduler-timeline-month-view', providers: [{ provide: SchedulerView, useExisting: forwardRef(() => TimelineMonthViewComponent) }], template: ` <ng-template #content> <timeline-multi-day-view viewName="timeline-month" [name]="name" [getNextDate]="getNextDate" [getStartDate]="getStartDate" [getEndDate]="getEndDate" [eventHeight]="viewEventHeight" [columnWidth]="viewColumnWidth" [currentTimeMarker]="viewCurrentTimeMarker" [highlightOngoingEvents]="viewHighlightOngoingEvents" [showWorkHours]="shouldShowWorkHours" [scrollTime]="viewScrollTime" [startTime]="viewStartTime" [endTime]="viewEndTime" [workDayStart]="viewWorkDayStart" [workDayEnd]="viewWorkDayEnd" [workWeekStart]="viewWorkWeekStart" [workWeekEnd]="viewWorkWeekEnd" [slotDuration]="viewSlotDuration" [slotDivisions]="viewSlotDivisions" [slotClass]="viewSlotClass" [eventClass]="viewEventClass" [eventStyles]="viewEventStyles" [eventTemplate]="eventTemplate?.templateRef" [groupHeaderTemplate]="groupHeaderTemplate?.templateRef" [timeSlotTemplate]="timeSlotTemplate?.templateRef" [dateHeaderTemplate]="dateHeaderTemplate?.templateRef" [majorTimeHeaderTemplate]="majorTimeHeaderTemplate?.templateRef" [minorTimeHeaderTemplate]="minorTimeHeaderTemplate?.templateRef" [selectedDateFormat]="selectedDateFormat" [selectedShortDateFormat]="selectedShortDateFormat"> </timeline-multi-day-view> <div *ngIf="viewShowFooter" viewFooter kendoWorkHoursFooter [showWorkHours]="shouldShowWorkHours" (itemClick)="showWorkHours = !shouldShowWorkHours"></div> </ng-template> `, standalone: true, imports: [TimelineMultiDayViewComponent, ViewFooterComponent, WorkHoursFooterDirective, NgIf] }] }], ctorParameters: function () { return [{ type: i1.LocalizationService }, { type: i0.ChangeDetectorRef }, { type: i2.ViewContextService }, { type: i3.ViewStateService }]; }, propDecorators: { selectedDateFormat: [{ type: Input }], selectedShortDateFormat: [{ type: Input }], numberOfMonths: [{ type: Input }] } });