@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.
199 lines (198 loc) • 10.2 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { Component, ContentChild, forwardRef, Input, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
import { LocalizationService } from '@progress/kendo-angular-l10n';
import { IntlService } from '@progress/kendo-angular-intl';
import { addDays, addWeeks, firstDayInWeek, getDate } from '@progress/kendo-date-math';
import { SchedulerView } from '../../types';
import { ConfigurationViewBase } from '../common/configuration-view-base';
import { ViewContextService } from '../view-context.service';
import { ViewStateService } from '../view-state.service';
import { MultiWeekDaySlotTemplateDirective } from '../templates';
import { DAYS_IN_WEEK_COUNT, DEFAULT_EVENT_HEIGHT, WEEKS_COUNT } from '../constants';
import { isPresent } from '../../common/util';
import { MonthViewRendererComponent } from './month-view-renderer.component';
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";
import * as i4 from "@progress/kendo-angular-intl";
/**
* The component for rendering the **Multi-Week** view.
*/
export class MultiWeekViewComponent extends ConfigurationViewBase {
intl;
/**
* @hidden
*/
get title() {
return this.localization.get('multiWeekViewTitle');
}
/**
* The height of the rendered events. Setting this property to `'auto'` will
* set the height of each event automatically based on its content
* ([see example](slug:multiweek_views_scheduler#configuring-the-height-of-the-scheduler-events)).
* > When set to `'auto'` it will automatically set the `adaptiveSlotHeight` property to `true`.
*/
eventHeight;
/**
* The number of events to be rendered per day. Setting this property to 'auto'
* will display all events in the respective slot
* ([see example](slug:multiweek_views_scheduler#setting-the-number-of-events-per-day)).
* > When set to `'auto'` it will automatically set the `adaptiveSlotHeight` property to `true`.
* > If set to `0` it will be normalized internally to `1`.
* @default 2
*/
set eventsPerDay(events) {
this._eventsPerDay = !events ? 1 : events;
}
get eventsPerDay() {
return this._eventsPerDay;
}
_eventsPerDay;
/**
* Increases the slot group (row) height when containing events up to the number of displayed events
* and reduces its height if there are less events for that specific slot group (row)
* ([see example](slug:multiweek_views_scheduler#enabling-the-adaptive-slot-height-of-the-scheduler)).
* @default false
*/
adaptiveSlotHeight;
/**
* The number of weeks to be rendered.
* @default 6
*/
numberOfWeeks = WEEKS_COUNT;
/**
* The long-date format for displaying the
* selected date in the Scheduler toolbar.
* ([more information]({% slug parsingandformatting_intl %}#toc-date-formatting)).
* @default '{0:D} - {1:D}'
*/
selectedDateFormat = '{0:D} - {1:D}';
/**
* The short-date format for displaying the
* selected date in the Scheduler toolbar.
* ([more information]({% slug parsingandformatting_intl %}#toc-date-formatting)).
* @default '{0:d} - {1:d}'
*/
selectedShortDateFormat = '{0:d} - {1:d}';
multiWeekDaySlotTemplate;
/**
* The invariant name for this view (`multiWeek`).
*/
name = 'multiWeek';
get viewEventHeight() {
return isPresent(this.eventHeight) ? this.eventHeight : (this.schedulerOptions.eventHeight || DEFAULT_EVENT_HEIGHT);
}
constructor(localization, changeDetector, viewContext, viewState, intl) {
super(localization, changeDetector, viewContext, viewState);
this.intl = intl;
}
ngOnChanges(changes) {
if ((changes['eventHeight'] && changes['eventHeight'].currentValue === 'auto') ||
(changes['eventsPerDay'] && changes['eventsPerDay'].currentValue === 'auto')) {
this.adaptiveSlotHeight = true;
}
if ((changes['eventHeight'] && changes['eventHeight'].currentValue === 'auto' && !this.eventsPerDay) ||
(changes['adaptiveSlotHeight'] && changes['adaptiveSlotHeight'].currentValue === true && !this.eventsPerDay)) {
this.eventsPerDay = 2;
}
}
/**
* @hidden
*/
dateRange(date, weekStart) {
const periodStart = getDate(date);
const start = firstDayInWeek(periodStart, weekStart);
const end = addDays(start, (DAYS_IN_WEEK_COUNT * this.numberOfWeeks));
const text = this.intl.format(this.selectedDateFormat, start, end);
const shortText = this.intl.format(this.selectedShortDateFormat, start, end);
return { start, end, text, shortText };
}
/**
* @hidden
*/
newRange(date, direction = 1) {
return firstDayInWeek(addWeeks(date, this.numberOfWeeks * direction));
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MultiWeekViewComponent, deps: [{ token: i1.LocalizationService }, { token: i0.ChangeDetectorRef }, { token: i2.ViewContextService }, { token: i3.ViewStateService }, { token: i4.IntlService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: MultiWeekViewComponent, isStandalone: true, selector: "kendo-scheduler-multi-week-view", inputs: { eventHeight: "eventHeight", eventsPerDay: "eventsPerDay", adaptiveSlotHeight: "adaptiveSlotHeight", numberOfWeeks: "numberOfWeeks", selectedDateFormat: "selectedDateFormat", selectedShortDateFormat: "selectedShortDateFormat" }, providers: [{
provide: SchedulerView,
useExisting: forwardRef(() => MultiWeekViewComponent)
}], queries: [{ propertyName: "multiWeekDaySlotTemplate", first: true, predicate: MultiWeekDaySlotTemplateDirective, descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
<ng-template
<month-view
type="multiWeek"
[ ]="viewEventHeight"
[ ]="adaptiveSlotHeight"
[ ]="eventsPerDay"
[ ]="eventTemplate?.templateRef"
[ ]="viewSlotClass"
[ ]="viewEventClass"
[ ]="viewEventStyles"
[ ]="groupHeaderTemplate?.templateRef"
[ ]="multiWeekDaySlotTemplate?.templateRef"
[ ]="selectedDateFormat"
[ ]="selectedShortDateFormat"
[ ]="viewHighlightOngoingEvents"
[ ]="viewWeekStart"
[ ]="numberOfWeeks"
[ ]="dateRange"
[ ]="newRange">
</month-view>
</ng-template>
`, isInline: true, dependencies: [{ kind: "component", type: MonthViewRendererComponent, selector: "month-view", inputs: ["monthDaySlotTemplate", "highlightOngoingEvents", "type", "eventsPerDay", "adaptiveSlotHeight", "numberOfWeeks", "newRange", "dateRangeFn"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MultiWeekViewComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'kendo-scheduler-multi-week-view',
providers: [{
provide: SchedulerView,
useExisting: forwardRef(() => MultiWeekViewComponent)
}],
template: `
<ng-template
<month-view
type="multiWeek"
[ ]="viewEventHeight"
[ ]="adaptiveSlotHeight"
[ ]="eventsPerDay"
[ ]="eventTemplate?.templateRef"
[ ]="viewSlotClass"
[ ]="viewEventClass"
[ ]="viewEventStyles"
[ ]="groupHeaderTemplate?.templateRef"
[ ]="multiWeekDaySlotTemplate?.templateRef"
[ ]="selectedDateFormat"
[ ]="selectedShortDateFormat"
[ ]="viewHighlightOngoingEvents"
[ ]="viewWeekStart"
[ ]="numberOfWeeks"
[ ]="dateRange"
[ ]="newRange">
</month-view>
</ng-template>
`,
standalone: true,
imports: [MonthViewRendererComponent]
}]
}], ctorParameters: function () { return [{ type: i1.LocalizationService }, { type: i0.ChangeDetectorRef }, { type: i2.ViewContextService }, { type: i3.ViewStateService }, { type: i4.IntlService }]; }, propDecorators: { eventHeight: [{
type: Input
}], eventsPerDay: [{
type: Input
}], adaptiveSlotHeight: [{
type: Input
}], numberOfWeeks: [{
type: Input
}], selectedDateFormat: [{
type: Input
}], selectedShortDateFormat: [{
type: Input
}], multiWeekDaySlotTemplate: [{
type: ContentChild,
args: [MultiWeekDaySlotTemplateDirective]
}] } });