@progress/kendo-angular-scheduler 21.4.1-develop.1 → 22.0.0-develop.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/editing/recurrence/localization/messages.d.ts +1 -1
  2. package/editing/resource-editor-base.d.ts +1 -1
  3. package/editing-directives/editing-directive-base.d.ts +1 -1
  4. package/fesm2022/progress-kendo-angular-scheduler.mjs +313 -313
  5. package/localization/messages.d.ts +1 -1
  6. package/package.json +20 -28
  7. package/schematics/ngAdd/index.js +3 -3
  8. package/views/common/base-view.d.ts +1 -1
  9. package/views/common/configuration-view-base.d.ts +1 -1
  10. package/views/day-time/day-time-view-base.d.ts +1 -1
  11. package/views/day-time/day-time-view.component.d.ts +1 -1
  12. package/views/multi-day/multi-day-view-base.d.ts +1 -1
  13. package/views/timeline/timeline-base.d.ts +1 -1
  14. package/views/view-items/base-slot.directive.d.ts +1 -1
  15. package/views/view-items/base-view-item.d.ts +1 -1
  16. package/esm2022/common/constants.mjs +0 -8
  17. package/esm2022/common/default-model-fields.mjs +0 -20
  18. package/esm2022/common/dom-queries.mjs +0 -107
  19. package/esm2022/common/modifiers.mjs +0 -31
  20. package/esm2022/common/util.mjs +0 -227
  21. package/esm2022/data-binding.directive.mjs +0 -162
  22. package/esm2022/directives.mjs +0 -136
  23. package/esm2022/editing/date-time-picker.component.mjs +0 -190
  24. package/esm2022/editing/dialogs.service.mjs +0 -96
  25. package/esm2022/editing/edit-dialog-template.directive.mjs +0 -53
  26. package/esm2022/editing/edit-dialog.component.mjs +0 -679
  27. package/esm2022/editing/edit.service.mjs +0 -107
  28. package/esm2022/editing/local-data-changes.service.mjs +0 -18
  29. package/esm2022/editing/recurrence/end-rule-radio-button.directive.mjs +0 -77
  30. package/esm2022/editing/recurrence/localization/custom-messages.component.mjs +0 -44
  31. package/esm2022/editing/recurrence/localization/localized-messages.directive.mjs +0 -39
  32. package/esm2022/editing/recurrence/localization/messages.mjs +0 -239
  33. package/esm2022/editing/recurrence/localization/recurrence-localization.service.mjs +0 -47
  34. package/esm2022/editing/recurrence/recurrence-editor.component.mjs +0 -497
  35. package/esm2022/editing/recurrence/recurrence-end-rule-editor.component.mjs +0 -334
  36. package/esm2022/editing/recurrence/recurrence-frequency-editor.component.mjs +0 -105
  37. package/esm2022/editing/recurrence/recurrence-interval-editor.component.mjs +0 -169
  38. package/esm2022/editing/recurrence/recurrence-monthly-yearly-editor.component.mjs +0 -468
  39. package/esm2022/editing/recurrence/recurrence-weekday-rule-editor.component.mjs +0 -138
  40. package/esm2022/editing/recurrence/recurrence.service.mjs +0 -254
  41. package/esm2022/editing/recurrence/repeat-on-radio-button.directive.mjs +0 -81
  42. package/esm2022/editing/resource-editor-base.mjs +0 -59
  43. package/esm2022/editing/resource-multiple-editor.component.mjs +0 -101
  44. package/esm2022/editing/resource-single-editor.component.mjs +0 -82
  45. package/esm2022/editing/timezone-editor.component.mjs +0 -193
  46. package/esm2022/editing-directives/base-edit.service.mjs +0 -320
  47. package/esm2022/editing-directives/edit-service.interface.mjs +0 -5
  48. package/esm2022/editing-directives/editing-directive-base.mjs +0 -242
  49. package/esm2022/editing-directives/local-edit.service.mjs +0 -122
  50. package/esm2022/editing-directives/reactive-editing.directive.mjs +0 -132
  51. package/esm2022/editing-directives/utils.mjs +0 -107
  52. package/esm2022/events/add-event.mjs +0 -26
  53. package/esm2022/events/cancel-event.mjs +0 -14
  54. package/esm2022/events/create-event.mjs +0 -40
  55. package/esm2022/events/date-change-event.mjs +0 -29
  56. package/esm2022/events/drag-end-event.mjs +0 -46
  57. package/esm2022/events/drag-event.mjs +0 -54
  58. package/esm2022/events/drag-start-event.mjs +0 -30
  59. package/esm2022/events/edit-event-base.mjs +0 -32
  60. package/esm2022/events/edit-event.mjs +0 -30
  61. package/esm2022/events/event-click-event.mjs +0 -32
  62. package/esm2022/events/event-keydown-event.mjs +0 -28
  63. package/esm2022/events/more-events-click.mjs +0 -24
  64. package/esm2022/events/navigate-event.mjs +0 -26
  65. package/esm2022/events/preventable-event.mjs +0 -28
  66. package/esm2022/events/remove-event.mjs +0 -30
  67. package/esm2022/events/resize-end-event.mjs +0 -38
  68. package/esm2022/events/resize-event.mjs +0 -46
  69. package/esm2022/events/resize-start-event.mjs +0 -30
  70. package/esm2022/events/save-event.mjs +0 -18
  71. package/esm2022/events/slot-click-event.mjs +0 -44
  72. package/esm2022/events/slot-drag-end-event.mjs +0 -10
  73. package/esm2022/events/slot-drag-event.mjs +0 -40
  74. package/esm2022/events/slot-drag-start-event.mjs +0 -44
  75. package/esm2022/events/view-event-map.mjs +0 -35
  76. package/esm2022/events.mjs +0 -27
  77. package/esm2022/index.mjs +0 -83
  78. package/esm2022/loading.component.mjs +0 -52
  79. package/esm2022/localization/custom-messages.component.mjs +0 -56
  80. package/esm2022/localization/localized-messages.directive.mjs +0 -39
  81. package/esm2022/localization/messages.mjs +0 -614
  82. package/esm2022/localization/scheduler-localization.service.mjs +0 -31
  83. package/esm2022/navigation/focus-position.interface.mjs +0 -5
  84. package/esm2022/navigation/focus.service.mjs +0 -202
  85. package/esm2022/navigation/focusable-element.interface.mjs +0 -5
  86. package/esm2022/navigation/focusable.directive.mjs +0 -98
  87. package/esm2022/navigation/shortcuts.directive.mjs +0 -239
  88. package/esm2022/navigation.mjs +0 -6
  89. package/esm2022/package-metadata.mjs +0 -16
  90. package/esm2022/pdf/pdf-command.directive.mjs +0 -96
  91. package/esm2022/pdf/pdf-export-event.mjs +0 -10
  92. package/esm2022/pdf/pdf.component.mjs +0 -241
  93. package/esm2022/pdf/pdf.module.mjs +0 -42
  94. package/esm2022/pdf/pdf.service.mjs +0 -36
  95. package/esm2022/progress-kendo-angular-scheduler.mjs +0 -8
  96. package/esm2022/scheduler.component.mjs +0 -1981
  97. package/esm2022/scheduler.module.mjs +0 -138
  98. package/esm2022/toolbar/navigation.component.mjs +0 -391
  99. package/esm2022/toolbar/toolbar-context.mjs +0 -5
  100. package/esm2022/toolbar/toolbar-template.directive.mjs +0 -50
  101. package/esm2022/toolbar/toolbar.component.mjs +0 -168
  102. package/esm2022/toolbar/toolbar.service.mjs +0 -46
  103. package/esm2022/toolbar/view-selector.component.mjs +0 -181
  104. package/esm2022/types/actions.mjs +0 -5
  105. package/esm2022/types/create-form-group-args.interface.mjs +0 -5
  106. package/esm2022/types/crud-operation.enum.mjs +0 -18
  107. package/esm2022/types/current-time-settings.interface.mjs +0 -5
  108. package/esm2022/types/date-range.interface.mjs +0 -5
  109. package/esm2022/types/datepicker-options.interface.mjs +0 -5
  110. package/esm2022/types/edit-event-args.interface.mjs +0 -5
  111. package/esm2022/types/edit-mode.enum.mjs +0 -23
  112. package/esm2022/types/editable-settings.interface.mjs +0 -5
  113. package/esm2022/types/event-style-args.interface.mjs +0 -5
  114. package/esm2022/types/focusable-container.mjs +0 -5
  115. package/esm2022/types/group.interface.mjs +0 -5
  116. package/esm2022/types/numeric-options.interface.mjs +0 -5
  117. package/esm2022/types/ongoing-events-settings.interface.mjs +0 -5
  118. package/esm2022/types/resource.interface.mjs +0 -5
  119. package/esm2022/types/scheduler-event.mjs +0 -5
  120. package/esm2022/types/scheduler-model-fields.interface.mjs +0 -5
  121. package/esm2022/types/scheduler-slot.interface.mjs +0 -5
  122. package/esm2022/types/scheduler-view.mjs +0 -9
  123. package/esm2022/types/slot-class-args.interface.mjs +0 -5
  124. package/esm2022/types/slot-selection.mjs +0 -35
  125. package/esm2022/types/view-item.interface.mjs +0 -5
  126. package/esm2022/types.mjs +0 -12
  127. package/esm2022/views/agenda/agenda-header-item.component.mjs +0 -85
  128. package/esm2022/views/agenda/agenda-header.component.mjs +0 -75
  129. package/esm2022/views/agenda/agenda-task-item.component.mjs +0 -137
  130. package/esm2022/views/agenda/agenda-view-internal.component.mjs +0 -424
  131. package/esm2022/views/agenda/agenda-view-list.component.mjs +0 -256
  132. package/esm2022/views/agenda/agenda-view.component.mjs +0 -130
  133. package/esm2022/views/agenda/tasks.collection.mjs +0 -96
  134. package/esm2022/views/agenda/utils.mjs +0 -176
  135. package/esm2022/views/common/base-view.mjs +0 -1099
  136. package/esm2022/views/common/configuration-view-base.mjs +0 -164
  137. package/esm2022/views/common/dom-events.service.mjs +0 -22
  138. package/esm2022/views/common/hint-container.component.mjs +0 -41
  139. package/esm2022/views/common/repeat.pipe.mjs +0 -36
  140. package/esm2022/views/common/resize-hint.component.mjs +0 -97
  141. package/esm2022/views/common/resource-iterator.pipe.mjs +0 -49
  142. package/esm2022/views/common/scheduler-task.mjs +0 -5
  143. package/esm2022/views/common/slot-selectable.directive.mjs +0 -137
  144. package/esm2022/views/common/view-footer.component.mjs +0 -103
  145. package/esm2022/views/common/work-hours-footer.directive.mjs +0 -45
  146. package/esm2022/views/constants.mjs +0 -31
  147. package/esm2022/views/day-time/day-time-slot.service.mjs +0 -633
  148. package/esm2022/views/day-time/day-time-view-base.mjs +0 -244
  149. package/esm2022/views/day-time/day-time-view-item.component.mjs +0 -216
  150. package/esm2022/views/day-time/day-time-view.component.mjs +0 -437
  151. package/esm2022/views/day-time/event-slot.directive.mjs +0 -138
  152. package/esm2022/views/day-time/utils.mjs +0 -32
  153. package/esm2022/views/month/month-slot.component.mjs +0 -166
  154. package/esm2022/views/month/month-slot.service.mjs +0 -404
  155. package/esm2022/views/month/month-view-item.component.mjs +0 -161
  156. package/esm2022/views/month/month-view-renderer.component.mjs +0 -683
  157. package/esm2022/views/month/month-view.component.mjs +0 -203
  158. package/esm2022/views/month/multi-week-view.component.mjs +0 -202
  159. package/esm2022/views/month/utils.mjs +0 -107
  160. package/esm2022/views/multi-day/day-view.component.mjs +0 -186
  161. package/esm2022/views/multi-day/multi-day-view-base.mjs +0 -55
  162. package/esm2022/views/multi-day/multi-day-view-renderer.component.mjs +0 -1002
  163. package/esm2022/views/multi-day/multi-day-view.component.mjs +0 -197
  164. package/esm2022/views/multi-day/utils.mjs +0 -63
  165. package/esm2022/views/multi-day/week-view.component.mjs +0 -189
  166. package/esm2022/views/multi-day/work-week-view.component.mjs +0 -172
  167. package/esm2022/views/scheduler-view.directive.mjs +0 -65
  168. package/esm2022/views/templates/agenda-date-template.directive.mjs +0 -41
  169. package/esm2022/views/templates/agenda-time-template.directive.mjs +0 -46
  170. package/esm2022/views/templates/all-day-event-template.directive.mjs +0 -42
  171. package/esm2022/views/templates/all-day-slot-template.directive.mjs +0 -42
  172. package/esm2022/views/templates/date-header-template.directive.mjs +0 -42
  173. package/esm2022/views/templates/event-template.directive.mjs +0 -42
  174. package/esm2022/views/templates/group-header-template.directive.mjs +0 -42
  175. package/esm2022/views/templates/major-time-header-template.directive.mjs +0 -41
  176. package/esm2022/views/templates/minor-time-header-template.directive.mjs +0 -41
  177. package/esm2022/views/templates/month-day-slot-template.directive.mjs +0 -42
  178. package/esm2022/views/templates/multi-week-day-slot-template.directive.mjs +0 -42
  179. package/esm2022/views/templates/time-slot-template.directive.mjs +0 -43
  180. package/esm2022/views/templates.mjs +0 -16
  181. package/esm2022/views/timeline/timeline-base.mjs +0 -39
  182. package/esm2022/views/timeline/timeline-month-view.component.mjs +0 -211
  183. package/esm2022/views/timeline/timeline-multi-day-view.component.mjs +0 -649
  184. package/esm2022/views/timeline/timeline-view.component.mjs +0 -189
  185. package/esm2022/views/timeline/timeline-week-view.component.mjs +0 -181
  186. package/esm2022/views/timeline/utils.mjs +0 -60
  187. package/esm2022/views/utils.mjs +0 -373
  188. package/esm2022/views/view-context.service.mjs +0 -111
  189. package/esm2022/views/view-items/base-slot.directive.mjs +0 -104
  190. package/esm2022/views/view-items/base-slot.service.mjs +0 -82
  191. package/esm2022/views/view-items/base-view-item.mjs +0 -194
  192. package/esm2022/views/view-items/item-map.mjs +0 -38
  193. package/esm2022/views/view-items/types.mjs +0 -5
  194. package/esm2022/views/view-state.service.mjs +0 -144
  195. package/esm2022/views/year/utils.mjs +0 -60
  196. package/esm2022/views/year/year-view-internal.component.mjs +0 -471
  197. package/esm2022/views/year/year-view.component.mjs +0 -136
@@ -1,1099 +0,0 @@
1
- /**-----------------------------------------------------------------------------------------
2
- * Copyright © 2026 Progress Software Corporation. All rights reserved.
3
- * Licensed under commercial license. See LICENSE.md in the project root for more information
4
- *-------------------------------------------------------------------------------------------*/
5
- import { ViewChild, NgZone, ElementRef, Renderer2, Input, TemplateRef, ChangeDetectorRef, Directive } from '@angular/core';
6
- import { anyChanged, scrollbarWidth, guid, ScrollbarWidthService } from '@progress/kendo-angular-common';
7
- import { IntlService } from '@progress/kendo-angular-intl';
8
- import { Day, ZonedDate } from '@progress/kendo-date-math';
9
- import { Subscription, BehaviorSubject, combineLatest, fromEvent, merge } from 'rxjs';
10
- import { switchMap, take, map, filter, tap } from 'rxjs/operators';
11
- import { closestInScope, hasClasses, preventLockedScroll, wheelDeltaY, hasScrollbar } from '../../common/dom-queries';
12
- import { groupResources, getField, setField, fromClick, fromDoubleClick } from '../../common/util';
13
- import { BaseSlotService } from '../view-items/base-slot.service';
14
- import { ViewContextService } from '../view-context.service';
15
- import { ViewStateService } from '../view-state.service';
16
- import { assignTasksResources, toPx, elementOffset, pointDistance, ignoreContentChild, resourceItemByValue, convertNgClassBindings, toUTCDateTime, dateWithTime, normaliseRangeStartAndEnd } from '../utils';
17
- import { Draggable } from '@progress/kendo-draggable';
18
- import { HintContainerComponent } from '../common/hint-container.component';
19
- import { PDFService } from '../../pdf/pdf.service';
20
- import { LocalizationService } from '@progress/kendo-angular-l10n';
21
- import { slotDragEventName } from '../../types/slot-selection';
22
- import { SlotDragStartEvent } from '../../events/slot-drag-start-event';
23
- import * as i0 from "@angular/core";
24
- import * as i1 from "../view-context.service";
25
- import * as i2 from "../view-state.service";
26
- import * as i3 from "@progress/kendo-angular-intl";
27
- import * as i4 from "../view-items/base-slot.service";
28
- import * as i5 from "../../pdf/pdf.service";
29
- import * as i6 from "@progress/kendo-angular-l10n";
30
- import * as i7 from "@progress/kendo-angular-common";
31
- const SCROLL_CHANGE = 15;
32
- const MIN_DISTANCE = 60;
33
- const SCROLL_INTERVAL = 50;
34
- const MIN_MOVE_DISTANCE = 10;
35
- /** @hidden */
36
- export class BaseView {
37
- viewContext;
38
- viewState;
39
- intl;
40
- slotService;
41
- zone;
42
- renderer;
43
- element;
44
- pdfService;
45
- localization;
46
- cdr;
47
- scrollBarWidthService;
48
- eventTemplate;
49
- groupHeaderTemplate;
50
- selectedDateFormat;
51
- selectedShortDateFormat;
52
- eventHeight;
53
- showToolbar;
54
- showFooter;
55
- slotClass;
56
- eventClass;
57
- eventStyles;
58
- weekStart;
59
- content;
60
- header;
61
- contentTable;
62
- times;
63
- timesHeader;
64
- timesTable;
65
- headerWrap;
66
- hintContainer;
67
- get eventTemplateRef() {
68
- return this.eventTemplate || (this.schedulerEventTemplate || {}).templateRef;
69
- }
70
- get groupHeaderTemplateRef() {
71
- return this.groupHeaderTemplate || (this.schedulerGroupHeaderTemplate || {}).templateRef;
72
- }
73
- /**
74
- * The non-all-day events.
75
- */
76
- items = new BehaviorSubject(null);
77
- horizontalResources = [];
78
- verticalResources = [];
79
- dragHints = [];
80
- resizeHints = [];
81
- editable;
82
- selectable; // initialized to false in the scheduler component
83
- getField = getField;
84
- changes = new BehaviorSubject(null);
85
- viewRangeChange = new BehaviorSubject(null);
86
- subs = new Subscription();
87
- groupedResources = [];
88
- spans = [];
89
- contentHeight;
90
- /**
91
- * All events that the user provided.
92
- */
93
- tasks;
94
- group;
95
- resources;
96
- domEvents = [];
97
- schedulerEventTemplate;
98
- schedulerGroupHeaderTemplate;
99
- min;
100
- max;
101
- selectedDate;
102
- resourcesCache = {};
103
- timezone;
104
- draggable;
105
- /**
106
- * The event which is currently being resized.
107
- */
108
- resizing;
109
- dragging;
110
- dragArgs;
111
- /**
112
- * The slot which is currently being dragged over while selecting a range of slots.
113
- */
114
- dragSelecting = null;
115
- /**
116
- * The slot where the drag-selecting originated. Used for flipping the start and end of the emitted range.
117
- */
118
- dragSelectOrigin = null;
119
- container;
120
- containerOffset;
121
- pressLocation;
122
- pressTarget;
123
- scrollInterval;
124
- autoHeight = false;
125
- rtl = false;
126
- isSlotSelected = () => false;
127
- constructor(viewContext, viewState, intl, slotService, zone, renderer, element, pdfService, localization, cdr, scrollBarWidthService) {
128
- this.viewContext = viewContext;
129
- this.viewState = viewState;
130
- this.intl = intl;
131
- this.slotService = slotService;
132
- this.zone = zone;
133
- this.renderer = renderer;
134
- this.element = element;
135
- this.pdfService = pdfService;
136
- this.localization = localization;
137
- this.cdr = cdr;
138
- this.scrollBarWidthService = scrollBarWidthService;
139
- this.setSlotClass = this.setSlotClass.bind(this);
140
- this.setHintClass = this.setHintClass.bind(this);
141
- this.weekStart = intl.firstDay();
142
- }
143
- /**
144
- * Generates a list of space-separated IDs based on a collection of items to associate scrollable containers
145
- * with the respective tasks through the aria-owns attribute for a11y compliance.
146
- */
147
- matchOwned(items) {
148
- const ids = items.reduce((acc, curr) => [...acc, ...curr.resources.map(ir => `${curr.elementId}_${ir.leafIdx}`)], []);
149
- return ids.join(' ');
150
- }
151
- ngOnInit() {
152
- const updateView = this.updateView.bind(this);
153
- this.resourcesByIndex = this.resourcesByIndex.bind(this);
154
- this.subs.add(this.viewContext.selectedDate.subscribe(this.onSelectDate.bind(this)));
155
- this.subs.add(this.viewState.optionsChange.subscribe(this.onStateOptionsChange.bind(this)));
156
- this.subs.add(this.viewContext.action.subscribe(this.onAction.bind(this)));
157
- this.subs.add(this.viewContext.execute.subscribe(this.execute.bind(this)));
158
- this.subs.add(this.viewContext.resize.subscribe(() => {
159
- this.toggleElement(false);
160
- this.updateView();
161
- }));
162
- this.subs.add(this.viewContext.optionsChange.subscribe(this.optionsChange.bind(this)));
163
- this.subs.add(this.changes.subscribe(() => {
164
- this.toggleElement(false);
165
- }));
166
- this.subs.add(combineLatest(this.viewContext.items, this.viewState.dateRange, this.viewRangeChange)
167
- .pipe(map(([items, dateRange]) => this.createTasks(items, dateRange)))
168
- .subscribe((tasks) => {
169
- this.tasks = tasks.map(t => ({ ...t, elementId: guid() }));
170
- this.assignResources();
171
- this.onTasksChange();
172
- }));
173
- this.subs.add(combineLatest(this.items, this.changes, this.localization.changes).pipe(switchMap(() => this.onStable()))
174
- .subscribe(updateView));
175
- this.subs.add(this.pdfService.createElement.subscribe(this.createPDFElement.bind(this)));
176
- }
177
- ngOnChanges(changes) {
178
- if (anyChanged(['selectedDateFormat', 'selectedShortDateFormat'], changes)) {
179
- this.viewState.notifyDateRange(this.dateRange(this.selectedDate));
180
- }
181
- if (changes.eventHeight) {
182
- this.changes.next(null);
183
- }
184
- }
185
- ngAfterViewInit() {
186
- this.bindEvents();
187
- this.subs.add(this.localization.changes.subscribe(({ rtl }) => {
188
- this.rtl = rtl;
189
- }));
190
- }
191
- ngOnDestroy() {
192
- this.subs.unsubscribe();
193
- this.domEvents.forEach(unbindHandler => unbindHandler());
194
- this.domEvents = [];
195
- if (this.draggable) {
196
- this.draggable.destroy();
197
- this.draggable = null;
198
- }
199
- }
200
- itemIndex(index, _) {
201
- return index;
202
- }
203
- resourcesByIndex(index) {
204
- if (!this.resources) {
205
- return [];
206
- }
207
- if (!this.group) { // When we have resources, but are not grouped, return all resources.
208
- return this.resources.reduce((result, resource) => result.concat(resource.data || []), []);
209
- }
210
- if (!this.resourcesCache[index]) {
211
- const resources = this.taskResources;
212
- const result = [];
213
- let currentIndex = index;
214
- for (let idx = 0; idx < resources.length; idx++) {
215
- const data = resources[idx].data || [];
216
- const dataIdx = Math.floor(currentIndex / this.spans[idx]);
217
- result.push(data[dataIdx]);
218
- currentIndex -= dataIdx * this.spans[idx];
219
- }
220
- this.resourcesCache[index] = result;
221
- }
222
- return this.resourcesCache[index];
223
- }
224
- dragResourcesByIndex(index) {
225
- const allResources = this.resources || [];
226
- const result = [];
227
- if (this.groupedResources.length) {
228
- const resources = this.resourcesByIndex(index).slice(0);
229
- const taskResources = this.taskResources;
230
- for (let idx = 0; idx < taskResources.length; idx++) {
231
- const index = this.resources.indexOf(taskResources[idx]);
232
- if (index >= 0) {
233
- result[index] = resources[idx];
234
- }
235
- }
236
- }
237
- for (let idx = 0; idx < allResources.length; idx++) {
238
- if (!result[idx]) {
239
- result[idx] = resourceItemByValue(this.dragging.task.event, allResources[idx]);
240
- }
241
- }
242
- return result;
243
- }
244
- getEventClasses(item, resources, isAllDay) {
245
- if (this.eventClass) {
246
- return this.eventClass({
247
- event: item.event,
248
- resources,
249
- isAllDay
250
- });
251
- }
252
- }
253
- getEventStyles(item, itemResource, isAllDay) {
254
- const result = { backgroundColor: itemResource.color, borderColor: itemResource.color };
255
- if (this.eventStyles) {
256
- Object.assign(result, this.eventStyles({
257
- event: item.event,
258
- resources: itemResource.resources,
259
- isAllDay
260
- }));
261
- }
262
- return result;
263
- }
264
- // Similar to https://tc39.es/proposal-temporal/docs/plaindate.html
265
- // Stores a "plain date" in the UTC parts of a regular `Date`.
266
- toPlainDate(date) {
267
- const result = toUTCDateTime(this.convertDate(date));
268
- return result;
269
- }
270
- // Similar to https://tc39.es/proposal-temporal/docs/plaindatetime.html
271
- // Stores a "plain date-time" in the UTC parts of a regular `Date`.
272
- toPlainDateTime(date, time) {
273
- if (!date || !time) {
274
- return null;
275
- }
276
- return this.toPlainDate(dateWithTime(date, time));
277
- }
278
- optionsChange(options) {
279
- this.schedulerEventTemplate = options.eventTemplate;
280
- this.schedulerGroupHeaderTemplate = options.groupHeaderTemplate;
281
- this.min = options.min;
282
- this.max = options.max;
283
- this.editable = options.editable;
284
- this.timezone = options.timezone;
285
- this.selectable = options.selectable;
286
- this.isSlotSelected = options.isSlotSelected;
287
- if (!options.changes || anyChanged(['group', 'resources'], options.changes, false) ||
288
- options.group !== this.group || options.resources !== this.resources) {
289
- this.group = options.group;
290
- this.resources = options.resources;
291
- this.groupResources();
292
- this.resourcesCache = {};
293
- if (this.tasks && this.tasks.length) {
294
- this.assignResources();
295
- this.onTasksChange();
296
- }
297
- this.changes.next(null);
298
- }
299
- this.onStateOptionsChange(options);
300
- }
301
- toggleElement(visible) {
302
- if (this.element) {
303
- this.renderer.setStyle(this.element.nativeElement, 'display', visible ? 'block' : 'none');
304
- }
305
- }
306
- onStable() {
307
- return this.zone.onStable.asObservable().pipe(take(1));
308
- }
309
- updateView() {
310
- this.slotService.invalidate();
311
- this.toggleElement(true);
312
- this.reflow();
313
- this.viewState.notifyLayoutEnd();
314
- this.viewState.emitEvent(slotDragEventName.refreshSlotSelection);
315
- }
316
- assignResources() {
317
- assignTasksResources(this.tasks, {
318
- taskResources: this.taskResources,
319
- hasGroups: this.groupedResources.length > 0,
320
- allResources: this.resources,
321
- spans: this.spans
322
- });
323
- }
324
- bindEvents() {
325
- const contentElement = this.content.nativeElement;
326
- const element = this.element.nativeElement;
327
- this.zone.runOutsideAngular(() => {
328
- if (this.times) {
329
- this.subs.add(merge(fromEvent(this.times.nativeElement, 'mousewheel'), fromEvent(this.times.nativeElement, 'DOMMouseScroll')).pipe(filter((event) => !event.ctrlKey), tap(preventLockedScroll(contentElement)), map(wheelDeltaY))
330
- .subscribe(x => contentElement.scrollTop -= x));
331
- }
332
- this.subs.add(merge(fromClick(contentElement), fromEvent(contentElement, 'contextmenu'))
333
- .subscribe(e => this.onClick(e)));
334
- this.subs.add(fromDoubleClick(contentElement)
335
- .subscribe(e => this.onClick(e, 'dblclick')));
336
- this.subs.add(fromEvent(element, 'keydown')
337
- .subscribe(e => this.onKeydown(e)));
338
- this.domEvents.push(this.renderer.listen(contentElement, 'scroll', () => {
339
- if (this.headerWrap) {
340
- this.headerWrap.nativeElement.scrollLeft = contentElement.scrollLeft;
341
- }
342
- if (this.times) {
343
- this.times.nativeElement.scrollTop = contentElement.scrollTop;
344
- }
345
- }));
346
- this.draggable = new Draggable({
347
- press: this.onPress.bind(this),
348
- drag: this.onDrag.bind(this),
349
- release: this.onRelease.bind(this)
350
- });
351
- this.draggable.bindTo(element);
352
- });
353
- }
354
- onPress(args) {
355
- const editResizable = this.editable && this.editable.resize !== false;
356
- const editDraggable = this.editable && this.editable.drag !== false;
357
- const target = args.originalEvent.target;
358
- if (closestInScope(target, node => hasClasses(node, 'k-more-events'), this.element.nativeElement)) {
359
- return;
360
- }
361
- if (hasClasses(target, 'k-resize-handle')) {
362
- if (!editResizable) {
363
- return;
364
- }
365
- this.initResize(args);
366
- }
367
- else if (editDraggable) {
368
- const task = this.targetTask(target);
369
- if (task) {
370
- if (!args.isTouch) {
371
- args.originalEvent.preventDefault();
372
- }
373
- this.pressLocation = { x: args.pageX, y: args.pageY };
374
- this.pressTarget = task;
375
- }
376
- }
377
- const notDraggingEvent = !this.pressTarget;
378
- if (notDraggingEvent && this.selectable) {
379
- //fixes https://github.com/telerik/kendo-angular/issues/4446
380
- args.originalEvent.preventDefault();
381
- this.initDragSelect(args);
382
- }
383
- this.dragArgs = args;
384
- }
385
- onDrag(args) {
386
- if (this.resizing) {
387
- this.resize(args);
388
- this.scrollContainer(this.resize, args);
389
- }
390
- else {
391
- this.initDrag(args);
392
- if (this.dragging) {
393
- this.drag(args);
394
- args.originalEvent.preventDefault();
395
- this.scrollContainer(this.drag, args);
396
- }
397
- if (this.dragSelecting) {
398
- this.dragSelect(args);
399
- }
400
- }
401
- this.dragArgs = args;
402
- }
403
- onRelease(args) {
404
- clearInterval(this.scrollInterval);
405
- const { resizing, dragging, dragSelecting } = this;
406
- if (resizing) {
407
- this.emitEvent('resizeEnd', {
408
- event: resizing.task.event,
409
- dataItem: resizing.task.event.dataItem,
410
- start: this.convertDate(resizing.start),
411
- end: this.convertDate(resizing.end)
412
- });
413
- this.resizeHints = [];
414
- }
415
- if (dragging) {
416
- this.emitEvent('dragEnd', {
417
- event: dragging.task.event,
418
- dataItem: dragging.task.event.dataItem,
419
- start: dragging.start ? this.convertDate(dragging.start) : dragging.task.start.toLocalDate(),
420
- end: dragging.end ? this.convertDate(dragging.end) : dragging.task.end.toLocalDate(),
421
- resources: dragging.resources,
422
- isAllDay: this.draggedIsAllDay(dragging.task, dragging.slot)
423
- });
424
- this.dragHints = [];
425
- }
426
- if (resizing || dragging) {
427
- this.removeSlotClass();
428
- this.updateHintContainer();
429
- this.resizing = null;
430
- this.dragging = null;
431
- }
432
- if (dragSelecting) {
433
- const { start, end } = normaliseRangeStartAndEnd(this.dragSelectOrigin, this.dragSelecting);
434
- const range = {
435
- start: this.convertDate(start),
436
- end: this.convertDate(end),
437
- isAllDay: this.dragSelecting.isDaySlot,
438
- resources: this.resourcesByIndex(this.dragSelecting.id.resourceIndex),
439
- originalEvent: args.originalEvent
440
- };
441
- this.viewState.notifySlotSelectionEnd(range);
442
- this.dragSelectOrigin = null;
443
- this.dragSelecting = null;
444
- this.cdr.markForCheck();
445
- }
446
- this.container = null;
447
- this.dragArgs = null;
448
- this.pressLocation = null;
449
- this.pressTarget = null;
450
- }
451
- setHintClass(className) {
452
- (this.dragging || this.resizing).hintClass = className;
453
- }
454
- updateHintClass() {
455
- const current = this.dragging || this.resizing;
456
- let update = false;
457
- this.hints.forEach(hint => {
458
- if (hint.class !== current.hintClass) {
459
- hint.class = current.hintClass;
460
- update = true;
461
- }
462
- });
463
- if (update) {
464
- this.updateHintContainer();
465
- }
466
- }
467
- removeHintClass() {
468
- (this.dragging || this.resizing).hintClass = null;
469
- }
470
- setSlotClass(className) {
471
- const current = this.dragging || this.resizing;
472
- current.slotClass = className;
473
- this.renderer.addClass(current.slot.nativeElement, current.slotClass);
474
- }
475
- removeSlotClass() {
476
- const current = this.dragging || this.resizing;
477
- if (current.slotClass) {
478
- this.renderer.removeClass(current.slot.nativeElement, current.slotClass);
479
- current.slotClass = null;
480
- }
481
- }
482
- get hints() {
483
- return this.dragging ? this.dragHints : this.resizeHints;
484
- }
485
- initDrag(args) {
486
- if (!this.dragging && this.pressLocation && pointDistance(this.pressLocation.x, this.pressLocation.y, args.pageX, args.pageY) >= MIN_MOVE_DISTANCE) {
487
- const dragging = this.pressTarget;
488
- const task = dragging.task;
489
- if (this.emitEvent('dragStart', { event: task.event, dataItem: task.event.dataItem })) {
490
- this.pressLocation = null;
491
- this.pressTarget = null;
492
- return;
493
- }
494
- this.updateDragContainer(args);
495
- if (this.containerOffset === undefined) {
496
- return;
497
- }
498
- const { x, y } = this.coordinatesOffset(this.pressLocation.x, this.pressLocation.y);
499
- const slot = this.slotByPosition(Math.ceil(x), Math.ceil(y), this.container);
500
- if (!slot) {
501
- return;
502
- }
503
- this.dragging = dragging;
504
- this.dragging.offset = {
505
- start: slot.start.getTime() - task.start.toUTCDate().getTime(),
506
- end: task.end.toUTCDate().getTime() - slot.start.getTime()
507
- };
508
- this.dragging.slot = slot;
509
- this.dragging.startResources = this.dragging.resourceItems = this.dragResourcesByIndex(slot.id.resourceIndex);
510
- this.dragging.resources = this.resourceValues(task, this.dragging.startResources);
511
- }
512
- }
513
- updateDragContainer(_args) {
514
- if (!this.container) {
515
- this.container = this.content.nativeElement;
516
- this.containerOffset = elementOffset(this.container);
517
- }
518
- }
519
- drag(args) {
520
- this.updateDragContainer(args);
521
- if (!this.container) {
522
- return;
523
- }
524
- const { x, y } = this.coordinatesOffset(args.pageX, args.pageY);
525
- const slot = this.slotByPosition(x, y, this.container);
526
- if (slot && (slot !== this.dragging.slot || !this.dragHints.length)) {
527
- const dragging = this.dragging;
528
- const { slot: currentSlot, task } = dragging;
529
- const { ranges, start, end, isAllDay } = this.dragRanges(slot);
530
- let resourceItems, resourceValues;
531
- if (currentSlot.id.resourceIndex !== slot.id.resourceIndex) {
532
- resourceItems = this.dragResourcesByIndex(slot.id.resourceIndex);
533
- resourceValues = this.resourceValues(task, resourceItems);
534
- }
535
- else {
536
- resourceItems = dragging.resourceItems;
537
- resourceValues = dragging.resources;
538
- }
539
- this.removeSlotClass();
540
- dragging.start = start;
541
- dragging.end = end;
542
- dragging.slot = slot;
543
- dragging.resources = resourceValues;
544
- dragging.resourceItems = resourceItems;
545
- dragging.hintClass = null;
546
- if (this.emitEvent('drag', {
547
- event: task.event,
548
- dataItem: task.event.dataItem,
549
- start: this.convertDate(start),
550
- end: this.convertDate(end),
551
- resources: resourceValues,
552
- isAllDay,
553
- setHintClass: this.setHintClass,
554
- setSlotClass: this.setSlotClass
555
- })) {
556
- this.updateHintClass();
557
- return;
558
- }
559
- const color = this.dragResourceColor(task, resourceItems);
560
- const hintClasses = this.dragHintClasses();
561
- this.dragHints = [];
562
- for (let idx = 0; idx < ranges.length; idx++) {
563
- const slots = ranges[idx];
564
- const first = slots[0];
565
- const last = slots[slots.length - 1];
566
- const size = this.dragHintSize(first, last);
567
- const origin = first.rect.left;
568
- const styles = {
569
- top: toPx(first.rect.top),
570
- left: this.localization.rtl ? '' : toPx(origin),
571
- right: !this.localization.rtl ? '' : toPx(origin),
572
- width: size.width,
573
- height: size.height,
574
- backgroundColor: color,
575
- borderColor: color
576
- };
577
- if (this.eventStyles) {
578
- Object.assign(styles, this.eventStyles(this.dragHintEventStyleArgs()));
579
- }
580
- this.dragHints.push({
581
- item: Object.assign({}, this.dragging.task, {
582
- startTime: start,
583
- endTime: end
584
- }),
585
- resources: resourceItems,
586
- class: hintClasses,
587
- style: styles
588
- });
589
- }
590
- this.updateHintContainer();
591
- }
592
- }
593
- initDragSelect(args) {
594
- this.updateDragContainer(args);
595
- if (!this.containerOffset) {
596
- return;
597
- }
598
- const { x, y } = this.coordinatesOffset(args.pageX, args.pageY);
599
- const slot = this.slotByPosition(x, y, this.container);
600
- if (!slot) {
601
- return;
602
- }
603
- const range = {
604
- start: this.convertDate(slot.start),
605
- end: this.convertDate(slot.end),
606
- isAllDay: slot.isDaySlot,
607
- resources: this.resourcesByIndex(slot.id.resourceIndex),
608
- originalEvent: args.originalEvent
609
- };
610
- const slotDragStartEvent = new SlotDragStartEvent(null, range);
611
- this.viewState.notifySlotSelectionStart(slotDragStartEvent);
612
- if (!slotDragStartEvent.isDefaultPrevented()) {
613
- this.dragSelecting = slot;
614
- this.dragSelectOrigin = slot;
615
- this.cdr.markForCheck();
616
- }
617
- }
618
- dragSelect(args) {
619
- const { x, y } = this.coordinatesOffset(args.pageX, args.pageY);
620
- const slot = this.slotByPosition(x, y, this.container);
621
- if (!slot) {
622
- return;
623
- }
624
- if (this.dragSelecting !== slot) {
625
- this.dragSelecting = slot;
626
- const { start, end } = normaliseRangeStartAndEnd(this.dragSelectOrigin, this.dragSelecting);
627
- const range = {
628
- start: this.convertDate(start),
629
- end: this.convertDate(end),
630
- isAllDay: slot.isDaySlot,
631
- resources: this.resourcesByIndex(slot.id.resourceIndex),
632
- originalEvent: args.originalEvent
633
- };
634
- this.viewState.notifySlotSelectionDrag(range);
635
- this.cdr.markForCheck();
636
- }
637
- }
638
- dragHintClasses() {
639
- const hintClass = this.dragging.hintClass;
640
- let result = [];
641
- if (hintClass) {
642
- result.push(hintClass);
643
- }
644
- if (this.eventClass) {
645
- const eventClass = this.eventClass(this.dragHintEventStyleArgs());
646
- result = result.concat(convertNgClassBindings(eventClass));
647
- }
648
- return result;
649
- }
650
- dragHintEventStyleArgs() {
651
- return {
652
- event: this.dragging.task.event,
653
- resources: this.dragging.resourceItems
654
- };
655
- }
656
- draggedIsAllDay(task, _slot) {
657
- return Boolean(task.event.isAllDay);
658
- }
659
- dragResourceColor(task, slotResources) {
660
- if (this.groupedResources.length) {
661
- const index = this.resources.indexOf(this.groupedResources[0]);
662
- return getField(slotResources[index], this.groupedResources[0].colorField);
663
- }
664
- else if (this.resources && this.resources.length) {
665
- return task.resources[0].color;
666
- }
667
- return '';
668
- }
669
- resourceValues(task, currentResources) {
670
- const result = {};
671
- for (let idx = 0; idx < currentResources.length; idx++) {
672
- const resource = this.resources[idx];
673
- const resourceItem = currentResources[idx];
674
- let value;
675
- if (Array.isArray(resourceItem)) { // not grouped multiple resource
676
- value = getField(task.event, resource.field);
677
- }
678
- else {
679
- value = getField(currentResources[idx], resource.valueField);
680
- if (resource.multiple) {
681
- const startValue = getField(this.dragging.startResources[idx], resource.valueField);
682
- if (startValue !== value) {
683
- value = [value];
684
- }
685
- else {
686
- value = getField(task.event.dataItem, resource.field);
687
- }
688
- }
689
- }
690
- setField(result, resource.field, value);
691
- }
692
- return result;
693
- }
694
- initResize(args) {
695
- args.originalEvent.preventDefault();
696
- const target = args.originalEvent.target;
697
- const resizing = this.targetTask(target);
698
- if (this.emitEvent('resizeStart', { event: resizing.task.event, dataItem: resizing.task.event.dataItem })) {
699
- return;
700
- }
701
- this.resizing = resizing;
702
- resizing.start = resizing.task.start.toUTCDate();
703
- resizing.end = resizing.task.end.toUTCDate();
704
- if (hasClasses(target, 'k-resize-n')) {
705
- resizing.direction = 'n';
706
- }
707
- else if (hasClasses(target, 'k-resize-s')) {
708
- resizing.direction = 's';
709
- }
710
- else if (hasClasses(target, 'k-resize-w')) {
711
- resizing.direction = 'w';
712
- }
713
- else {
714
- resizing.direction = 'e';
715
- }
716
- this.updateDragContainer(args);
717
- const { x, y } = this.coordinatesOffset(args.pageX, args.pageY);
718
- resizing.slot = this.slotByPosition(Math.ceil(x), Math.ceil(y), this.container);
719
- resizing.offset = {
720
- start: resizing.task.start.toUTCDate().getTime() - resizing.slot.start.getTime(),
721
- end: resizing.task.end.toUTCDate().getTime() - resizing.slot.start.getTime()
722
- };
723
- }
724
- resize(args) {
725
- const { x, y } = this.coordinatesOffset(args.pageX, args.pageY);
726
- const resizing = this.resizing;
727
- const { direction, task, offset } = resizing;
728
- const slot = this.slotService.groupSlotByPosition(resizing.slot, x, y);
729
- if (!slot || slot === resizing.slot) {
730
- return;
731
- }
732
- this.removeSlotClass();
733
- const { start, end, ranges } = this.slotService.resizeRanges(slot, task, direction === 'w' || direction === 'n', offset);
734
- resizing.hintClass = null;
735
- resizing.start = start;
736
- resizing.end = end;
737
- resizing.slot = slot;
738
- if (this.emitEvent('resize', {
739
- event: task.event,
740
- dataItem: task.event.dataItem,
741
- start: this.convertDate(start),
742
- end: this.convertDate(end),
743
- setHintClass: this.setHintClass,
744
- setSlotClass: this.setSlotClass
745
- })) {
746
- this.updateHintClass();
747
- return;
748
- }
749
- this.updateResizeHints(ranges, start, end);
750
- this.updateHintContainer();
751
- }
752
- updateResizeHints(ranges, _start, _end) {
753
- const resizing = this.resizing;
754
- const direction = resizing.direction;
755
- const horizontal = direction === 'w' || direction === 'e';
756
- const resizeStart = direction === 'w' || direction === 'n';
757
- this.resizeHints = [];
758
- for (let idx = 0; idx < ranges.length; idx++) {
759
- const range = ranges[idx];
760
- const firstSlot = range[0];
761
- const lastSlot = range[range.length - 1];
762
- const first = idx === 0;
763
- const last = idx === ranges.length - 1;
764
- this.resizeHints.push({
765
- first: first,
766
- last: last,
767
- rect: {
768
- left: firstSlot.rect.left,
769
- top: firstSlot.top,
770
- height: horizontal ? firstSlot.height : Math.abs(lastSlot.rect.top - firstSlot.rect.top) + lastSlot.rect.height,
771
- width: horizontal ? Math.abs(lastSlot.rect.left - firstSlot.rect.left) + lastSlot.rect.width : firstSlot.width
772
- },
773
- start: first && !resizeStart ? resizing.start : firstSlot.start,
774
- end: last && resizeStart ? resizing.end : lastSlot.end,
775
- class: resizing.hintClass
776
- });
777
- }
778
- }
779
- coordinatesOffset(x, y, container = this.container, offset = this.containerOffset) {
780
- const position = x - offset.left + container.scrollLeft;
781
- return {
782
- x: !this.localization.rtl ? position : this.slotService.containerSize - position,
783
- y: y - offset.top + container.scrollTop
784
- };
785
- }
786
- scrollContainer(callback, args) {
787
- clearInterval(this.scrollInterval);
788
- const container = this.container;
789
- if (!container) {
790
- return;
791
- }
792
- const viewPortY = args.pageY - this.containerOffset.top;
793
- const pointerYDistance = Math.abs(container.offsetHeight - viewPortY);
794
- const deltaY = args.pageY - this.dragArgs.pageY;
795
- const viewPortX = args.pageX - this.containerOffset.left;
796
- const pointerXDistance = Math.abs(container.offsetWidth - viewPortX);
797
- const deltaX = args.pageX - this.dragArgs.pageX;
798
- let scroll = false;
799
- let leftChange = 0;
800
- let topChange = 0;
801
- if (pointerYDistance < MIN_DISTANCE && container.scrollTop + container.offsetHeight < container.scrollHeight && deltaY > 0) {
802
- scroll = true;
803
- topChange = SCROLL_CHANGE;
804
- this.container.scrollTop += MIN_DISTANCE - pointerYDistance;
805
- }
806
- else if (viewPortY < MIN_DISTANCE && container.scrollTop > 0 && deltaY < 0) {
807
- scroll = true;
808
- topChange = -SCROLL_CHANGE;
809
- this.container.scrollTop -= MIN_DISTANCE - viewPortY;
810
- }
811
- if (pointerXDistance < MIN_DISTANCE && container.scrollLeft + container.offsetWidth < container.scrollWidth && deltaX > 0) {
812
- scroll = true;
813
- leftChange = SCROLL_CHANGE;
814
- this.container.scrollLeft += MIN_DISTANCE - pointerXDistance;
815
- }
816
- else if (viewPortX < MIN_DISTANCE && container.scrollLeft > 0 && deltaY < 0) {
817
- scroll = true;
818
- leftChange = -SCROLL_CHANGE;
819
- this.container.scrollLeft -= MIN_DISTANCE - viewPortX;
820
- }
821
- if (scroll) {
822
- this.scrollInterval = setInterval(() => {
823
- if (this.container) {
824
- this.container.scrollLeft += leftChange;
825
- this.container.scrollTop += topChange;
826
- callback.call(this, args);
827
- }
828
- else {
829
- clearInterval(this.scrollInterval);
830
- }
831
- }, SCROLL_INTERVAL);
832
- }
833
- }
834
- emitEvent(name, args) {
835
- this.viewState.emitEvent(name, args);
836
- return args.prevented;
837
- }
838
- targetTask(target) {
839
- const eventTarget = closestInScope(target, node => node.hasAttribute('data-task-index'), this.element.nativeElement);
840
- if (eventTarget) {
841
- const index = parseInt(eventTarget.getAttribute('data-task-index'), 10);
842
- return {
843
- target: eventTarget,
844
- task: this.tasks.find(t => t.index === index)
845
- };
846
- }
847
- }
848
- updateHintContainer() {
849
- if (this.hintContainer) {
850
- this.hintContainer.detectChanges();
851
- }
852
- }
853
- /**
854
- * Converts a "view date" (date stored in the UTC parts of a Date object) to a local date.
855
- */
856
- convertDate(date) {
857
- return ZonedDate.fromUTCDate(date, this.timezone).toLocalDate();
858
- }
859
- onClick(e, eventType = e.type) {
860
- this.emitSlotEvent(e, eventType);
861
- this.emitTaskEvent(e, eventType);
862
- }
863
- emitSlotEvent(e, eventType) {
864
- const targetSlot = closestInScope(e.target, node => node.hasAttribute('data-slot-index'), this.element.nativeElement);
865
- if (targetSlot) {
866
- const slotIndex = targetSlot.getAttribute('data-slot-index');
867
- const name = eventType === 'dblclick' ? 'slotDblClick' : 'slotClick';
868
- const slot = this.slotByIndex(slotIndex, e);
869
- this.viewState.emitEvent(name, {
870
- type: eventType,
871
- slot: slot,
872
- start: this.convertDate(slot.start),
873
- end: this.convertDate(slot.end),
874
- isAllDay: slot.isDaySlot,
875
- originalEvent: e,
876
- resources: this.resources && this.resources.length ?
877
- this.resourcesByIndex(slot.id.resourceIndex) : []
878
- });
879
- }
880
- }
881
- emitTaskEvent(e, eventType) {
882
- const targetTask = this.targetTask(e.target);
883
- if (targetTask) {
884
- const task = targetTask.task;
885
- const isSingle = eventType === 'click';
886
- const isDouble = eventType === 'dblclick';
887
- if (isSingle && closestInScope(e.target, node => hasClasses(node, 'k-event-delete'), targetTask.target)) {
888
- this.viewState.emitEvent('remove', { event: task.event, dataItem: task.event.dataItem });
889
- }
890
- else {
891
- const name = isDouble ? 'eventDblClick' : 'eventClick';
892
- this.viewState.emitEvent(name, { type: eventType, event: task.event, originalEvent: e });
893
- targetTask.target.focus();
894
- }
895
- }
896
- }
897
- onKeydown(e) {
898
- const targetTask = this.targetTask(e.target);
899
- if (targetTask) {
900
- const task = targetTask.task;
901
- this.viewState.emitEvent('eventKeydown', { event: task.event, dataItem: task.event.dataItem, originalEvent: e });
902
- }
903
- }
904
- syncTables() {
905
- if (this.timesTable) {
906
- this.renderer.setStyle(this.timesTable.nativeElement, 'height', `${this.contentTable.nativeElement.offsetHeight}px`);
907
- }
908
- // Need to explicitly set 'padding-inline-xxx' to 0px when the Scheduler has no height set
909
- if (!hasScrollbar(this.content.nativeElement, 'vertical')) {
910
- this.renderer.setStyle(this.header.nativeElement, !this.localization.rtl ? 'padding-inline-end' : 'padding-inline-start', '0px');
911
- }
912
- this.renderer.removeStyle(this.header.nativeElement, this.localization.rtl ? 'padding-inline-end' : 'padding-inline-start');
913
- if (this.times) {
914
- const times = this.times.nativeElement;
915
- this.timesHeader.nativeElement.style.width = `${times.offsetWidth}px`;
916
- const contentHeight = this.contentHeight === 'auto' ? this.content.nativeElement.offsetHeight : this.contentHeight;
917
- this.renderer.setStyle(times, 'height', `${contentHeight - (hasScrollbar(this.content.nativeElement, 'horizontal') ? scrollbarWidth() : 0)}px`);
918
- times.scrollTop = this.content.nativeElement.scrollTop;
919
- }
920
- }
921
- updateContentHeight() {
922
- const element = this.element.nativeElement;
923
- const parent = element.parentNode;
924
- const content = this.content.nativeElement;
925
- const autoHeight = this.autoHeight || !parent?.style.height;
926
- const scrollLeft = content.scrollLeft;
927
- const scrollTop = content.scrollTop;
928
- this.renderer.setStyle(content, 'height', '');
929
- if (this.times) {
930
- this.renderer.setStyle(this.times.nativeElement, 'height', '');
931
- }
932
- if (autoHeight) {
933
- this.contentHeight = 'auto';
934
- return;
935
- }
936
- let height = parent.clientHeight;
937
- for (let idx = 0; idx < parent.children.length; idx++) {
938
- const child = parent.children[idx];
939
- if (child !== element && !ignoreContentChild(child)) {
940
- height -= child.offsetHeight;
941
- }
942
- }
943
- height -= this.headerWrap ? this.headerWrap.nativeElement.offsetHeight : 0;
944
- this.renderer.setStyle(content, 'height', `${height}px`);
945
- this.contentHeight = height;
946
- content.scrollLeft = scrollLeft;
947
- content.scrollTop = scrollTop;
948
- }
949
- groupResources() {
950
- const resources = this.resources || [];
951
- const group = this.group || {};
952
- this.groupedResources = groupResources(group, resources);
953
- if (group.orientation !== 'vertical') {
954
- this.horizontalResources = this.groupedResources;
955
- this.verticalResources = [];
956
- }
957
- else {
958
- this.verticalResources = this.groupedResources;
959
- this.horizontalResources = [];
960
- }
961
- this.spans = this.resourceSpans();
962
- }
963
- get taskResources() {
964
- if (this.groupedResources.length) {
965
- return this.groupedResources;
966
- }
967
- else if (this.resources && this.resources.length) {
968
- return [this.resources[0]];
969
- }
970
- else {
971
- return [{}];
972
- }
973
- }
974
- resourceSpans() {
975
- const spans = [1];
976
- const resources = this.groupedResources;
977
- let span = 1;
978
- for (let idx = resources.length - 1; idx > 0; idx--) {
979
- span *= ((resources[idx].data || []).length || 1);
980
- spans.unshift(span);
981
- }
982
- return spans;
983
- }
984
- isInRange(date) {
985
- const dateRange = this.dateRange(date);
986
- return (!this.min || this.min < dateRange.end) && (!this.max || dateRange.start <= this.max);
987
- }
988
- createPDFElement() {
989
- const contentHeight = this.contentHeight;
990
- const scrollTop = this.content.nativeElement.scrollTop;
991
- if (contentHeight !== 'auto') {
992
- this.autoHeight = true;
993
- this.updateView();
994
- }
995
- const element = this.element.nativeElement.cloneNode(true);
996
- element.style.width = `${this.pdfWidth()}px`;
997
- if (contentHeight !== 'auto') {
998
- this.autoHeight = false;
999
- this.updateView();
1000
- }
1001
- this.pdfService.elementReady.emit({
1002
- element: element
1003
- });
1004
- this.content.nativeElement.scrollTop = scrollTop;
1005
- }
1006
- pdfWidth() {
1007
- return this.element.nativeElement.offsetWidth;
1008
- }
1009
- containerByPosition({ x, y }) {
1010
- const content = this.content.nativeElement;
1011
- const offset = elementOffset(content);
1012
- if (offset.top <= y && y <= offset.top + offset.height && offset.left <= x && x <= offset.left + offset.width) {
1013
- return {
1014
- element: content,
1015
- offset: offset
1016
- };
1017
- }
1018
- }
1019
- execute(e) {
1020
- if (e.name === 'slotByPosition') {
1021
- const container = this.containerByPosition(e.args);
1022
- if (container) {
1023
- const offset = this.coordinatesOffset(e.args.x, e.args.y, container.element, container.offset);
1024
- const slot = this.slotByPosition(offset.x, offset.y, container.element);
1025
- e.result(this.slotFields(slot));
1026
- }
1027
- }
1028
- else if (e.name === 'eventFromElement') {
1029
- const target = this.targetTask(e.args.element);
1030
- if (target) {
1031
- e.result(target.task.event);
1032
- }
1033
- }
1034
- }
1035
- slotFields(slot) {
1036
- return {
1037
- element: slot.element,
1038
- resources: this.groupedResources.length ? this.resourcesByIndex(slot.id.resourceIndex) : [],
1039
- start: this.convertDate(slot.start),
1040
- end: this.convertDate(slot.end)
1041
- };
1042
- }
1043
- onStateOptionsChange(changes) {
1044
- if (changes?.showFooter || changes?.showToolbar) {
1045
- this.zone.onStable.pipe(take(1)).subscribe(() => this.updateView());
1046
- }
1047
- }
1048
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: BaseView, deps: [{ token: i1.ViewContextService }, { token: i2.ViewStateService }, { token: i3.IntlService }, { token: i4.BaseSlotService }, { token: i0.NgZone }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i5.PDFService }, { token: i6.LocalizationService }, { token: i0.ChangeDetectorRef }, { token: i7.ScrollbarWidthService }], target: i0.ɵɵFactoryTarget.Directive });
1049
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: BaseView, inputs: { eventTemplate: "eventTemplate", groupHeaderTemplate: "groupHeaderTemplate", selectedDateFormat: "selectedDateFormat", selectedShortDateFormat: "selectedShortDateFormat", eventHeight: "eventHeight", showToolbar: "showToolbar", showFooter: "showFooter", slotClass: "slotClass", eventClass: "eventClass", eventStyles: "eventStyles", weekStart: "weekStart" }, viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true }, { propertyName: "header", first: true, predicate: ["header"], descendants: true }, { propertyName: "contentTable", first: true, predicate: ["contentTable"], descendants: true }, { propertyName: "times", first: true, predicate: ["times"], descendants: true }, { propertyName: "timesHeader", first: true, predicate: ["timesHeader"], descendants: true }, { propertyName: "timesTable", first: true, predicate: ["timesTable"], descendants: true }, { propertyName: "headerWrap", first: true, predicate: ["headerWrap"], descendants: true }, { propertyName: "hintContainer", first: true, predicate: ["hintContainer"], descendants: true }], usesOnChanges: true, ngImport: i0 });
1050
- }
1051
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: BaseView, decorators: [{
1052
- type: Directive
1053
- }], ctorParameters: () => [{ type: i1.ViewContextService }, { type: i2.ViewStateService }, { type: i3.IntlService }, { type: i4.BaseSlotService }, { type: i0.NgZone }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i5.PDFService }, { type: i6.LocalizationService }, { type: i0.ChangeDetectorRef }, { type: i7.ScrollbarWidthService }], propDecorators: { eventTemplate: [{
1054
- type: Input
1055
- }], groupHeaderTemplate: [{
1056
- type: Input
1057
- }], selectedDateFormat: [{
1058
- type: Input
1059
- }], selectedShortDateFormat: [{
1060
- type: Input
1061
- }], eventHeight: [{
1062
- type: Input
1063
- }], showToolbar: [{
1064
- type: Input
1065
- }], showFooter: [{
1066
- type: Input
1067
- }], slotClass: [{
1068
- type: Input
1069
- }], eventClass: [{
1070
- type: Input
1071
- }], eventStyles: [{
1072
- type: Input
1073
- }], weekStart: [{
1074
- type: Input
1075
- }], content: [{
1076
- type: ViewChild,
1077
- args: ['content', { static: false }]
1078
- }], header: [{
1079
- type: ViewChild,
1080
- args: ['header', { static: false }]
1081
- }], contentTable: [{
1082
- type: ViewChild,
1083
- args: ['contentTable', { static: false }]
1084
- }], times: [{
1085
- type: ViewChild,
1086
- args: ['times', { static: false }]
1087
- }], timesHeader: [{
1088
- type: ViewChild,
1089
- args: ['timesHeader', { static: false }]
1090
- }], timesTable: [{
1091
- type: ViewChild,
1092
- args: ['timesTable', { static: false }]
1093
- }], headerWrap: [{
1094
- type: ViewChild,
1095
- args: ['headerWrap', { static: false }]
1096
- }], hintContainer: [{
1097
- type: ViewChild,
1098
- args: ['hintContainer', { static: false }]
1099
- }] } });