@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.
145 lines (144 loc) • 5.08 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 { Injectable } from '@angular/core';
import { BehaviorSubject, Subject } from 'rxjs';
import * as i0 from "@angular/core";
const emptyDateRange = () => ({
start: new Date(0),
end: new Date(0),
text: '',
shortText: ''
});
/**
* A service for publishing the view state and actions to the Scheduler.
*/
export class ViewStateService {
/**
* Represents a stream that publishes the visible date range for the current view to the Scheduler.
*/
dateRange;
/**
* Represents a stream that publishes changes to the selected date, which initiate from the view.
*/
nextDate;
/**
* Represents a stream for navigating from the current view to another view.
*/
navigate;
/**
* Represents a stream that publishes events for navigation between views.
*/
viewEvent;
/**
* Represents a stream that indicates when the view layout finishes.
*/
layoutEnd;
/**
* Represents a stream that indicates when the view options change.
*/
optionsChange;
/**
* Represents a stream that indicates when the user starts a new slot selection.
*/
slotSelectionStart;
/**
* Represents a stream that indicates when the user drags over a different slot during selection.
*/
slotSelectionDrag;
/**
* Represents a stream that indicates when the user finishes making a slot selection.
*/
slotSelectionEnd;
/**
* @hidden
*/
toggleWorkHours = new Subject();
/**
* @hidden
*/
toolbarVisibilityByView = new Map();
dateRangeSource = new BehaviorSubject(emptyDateRange());
nextDateSource = new Subject();
navigateSource = new Subject();
viewEventSource = new Subject();
layoutEndSource = new Subject();
optionsChangeSource = new Subject();
slotSelectionStartSource = new Subject();
slotSelectionStartDragSource = new Subject();
slotSelectionStartEndSource = new Subject();
constructor() {
this.dateRange = this.dateRangeSource.asObservable();
this.nextDate = this.nextDateSource.asObservable();
this.navigate = this.navigateSource.asObservable();
this.viewEvent = this.viewEventSource.asObservable();
this.layoutEnd = this.layoutEndSource.asObservable();
this.optionsChange = this.optionsChangeSource.asObservable();
this.slotSelectionStart = this.slotSelectionStartSource.asObservable();
this.slotSelectionDrag = this.slotSelectionStartDragSource.asObservable();
this.slotSelectionEnd = this.slotSelectionStartEndSource.asObservable();
}
/**
* Publishes the date that will be displayed by the Scheduler
* typically as a result from processing a navigation action.
*/
notifyNextDate(date) {
this.nextDateSource.next(date);
}
/**
* Publishes the visible date range of the view.
* The view will calculate and set the new data range when
* the selected date changes.
*/
notifyDateRange(range) {
this.dateRangeSource.next(range);
}
/**
* Notifies the Scheduler that the view has completed its layout.
*/
notifyLayoutEnd() {
this.layoutEndSource.next();
}
/**
* Navigates to another view.
*/
navigateTo(args) {
this.navigateSource.next(args);
}
/**
* Notifies the Scheduler that the view options have been changed.
*/
notifyOptionsChange(changes) {
this.optionsChangeSource.next(changes);
}
/**
* Emits a DOM event to the Scheduler.
*/
emitEvent(name, args) {
this.viewEventSource.next({
name: name,
args: args
});
}
/** @hidden */
notifySlotSelectionStart(selection) {
this.slotSelectionStartSource.next(selection);
}
/** @hidden */
notifySlotSelectionDrag(selection) {
this.slotSelectionStartDragSource.next(selection);
}
/** @hidden */
notifySlotSelectionEnd(selection) {
this.slotSelectionStartEndSource.next(selection);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ViewStateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ViewStateService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ViewStateService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}], ctorParameters: function () { return []; } });