@syncfusion/ej2-schedule 30.2.7 → 31.1.17

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 (304) hide show
  1. package/dist/ej2-schedule.min.js +2 -2
  2. package/dist/ej2-schedule.umd.min.js +2 -2
  3. package/dist/ej2-schedule.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-schedule.es2015.js +110 -36
  5. package/dist/es6/ej2-schedule.es2015.js.map +1 -1
  6. package/dist/es6/ej2-schedule.es5.js +110 -36
  7. package/dist/es6/ej2-schedule.es5.js.map +1 -1
  8. package/dist/global/ej2-schedule.min.js +2 -2
  9. package/dist/global/ej2-schedule.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/dist/ts/common/calendar-util.d.ts +92 -0
  12. package/dist/ts/common/calendar-util.ts +261 -0
  13. package/dist/ts/common/index.d.ts +4 -0
  14. package/dist/ts/common/index.ts +4 -0
  15. package/dist/ts/components.d.ts +5 -0
  16. package/dist/ts/components.ts +5 -0
  17. package/dist/ts/index.d.ts +6 -0
  18. package/dist/ts/index.ts +7 -0
  19. package/dist/ts/recurrence-editor/date-generator.d.ts +76 -0
  20. package/dist/ts/recurrence-editor/date-generator.ts +1699 -0
  21. package/dist/ts/recurrence-editor/index.d.ts +6 -0
  22. package/dist/ts/recurrence-editor/index.ts +6 -0
  23. package/dist/ts/recurrence-editor/recurrence-editor-model.d.ts +112 -0
  24. package/dist/ts/recurrence-editor/recurrence-editor.d.ts +245 -0
  25. package/dist/ts/recurrence-editor/recurrence-editor.ts +1257 -0
  26. package/dist/ts/schedule/actions/action-base.d.ts +44 -0
  27. package/dist/ts/schedule/actions/action-base.ts +493 -0
  28. package/dist/ts/schedule/actions/crud.d.ts +41 -0
  29. package/dist/ts/schedule/actions/crud.ts +784 -0
  30. package/dist/ts/schedule/actions/data.d.ts +63 -0
  31. package/dist/ts/schedule/actions/data.ts +128 -0
  32. package/dist/ts/schedule/actions/drag.d.ts +75 -0
  33. package/dist/ts/schedule/actions/drag.ts +1401 -0
  34. package/dist/ts/schedule/actions/keyboard.d.ts +100 -0
  35. package/dist/ts/schedule/actions/keyboard.ts +1435 -0
  36. package/dist/ts/schedule/actions/resize.d.ts +27 -0
  37. package/dist/ts/schedule/actions/resize.ts +602 -0
  38. package/dist/ts/schedule/actions/scroll.d.ts +69 -0
  39. package/dist/ts/schedule/actions/scroll.ts +105 -0
  40. package/dist/ts/schedule/actions/touch.d.ts +32 -0
  41. package/dist/ts/schedule/actions/touch.ts +314 -0
  42. package/dist/ts/schedule/actions/virtual-scroll.d.ts +55 -0
  43. package/dist/ts/schedule/actions/virtual-scroll.ts +596 -0
  44. package/dist/ts/schedule/actions/work-cells.d.ts +14 -0
  45. package/dist/ts/schedule/actions/work-cells.ts +151 -0
  46. package/dist/ts/schedule/base/constant.d.ts +102 -0
  47. package/dist/ts/schedule/base/constant.ts +103 -0
  48. package/dist/ts/schedule/base/css-constant.d.ts +475 -0
  49. package/dist/ts/schedule/base/css-constant.ts +475 -0
  50. package/dist/ts/schedule/base/interface.d.ts +673 -0
  51. package/dist/ts/schedule/base/interface.ts +738 -0
  52. package/dist/ts/schedule/base/resource.d.ts +59 -0
  53. package/dist/ts/schedule/base/resource.ts +1091 -0
  54. package/dist/ts/schedule/base/schedule-model.d.ts +930 -0
  55. package/dist/ts/schedule/base/schedule.d.ts +1967 -0
  56. package/dist/ts/schedule/base/schedule.ts +4221 -0
  57. package/dist/ts/schedule/base/type.d.ts +134 -0
  58. package/dist/ts/schedule/base/type.ts +142 -0
  59. package/dist/ts/schedule/base/util.d.ts +266 -0
  60. package/dist/ts/schedule/base/util.ts +492 -0
  61. package/dist/ts/schedule/event-renderer/agenda-base.d.ts +15 -0
  62. package/dist/ts/schedule/event-renderer/agenda-base.ts +423 -0
  63. package/dist/ts/schedule/event-renderer/event-base.d.ts +101 -0
  64. package/dist/ts/schedule/event-renderer/event-base.ts +1501 -0
  65. package/dist/ts/schedule/event-renderer/inline-edit.d.ts +23 -0
  66. package/dist/ts/schedule/event-renderer/inline-edit.ts +287 -0
  67. package/dist/ts/schedule/event-renderer/month.d.ts +60 -0
  68. package/dist/ts/schedule/event-renderer/month.ts +760 -0
  69. package/dist/ts/schedule/event-renderer/timeline-view.d.ts +51 -0
  70. package/dist/ts/schedule/event-renderer/timeline-view.ts +606 -0
  71. package/dist/ts/schedule/event-renderer/vertical-view.d.ts +57 -0
  72. package/dist/ts/schedule/event-renderer/vertical-view.ts +898 -0
  73. package/dist/ts/schedule/event-renderer/year.d.ts +27 -0
  74. package/dist/ts/schedule/event-renderer/year.ts +623 -0
  75. package/dist/ts/schedule/exports/calendar-export.d.ts +16 -0
  76. package/dist/ts/schedule/exports/calendar-export.ts +160 -0
  77. package/dist/ts/schedule/exports/calendar-import.d.ts +18 -0
  78. package/dist/ts/schedule/exports/calendar-import.ts +277 -0
  79. package/dist/ts/schedule/exports/excel-export.d.ts +14 -0
  80. package/dist/ts/schedule/exports/excel-export.ts +89 -0
  81. package/dist/ts/schedule/exports/index.d.ts +7 -0
  82. package/dist/ts/schedule/exports/index.ts +7 -0
  83. package/dist/ts/schedule/exports/print.d.ts +20 -0
  84. package/dist/ts/schedule/exports/print.ts +233 -0
  85. package/dist/ts/schedule/index.d.ts +26 -0
  86. package/dist/ts/schedule/index.ts +26 -0
  87. package/dist/ts/schedule/models/event-settings-model.d.ts +165 -0
  88. package/dist/ts/schedule/models/event-settings.d.ts +149 -0
  89. package/dist/ts/schedule/models/event-settings.ts +187 -0
  90. package/dist/ts/schedule/models/field-options-model.d.ts +37 -0
  91. package/dist/ts/schedule/models/field-options.d.ts +31 -0
  92. package/dist/ts/schedule/models/field-options.ts +41 -0
  93. package/dist/ts/schedule/models/fields-model.d.ts +129 -0
  94. package/dist/ts/schedule/models/fields.d.ts +117 -0
  95. package/dist/ts/schedule/models/fields.ts +149 -0
  96. package/dist/ts/schedule/models/group-model.d.ts +69 -0
  97. package/dist/ts/schedule/models/group.d.ts +60 -0
  98. package/dist/ts/schedule/models/group.ts +75 -0
  99. package/dist/ts/schedule/models/header-rows-model.d.ts +33 -0
  100. package/dist/ts/schedule/models/header-rows.d.ts +30 -0
  101. package/dist/ts/schedule/models/header-rows.ts +35 -0
  102. package/dist/ts/schedule/models/models.d.ts +14 -0
  103. package/dist/ts/schedule/models/models.ts +15 -0
  104. package/dist/ts/schedule/models/quick-info-templates-model.d.ts +52 -0
  105. package/dist/ts/schedule/models/quick-info-templates.d.ts +47 -0
  106. package/dist/ts/schedule/models/quick-info-templates.ts +56 -0
  107. package/dist/ts/schedule/models/resources-model.d.ts +122 -0
  108. package/dist/ts/schedule/models/resources.d.ts +106 -0
  109. package/dist/ts/schedule/models/resources.ts +138 -0
  110. package/dist/ts/schedule/models/time-scale-model.d.ts +57 -0
  111. package/dist/ts/schedule/models/time-scale.d.ts +50 -0
  112. package/dist/ts/schedule/models/time-scale.ts +61 -0
  113. package/dist/ts/schedule/models/toolbar-model.d.ts +196 -0
  114. package/dist/ts/schedule/models/toolbar.d.ts +176 -0
  115. package/dist/ts/schedule/models/toolbar.ts +196 -0
  116. package/dist/ts/schedule/models/views-model.d.ts +370 -0
  117. package/dist/ts/schedule/models/views.d.ts +335 -0
  118. package/dist/ts/schedule/models/views.ts +408 -0
  119. package/dist/ts/schedule/models/work-hours-model.d.ts +29 -0
  120. package/dist/ts/schedule/models/work-hours.d.ts +24 -0
  121. package/dist/ts/schedule/models/work-hours.ts +31 -0
  122. package/dist/ts/schedule/popups/event-tooltip.d.ts +16 -0
  123. package/dist/ts/schedule/popups/event-tooltip.ts +203 -0
  124. package/dist/ts/schedule/popups/event-window.d.ts +118 -0
  125. package/dist/ts/schedule/popups/event-window.ts +2055 -0
  126. package/dist/ts/schedule/popups/form-validator.d.ts +16 -0
  127. package/dist/ts/schedule/popups/form-validator.ts +110 -0
  128. package/dist/ts/schedule/popups/quick-popups.d.ts +78 -0
  129. package/dist/ts/schedule/popups/quick-popups.ts +1470 -0
  130. package/dist/ts/schedule/renderer/agenda.d.ts +45 -0
  131. package/dist/ts/schedule/renderer/agenda.ts +497 -0
  132. package/dist/ts/schedule/renderer/day.d.ts +20 -0
  133. package/dist/ts/schedule/renderer/day.ts +28 -0
  134. package/dist/ts/schedule/renderer/header-renderer.d.ts +48 -0
  135. package/dist/ts/schedule/renderer/header-renderer.ts +736 -0
  136. package/dist/ts/schedule/renderer/month-agenda.d.ts +29 -0
  137. package/dist/ts/schedule/renderer/month-agenda.ts +184 -0
  138. package/dist/ts/schedule/renderer/month.d.ts +61 -0
  139. package/dist/ts/schedule/renderer/month.ts +766 -0
  140. package/dist/ts/schedule/renderer/renderer.d.ts +13 -0
  141. package/dist/ts/schedule/renderer/renderer.ts +165 -0
  142. package/dist/ts/schedule/renderer/timeline-header-row.d.ts +15 -0
  143. package/dist/ts/schedule/renderer/timeline-header-row.ts +132 -0
  144. package/dist/ts/schedule/renderer/timeline-month.d.ts +29 -0
  145. package/dist/ts/schedule/renderer/timeline-month.ts +184 -0
  146. package/dist/ts/schedule/renderer/timeline-view.d.ts +31 -0
  147. package/dist/ts/schedule/renderer/timeline-view.ts +308 -0
  148. package/dist/ts/schedule/renderer/timeline-year.d.ts +22 -0
  149. package/dist/ts/schedule/renderer/timeline-year.ts +450 -0
  150. package/dist/ts/schedule/renderer/vertical-view.d.ts +63 -0
  151. package/dist/ts/schedule/renderer/vertical-view.ts +911 -0
  152. package/dist/ts/schedule/renderer/view-base.d.ts +83 -0
  153. package/dist/ts/schedule/renderer/view-base.ts +709 -0
  154. package/dist/ts/schedule/renderer/week.d.ts +22 -0
  155. package/dist/ts/schedule/renderer/week.ts +35 -0
  156. package/dist/ts/schedule/renderer/work-week.d.ts +22 -0
  157. package/dist/ts/schedule/renderer/work-week.ts +36 -0
  158. package/dist/ts/schedule/renderer/year.d.ts +46 -0
  159. package/dist/ts/schedule/renderer/year.ts +470 -0
  160. package/dist/ts/schedule/timezone/timezone.d.ts +16 -0
  161. package/dist/ts/schedule/timezone/timezone.ts +313 -0
  162. package/package.json +56 -21
  163. package/src/schedule/actions/action-base.js +3 -0
  164. package/src/schedule/actions/drag.js +11 -4
  165. package/src/schedule/actions/keyboard.js +1 -1
  166. package/src/schedule/actions/resize.js +8 -5
  167. package/src/schedule/base/css-constant.d.ts +2 -0
  168. package/src/schedule/base/css-constant.js +2 -0
  169. package/src/schedule/base/schedule.js +15 -1
  170. package/src/schedule/event-renderer/agenda-base.d.ts +1 -1
  171. package/src/schedule/event-renderer/agenda-base.js +5 -4
  172. package/src/schedule/event-renderer/inline-edit.js +11 -6
  173. package/src/schedule/event-renderer/month.js +5 -3
  174. package/src/schedule/event-renderer/vertical-view.js +3 -0
  175. package/src/schedule/event-renderer/year.d.ts +2 -0
  176. package/src/schedule/event-renderer/year.js +28 -4
  177. package/src/schedule/popups/event-tooltip.js +4 -0
  178. package/src/schedule/popups/event-window.js +2 -2
  179. package/src/schedule/popups/quick-popups.js +5 -1
  180. package/src/schedule/renderer/agenda.js +3 -2
  181. package/src/schedule/renderer/vertical-view.js +1 -1
  182. package/src/schedule/renderer/year.js +3 -2
  183. package/styles/bds-lite.css +11 -8
  184. package/styles/bds.css +11 -8
  185. package/styles/bootstrap-dark-lite.css +12 -9
  186. package/styles/bootstrap-dark.css +12 -9
  187. package/styles/bootstrap-lite.css +12 -9
  188. package/styles/bootstrap.css +12 -9
  189. package/styles/bootstrap4-lite.css +11 -8
  190. package/styles/bootstrap4.css +11 -8
  191. package/styles/bootstrap5-dark-lite.css +11 -8
  192. package/styles/bootstrap5-dark.css +11 -8
  193. package/styles/bootstrap5-lite.css +11 -8
  194. package/styles/bootstrap5.3-lite.css +11 -8
  195. package/styles/bootstrap5.3.css +11 -8
  196. package/styles/bootstrap5.css +11 -8
  197. package/styles/fabric-dark-lite.css +12 -9
  198. package/styles/fabric-dark.css +12 -9
  199. package/styles/fabric-lite.css +12 -9
  200. package/styles/fabric.css +12 -9
  201. package/styles/fluent-dark-lite.css +13 -10
  202. package/styles/fluent-dark.css +13 -10
  203. package/styles/fluent-lite.css +13 -10
  204. package/styles/fluent.css +13 -10
  205. package/styles/fluent2-lite.css +11 -8
  206. package/styles/fluent2.css +11 -8
  207. package/styles/highcontrast-light-lite.css +12 -9
  208. package/styles/highcontrast-light.css +12 -9
  209. package/styles/highcontrast-lite.css +12 -9
  210. package/styles/highcontrast.css +12 -9
  211. package/styles/material-dark-lite.css +12 -9
  212. package/styles/material-dark.css +12 -9
  213. package/styles/material-lite.css +12 -9
  214. package/styles/material.css +12 -9
  215. package/styles/material3-dark-lite.css +11 -8
  216. package/styles/material3-dark.css +11 -8
  217. package/styles/material3-lite.css +11 -8
  218. package/styles/material3.css +11 -8
  219. package/styles/recurrence-editor/_bds-definition.scss +1 -0
  220. package/styles/recurrence-editor/_bootstrap-dark-definition.scss +1 -0
  221. package/styles/recurrence-editor/_bootstrap-definition.scss +1 -0
  222. package/styles/recurrence-editor/_bootstrap4-definition.scss +1 -0
  223. package/styles/recurrence-editor/_bootstrap5-definition.scss +1 -0
  224. package/styles/recurrence-editor/_bootstrap5.3-definition.scss +1 -0
  225. package/styles/recurrence-editor/_fabric-dark-definition.scss +1 -0
  226. package/styles/recurrence-editor/_fabric-definition.scss +1 -0
  227. package/styles/recurrence-editor/_fluent-definition.scss +1 -0
  228. package/styles/recurrence-editor/_fluent2-definition.scss +1 -0
  229. package/styles/recurrence-editor/_fusionnew-definition.scss +1 -0
  230. package/styles/recurrence-editor/_highcontrast-definition.scss +1 -0
  231. package/styles/recurrence-editor/_highcontrast-light-definition.scss +1 -0
  232. package/styles/recurrence-editor/_layout.scss +5 -1
  233. package/styles/recurrence-editor/_material-dark-definition.scss +1 -0
  234. package/styles/recurrence-editor/_material-definition.scss +1 -0
  235. package/styles/recurrence-editor/_material3-definition.scss +1 -0
  236. package/styles/recurrence-editor/_tailwind-definition.scss +1 -0
  237. package/styles/recurrence-editor/_tailwind3-definition.scss +1 -0
  238. package/styles/recurrence-editor/bds.css +3 -0
  239. package/styles/recurrence-editor/bootstrap-dark.css +4 -1
  240. package/styles/recurrence-editor/bootstrap.css +4 -1
  241. package/styles/recurrence-editor/bootstrap4.css +3 -0
  242. package/styles/recurrence-editor/bootstrap5-dark.css +3 -0
  243. package/styles/recurrence-editor/bootstrap5.3.css +3 -0
  244. package/styles/recurrence-editor/bootstrap5.css +3 -0
  245. package/styles/recurrence-editor/fabric-dark.css +4 -1
  246. package/styles/recurrence-editor/fabric.css +4 -1
  247. package/styles/recurrence-editor/fluent-dark.css +4 -1
  248. package/styles/recurrence-editor/fluent.css +4 -1
  249. package/styles/recurrence-editor/fluent2.css +3 -0
  250. package/styles/recurrence-editor/highcontrast-light.css +4 -1
  251. package/styles/recurrence-editor/highcontrast.css +4 -1
  252. package/styles/recurrence-editor/material-dark.css +4 -1
  253. package/styles/recurrence-editor/material.css +4 -1
  254. package/styles/recurrence-editor/material3-dark.css +3 -0
  255. package/styles/recurrence-editor/material3.css +3 -0
  256. package/styles/recurrence-editor/tailwind-dark.css +3 -0
  257. package/styles/recurrence-editor/tailwind.css +3 -0
  258. package/styles/recurrence-editor/tailwind3.css +3 -0
  259. package/styles/schedule/_bds-definition.scss +2 -0
  260. package/styles/schedule/_bootstrap-dark-definition.scss +2 -0
  261. package/styles/schedule/_bootstrap-definition.scss +2 -0
  262. package/styles/schedule/_bootstrap4-definition.scss +2 -0
  263. package/styles/schedule/_bootstrap5-definition.scss +2 -0
  264. package/styles/schedule/_bootstrap5.3-definition.scss +2 -0
  265. package/styles/schedule/_fabric-dark-definition.scss +2 -0
  266. package/styles/schedule/_fabric-definition.scss +2 -0
  267. package/styles/schedule/_fluent-definition.scss +3 -1
  268. package/styles/schedule/_fluent2-definition.scss +2 -0
  269. package/styles/schedule/_fusionnew-definition.scss +2 -0
  270. package/styles/schedule/_highcontrast-definition.scss +2 -0
  271. package/styles/schedule/_highcontrast-light-definition.scss +2 -0
  272. package/styles/schedule/_layout.scss +12 -11
  273. package/styles/schedule/_material-dark-definition.scss +2 -0
  274. package/styles/schedule/_material-definition.scss +2 -0
  275. package/styles/schedule/_material3-definition.scss +2 -0
  276. package/styles/schedule/_tailwind-definition.scss +2 -0
  277. package/styles/schedule/_tailwind3-definition.scss +2 -0
  278. package/styles/schedule/bds.css +8 -8
  279. package/styles/schedule/bootstrap-dark.css +8 -8
  280. package/styles/schedule/bootstrap.css +8 -8
  281. package/styles/schedule/bootstrap4.css +8 -8
  282. package/styles/schedule/bootstrap5-dark.css +8 -8
  283. package/styles/schedule/bootstrap5.3.css +8 -8
  284. package/styles/schedule/bootstrap5.css +8 -8
  285. package/styles/schedule/fabric-dark.css +8 -8
  286. package/styles/schedule/fabric.css +8 -8
  287. package/styles/schedule/fluent-dark.css +9 -9
  288. package/styles/schedule/fluent.css +9 -9
  289. package/styles/schedule/fluent2.css +8 -8
  290. package/styles/schedule/highcontrast-light.css +8 -8
  291. package/styles/schedule/highcontrast.css +8 -8
  292. package/styles/schedule/material-dark.css +8 -8
  293. package/styles/schedule/material.css +8 -8
  294. package/styles/schedule/material3-dark.css +8 -8
  295. package/styles/schedule/material3.css +8 -8
  296. package/styles/schedule/tailwind-dark.css +8 -8
  297. package/styles/schedule/tailwind.css +8 -8
  298. package/styles/schedule/tailwind3.css +8 -8
  299. package/styles/tailwind-dark-lite.css +11 -8
  300. package/styles/tailwind-dark.css +11 -8
  301. package/styles/tailwind-lite.css +11 -8
  302. package/styles/tailwind.css +11 -8
  303. package/styles/tailwind3-lite.css +11 -8
  304. package/styles/tailwind3.css +11 -8
@@ -0,0 +1,4221 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { Component, ModuleDeclaration, Property, Event, Animation, Collection, append } from '@syncfusion/ej2-base';
3
+ import { EventHandler, EmitType, Browser, Internationalization, getDefaultDateObject, cldrData, L10n } from '@syncfusion/ej2-base';
4
+ import { getValue, compile, extend, isNullOrUndefined, NotifyPropertyChanges, INotifyPropertyChanged, Complex } from '@syncfusion/ej2-base';
5
+ import { getElement, removeClass, addClass, classList, remove, SanitizeHtmlHelper } from '@syncfusion/ej2-base';
6
+ import { createSpinner, hideSpinner, showSpinner } from '@syncfusion/ej2-popups';
7
+ import { ScheduleModel } from './schedule-model';
8
+ import { HeaderRenderer } from '../renderer/header-renderer';
9
+ import { Scroll } from '../actions/scroll';
10
+ import { ScheduleTouch } from '../actions/touch';
11
+ import { KeyboardInteraction } from '../actions/keyboard';
12
+ import { Data } from '../actions/data';
13
+ import { View, CurrentAction, ReturnType, WeekRule, NavigationDirection } from '../base/type';
14
+ import { EventBase } from '../event-renderer/event-base';
15
+ import { InlineEdit } from '../event-renderer/inline-edit';
16
+ import { QuickPopups } from '../popups/quick-popups';
17
+ import { EventTooltip } from '../popups/event-tooltip';
18
+ import { EventWindow } from '../popups/event-window';
19
+ import { Render } from '../renderer/renderer';
20
+ import { Day } from '../renderer/day';
21
+ import { Week } from '../renderer/week';
22
+ import { WorkWeek } from '../renderer/work-week';
23
+ import { Month } from '../renderer/month';
24
+ import { Year } from '../renderer/year';
25
+ import { Agenda } from '../renderer/agenda';
26
+ import { MonthAgenda } from '../renderer/month-agenda';
27
+ import { TimelineViews } from '../renderer/timeline-view';
28
+ import { TimelineMonth } from '../renderer/timeline-month';
29
+ import { TimelineYear } from '../renderer/timeline-year';
30
+ import { WorkHours } from '../models/work-hours';
31
+ import { TimeScale } from '../models/time-scale';
32
+ import { QuickInfoTemplates } from '../models/quick-info-templates';
33
+ import { HeaderRows } from '../models/header-rows';
34
+ import { Crud } from '../actions/crud';
35
+ import { Resize } from '../actions/resize';
36
+ import { DragAndDrop } from '../actions/drag';
37
+ import { VirtualScroll } from '../actions/virtual-scroll';
38
+ import { WorkCellInteraction } from '../actions/work-cells';
39
+ import { WorkHoursModel, ViewsModel, EventSettingsModel, GroupModel, ResourcesModel, TimeScaleModel, ToolbarItemModel } from '../models/models';
40
+ import { QuickInfoTemplatesModel, HeaderRowsModel } from '../models/models';
41
+ import { EventSettings } from '../models/event-settings';
42
+ import { Group } from '../models/group';
43
+ import { Resources } from '../models/resources';
44
+ import { ICalendarExport } from '../exports/calendar-export';
45
+ import { ICalendarImport } from '../exports/calendar-import';
46
+ import { ExcelExport } from '../exports/excel-export';
47
+ import { Print } from '../exports/print';
48
+ import { IRenderer, ActionEventArgs, NavigatingEventArgs, CellClickEventArgs, RenderCellEventArgs, ScrollCss, TimezoneFields, ExcelExportEventArgs, BeforePasteEventArgs, TooltipOpenEventArgs } from '../base/interface';
49
+ import { EventClickArgs, EventRenderedArgs, PopupOpenEventArgs, UIStateArgs, DragEventArgs, ResizeEventArgs } from '../base/interface';
50
+ import { EventFieldsMapping, TdData, ResourceDetails, ResizeEdges, StateArgs, ExportOptions, SelectEventArgs } from '../base/interface';
51
+ import { ViewsData, PopupCloseEventArgs, HoverEventArgs, MoreEventsClickArgs, ScrollEventArgs, CallbackFunction, BeforePrintEventArgs } from '../base/interface';
52
+ import { CalendarUtil, Gregorian, Islamic, CalendarType } from '../../common/calendar-util';
53
+ import { ResourceBase } from '../base/resource';
54
+ import { Timezone, timezoneData } from '../timezone/timezone';
55
+ import { RecurrenceEditor } from '../../recurrence-editor/recurrence-editor';
56
+ import * as events from '../base/constant';
57
+ import * as cls from '../base/css-constant';
58
+ import * as util from '../base/util';
59
+ import { ToolbarItem } from '../models/toolbar';
60
+
61
+ /**
62
+ * Represents the Schedule component that displays a list of events scheduled against specific date and timings,
63
+ * thus helping us to plan and manage it properly.
64
+ * ```html
65
+ * <div id="schedule"></div>
66
+ * ```
67
+ * ```typescript
68
+ * <script>
69
+ * var scheduleObj = new Schedule();
70
+ * scheduleObj.appendTo("#schedule");
71
+ * </script>
72
+ * ```
73
+ */
74
+ @NotifyPropertyChanges
75
+ export class Schedule extends Component<HTMLElement> implements INotifyPropertyChanged {
76
+ // internal variables
77
+ public globalize: Internationalization;
78
+ public localeObj: L10n;
79
+ public isAdaptive: boolean;
80
+ public dataModule: Data;
81
+ public eventTooltip: EventTooltip;
82
+ public eventWindow: EventWindow;
83
+ public renderModule: Render;
84
+ public headerModule: HeaderRenderer;
85
+ public scrollModule: Scroll;
86
+ public inlineModule: InlineEdit;
87
+ public virtualScrollModule: VirtualScroll;
88
+ public iCalendarExportModule: ICalendarExport;
89
+ public iCalendarImportModule: ICalendarImport;
90
+ public crudModule: Crud;
91
+ public scheduleTouchModule: ScheduleTouch;
92
+ public keyboardInteractionModule: KeyboardInteraction;
93
+ public activeView: IRenderer;
94
+ public activeCellsData: CellClickEventArgs;
95
+ public activeEventData: EventClickArgs;
96
+ public eventBase: EventBase;
97
+ public workCellAction: WorkCellInteraction;
98
+ public tzModule: Timezone;
99
+ public resourceBase: ResourceBase;
100
+ public currentTimezoneDate: Date;
101
+ private cellHeaderTemplateFn: CallbackFunction;
102
+ private cellTemplateFn: CallbackFunction;
103
+ private dateHeaderTemplateFn: CallbackFunction;
104
+ private dateRangeTemplateFn: CallbackFunction;
105
+ private dayHeaderTemplateFn: CallbackFunction;
106
+ private monthHeaderTemplateFn: CallbackFunction;
107
+ private majorSlotTemplateFn: CallbackFunction;
108
+ private minorSlotTemplateFn: CallbackFunction;
109
+ private appointmentTemplateFn: CallbackFunction;
110
+ private eventTooltipTemplateFn: CallbackFunction;
111
+ private headerTooltipTemplateFn: CallbackFunction;
112
+ private editorTemplateFn: CallbackFunction;
113
+ private editorHeaderTemplateFn: CallbackFunction;
114
+ private editorFooterTemplateFn: CallbackFunction;
115
+ private quickInfoTemplatesHeaderFn: CallbackFunction;
116
+ private quickInfoTemplatesContentFn: CallbackFunction;
117
+ private quickInfoTemplatesFooterFn: CallbackFunction;
118
+ private resourceHeaderTemplateFn: CallbackFunction;
119
+ private headerIndentTemplateFn: CallbackFunction;
120
+ private defaultLocale: Record<string, any>;
121
+ public dayModule: Day;
122
+ public weekModule: Week;
123
+ public workWeekModule: WorkWeek;
124
+ public monthAgendaModule: MonthAgenda;
125
+ public monthModule: Month;
126
+ public yearModule: Year;
127
+ public agendaModule: Agenda;
128
+ public timelineViewsModule: TimelineViews;
129
+ public timelineMonthModule: TimelineMonth;
130
+ public timelineYearModule: TimelineYear;
131
+ public resizeModule: Resize;
132
+ public dragAndDropModule: DragAndDrop;
133
+ public excelExportModule: ExcelExport;
134
+ public printModule: Print;
135
+ public viewOptions: { [key: string]: ViewsData[] };
136
+ public viewCollections: ViewsData[];
137
+ public viewIndex: number;
138
+ public activeViewOptions: ViewsData;
139
+ public eventFields: EventFieldsMapping;
140
+ public editorTitles: EventFieldsMapping;
141
+ public eventsData: Record<string, any>[];
142
+ public eventsProcessed: Record<string, any>[];
143
+ public overlapAppointments: Record<string, any>[];
144
+ public blockData: Record<string, any>[];
145
+ public blockProcessed: Record<string, any>[];
146
+ public resourceCollection: ResourcesModel[];
147
+ public currentAction: CurrentAction;
148
+ public quickPopup: QuickPopups;
149
+ public selectedElements: Element[];
150
+ public uiStateValues: UIStateArgs;
151
+ public internalTimeFormat: string;
152
+ public calendarUtil: CalendarUtil;
153
+ public scrollTop: number;
154
+ public scrollLeft: number;
155
+ public isPrinting: boolean;
156
+ public registeredTemplate: Object;
157
+ public adaptiveGroupIndex: number = 0;
158
+ public activeEventTemplates: string[];
159
+
160
+ // Schedule Options
161
+ /**
162
+ * Sets the `width` of the Schedule component, accepting both string and number values.
163
+ *
164
+ * {% codeBlock src='schedule/width/index.md' %}{% endcodeBlock %}
165
+ *
166
+ * The string value can be either pixel or percentage format.
167
+ * When set to `auto`, the Schedule width gets auto-adjusted and display its content related to the viewable screen size.
168
+ *
169
+ * @default 'auto'
170
+ */
171
+ @Property('auto')
172
+ public width: string | number;
173
+
174
+ /**
175
+ * Sets the `height` of the Schedule component, accepting both string and number values.
176
+ *
177
+ * {% codeBlock src='schedule/height/index.md' %}{% endcodeBlock %}
178
+ *
179
+ * The string type includes either pixel or percentage values.
180
+ * When `height` is set with specific pixel value, then the Schedule will be rendered to that specified space.
181
+ * In case, if `auto` value is set, then the height of the Schedule gets auto-adjusted within the given container.
182
+ *
183
+ * @default 'auto'
184
+ */
185
+ @Property('auto')
186
+ public height: string | number;
187
+
188
+ /**
189
+ * When set to `false`, hides the header bar of the Schedule from UI. By default,
190
+ * the header bar holds the date and view navigation options, to which the user can add their own custom items onto it.
191
+ *
192
+ * @default true
193
+ */
194
+ @Property(true)
195
+ public showHeaderBar: boolean;
196
+
197
+ /**
198
+ * When set to `false`, hides the current time indicator from the Schedule. Otherwise,
199
+ * it visually depicts the live current system time appropriately on the user interface.
200
+ *
201
+ * @default true
202
+ */
203
+ @Property(true)
204
+ public showTimeIndicator: boolean;
205
+
206
+ /**
207
+ * Defines whether to enable date navigations via swipe in touch devices or not.
208
+ *
209
+ * @default true
210
+ */
211
+ @Property(true)
212
+ public allowSwiping: boolean;
213
+
214
+ /**
215
+ * Specifies whether overlapping appointments are allowed within the same time slot in the Scheduler.
216
+ *
217
+ * @remarks
218
+ * When set to `false`, the Scheduler enforces restrictions to prevent creating or displaying overlapping appointments within the same time duration.
219
+ * This setting includes the following limitations:
220
+ *
221
+ * - **Initial Loading**: The alert for overlapping appointments will not display during the initial load. Overlapping events will be ignored in rendering, including occurrences.
222
+ *
223
+ * - **Dynamic Add/Edit**: When adding or editing events dynamically, overlapping validation is performed. If an overlap is detected for a single event, an alert will be shown, and the event will not be saved.
224
+ *
225
+ * For recurring events, an alert will be displayed, and the event will not be saved. To save recurring events while ignoring overlapping occurrences, trigger the `PopupOpen` event. The `Data` field will contain the parent recurrence data, and the `overlapEvents` field will contain the overlap events. Using these details, users can include exceptions in the recurrence events and save them with the `addEvent` method.
226
+ *
227
+ * - **Out-of-Date-Range Events**: The `allowOverlap` setting only prevents overlaps for events within the current view date range. To validate overlap events outside the current date range, use the `actionBegin` event to send a request to the server for validation and return a promise-based response. Assign this promise response to the `promise` field in `ActionEventArgs` to handle asynchronous server validation.
228
+ *
229
+ * @default true
230
+ */
231
+ @Property(true)
232
+ public allowOverlap: boolean;
233
+
234
+ /**
235
+ * Specifies the number of additional rows or columns to render outside the visible area during virtual scrolling.
236
+ * This property helps in achieving smoother scrolling by pre-loading data just outside the visible region.
237
+ *
238
+ * @remarks
239
+ * The default value is 3. Increasing this value can result in smoother scrolling but may impact performance
240
+ * with larger datasets. Decreasing it can improve performance but may cause more frequent data fetches during scrolling.
241
+ * This property only takes effect when `allowVirtualScrolling` is enabled for the current view.
242
+ *
243
+ * @default 3
244
+ */
245
+ @Property(3)
246
+ public overscanCount: number;
247
+
248
+ /**
249
+ * To render the custom toolbar items, the `toolbarItems` property can be used. It contains built-in and custom toolbar items.
250
+ * To avail the built-in toolbar items, the below string values are assigned to the `name` property of the `ToolbarItemModel`.
251
+ * * `Previous`: Schedule component navigates to the previous date from the current date.
252
+ * * `Next`: Schedule component navigates to the next date from the current date.
253
+ * * `Today`: Schedule component navigates to the current date from any date.
254
+ * * `Views`: Schedule component render the defined view options in the toolbar. If view option is not defined, then it will render default view options in the Schedule.
255
+ * * `DateRangeText`: Schedule component displays the current date text range.
256
+ * * `NewEvent`: Schedule component render the icon to add a new event.
257
+ *
258
+ * @default []
259
+ */
260
+ @Collection<ToolbarItemModel>([], ToolbarItem)
261
+ public toolbarItems: ToolbarItemModel[]
262
+
263
+ /**
264
+ * To set the active view on scheduler, the `currentView` property can be used and it usually accepts either of the following available
265
+ * view options. The view option specified in this property will be initially loaded on the schedule.
266
+ * * `Day`: Denotes Day view of the scheduler.
267
+ * * `Week`: Denotes Week view of the scheduler.
268
+ * * `WorkWeek`: Denotes Work Week view of the scheduler.
269
+ * * `Month`: Denotes Month view of the scheduler.
270
+ * * `Year`: Denotes Year view of the scheduler.
271
+ * * `Agenda`: Denotes Agenda view of the scheduler.
272
+ * * `MonthAgenda`: Denotes Month Agenda view of the scheduler.
273
+ * * `TimelineDay`: Denotes Timeline Day view of the scheduler.
274
+ * * `TimelineWeek`: Denotes Timeline Week view of the scheduler.
275
+ * * `TimelineWorkWeek`: Denotes Timeline Work Week view of the scheduler.
276
+ * * `TimelineMonth`: Denotes Timeline Month view of the scheduler.
277
+ * * `TimelineYear`: Denotes Timeline Year view of the scheduler.
278
+ *
279
+ * {% codeBlock src='schedule/currentView/index.md' %}{% endcodeBlock %}
280
+ *
281
+ * @default 'Week'
282
+ */
283
+ @Property('Week')
284
+ public currentView: View;
285
+
286
+ /**
287
+ * This property holds the views collection and its configurations. It accepts either the array of view names or the array of view
288
+ * objects that holds different configurations for each views. By default,
289
+ * Schedule displays all the views namely `Day`, `Week`, `Work Week`, `Month` and `Agenda`.
290
+ *
291
+ * Example for array of views:
292
+ * {% codeBlock src="schedule/views/index.md" %}{% endcodeBlock %}
293
+ *
294
+ * Example for array of view objects:
295
+ * {% codeBlock src='schedule/viewOption/index.md' %}{% endcodeBlock %}
296
+ *
297
+ * @default '["Day", "Week", "WorkWeek", "Month", "Agenda"]'
298
+ */
299
+ @Property(['Day', 'Week', 'WorkWeek', 'Month', 'Agenda'])
300
+ public views: View[] | ViewsModel[];
301
+
302
+ /**
303
+ * To mark the active (current) date on the Schedule, `selectedDate` property can be defined.
304
+ * Usually, it defaults to the current System date.
305
+ *
306
+ * {% codeBlock src='schedule/selectedDate/index.md' %}{% endcodeBlock %}
307
+ *
308
+ * @default 'new Date()'
309
+ * @aspDefaultValue DateTime.Now
310
+ */
311
+ @Property(new Date())
312
+ public selectedDate: Date;
313
+
314
+ /**
315
+ * To define the minimum date on the Schedule, `minDate` property can be defined.
316
+ * Usually, it defaults to the new Date(1900, 0, 1).
317
+ *
318
+ * {% codeBlock src='schedule/minDate/index.md' %}{% endcodeBlock %}
319
+ *
320
+ * @default new Date(1900, 0, 1)
321
+ * @aspDefaultValue new DateTime(1900, 1, 1)
322
+ */
323
+ @Property(new Date(1900, 0, 1))
324
+ public minDate: Date;
325
+
326
+ /**
327
+ * To define the maximum date on the Schedule, `maxDate` property can be defined.
328
+ * Usually, it defaults to the new Date(2099, 11, 31).
329
+ *
330
+ * {% codeBlock src='schedule/maxDate/index.md' %}{% endcodeBlock %}
331
+ *
332
+ * @default new Date(2099, 11, 31)
333
+ * @aspDefaultValue new DateTime(2099, 12, 31)
334
+ */
335
+ @Property(new Date(2099, 11, 31))
336
+ public maxDate: Date;
337
+
338
+ /**
339
+ * By default, Schedule follows the date-format as per the default culture assigned to it.
340
+ * It is also possible to manually set specific date format by using the `dateFormat` property.
341
+ *
342
+ * {% codeBlock src='schedule/dateFormat/index.md' %}{% endcodeBlock %}
343
+ *
344
+ * The format of the date range label in the header bar depends on the `dateFormat` value or else based on the
345
+ * locale assigned to the Schedule.
346
+ *
347
+ * @default null
348
+ */
349
+ @Property()
350
+ public dateFormat: string;
351
+
352
+ /**
353
+ * It allows the Scheduler to display in other calendar modes.
354
+ * By default, Scheduler is displayed in `Gregorian` calendar mode.
355
+ *
356
+ * {% codeBlock src='schedule/calendarMode/index.md' %}{% endcodeBlock %}
357
+ *
358
+ * To change the mode, you can set either `Gregorian` or `Islamic` as a value to this `calendarMode` property.
359
+ *
360
+ * @default 'Gregorian'
361
+ */
362
+ @Property('Gregorian')
363
+ public calendarMode: CalendarType;
364
+
365
+ /**
366
+ * When set to `false`, it hides the weekend days of a week from the Schedule. The days which are not defined in the working days
367
+ * collection are usually treated as weekend days.
368
+ *
369
+ * Note: By default, this option is not applicable on `Work Week` view.
370
+ * For example, if the working days are defined as [1, 2, 3, 4], then the remaining days of that week will be considered as
371
+ * the weekend days and will be hidden on all the views.
372
+ *
373
+ * @default true
374
+ */
375
+ @Property(true)
376
+ public showWeekend: boolean;
377
+
378
+ /**
379
+ * This option allows the user to set the first day of a week on Schedule. It should be based on the locale set to it and each culture
380
+ * defines its own first day of week values. If needed, the user can set it manually on his own by defining the value through
381
+ * this property. It usually accepts the integer values, whereby 0 is always denoted as Sunday, 1 as Monday and so on.
382
+ *
383
+ * {% codeBlock src='schedule/firstDayOfWeek/index.md' %}{% endcodeBlock %}
384
+ *
385
+ * @default 0
386
+ */
387
+ @Property(0)
388
+ public firstDayOfWeek: number;
389
+
390
+ /**
391
+ * It allows the Scheduler to display week numbers based on following available week options. The week
392
+ * option specified in this property will be initially loaded on the schedule.
393
+ * * `FirstDay`: Denotes that the first week of the year starts on the first day of the year and ends before the following designated first day of the week.
394
+ * * `FirstFourDayWeek`:Denotes that the first week of the year is the first week with four or more days before the designated first day of the week.
395
+ * * `FirstFullWeek`: Denotes that the first week of the year begins on the first occurrence of the designated first day of the week on or after the first day of the year.
396
+ *
397
+ * {% codeBlock src='schedule/weekRule/index.md' %}{% endcodeBlock %}
398
+ *
399
+ * @default 'FirstDay'
400
+ */
401
+ @Property('FirstDay')
402
+ public weekRule: WeekRule;
403
+
404
+ /**
405
+ * It is used to set the working days on Schedule. The only days that are defined in this collection will be rendered on the `workWeek`
406
+ * view whereas on other views, it will display all the usual days and simply highlights the working days with different shade.
407
+ *
408
+ * {% codeBlock src='schedule/workDays/index.md' %}{% endcodeBlock %}
409
+ *
410
+ * @default '[1, 2, 3, 4, 5]'
411
+ * @aspType int[]
412
+ */
413
+ @Property([1, 2, 3, 4, 5])
414
+ public workDays: number[];
415
+
416
+ /**
417
+ * This option allows the user to set the number of months count to be displayed on the Schedule.
418
+ *
419
+ * {% codeBlock src='schedule/monthsCount/index.md' %}{% endcodeBlock %}
420
+ *
421
+ * @default 12
422
+ * @aspType int
423
+ */
424
+ @Property(12)
425
+ public monthsCount: number;
426
+
427
+ /**
428
+ * It is used to specify the starting hour, from which the Schedule starts to display. It accepts the time string in a short skeleton
429
+ * format and also, hides the time beyond the specified start time.
430
+ *
431
+ * {% codeBlock src='schedule/startHour/index.md' %}{% endcodeBlock %}
432
+ *
433
+ * @default '00:00'
434
+ */
435
+ @Property('00:00')
436
+ public startHour: string;
437
+
438
+ /**
439
+ * It is used to specify the end hour, at which the Schedule ends. It too accepts the time string in a short skeleton format.
440
+ *
441
+ * {% codeBlock src='schedule/endHour/index.md' %}{% endcodeBlock %}
442
+ *
443
+ * @default '24:00'
444
+ */
445
+ @Property('24:00')
446
+ public endHour: string;
447
+
448
+ /**
449
+ * By default, Schedule follows the time-format as per the default culture assigned to it.
450
+ * It is also possible to manually set specific time format by using the `timeFormat` property.
451
+ *
452
+ * {% codeBlock src='schedule/timeFormat/index.md' %}{% endcodeBlock %}
453
+ *
454
+ * @default null
455
+ */
456
+ @Property(null)
457
+ public timeFormat: string;
458
+
459
+ /**
460
+ * Specifies whether to enable the rendering of untrusted HTML values in the Schedule component.
461
+ * When this property is enabled, the component will sanitize any suspected untrusted strings and scripts before rendering them.
462
+ *
463
+ * @default true
464
+ */
465
+ @Property(true)
466
+ public enableHtmlSanitizer: boolean;
467
+
468
+ /**
469
+ * When set to `true`, If valid, the scroll on the all day row is activated when the all day row
470
+ * height reaches the max height when the all day row is expanded.
471
+ *
472
+ * @default false
473
+ */
474
+ @Property(false)
475
+ public enableAllDayScroll: boolean;
476
+
477
+ /**
478
+ * When set to `true`, the header view navigations are listed under the popup and if we enable resource grouping, the compact view will be enabled.
479
+ *
480
+ * @default false
481
+ */
482
+ @Property(false)
483
+ public enableAdaptiveUI: boolean;
484
+
485
+ /**
486
+ * When set to `true`, allows the resizing of appointments. It allows the rescheduling of appointments either by changing the
487
+ * start or end time by dragging the event resize handlers.
488
+ *
489
+ * @default true
490
+ */
491
+ @Property(true)
492
+ public allowResizing: boolean;
493
+
494
+ /**
495
+ * The working hours should be highlighted on Schedule with different color shade and an additional option must be provided to
496
+ * highlight it or not. This functionality is handled through `workHours` property and the start work hour should be 9 AM by default
497
+ * and end work hour should point to 6 PM. The start and end working hours needs to be provided as Time value of short skeleton type.
498
+ *
499
+ * {% codeBlock src='schedule/workHours/index.md' %}{% endcodeBlock %}
500
+ *
501
+ * @default { highlight: true, start: '09:00', end: '18:00' }
502
+ */
503
+ @Complex<WorkHoursModel>({}, WorkHours)
504
+ public workHours: WorkHoursModel;
505
+
506
+ /**
507
+ * Allows to set different time duration on Schedule along with the customized grid count. It also has template option to
508
+ * customize the time slots with required time values in its own format.
509
+ *
510
+ * {% codeBlock src='schedule/timeScale/index.md' %}{% endcodeBlock %}
511
+ *
512
+ * @default { enable: true, interval: 60, slotCount: 2, majorSlotTemplate: null, minorSlotTemplate: null }
513
+ */
514
+ @Complex<TimeScaleModel>({}, TimeScale)
515
+ public timeScale: TimeScaleModel;
516
+
517
+ /**
518
+ * When set to `true`, allows the keyboard interaction to take place on Schedule.
519
+ *
520
+ * @default true
521
+ */
522
+ @Property(true)
523
+ public allowKeyboardInteraction: boolean;
524
+
525
+ /**
526
+ * When set to `true`, allows the appointments to move over the time slots. When an appointment is dragged, both its start
527
+ * and end time tends to change simultaneously allowing it to reschedule the appointment on some other time.
528
+ *
529
+ * @default true
530
+ */
531
+ @Property(true)
532
+ public allowDragAndDrop: boolean;
533
+
534
+ /**
535
+ * It accepts either the string or HTMLElement as template design content and parse it appropriately before displaying it onto
536
+ * the date header cells. The field that can be accessed via this template is `date`.
537
+ *
538
+ * {% codeBlock src='schedule/dateHeaderTemplate/index.md' %}{% endcodeBlock %}
539
+ *
540
+ * @default null
541
+ * @angularType string | object
542
+ * @reactType string | function | JSX.Element
543
+ * @vueType string | function
544
+ * @aspType string
545
+ */
546
+ @Property()
547
+ public dateHeaderTemplate: string | Function;
548
+
549
+ /**
550
+ * It accepts either the string or HTMLElement as template design content and parse it appropriately before displaying it onto the header date range.
551
+ *
552
+ * @default null
553
+ * @angularType string | object
554
+ * @reactType string | function | JSX.Element
555
+ * @vueType string | function
556
+ * @aspType string
557
+ */
558
+ @Property()
559
+ public dateRangeTemplate: string | Function;
560
+
561
+ /**
562
+ * It accepts either the string or HTMLElement as template design content and parse it appropriately before displaying it onto
563
+ * the month date cells. This template is only applicable for month view day cells.
564
+ *
565
+ * {% codeBlock src='schedule/cellHeaderTemplate/index.md' %}{% endcodeBlock %}
566
+ *
567
+ * @default null
568
+ * @angularType string | object
569
+ * @reactType string | function | JSX.Element
570
+ * @vueType string | function
571
+ * @aspType string
572
+ */
573
+ @Property()
574
+ public cellHeaderTemplate: string | Function;
575
+
576
+ /**
577
+ * It accepts either the string or HTMLElement as template design content and parse it appropriately before displaying it onto
578
+ * the day header cells. This template is only applicable for year view header cells.
579
+ *
580
+ * {% codeBlock src='schedule/dayHeaderTemplate/index.md' %}{% endcodeBlock %}
581
+ *
582
+ * @default null
583
+ * @angularType string | object
584
+ * @reactType string | function | JSX.Element
585
+ * @vueType string | function
586
+ * @aspType string
587
+ */
588
+ @Property()
589
+ public dayHeaderTemplate: string | Function;
590
+
591
+ /**
592
+ * It accepts either the string or HTMLElement as template design content and parse it appropriately before displaying it onto
593
+ * the month header cells. This template is only applicable for year view header cells.
594
+ *
595
+ * {% codeBlock src='schedule/monthHeaderTemplate/index.md' %}{% endcodeBlock %}
596
+ *
597
+ * @default null
598
+ * @angularType string | object
599
+ * @reactType string | function | JSX.Element
600
+ * @vueType string | function
601
+ * @aspType string
602
+ */
603
+ @Property()
604
+ public monthHeaderTemplate: string | Function;
605
+
606
+ /**
607
+ * The template option which is used to render the customized work cells on the Schedule. Here, the template accepts either
608
+ * the string or HTMLElement as template design and then the parsed design is displayed onto the work cells.
609
+ * The fields accessible via template are as follows.
610
+ * * `date`: Returns the date of the cell.
611
+ * * `groupIndex`: Returns the group index of the cell.
612
+ * * `type`: Returns the type of the work cell.
613
+ *
614
+ * Refer to the below code snippet.
615
+ *
616
+ * {% codeBlock src='schedule/cellTemplate/index.md' %}{% endcodeBlock %}
617
+ *
618
+ * @default null
619
+ * @angularType string | object
620
+ * @reactType string | function | JSX.Element
621
+ * @vueType string | function
622
+ * @aspType string
623
+ */
624
+ @Property()
625
+ public cellTemplate: string | Function;
626
+
627
+ /**
628
+ * When set to `true`, makes the Schedule to render in a read only mode. No CRUD actions will be allowed at this time.
629
+ *
630
+ * @default false
631
+ */
632
+ @Property(false)
633
+ public readonly: boolean;
634
+
635
+ /**
636
+ * When set to `true`, displays a quick popup with cell or event details on single clicking over the cells or on events.
637
+ * By default, it is set to `true`.
638
+ *
639
+ * @default true
640
+ */
641
+ @Property(true)
642
+ public showQuickInfo: boolean;
643
+
644
+ /**
645
+ * This property helps user to add/edit the event in inline. By default, it is set to `false`.
646
+ *
647
+ * @default false
648
+ */
649
+ @Property(false)
650
+ public allowInline: boolean;
651
+
652
+ /**
653
+ * This property helps user to allow/prevent the selection of multiple cells. By default, it is set to `true`.
654
+ *
655
+ * @default true
656
+ */
657
+ @Property(true)
658
+ public allowMultiCellSelection: boolean;
659
+
660
+ /**
661
+ * This property helps user to allow/prevent the selection of multiple days(rows). By default, it is set to `true`.
662
+ *
663
+ * @default true
664
+ */
665
+ @Property(true)
666
+ public allowMultiRowSelection: boolean;
667
+
668
+ /**
669
+ * This property helps to show quick popup after multiple cell selection. By default, it is set to `false`.
670
+ *
671
+ * @default false
672
+ */
673
+ @Property(false)
674
+ public quickInfoOnSelectionEnd: boolean;
675
+
676
+ /**
677
+ * When set to `true`, displays the week number of the current view date range. By default, it is set to `false`.
678
+ *
679
+ * @default false
680
+ */
681
+ @Property(false)
682
+ public showWeekNumber: boolean;
683
+
684
+ /**
685
+ * when set to `true`, allows the height of the work-cells to adjust automatically
686
+ * based on the number of appointments present in those time ranges.
687
+ *
688
+ * @default false
689
+ */
690
+ @Property(false)
691
+ public rowAutoHeight: boolean;
692
+
693
+ /**
694
+ * This property helps to drag the multiple selected events. By default, it is set to `false`.
695
+ *
696
+ * @default false
697
+ */
698
+ @Property(false)
699
+ public allowMultiDrag: boolean;
700
+
701
+ /**
702
+ * This property helps render the year view customized months. By default, it is set to `0`.
703
+ *
704
+ * {% codeBlock src='schedule/firstMonthOfYear/index.md' %}{% endcodeBlock %}
705
+ *
706
+ * @default 0
707
+ */
708
+ @Property(0)
709
+ public firstMonthOfYear: number;
710
+
711
+ /**
712
+ * The template option to render the customized editor window. The form elements defined within this template should be accompanied
713
+ * with `e-field` class, so as to fetch and process it from internally.
714
+ *
715
+ * {% codeBlock src='schedule/editorTemplate/index.md' %}{% endcodeBlock %}
716
+ *
717
+ * @default null
718
+ * @angularType string | object
719
+ * @reactType string | function | JSX.Element
720
+ * @vueType string | function
721
+ * @aspType string
722
+ */
723
+ @Property()
724
+ public editorTemplate: string | Function;
725
+
726
+ /**
727
+ * The template option to render the customized header of the editor window.
728
+ *
729
+ *
730
+ * @default null
731
+ * @angularType string | object
732
+ * @reactType string | function | JSX.Element
733
+ * @vueType string | function
734
+ * @aspType string
735
+ */
736
+ @Property()
737
+ public editorHeaderTemplate: string | Function;
738
+
739
+ /**
740
+ * The template option to render the customized footer of the editor window.
741
+ *
742
+ *
743
+ * @default null
744
+ * @angularType string | object
745
+ * @reactType string | function | JSX.Element
746
+ * @vueType string | function
747
+ * @aspType string
748
+ */
749
+ @Property()
750
+ public editorFooterTemplate: string | Function;
751
+
752
+ /**
753
+ * The template option to customize the quick window. The three sections of the quick popup whereas the header, content,
754
+ * and footer can be easily customized with individual template option.
755
+ *
756
+ * {% codeBlock src='schedule/quickInfoTemplates/index.md' %}{% endcodeBlock %}
757
+ *
758
+ * @default null
759
+ */
760
+ @Complex<QuickInfoTemplatesModel>({}, QuickInfoTemplates)
761
+ public quickInfoTemplates: QuickInfoTemplatesModel;
762
+
763
+ /**
764
+ * Sets the number of days to be displayed by default in Agenda View and in case of virtual scrolling,
765
+ * the number of days will be fetched on each scroll-end based on this count.
766
+ *
767
+ * {% codeBlock src='schedule/agendaDaysCount/index.md' %}{% endcodeBlock %}
768
+ *
769
+ * @default 7
770
+ */
771
+ @Property(7)
772
+ public agendaDaysCount: number;
773
+
774
+ /**
775
+ * The days which does not has even a single event to display will be hidden from the UI of Agenda View by default.
776
+ * When this property is set to `false`, the empty dates will also be displayed on the Schedule.
777
+ *
778
+ * @default true
779
+ */
780
+ @Property(true)
781
+ public hideEmptyAgendaDays: boolean;
782
+
783
+ /**
784
+ * The recurrence validation will be done by default. When this property is set to `false`, the recurrence validation will be skipped.
785
+ *
786
+ * @default true
787
+ */
788
+ @Property(true)
789
+ public enableRecurrenceValidation: boolean;
790
+
791
+ /**
792
+ * Schedule will be assigned with specific timezone, so as to display the events in it accordingly. By default,
793
+ * Schedule dates are processed with System timezone, as no timezone will be assigned specifically to the Schedule at the initial time.
794
+ * Whenever the Schedule is bound to remote data services, it is always recommended to set specific timezone to Schedule to make the
795
+ * events on it to display on the same time irrespective of the system timezone. It usually accepts
796
+ * the valid [IANA](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) timezone names.
797
+ *
798
+ * {% codeBlock src='schedule/timezone/index.md' %}{% endcodeBlock %}
799
+ *
800
+ * @default null
801
+ */
802
+ @Property()
803
+ public timezone: string;
804
+
805
+ /**
806
+ * Complete set of settings related to Schedule events to bind it to local or remote dataSource, map applicable database fields and
807
+ * other validation to be carried out on the available fields.
808
+ *
809
+ * {% codeBlock src='schedule/eventSettings/index.md' %}{% endcodeBlock %}
810
+ *
811
+ * @default null
812
+ */
813
+ @Complex<EventSettingsModel>({}, EventSettings)
814
+ public eventSettings: EventSettingsModel;
815
+
816
+ /**
817
+ * Allows to define the collection of timezone items in the Schedule. Only the items bound to this property get listed out in the timezone dropdown of the appointment window.
818
+ *
819
+ * {% codeBlock src='schedule/timezoneDatasource/index.md' %}{% endcodeBlock %}
820
+ *
821
+ * @default timezoneData
822
+ */
823
+ @Property(timezoneData)
824
+ public timezoneDataSource: TimezoneFields[];
825
+
826
+ /**
827
+ * Template option to customize the resource header bar. Here, the template accepts either
828
+ * the string or HTMLElement as template design and then the parsed design is displayed onto the resource header cells.
829
+ * The following can be accessible via template.
830
+ * * `resource` - All the resource fields.
831
+ * * `resourceData` - Object collection of current resource.
832
+ *
833
+ * Refer to the below code snippet.
834
+ *
835
+ * {% codeBlock src='schedule/resourceHeaderTemplate/index.md' %}{% endcodeBlock %}
836
+ *
837
+ * @default null
838
+ * @angularType string | object
839
+ * @reactType string | function | JSX.Element
840
+ * @vueType string | function
841
+ * @aspType string
842
+ */
843
+ @Property()
844
+ public resourceHeaderTemplate: string | Function;
845
+
846
+ /**
847
+ * Template option to customize the header indent bar. Here, the template accepts either
848
+ * the string or HTMLElement as template design and then the parsed design is displayed onto the header indent cell.
849
+ *
850
+ * Refer to the below code snippet.
851
+ *
852
+ * {% codeBlock src='schedule/headerIndentTemplate/index.md' %}{% endcodeBlock %}
853
+ *
854
+ * @default null
855
+ * @angularType string | object
856
+ * @reactType string | function | JSX.Element
857
+ * @vueType string | function
858
+ * @aspType string
859
+ */
860
+ @Property()
861
+ public headerIndentTemplate: string | Function;
862
+
863
+ /**
864
+ * Allows defining the group related settings of multiple resources. When this property is non-empty, it means
865
+ * that the resources will be grouped on the schedule layout based on the provided resource names.
866
+ *
867
+ * {% codeBlock src='schedule/group/index.md' %}{% endcodeBlock %}
868
+ *
869
+ * @default {}
870
+ */
871
+ @Complex<GroupModel>({}, Group)
872
+ public group: GroupModel;
873
+
874
+ /**
875
+ * Allows defining the collection of resources to be displayed on the Schedule. The resource collection needs to be defined
876
+ * with unique resource names to identify it along with the respective dataSource and field mapping options.
877
+ *
878
+ * {% codeBlock src='schedule/resources/index.md' %}{% endcodeBlock %}
879
+ *
880
+ * @default []
881
+ */
882
+ @Collection<ResourcesModel>([], Resources)
883
+ public resources: ResourcesModel[];
884
+
885
+ /**
886
+ * Allows defining the collection of custom header rows to display the year, month, week, date and hour label as an individual row
887
+ * on the timeline view of the scheduler.
888
+ *
889
+ * {% codeBlock src='schedule/headerRows/index.md' %}{% endcodeBlock %}
890
+ *
891
+ * @default []
892
+ */
893
+ @Collection<HeaderRowsModel>([], HeaderRows)
894
+ public headerRows: HeaderRowsModel[];
895
+
896
+ /**
897
+ * It is used to customize the Schedule which accepts custom CSS class names that defines specific user-defined styles and themes
898
+ * to be applied on the Schedule element.
899
+ *
900
+ * {% codeBlock src='schedule/cssClass/index.md' %}{% endcodeBlock %}
901
+ *
902
+ * @default null
903
+ */
904
+ @Property()
905
+ public cssClass: string;
906
+
907
+ /**
908
+ * Enables clipboard functionality for appointments, allowing them to be copied using keyboard shortcuts and pasted onto the Scheduler.
909
+ * When set to `true`, users can use keyboard shortcuts to cut, copy appointments and paste them into different time slots or calendars.
910
+ *
911
+ * @default false
912
+ * @remarks The `allowKeyboardInteraction` property should be enabled to use the keyboard shortcuts.
913
+ */
914
+ @Property(false)
915
+ public allowClipboard : boolean;
916
+
917
+ /**
918
+ * It enables the external drag and drop support for appointments on scheduler, to be able to move them out of the scheduler layout.
919
+ * When the drag area is explicitly set with specific DOM element name, the appointments can be dragged anywhere within the specified drag area location.
920
+ *
921
+ * {% codeBlock src='schedule/eventDragArea/index.md' %}{% endcodeBlock %}
922
+ *
923
+ * @default null
924
+ */
925
+ @Property()
926
+ public eventDragArea: string;
927
+
928
+ /**
929
+ * Triggers after the scheduler component is created.
930
+ *
931
+ * @event 'created'
932
+ */
933
+ @Event()
934
+ public created: EmitType<Record<string, any>>;
935
+
936
+ /**
937
+ * Triggers when the scheduler component is destroyed.
938
+ *
939
+ * @event 'destroyed'
940
+ */
941
+ @Event()
942
+ public destroyed: EmitType<Record<string, any>>;
943
+
944
+ /**
945
+ * Triggers when the scheduler cells are single clicked or on single tap on the same cells in mobile devices.
946
+ *
947
+ * @event 'cellClick'
948
+ */
949
+ @Event()
950
+ public cellClick: EmitType<CellClickEventArgs>;
951
+
952
+ /**
953
+ * Triggers when the scheduler cells are double clicked.
954
+ *
955
+ * @event 'cellDoubleClick'
956
+ */
957
+ @Event()
958
+ public cellDoubleClick: EmitType<CellClickEventArgs>;
959
+
960
+ /**
961
+ * Triggers when the more events indicator are clicked.
962
+ *
963
+ * @event 'moreEventsClick'
964
+ */
965
+ @Event()
966
+ public moreEventsClick: EmitType<MoreEventsClickArgs>;
967
+
968
+ /**
969
+ * Triggers when the scheduler elements are hovered.
970
+ *
971
+ * @event 'hover'
972
+ */
973
+ @Event()
974
+ public hover: EmitType<HoverEventArgs>;
975
+
976
+ /**
977
+ * Triggers when multiple cells or events are selected on the Scheduler.
978
+ *
979
+ * @event 'select'
980
+ */
981
+ @Event()
982
+ public select: EmitType<SelectEventArgs>;
983
+
984
+ /**
985
+ * Triggers on beginning of every scheduler action.
986
+ *
987
+ * @event 'actionBegin'
988
+ */
989
+ @Event()
990
+ public actionBegin: EmitType<ActionEventArgs>;
991
+
992
+ /**
993
+ * Triggers on successful completion of the scheduler actions.
994
+ *
995
+ * @event 'actionComplete'
996
+ */
997
+ @Event()
998
+ public actionComplete: EmitType<ActionEventArgs>;
999
+
1000
+ /**
1001
+ * Triggers when a scheduler action gets failed or interrupted and an error information will be returned.
1002
+ *
1003
+ * @event 'actionFailure'
1004
+ */
1005
+ @Event()
1006
+ public actionFailure: EmitType<ActionEventArgs>;
1007
+
1008
+ /**
1009
+ * Triggers before the date or view navigation takes place on scheduler.
1010
+ *
1011
+ * @event 'navigating'
1012
+ */
1013
+ @Event()
1014
+ public navigating: EmitType<NavigatingEventArgs>;
1015
+
1016
+ /**
1017
+ * Triggers before each element of the schedule rendering on the page.
1018
+ *
1019
+ * @event 'renderCell'
1020
+ */
1021
+ @Event()
1022
+ public renderCell: EmitType<RenderCellEventArgs>;
1023
+
1024
+ /**
1025
+ * Triggers when the events are single clicked or on single tapping the events on the mobile devices.
1026
+ *
1027
+ * @event 'eventClick'
1028
+ */
1029
+ @Event()
1030
+ public eventClick: EmitType<EventClickArgs>;
1031
+
1032
+ /**
1033
+ * Triggers when the events are double clicked or on double tapping the events on the desktop devices.
1034
+ *
1035
+ * @event 'eventDoubleClick'
1036
+ */
1037
+ @Event()
1038
+ public eventDoubleClick: EmitType<EventClickArgs>;
1039
+
1040
+ /**
1041
+ * Triggers before each of the event getting rendered on the scheduler user interface.
1042
+ *
1043
+ * @event 'eventRendered'
1044
+ */
1045
+ @Event()
1046
+ public eventRendered: EmitType<EventRenderedArgs>;
1047
+
1048
+ /**
1049
+ * Triggers before the data binds to the scheduler.
1050
+ *
1051
+ * @event 'dataBinding'
1052
+ */
1053
+ @Event()
1054
+ public dataBinding: EmitType<ReturnType>;
1055
+
1056
+ /**
1057
+ * Triggers before any of the scheduler popups opens on the page.
1058
+ *
1059
+ * @event 'popupOpen'
1060
+ */
1061
+ @Event()
1062
+ public popupOpen: EmitType<PopupOpenEventArgs>;
1063
+
1064
+ /**
1065
+ * Triggers before any of the scheduler popups close on the page.
1066
+ *
1067
+ * @event 'popupClose'
1068
+ */
1069
+ @Event()
1070
+ public popupClose: EmitType<PopupCloseEventArgs>;
1071
+
1072
+ /**
1073
+ * Triggers when an appointment is started to drag.
1074
+ *
1075
+ * @event 'dragStart'
1076
+ */
1077
+ @Event()
1078
+ public dragStart: EmitType<DragEventArgs>;
1079
+
1080
+ /**
1081
+ * Triggers when an appointment is being in a dragged state.
1082
+ *
1083
+ * @event 'drag'
1084
+ */
1085
+ @Event()
1086
+ public drag: EmitType<DragEventArgs>;
1087
+
1088
+ /**
1089
+ * Triggers when the dragging of appointment is stopped.
1090
+ *
1091
+ * @event 'dragStop'
1092
+ */
1093
+ @Event()
1094
+ public dragStop: EmitType<DragEventArgs>;
1095
+
1096
+ /**
1097
+ * Triggers when an appointment is started to resize.
1098
+ *
1099
+ * @event 'resizeStart'
1100
+ */
1101
+ @Event()
1102
+ public resizeStart: EmitType<ResizeEventArgs>;
1103
+
1104
+ /**
1105
+ * Triggers when an appointment is being in a resizing action.
1106
+ *
1107
+ * @event 'resizing'
1108
+ */
1109
+ @Event()
1110
+ public resizing: EmitType<ResizeEventArgs>;
1111
+
1112
+ /**
1113
+ * Triggers when the resizing of appointment is stopped.
1114
+ *
1115
+ * @event 'resizeStop'
1116
+ */
1117
+ @Event()
1118
+ public resizeStop: EmitType<ResizeEventArgs>;
1119
+
1120
+ /**
1121
+ * Triggers when the scroll action is started.
1122
+ * This event triggers only when `allowVirtualScrolling` or `enableLazyLoading` properties are enabled along with resource grouping.
1123
+ *
1124
+ * @event 'virtualScrollStart'
1125
+ */
1126
+ @Event()
1127
+ public virtualScrollStart: EmitType<ScrollEventArgs>;
1128
+
1129
+ /**
1130
+ * Triggers when the scroll action is stopped.
1131
+ * This event triggers only when `allowVirtualScrolling` or `enableLazyLoading` properties are enabled along with resource grouping.
1132
+ *
1133
+ * @event 'virtualScrollStop'
1134
+ */
1135
+ @Event()
1136
+ public virtualScrollStop: EmitType<ScrollEventArgs>;
1137
+
1138
+ /**
1139
+ * Triggers once the event data is bound to the scheduler.
1140
+ *
1141
+ * @event 'dataBound'
1142
+ */
1143
+ @Event()
1144
+ public dataBound: EmitType<ReturnType>;
1145
+
1146
+ /**
1147
+ * Triggers once when pasting an event on the scheduler.
1148
+ *
1149
+ * @event 'beforePaste'
1150
+ */
1151
+ @Event()
1152
+ public beforePaste : EmitType<BeforePasteEventArgs>;
1153
+
1154
+ /**
1155
+ * Triggers when the print event is called.
1156
+ *
1157
+ * @event 'beforePrint'
1158
+ */
1159
+ @Event()
1160
+ public beforePrint: EmitType<BeforePrintEventArgs>;
1161
+
1162
+ /**
1163
+ * Triggers before the Excel export process begins.
1164
+ *
1165
+ * @event 'excelExport'
1166
+ */
1167
+ @Event()
1168
+ public excelExport: EmitType<ExcelExportEventArgs>;
1169
+
1170
+ /**
1171
+ * Triggers before the tooltip is rendered.
1172
+ *
1173
+ * @event 'tooltipOpen'
1174
+ */
1175
+ @Event()
1176
+ public tooltipOpen: EmitType<TooltipOpenEventArgs>;
1177
+
1178
+
1179
+ /**
1180
+ * Constructor for creating the Schedule widget
1181
+ *
1182
+ * @param {ScheduleModel} options Accepts the schedule model properties to initiate the rendering
1183
+ * @param {string | HTMLElement} element Accepts the DOM element reference
1184
+ */
1185
+ constructor(options?: ScheduleModel, element?: string | HTMLElement) {
1186
+ super(options, <HTMLElement | string>element);
1187
+ }
1188
+
1189
+ /**
1190
+ * Core method that initializes the control rendering.
1191
+ *
1192
+ * @returns {void}
1193
+ * @private
1194
+ */
1195
+ public render(): void {
1196
+ const addClasses: string[] = [];
1197
+ const removeClasses: string[] = [];
1198
+ addClasses.push(cls.ROOT);
1199
+ if (this.enableRtl) {
1200
+ addClasses.push(cls.RTL);
1201
+ } else {
1202
+ removeClasses.push(cls.RTL);
1203
+ }
1204
+ if (this.isAdaptive) {
1205
+ addClasses.push(cls.DEVICE_CLASS);
1206
+ } else {
1207
+ removeClasses.push(cls.DEVICE_CLASS);
1208
+ }
1209
+ if (this.enableAdaptiveUI) {
1210
+ addClasses.push(cls.ADAPTIVE_CLASS);
1211
+ } else {
1212
+ removeClasses.push(cls.ADAPTIVE_CLASS);
1213
+ }
1214
+ if (this.allowMultiDrag) {
1215
+ addClasses.push(cls.MULTI_DRAG);
1216
+ } else {
1217
+ removeClasses.push(cls.MULTI_DRAG);
1218
+ }
1219
+ if (this.cssClass) {
1220
+ const cssClass: string[] = this.cssClass.split(' ');
1221
+ for (const cls of cssClass) {
1222
+ addClasses.push(cls);
1223
+ }
1224
+ }
1225
+ classList(this.element, addClasses, removeClasses);
1226
+ this.validateDate();
1227
+ createSpinner({ target: this.element });
1228
+ this.scrollModule = new Scroll(this);
1229
+ this.scrollModule.setWidth();
1230
+ this.scrollModule.setHeight();
1231
+ this.renderModule = new Render(this);
1232
+ this.eventBase = new EventBase(this);
1233
+ this.workCellAction = new WorkCellInteraction(this);
1234
+ if (this.allowKeyboardInteraction) {
1235
+ this.keyboardInteractionModule = new KeyboardInteraction(this);
1236
+ }
1237
+ this.inlineModule = new InlineEdit(this);
1238
+ this.initializeDataModule();
1239
+ this.renderTableContainer();
1240
+ this.activeViewOptions = this.getActiveViewOptions();
1241
+ this.initializeResources();
1242
+ this.wireEvents();
1243
+ }
1244
+
1245
+ private renderTableContainer(): void {
1246
+ if (!this.element.querySelector('.' + cls.TABLE_CONTAINER_CLASS)) {
1247
+ this.element.appendChild(this.createElement('div', { className: cls.TABLE_CONTAINER_CLASS }));
1248
+ }
1249
+ }
1250
+
1251
+ public getEventTemplateName(resIndex: number): string {
1252
+ const templateName: string = 'eventTemplate_' + resIndex;
1253
+ if (this.activeEventTemplates.indexOf(templateName) < 0) {
1254
+ this.activeEventTemplates.push(templateName);
1255
+ }
1256
+ return templateName;
1257
+ }
1258
+
1259
+ /**
1260
+ * Method to get element width
1261
+ *
1262
+ * @param {HTMLElement} element Accepts the DOM element
1263
+ * @returns {number} Returns the width of the given element
1264
+ * @private
1265
+ */
1266
+ public getElementWidth(element: HTMLElement): number {
1267
+ return util.getElementWidth(element, this.uiStateValues.isTransformed);
1268
+ }
1269
+
1270
+ /**
1271
+ * Method to get element height
1272
+ *
1273
+ * @param {HTMLElement} element Accepts the DOM element
1274
+ * @returns {number} Returns the Height of the given element
1275
+ * @private
1276
+ */
1277
+ public getElementHeight(element: HTMLElement): number {
1278
+ return util.getElementHeight(element, this.uiStateValues.isTransformed);
1279
+ }
1280
+
1281
+ /**
1282
+ * Method to get height from element
1283
+ *
1284
+ * @param {Element} element Accepts the DOM element
1285
+ * @param {string} elementClass Accepts the element class
1286
+ * @returns {number} Returns the height of the element
1287
+ * @private
1288
+ */
1289
+ public getElementHeightFromClass(element: Element, elementClass: string): number {
1290
+ return util.getElementHeightFromClass(element, elementClass, this.uiStateValues.isTransformed);
1291
+ }
1292
+
1293
+ /**
1294
+ * Method to render react templates
1295
+ *
1296
+ * @param {Function} callback - Specifies the callBack method
1297
+ * @returns {void}
1298
+ * @private
1299
+ */
1300
+ public renderTemplates(callback?: Function): void {
1301
+ if ((this as any).isReact) {
1302
+ this.renderReactTemplates(callback);
1303
+ } else if (callback) {
1304
+ callback();
1305
+ }
1306
+ }
1307
+
1308
+ /**
1309
+ * Method to reset react templates
1310
+ *
1311
+ * @param {string[]} templates Accepts the template ID
1312
+ * @returns {void}
1313
+ * @private
1314
+ */
1315
+ public resetTemplates(templates?: string[]): void {
1316
+ if ((this as any).isAngular || (this as any).isReact) {
1317
+ this.clearTemplate(templates);
1318
+ }
1319
+ }
1320
+
1321
+ /**
1322
+ * This method renders untrusted strings and scripts securely by sanitizing them first.
1323
+ *
1324
+ * @param {string} value - A string value representing the HTML string value to be sanitized.
1325
+ * @param {HTMLElement} element - An HTML element to which the sanitized or unsanitized HTML string will be assigned.
1326
+ * @returns {void}
1327
+ * @private
1328
+ */
1329
+ public sanitize(value: string, element: HTMLElement): void {
1330
+ if (this.enableHtmlSanitizer) {
1331
+ element.innerText = SanitizeHtmlHelper.sanitize(value);
1332
+ } else {
1333
+ element.innerHTML = value;
1334
+ }
1335
+ }
1336
+
1337
+ private initializeResources(isSetModel: boolean = false): void {
1338
+ if (this.resources.length > 0) {
1339
+ this.resourceBase = new ResourceBase(this);
1340
+ this.resourceBase.bindResourcesData(isSetModel);
1341
+ } else {
1342
+ this.resourceBase = null;
1343
+ this.resourceCollection = [];
1344
+ this.renderElements(isSetModel);
1345
+ }
1346
+ }
1347
+
1348
+ private destroyEditorWindow(): void {
1349
+ if (this.eventWindow) {
1350
+ this.eventWindow.destroy();
1351
+ this.eventWindow = null;
1352
+ }
1353
+ this.eventWindow = new EventWindow(this);
1354
+ }
1355
+
1356
+ /**
1357
+ * Method to render the layout elements
1358
+ *
1359
+ * @param {boolean} isLayoutOnly Accepts the boolean value to render layout or not
1360
+ * @returns {void}
1361
+ * @private
1362
+ */
1363
+ public renderElements(isLayoutOnly: boolean): void {
1364
+ if (isLayoutOnly) {
1365
+ this.initializeView(this.currentView);
1366
+ this.eventWindow.refresh();
1367
+ return;
1368
+ }
1369
+ this.destroyHeaderModule();
1370
+ if (this.showHeaderBar) {
1371
+ this.headerModule = new HeaderRenderer(this);
1372
+ }
1373
+ this.renderTableContainer();
1374
+ this.uiStateValues.isTransformed = Math.round(this.element.getBoundingClientRect().width) !== this.element.offsetWidth;
1375
+ if (Browser.isDevice || Browser.isTouch) {
1376
+ this.scheduleTouchModule = new ScheduleTouch(this);
1377
+ }
1378
+ this.initializeView(this.currentView);
1379
+ this.destroyPopups();
1380
+ if (!this.isPrinting) {
1381
+ this.initializePopups();
1382
+ }
1383
+ }
1384
+
1385
+ private validateDate(selectedDate: Date = this.selectedDate): void {
1386
+ // persist the selected date value
1387
+ let date: Date = selectedDate instanceof Date ? new Date(selectedDate.getTime()) : new Date(selectedDate);
1388
+ const minDate: Date = isNullOrUndefined(this.minDate) ? new Date(1900, 0, 1) :
1389
+ this.minDate instanceof Date ? new Date(this.minDate.getTime()) : new Date(this.minDate);
1390
+ const maxDate: Date = isNullOrUndefined(this.maxDate) ? new Date(2099, 11, 31) :
1391
+ this.maxDate instanceof Date ? new Date(this.maxDate.getTime()) : new Date(this.maxDate);
1392
+ if (minDate <= maxDate) {
1393
+ if (date < minDate) {
1394
+ date = minDate;
1395
+ }
1396
+ if (date > maxDate) {
1397
+ date = maxDate;
1398
+ }
1399
+ this.setProperties({ selectedDate: new Date('' + date), minDate: new Date('' + minDate), maxDate: new Date('' + maxDate) }, true);
1400
+ if (this.eventWindow) {
1401
+ this.eventWindow.updateMinMaxDateToEditor();
1402
+ }
1403
+ } else {
1404
+ throw Error('minDate should be equal or less than maxDate');
1405
+ }
1406
+ }
1407
+
1408
+ private getViewIndex(viewName: View): number {
1409
+ for (let item: number = 0; item < this.viewCollections.length; item++) {
1410
+ const checkIndex: View = this.viewCollections[parseInt(item.toString(), 10)].option;
1411
+ if (checkIndex === viewName) {
1412
+ return item;
1413
+ }
1414
+ }
1415
+ return -1;
1416
+ }
1417
+
1418
+ private setViewOptions(isModuleLoad: boolean = false): void {
1419
+ if (isNullOrUndefined(this.views) || this.views.length === 0) {
1420
+ return;
1421
+ }
1422
+ this.viewOptions = {};
1423
+ this.viewCollections = [];
1424
+ let viewName: string;
1425
+ let selectedView: string;
1426
+ const prevIndex: number = this.viewIndex;
1427
+ let count: number = 0;
1428
+ this.viewIndex = -1;
1429
+ for (const view of this.views) {
1430
+ const isOptions: boolean = (typeof view === 'string') ? false : true;
1431
+ if (typeof view === 'string') {
1432
+ viewName = view;
1433
+ if (this.currentView === viewName) {
1434
+ selectedView = viewName;
1435
+ this.viewIndex = count;
1436
+ }
1437
+ } else {
1438
+ viewName = view.option;
1439
+ if (view.isSelected) {
1440
+ selectedView = viewName;
1441
+ this.viewIndex = count;
1442
+ }
1443
+ }
1444
+ const obj: ViewsData = extend({ option: viewName }, isOptions ? view : {});
1445
+ const fieldViewName: string = viewName.charAt(0).toLowerCase() + viewName.slice(1);
1446
+ obj.cellHeaderTemplateName = obj.cellHeaderTemplate ? obj.option : '';
1447
+ obj.dateHeaderTemplateName = obj.dateHeaderTemplate ? obj.option : '';
1448
+ obj.dateRangeTemplateName = obj.dateRangeTemplate ? obj.option : '';
1449
+ obj.cellTemplateName = obj.cellTemplate ? obj.option : '';
1450
+ obj.dayHeaderTemplateName = obj.dayHeaderTemplate ? obj.option : '';
1451
+ obj.monthHeaderTemplateName = obj.monthHeaderTemplate ? obj.option : '';
1452
+ obj.resourceHeaderTemplateName = obj.resourceHeaderTemplate ? obj.option : '';
1453
+ obj.headerIndentTemplateName = obj.headerIndentTemplate ? obj.option : '';
1454
+ obj.eventTemplateName = obj.eventTemplate ? obj.option : '';
1455
+ if (!isNullOrUndefined(obj.firstDayOfWeek) && obj.firstDayOfWeek === 0) {
1456
+ delete obj.firstDayOfWeek;
1457
+ }
1458
+ if (!isNullOrUndefined(obj.interval) && obj.interval === 1) {
1459
+ delete obj.interval;
1460
+ }
1461
+ this.viewCollections.push(obj);
1462
+ if (isNullOrUndefined(this.viewOptions[`${fieldViewName}`])) {
1463
+ this.viewOptions[`${fieldViewName}`] = [obj];
1464
+ } else {
1465
+ this.viewOptions[`${fieldViewName}`].push(obj);
1466
+ }
1467
+ count++;
1468
+ }
1469
+ if (!isModuleLoad && selectedView) {
1470
+ this.setProperties({ currentView: selectedView }, true);
1471
+ }
1472
+ if (this.viewIndex === -1) {
1473
+ const currentIndex: number = this.getViewIndex(this.currentView);
1474
+ this.viewIndex = ((typeof this.views[0] !== 'string') && (!isNullOrUndefined(prevIndex) && prevIndex !== -1)) ? prevIndex :
1475
+ (currentIndex === -1) ? 0 : currentIndex;
1476
+ }
1477
+ }
1478
+
1479
+ private getActiveViewOptions(): ViewsData {
1480
+ const timeScale: TimeScaleModel = {
1481
+ enable: this.timeScale.enable,
1482
+ interval: this.timeScale.interval,
1483
+ slotCount: this.timeScale.slotCount,
1484
+ majorSlotTemplate: this.timeScale.majorSlotTemplate,
1485
+ minorSlotTemplate: this.timeScale.minorSlotTemplate
1486
+ };
1487
+ const isYearView: boolean = this.viewCollections[this.viewIndex].option.indexOf('Year') > -1;
1488
+ const group: GroupModel = {
1489
+ byDate: isYearView ? false : this.group.byDate,
1490
+ byGroupID: this.group.byGroupID,
1491
+ allowGroupEdit: this.group.allowGroupEdit,
1492
+ resources: isNullOrUndefined(this.group.resources) ? [] : this.group.resources,
1493
+ headerTooltipTemplate: this.group.headerTooltipTemplate,
1494
+ enableCompactView: this.group.enableCompactView,
1495
+ hideNonWorkingDays: ['Day', 'Week', 'WorkWeek', 'Month'].indexOf(this.currentView) > -1 ? this.group.hideNonWorkingDays : false
1496
+ };
1497
+ const workDays: number[] = this.viewCollections[this.viewIndex].workDays ? [] : this.workDays;
1498
+ const scheduleOptions: ViewsModel = {
1499
+ dateFormat: this.dateFormat,
1500
+ endHour: this.endHour,
1501
+ isSelected: false,
1502
+ option: null,
1503
+ readonly: this.readonly,
1504
+ startHour: this.startHour,
1505
+ allowVirtualScrolling: false,
1506
+ allowOverlap: this.allowOverlap,
1507
+ overscanCount: this.overscanCount,
1508
+ cellHeaderTemplate: this.cellHeaderTemplate,
1509
+ dayHeaderTemplate: this.dayHeaderTemplate,
1510
+ monthHeaderTemplate: this.monthHeaderTemplate,
1511
+ cellTemplate: this.cellTemplate,
1512
+ eventTemplate: this.eventSettings.template,
1513
+ dateHeaderTemplate: this.dateHeaderTemplate,
1514
+ dateRangeTemplate: this.dateRangeTemplate,
1515
+ resourceHeaderTemplate: this.resourceHeaderTemplate,
1516
+ headerIndentTemplate: this.headerIndentTemplate,
1517
+ firstMonthOfYear: this.firstMonthOfYear,
1518
+ firstDayOfWeek: this.firstDayOfWeek,
1519
+ workDays: workDays,
1520
+ monthsCount: this.monthsCount,
1521
+ showWeekend: this.showWeekend,
1522
+ showWeekNumber: this.showWeekNumber,
1523
+ displayName: null,
1524
+ interval: 1,
1525
+ timeScale: timeScale,
1526
+ timeFormat: this.internalTimeFormat,
1527
+ group: group,
1528
+ headerRows: this.headerRows,
1529
+ orientation: 'Horizontal',
1530
+ numberOfWeeks: 0,
1531
+ displayDate: null,
1532
+ enableLazyLoading: false
1533
+ };
1534
+ const viewOptions: ViewsData = this.viewCollections[this.viewIndex];
1535
+ const viewsData: ViewsData = extend(scheduleOptions, viewOptions, undefined, true);
1536
+ if (this.firstDayOfWeek !== 0 && viewOptions.firstDayOfWeek && this.firstDayOfWeek !== viewOptions.firstDayOfWeek) {
1537
+ viewsData.firstDayOfWeek = this.firstDayOfWeek;
1538
+ }
1539
+ if (viewsData.displayDate) {
1540
+ viewsData.displayDate = viewsData.displayDate instanceof Date ? new Date(viewsData.displayDate.getTime()) :
1541
+ new Date(viewsData.displayDate);
1542
+ }
1543
+ if (viewsData.enableLazyLoading && !isNullOrUndefined(viewsData.group.resources) && viewsData.group.resources.length > 0 &&
1544
+ (['Agenda', 'MonthAgenda', 'Year', 'TimelineYear'].indexOf(viewsData.option) === -1 ||
1545
+ (viewsData.option === 'TimelineYear' && viewsData.orientation === 'Vertical'))) {
1546
+ viewsData.allowVirtualScrolling = true;
1547
+ }
1548
+ return viewsData;
1549
+ }
1550
+
1551
+ private initializeDataModule(): void {
1552
+ this.eventFields = {
1553
+ id: this.eventSettings.fields.id,
1554
+ isBlock: this.eventSettings.fields.isBlock,
1555
+ subject: this.eventSettings.fields.subject.name,
1556
+ startTime: this.eventSettings.fields.startTime.name,
1557
+ endTime: this.eventSettings.fields.endTime.name,
1558
+ startTimezone: this.eventSettings.fields.startTimezone.name,
1559
+ endTimezone: this.eventSettings.fields.endTimezone.name,
1560
+ location: this.eventSettings.fields.location.name,
1561
+ description: this.eventSettings.fields.description.name,
1562
+ isAllDay: this.eventSettings.fields.isAllDay.name,
1563
+ recurrenceID: this.eventSettings.fields.recurrenceID.name,
1564
+ recurrenceRule: this.eventSettings.fields.recurrenceRule.name,
1565
+ recurrenceException: this.eventSettings.fields.recurrenceException.name,
1566
+ isReadonly: this.eventSettings.fields.isReadonly,
1567
+ followingID: this.eventSettings.fields.followingID
1568
+ };
1569
+ this.setEditorTitles();
1570
+ this.dataModule = new Data(this, this.eventSettings.dataSource, this.eventSettings.query);
1571
+ this.crudModule = new Crud(this);
1572
+ }
1573
+
1574
+ private setEditorTitles(): void {
1575
+ this.editorTitles = {
1576
+ subject: this.eventSettings.fields.subject.title || this.localeObj.getConstant('title'),
1577
+ startTime: this.eventSettings.fields.startTime.title || this.localeObj.getConstant('start'),
1578
+ endTime: this.eventSettings.fields.endTime.title || this.localeObj.getConstant('end'),
1579
+ isAllDay: this.eventSettings.fields.isAllDay.title || this.localeObj.getConstant('allDay'),
1580
+ startTimezone: this.eventSettings.fields.startTimezone.title || this.localeObj.getConstant('startTimezone'),
1581
+ endTimezone: this.eventSettings.fields.endTimezone.title || this.localeObj.getConstant('endTimezone'),
1582
+ location: this.eventSettings.fields.location.title || this.localeObj.getConstant('location'),
1583
+ description: this.eventSettings.fields.description.title || this.localeObj.getConstant('description'),
1584
+ recurrenceRule: this.eventSettings.fields.recurrenceRule.title || this.localeObj.getConstant('repeat')
1585
+ };
1586
+ }
1587
+
1588
+ private initializeView(viewName: View): void {
1589
+ this.showSpinner();
1590
+ this.activeViewOptions = this.getActiveViewOptions();
1591
+ if (this.resourceBase) {
1592
+ this.resourceBase.setResourceCollection();
1593
+ }
1594
+ this.initializeTemplates();
1595
+ this.renderModule.render(viewName);
1596
+ }
1597
+
1598
+ private initializeTemplates(): void {
1599
+ this.cellHeaderTemplateFn = this.templateParser(this.activeViewOptions.cellHeaderTemplate);
1600
+ this.dayHeaderTemplateFn = this.templateParser(this.activeViewOptions.dayHeaderTemplate);
1601
+ this.monthHeaderTemplateFn = this.templateParser(this.activeViewOptions.monthHeaderTemplate);
1602
+ this.cellTemplateFn = this.templateParser(this.activeViewOptions.cellTemplate);
1603
+ this.dateHeaderTemplateFn = this.templateParser(this.activeViewOptions.dateHeaderTemplate);
1604
+ this.dateRangeTemplateFn = this.templateParser(this.activeViewOptions.dateRangeTemplate);
1605
+ this.majorSlotTemplateFn = this.templateParser(this.activeViewOptions.timeScale.majorSlotTemplate);
1606
+ this.minorSlotTemplateFn = this.templateParser(this.activeViewOptions.timeScale.minorSlotTemplate);
1607
+ this.appointmentTemplateFn = this.templateParser(this.activeViewOptions.eventTemplate);
1608
+ this.resourceHeaderTemplateFn = this.templateParser(this.activeViewOptions.resourceHeaderTemplate);
1609
+ this.headerIndentTemplateFn = this.templateParser(this.activeViewOptions.headerIndentTemplate);
1610
+ this.headerTooltipTemplateFn = this.templateParser(this.activeViewOptions.group.headerTooltipTemplate);
1611
+ this.eventTooltipTemplateFn = this.templateParser(this.eventSettings.tooltipTemplate);
1612
+ this.editorTemplateFn = this.templateParser(this.editorTemplate);
1613
+ this.editorHeaderTemplateFn = this.templateParser(this.editorHeaderTemplate);
1614
+ this.editorFooterTemplateFn = this.templateParser(this.editorFooterTemplate);
1615
+ this.quickInfoTemplatesHeaderFn = this.templateParser(this.quickInfoTemplates.header);
1616
+ this.quickInfoTemplatesContentFn = this.templateParser(this.quickInfoTemplates.content);
1617
+ this.quickInfoTemplatesFooterFn = this.templateParser(this.quickInfoTemplates.footer);
1618
+ }
1619
+
1620
+ private initializePopups(): void {
1621
+ this.eventWindow = new EventWindow(this);
1622
+ this.quickPopup = new QuickPopups(this);
1623
+ }
1624
+
1625
+ /**
1626
+ * Method to get day names
1627
+ *
1628
+ * @param {string} type Accepts the day name
1629
+ * @returns {string[]} Returns the collection of day names
1630
+ * @private
1631
+ */
1632
+ public getDayNames(type: string): string[] {
1633
+ const culShortNames: string[] = [];
1634
+ let cldrObj: string[];
1635
+ let nameSpace: string = '';
1636
+ if (isNullOrUndefined(this.locale) || this.locale === 'en' || this.locale === 'en-US') {
1637
+ nameSpace = 'days.stand-alone.';
1638
+ cldrObj = <string[]>(getValue(nameSpace + type, getDefaultDateObject(this.getCalendarMode())));
1639
+ } else {
1640
+ nameSpace = 'main.' + '' + this.locale + '.dates.calendars.' + this.getCalendarMode() + '.days.format.' + type;
1641
+ cldrObj = <string[]>(getValue(nameSpace, cldrData));
1642
+ }
1643
+ for (const obj of Object.keys(cldrObj)) {
1644
+ culShortNames.push(getValue(obj, cldrObj));
1645
+ }
1646
+ return culShortNames;
1647
+ }
1648
+
1649
+ private setCldrTimeFormat(): void {
1650
+ if (!isNullOrUndefined(this.timeFormat)) {
1651
+ this.internalTimeFormat = this.timeFormat;
1652
+ return;
1653
+ }
1654
+ if (isNullOrUndefined(this.locale) || this.locale === 'en' || this.locale === 'en-US') {
1655
+ this.internalTimeFormat = <string>(getValue('timeFormats.short', getDefaultDateObject(this.getCalendarMode())));
1656
+ } else {
1657
+ this.internalTimeFormat = <string>
1658
+ (getValue('main.' + '' + this.locale + '.dates.calendars.' + this.getCalendarMode() + '.timeFormats.short', cldrData));
1659
+ }
1660
+ }
1661
+
1662
+ /**
1663
+ * Method to get calendar mode
1664
+ *
1665
+ * @returns {string} Returns the calendar mode
1666
+ * @private
1667
+ */
1668
+ public getCalendarMode(): string {
1669
+ return !isNullOrUndefined(this.calendarMode) ? this.calendarMode.toLowerCase() : 'gregorian';
1670
+ }
1671
+
1672
+ /**
1673
+ * Method to get time in string
1674
+ *
1675
+ * @param {Date} date Accepts the date object
1676
+ * @returns {string} Returns the time in string
1677
+ * @private
1678
+ */
1679
+ public getTimeString(date: Date): string {
1680
+ const time: string = this.globalize.formatDate(date, {
1681
+ format: this.activeViewOptions.timeFormat,
1682
+ type: 'time', calendar: this.getCalendarMode()
1683
+ });
1684
+ return time.toLocaleUpperCase();
1685
+ }
1686
+
1687
+ /**
1688
+ * Method to get date object
1689
+ *
1690
+ * @param {Date} date Accepts the date object
1691
+ * @returns {Date} Returns the date object
1692
+ * @private
1693
+ */
1694
+ public getDateTime(date: Date): Date {
1695
+ return date instanceof Date ? new Date(date.getTime()) : new Date(date);
1696
+ }
1697
+
1698
+ private setCalendarMode(): void {
1699
+ if (this.calendarMode === 'Islamic') {
1700
+ this.calendarUtil = new Islamic();
1701
+ } else {
1702
+ this.calendarUtil = new Gregorian();
1703
+ }
1704
+ }
1705
+
1706
+ /**
1707
+ * Method to change the current view
1708
+ *
1709
+ * @param {View} view Accepts the view name
1710
+ * @param {Event} event Accepts the event object
1711
+ * @param {boolean} muteOnChange Accepts the value to enable or disable mute on change
1712
+ * @param {number} index Accepts the index value
1713
+ * @returns {void}
1714
+ * @private
1715
+ */
1716
+ public changeView(view: View, event?: Event, muteOnChange?: boolean, index?: number): void {
1717
+ if (isNullOrUndefined(index)) {
1718
+ index = this.getViewIndex(view);
1719
+ }
1720
+ if (!muteOnChange && index === this.viewIndex && this.currentView === view || index < 0) {
1721
+ return;
1722
+ }
1723
+ const previousView: View = this.activeViewOptions ? this.activeViewOptions.option : this.currentView;
1724
+ let args: ActionEventArgs = { requestType: 'viewNavigate', cancel: false, event: event };
1725
+ this.trigger(events.actionBegin, args, (actionArgs: ActionEventArgs) => {
1726
+ if (!actionArgs.cancel) {
1727
+ const navArgs: NavigatingEventArgs = {
1728
+ action: 'view', cancel: false, currentDate: this.selectedDate, previousView: previousView, currentView: view, viewIndex: index
1729
+ };
1730
+ this.trigger(events.navigating, navArgs, (navigationArgs: NavigatingEventArgs) => {
1731
+ if (!navigationArgs.cancel) {
1732
+ const isVertical: boolean = ['Day', 'Week', 'WorkWeek'].indexOf(view) > -1 && ['Day', 'Week', 'WorkWeek'].indexOf(previousView) < 0;
1733
+ this.uiStateValues.isInitial = isVertical || view.indexOf('Timeline') > -1 || view.indexOf('Year') > -1;
1734
+ this.uiStateValues.top = view.indexOf('Timeline') > -1 && previousView.indexOf('Timeline') < 0 ? 0 : this.uiStateValues.top;
1735
+ this.viewIndex = navigationArgs.viewIndex;
1736
+ this.setProperties({ currentView: view }, true);
1737
+ if (this.headerModule) {
1738
+ this.headerModule.updateActiveView();
1739
+ this.headerModule.setCalendarDate(this.selectedDate);
1740
+ this.headerModule.setCalendarView();
1741
+ }
1742
+ this.initializeView(this.currentView);
1743
+ this.animateLayout();
1744
+ args = { requestType: 'viewNavigate', cancel: false, event: event };
1745
+ this.trigger(events.actionComplete, args);
1746
+ } else {
1747
+ this.currentView = previousView;
1748
+ }
1749
+ });
1750
+ } else {
1751
+ this.currentView = previousView;
1752
+ }
1753
+ });
1754
+ }
1755
+
1756
+ /**
1757
+ * Method to change the view date
1758
+ *
1759
+ * @param {Date} selectedDate Accepts the selected date
1760
+ * @param {Event} event Accepts the event object
1761
+ * @returns {void}
1762
+ * @private
1763
+ */
1764
+ public changeDate(selectedDate: Date, event?: Event): void {
1765
+ let args: ActionEventArgs = { requestType: 'dateNavigate', cancel: false, event: event };
1766
+ this.trigger(events.actionBegin, args, (actionArgs: ActionEventArgs) => {
1767
+ if (!actionArgs.cancel) {
1768
+ const navArgs: NavigatingEventArgs = {
1769
+ action: 'date', cancel: false, previousDate: this.selectedDate, currentDate: selectedDate
1770
+ };
1771
+ this.trigger(events.navigating, navArgs, (navigationArgs: NavigatingEventArgs) => {
1772
+ if (!navigationArgs.cancel) {
1773
+ this.uiStateValues.isInitial = this.activeView.isTimelineView() && this.currentView !== 'TimelineYear';
1774
+ this.validateDate(navigationArgs.currentDate);
1775
+ if (this.headerModule) {
1776
+ this.headerModule.setCalendarDate(navigationArgs.currentDate);
1777
+ }
1778
+ if (this.currentView === 'MonthAgenda' && this.monthAgendaModule) {
1779
+ this.monthAgendaModule.monthAgendaDate = new Date('' + this.selectedDate);
1780
+ }
1781
+ this.initializeView(this.currentView);
1782
+ this.animateLayout();
1783
+ args = { requestType: 'dateNavigate', cancel: false, event: event };
1784
+ this.trigger(events.actionComplete, args);
1785
+ }
1786
+ });
1787
+ }
1788
+ });
1789
+ }
1790
+
1791
+ /**
1792
+ * Method to validate min and max date
1793
+ *
1794
+ * @param {Date} date Accepts the date object
1795
+ * @returns {boolean} Returns the boolean result to validate the min and max date
1796
+ * @private
1797
+ */
1798
+ public isMinMaxDate(date: Date = this.selectedDate): boolean {
1799
+ const maxDate: Date = isNullOrUndefined(this.maxDate) ? new Date(2099, 11, 31) : this.maxDate;
1800
+ const minDate: Date = isNullOrUndefined(this.minDate) ? new Date(1900, 0, 1) : this.minDate;
1801
+ return ((date.getTime() >= minDate.getTime()) && (date.getTime() <= maxDate.getTime()));
1802
+ }
1803
+
1804
+ /**
1805
+ * Method to validate the selected date
1806
+ *
1807
+ * @param {Date} date Accepts the date object
1808
+ * @returns {boolean} Returns the boolean value for given date is selected date or not
1809
+ * @private
1810
+ */
1811
+ public isSelectedDate(date: Date): boolean {
1812
+ return date.setHours(0, 0, 0, 0) === new Date('' + this.selectedDate).setHours(0, 0, 0, 0);
1813
+ }
1814
+
1815
+ /**
1816
+ * Method to get the current time
1817
+ *
1818
+ * @param {Date} date Accepts the date object
1819
+ * @returns {Date} Returns the date object after performing the timezone conversion
1820
+ * @private
1821
+ */
1822
+ public getCurrentTime(date: Date = new Date()): Date {
1823
+ if (this.timezone) {
1824
+ return this.tzModule.convert(date, this.tzModule.getLocalTimezoneName(), this.timezone);
1825
+ }
1826
+ return date;
1827
+ }
1828
+
1829
+ /** Method to get navigate view
1830
+ *
1831
+ * @returns {View} Return the navigate view name
1832
+ * @private
1833
+ */
1834
+ public getNavigateView(): View {
1835
+ if (this.activeView.isTimelineView()) {
1836
+ return this.currentView === 'TimelineMonth' || this.currentView === 'TimelineYear' ? 'TimelineDay' : 'Agenda';
1837
+ }
1838
+ return 'Day';
1839
+ }
1840
+
1841
+ private animateLayout(): void {
1842
+ if (!this.activeView.element) {
1843
+ return;
1844
+ }
1845
+ new Animation({ duration: 600, name: 'FadeIn', timingFunction: 'easeIn' }).animate(this.activeView.element);
1846
+ }
1847
+
1848
+ /**
1849
+ * To provide the array of modules needed for control rendering
1850
+ *
1851
+ * @returns {ModuleDeclaration[]} Returns the declared modules
1852
+ * @private
1853
+ */
1854
+ public requiredModules(): ModuleDeclaration[] {
1855
+ const modules: ModuleDeclaration[] = [];
1856
+ this.setViewOptions(true);
1857
+ for (let view of Object.keys(this.viewOptions)) {
1858
+ view = (view === 'timelineDay' || view === 'timelineWeek' || view === 'timelineWorkWeek') ? 'timelineViews' : view;
1859
+ modules.push({ member: view, args: [this] });
1860
+ }
1861
+ if (this.allowDragAndDrop) {
1862
+ modules.push({ member: 'dragAndDrop', args: [this] });
1863
+ }
1864
+ if (this.allowResizing) {
1865
+ modules.push({ member: 'resize', args: [this] });
1866
+ }
1867
+ modules.push({ member: 'excelExport', args: [this] });
1868
+ modules.push({ member: 'iCalendarExport', args: [this] });
1869
+ modules.push({ member: 'iCalendarImport', args: [this] });
1870
+ modules.push({ member: 'print', args: [this] });
1871
+ return modules;
1872
+ }
1873
+
1874
+ /**
1875
+ * Initializes the values of private members.
1876
+ *
1877
+ * @returns {void}
1878
+ * @private
1879
+ */
1880
+ protected preRender(): void {
1881
+ this.isAdaptive = Browser.isDevice as boolean || util.isIPadDevice();
1882
+ this.globalize = new Internationalization(this.locale);
1883
+ this.tzModule = new Timezone();
1884
+ if (this && isNullOrUndefined(this.uiStateValues) || !(this.enablePersistence)) {
1885
+ this.uiStateValues = {
1886
+ expand: false, isInitial: true, left: 0, top: 0, isGroupAdaptive: false,
1887
+ isIgnoreOccurrence: false, groupIndex: this.adaptiveGroupIndex, action: false,
1888
+ isBlock: false, isCustomMonth: true, isPreventTimezone: false, isTransformed: false
1889
+ };
1890
+ }
1891
+ this.currentTimezoneDate = this.getCurrentTime();
1892
+ this.activeCellsData = {
1893
+ startTime: new Date(this.currentTimezoneDate),
1894
+ endTime: new Date(this.currentTimezoneDate),
1895
+ isAllDay: false
1896
+ };
1897
+ this.activeEventData = { event: undefined, element: undefined };
1898
+ this.getDefaultLocale();
1899
+ this.localeObj = new L10n(this.getModuleName(), this.defaultLocale, this.locale);
1900
+ this.setCldrTimeFormat();
1901
+ this.setCalendarMode();
1902
+ this.eventsData = [];
1903
+ this.eventsProcessed = [];
1904
+ this.blockData = [];
1905
+ this.blockProcessed = [];
1906
+ this.resourceCollection = [];
1907
+ this.currentAction = null;
1908
+ this.selectedElements = [];
1909
+ this.activeEventTemplates = [];
1910
+ this.setViewOptions();
1911
+ }
1912
+
1913
+ private getDefaultLocale(): void {
1914
+ this.defaultLocale = {
1915
+ day: 'Day',
1916
+ week: 'Week',
1917
+ workWeek: 'Work Week',
1918
+ month: 'Month',
1919
+ year: 'Year',
1920
+ agenda: 'Agenda',
1921
+ weekAgenda: 'Week Agenda',
1922
+ workWeekAgenda: 'Work Week Agenda',
1923
+ monthAgenda: 'Month Agenda',
1924
+ today: 'Today',
1925
+ noEvents: 'No events',
1926
+ emptyContainer: 'There are no events scheduled on this day.',
1927
+ allDay: 'All day',
1928
+ start: 'Start',
1929
+ end: 'End',
1930
+ more: 'more',
1931
+ close: 'Close',
1932
+ cancel: 'Cancel',
1933
+ noTitle: '(No Title)',
1934
+ delete: 'Delete',
1935
+ deleteEvent: 'Delete Event',
1936
+ deleteMultipleEvent: 'Delete Multiple Events',
1937
+ selectedItems: 'Items selected',
1938
+ deleteSeries: 'Entire Series',
1939
+ edit: 'Edit',
1940
+ editSeries: 'Entire Series',
1941
+ editEvent: 'Edit Event',
1942
+ createEvent: 'Create',
1943
+ subject: 'Subject',
1944
+ addTitle: 'Add title',
1945
+ moreDetails: 'More Details',
1946
+ moreEvents: 'More Events',
1947
+ save: 'Save',
1948
+ editContent: 'How would you like to change the appointment in the series?',
1949
+ deleteContent: 'Are you sure you want to delete this event?',
1950
+ deleteMultipleContent: 'Are you sure you want to delete the selected events?',
1951
+ newEvent: 'New Event',
1952
+ title: 'Title',
1953
+ location: 'Location',
1954
+ description: 'Description',
1955
+ timezone: 'Timezone',
1956
+ startTimezone: 'Start Timezone',
1957
+ endTimezone: 'End Timezone',
1958
+ repeat: 'Repeat',
1959
+ saveButton: 'Save',
1960
+ cancelButton: 'Cancel',
1961
+ deleteButton: 'Delete',
1962
+ recurrence: 'Recurrence',
1963
+ wrongPattern: 'The recurrence pattern is not valid.',
1964
+ seriesChangeAlert: 'Do you want to cancel the changes made to specific ' +
1965
+ 'instances of this series and match it to the whole series again?',
1966
+ createError: 'The duration of the event must be shorter than how frequently it occurs. ' +
1967
+ 'Shorten the duration, or change the recurrence pattern in the recurrence event editor.',
1968
+ sameDayAlert: 'Two occurrences of the same event cannot occur on the same day.',
1969
+ occurenceAlert: 'Cannot reschedule an occurrence of the recurring appointment if it skips over ' +
1970
+ 'a later occurrence of the same appointment.',
1971
+ editRecurrence: 'Edit Recurrence',
1972
+ recurringEvent: 'Recurring Event',
1973
+ repeats: 'Repeats',
1974
+ alert: 'Alert',
1975
+ startEndError: 'The selected end date occurs before the start date.',
1976
+ invalidDateError: 'The entered date value is invalid.',
1977
+ blockAlert: 'Events cannot be scheduled within the blocked time range.',
1978
+ overlapAlert: 'Events cannot be scheduled during the chosen time as it overlaps with another event.',
1979
+ ok: 'Ok',
1980
+ yes: 'Yes',
1981
+ no: 'No',
1982
+ of: 'of',
1983
+ occurrence: 'Occurrence',
1984
+ series: 'Series',
1985
+ previous: 'Previous',
1986
+ next: 'Next',
1987
+ timelineDay: 'Timeline Day',
1988
+ timelineWeek: 'Timeline Week',
1989
+ timelineWorkWeek: 'Timeline Work Week',
1990
+ timelineMonth: 'Timeline Month',
1991
+ timelineYear: 'Timeline Year',
1992
+ editFollowingEvent: 'Following Events',
1993
+ deleteTitle: 'Delete Event',
1994
+ editTitle: 'Edit Event',
1995
+ beginFrom: 'Begin From',
1996
+ endAt: 'Ends At',
1997
+ expandAllDaySection: 'Expand-all-day-section',
1998
+ collapseAllDaySection: 'Collapse-all-day-section',
1999
+ searchTimezone: 'Search Timezone',
2000
+ noRecords: 'No records found'
2001
+ };
2002
+ }
2003
+
2004
+ private wireEvents(): void {
2005
+ EventHandler.add(<HTMLElement & Window><unknown>window, 'resize', this.onScheduleResize, this);
2006
+ EventHandler.add(<HTMLElement & Window><unknown>window, 'orientationchange', this.onScheduleResize, this);
2007
+ EventHandler.add(document, Browser.touchStartEvent, this.onDocumentClick, this);
2008
+ if (this.allowClipboard) {
2009
+ EventHandler.add(document, 'paste', this.onDocumentPaste, this);
2010
+ }
2011
+ }
2012
+
2013
+ /**
2014
+ * Method to remove selected class
2015
+ *
2016
+ * @returns {void}
2017
+ * @private
2018
+ */
2019
+ public removeSelectedClass(): void {
2020
+ const selectedCells: Element[] = this.getSelectedCells();
2021
+ for (const cell of selectedCells) {
2022
+ cell.removeAttribute('tabindex');
2023
+ }
2024
+ removeClass(selectedCells, cls.SELECTED_CELL_CLASS);
2025
+ if (this.keyboardInteractionModule && this.keyboardInteractionModule.selectedCells.length > 0) {
2026
+ this.keyboardInteractionModule.selectedCells = [];
2027
+ }
2028
+ }
2029
+
2030
+ /**
2031
+ * Method to add selected class
2032
+ *
2033
+ * @param {HTMLTableCellElement[]} cells Accepts the collection of elements
2034
+ * @param {HTMLTableCellElement} focusCell Accepts the focus element
2035
+ * @param {boolean} isPreventScroll Accepts the boolean value to prevent scroll
2036
+ * @returns {void}
2037
+ * @private
2038
+ */
2039
+ public addSelectedClass(cells: HTMLTableCellElement[], focusCell: HTMLTableCellElement, isPreventScroll?: boolean): void {
2040
+ addClass(cells, cls.SELECTED_CELL_CLASS);
2041
+ if (focusCell) {
2042
+ focusCell.setAttribute('tabindex', '0');
2043
+ focusCell.focus({ preventScroll: isPreventScroll || false });
2044
+ }
2045
+ }
2046
+
2047
+ /**
2048
+ * Method to select cell
2049
+ *
2050
+ * @param {HTMLElement | HTMLTableCellElement} element Accepts the select element
2051
+ * @returns {void}
2052
+ * @private
2053
+ */
2054
+ public selectCell(element: HTMLElement & HTMLTableCellElement): void {
2055
+ this.removeSelectedClass();
2056
+ this.addSelectedClass([element], element);
2057
+ }
2058
+
2059
+ /**
2060
+ * Method to get all day row element
2061
+ *
2062
+ * @returns {Element} Returns the all day row element
2063
+ * @private
2064
+ */
2065
+ public getAllDayRow(): Element {
2066
+ return this.element.querySelector('.' + cls.ALLDAY_ROW_CLASS);
2067
+ }
2068
+
2069
+ /**
2070
+ * Method to get content table element
2071
+ *
2072
+ * @returns {HTMLElement} Returns the content table element
2073
+ * @private
2074
+ */
2075
+ public getContentTable(): HTMLElement {
2076
+ return this.activeView.element.querySelector('.' + cls.CONTENT_TABLE_CLASS + ' tbody') as HTMLElement;
2077
+ }
2078
+
2079
+ /**
2080
+ * Method to get all content table rows
2081
+ *
2082
+ * @returns {HTMLElement[]} Returns the content table rows
2083
+ * @private
2084
+ */
2085
+ public getTableRows(): HTMLElement[] {
2086
+ return [].slice.call(this.element.querySelectorAll('.' + cls.CONTENT_TABLE_CLASS + ' tbody tr:not(.' + cls.HIDDEN_CLASS + ')'));
2087
+ }
2088
+
2089
+ /**
2090
+ * Method to get work cell elements
2091
+ *
2092
+ * @returns {Element[]} Returns the all work cell elements
2093
+ * @private
2094
+ */
2095
+ public getWorkCellElements(): Element[] {
2096
+ return [].slice.call(this.element.querySelectorAll('.' + cls.WORK_CELLS_CLASS));
2097
+ }
2098
+
2099
+ /**
2100
+ * Method to get the index from date collection
2101
+ *
2102
+ * @param {Date[]} collection Accepts the collections of date
2103
+ * @param {Date} date Accepts the date object
2104
+ * @returns {number} Returns the index compared date with date collections
2105
+ * @private
2106
+ */
2107
+ public getIndexOfDate(collection: Date[], date: Date): number {
2108
+ return collection.map(Number).indexOf(+date);
2109
+ }
2110
+
2111
+ /**
2112
+ * Method to find all day cell
2113
+ *
2114
+ * @param {Element} td Accepts the DOM Element
2115
+ * @returns {boolean} Returns the boolean value
2116
+ * @private
2117
+ */
2118
+ public isAllDayCell(td: Element): boolean {
2119
+ if (['Month', 'TimelineMonth', 'TimelineYear', 'MonthAgenda'].indexOf(this.currentView) > -1 ||
2120
+ td.classList.contains(cls.ALLDAY_CELLS_CLASS) ||
2121
+ td.classList.contains(cls.HEADER_CELLS_CLASS) || !this.activeViewOptions.timeScale.enable) {
2122
+ return true;
2123
+ }
2124
+ if (this.activeView.isTimelineView() && this.activeViewOptions.headerRows.length > 0 &&
2125
+ this.activeViewOptions.headerRows.slice(-1)[0].option !== 'Hour') {
2126
+ return true;
2127
+ }
2128
+ return false;
2129
+ }
2130
+
2131
+ /**
2132
+ * Method to get date from element
2133
+ *
2134
+ * @param {Element} td Accepts the DOM element
2135
+ * @returns {Date} Returns the date object
2136
+ * @private
2137
+ */
2138
+ public getDateFromElement(td: Element): Date {
2139
+ let dateString: string;
2140
+ if (!isNullOrUndefined(td)) {
2141
+ dateString = td.getAttribute('data-date');
2142
+ }
2143
+ if (!isNullOrUndefined(dateString)) {
2144
+ const dateInMS: number = parseInt(dateString, 10);
2145
+ const date: Date = new Date(dateInMS);
2146
+ return date;
2147
+ }
2148
+ return undefined;
2149
+ }
2150
+
2151
+ /**
2152
+ * Method to get target element from given selector
2153
+ *
2154
+ * @param {string} selector Accepts the element selector
2155
+ * @param {number} left Accepts the pageX value
2156
+ * @param {number} top Accepts the pageY value
2157
+ * @returns {Element[]} Returns the collection of elements based on the given selector
2158
+ * @private
2159
+ */
2160
+ public getTargetElement(selector: string, left: number, top: number): Element[] {
2161
+ const element: Element = document.elementFromPoint(left, top);
2162
+ let targetElement: Element;
2163
+ if (element) {
2164
+ targetElement = element.closest(selector);
2165
+ }
2166
+ return (targetElement) ? [targetElement] : null;
2167
+ }
2168
+
2169
+ /**
2170
+ * Method to process cell header template
2171
+ *
2172
+ * @returns {CallbackFunction} Returns the callback function
2173
+ * @private
2174
+ */
2175
+ public getCellHeaderTemplate(): CallbackFunction {
2176
+ return this.cellHeaderTemplateFn;
2177
+ }
2178
+
2179
+ /**
2180
+ * Method to process cell header template in year view.
2181
+ *
2182
+ * @returns {CallbackFunction} Returns the callback function
2183
+ * @private
2184
+ */
2185
+ public getDayHeaderTemplate(): CallbackFunction {
2186
+ return this.dayHeaderTemplateFn;
2187
+ }
2188
+
2189
+ /**
2190
+ * Method to process cell header template in year view.
2191
+ *
2192
+ * @returns {CallbackFunction} Returns the callback function
2193
+ * @private
2194
+ */
2195
+ public getMonthHeaderTemplate(): CallbackFunction {
2196
+ return this.monthHeaderTemplateFn;
2197
+ }
2198
+
2199
+ /**
2200
+ * Method to process cell template
2201
+ *
2202
+ * @returns {CallbackFunction} Returns the callback function
2203
+ * @private
2204
+ */
2205
+ public getCellTemplate(): CallbackFunction {
2206
+ return this.cellTemplateFn;
2207
+ }
2208
+
2209
+ /**
2210
+ * Method to process date header template
2211
+ *
2212
+ * @returns {CallbackFunction} Returns the callback function
2213
+ * @private
2214
+ */
2215
+ public getDateHeaderTemplate(): CallbackFunction {
2216
+ return this.dateHeaderTemplateFn;
2217
+ }
2218
+
2219
+ /**
2220
+ * Method to process date range template
2221
+ *
2222
+ * @returns {CallbackFunction} Returns the callback function
2223
+ * @private
2224
+ */
2225
+ public getDateRangeTemplate(): CallbackFunction {
2226
+ return this.dateRangeTemplateFn;
2227
+ }
2228
+
2229
+ /**
2230
+ * Method to process major slot template
2231
+ *
2232
+ * @returns {CallbackFunction} Returns the callback function
2233
+ * @private
2234
+ */
2235
+ public getMajorSlotTemplate(): CallbackFunction {
2236
+ return this.majorSlotTemplateFn;
2237
+ }
2238
+
2239
+ /**
2240
+ * Method to process minor slot template
2241
+ *
2242
+ * @returns {CallbackFunction} Returns the callback function
2243
+ * @private
2244
+ */
2245
+ public getMinorSlotTemplate(): CallbackFunction {
2246
+ return this.minorSlotTemplateFn;
2247
+ }
2248
+
2249
+ /**
2250
+ * Method to process appointment template
2251
+ *
2252
+ * @returns {CallbackFunction} Returns the callback function
2253
+ * @private
2254
+ */
2255
+ public getAppointmentTemplate(): CallbackFunction {
2256
+ return this.appointmentTemplateFn;
2257
+ }
2258
+
2259
+ /**
2260
+ * Method to process appointment tooltip template
2261
+ *
2262
+ * @returns {CallbackFunction} Returns the callback function
2263
+ * @private
2264
+ */
2265
+ public getEventTooltipTemplate(): CallbackFunction {
2266
+ return this.eventTooltipTemplateFn;
2267
+ }
2268
+
2269
+ /**
2270
+ * Method to process header tooltip template
2271
+ *
2272
+ * @returns {CallbackFunction} Returns the callback function
2273
+ * @private
2274
+ */
2275
+ public getHeaderTooltipTemplate(): CallbackFunction {
2276
+ return this.headerTooltipTemplateFn;
2277
+ }
2278
+
2279
+ /**
2280
+ * Method to process editor template
2281
+ *
2282
+ * @returns {CallbackFunction} Returns the callback function
2283
+ * @private
2284
+ */
2285
+ public getEditorTemplate(): CallbackFunction {
2286
+ return this.editorTemplateFn;
2287
+ }
2288
+
2289
+ /**
2290
+ * Method to process editor header template
2291
+ *
2292
+ * @returns {CallbackFunction} Returns the callback function
2293
+ * @private
2294
+ */
2295
+ public getEditorHeaderTemplate(): CallbackFunction {
2296
+ return this.editorHeaderTemplateFn;
2297
+ }
2298
+
2299
+ /**
2300
+ * Method to process editor footer template
2301
+ *
2302
+ * @returns {CallbackFunction} Returns the callback function
2303
+ * @private
2304
+ */
2305
+ public getEditorFooterTemplate(): CallbackFunction {
2306
+ return this.editorFooterTemplateFn;
2307
+ }
2308
+
2309
+ /**
2310
+ * Method to process quick info header template
2311
+ *
2312
+ * @returns {CallbackFunction} Returns the callback function
2313
+ * @private
2314
+ */
2315
+ public getQuickInfoTemplatesHeader(): CallbackFunction {
2316
+ return this.quickInfoTemplatesHeaderFn;
2317
+ }
2318
+
2319
+ /**
2320
+ * Method to process quick info content template
2321
+ *
2322
+ * @returns {CallbackFunction} Returns the callback function
2323
+ * @private
2324
+ */
2325
+ public getQuickInfoTemplatesContent(): CallbackFunction {
2326
+ return this.quickInfoTemplatesContentFn;
2327
+ }
2328
+
2329
+ /**
2330
+ * Method to process quick info footer template
2331
+ *
2332
+ * @returns {CallbackFunction} Returns the callback function
2333
+ * @private
2334
+ */
2335
+ public getQuickInfoTemplatesFooter(): CallbackFunction {
2336
+ return this.quickInfoTemplatesFooterFn;
2337
+ }
2338
+
2339
+ /**
2340
+ * Method to process resource header template
2341
+ *
2342
+ * @returns {CallbackFunction} Returns the callback function
2343
+ * @private
2344
+ */
2345
+ public getResourceHeaderTemplate(): CallbackFunction {
2346
+ return this.resourceHeaderTemplateFn;
2347
+ }
2348
+
2349
+ /**
2350
+ * Method to process indent template
2351
+ *
2352
+ * @returns {CallbackFunction} Returns the callback function
2353
+ * @private
2354
+ */
2355
+ public getHeaderIndentTemplate(): CallbackFunction {
2356
+ return this.headerIndentTemplateFn;
2357
+ }
2358
+
2359
+ /**
2360
+ * Method to get dynamic CSS properties
2361
+ *
2362
+ * @returns {ScrollCss} Returns the CSS properties dynamically
2363
+ * @private
2364
+ */
2365
+ public getCssProperties(): ScrollCss {
2366
+ const cssProps: ScrollCss = {
2367
+ border: this.enableRtl ? 'borderLeftWidth' : 'borderRightWidth',
2368
+ padding: this.enableRtl ? 'paddingLeft' : 'paddingRight',
2369
+ rtlBorder: this.enableRtl ? 'borderRightWidth' : 'borderLeftWidth',
2370
+ rtlPadding: this.enableRtl ? 'paddingRight' : 'paddingLeft'
2371
+ };
2372
+ return cssProps;
2373
+ }
2374
+
2375
+ /**
2376
+ * Method to remove new event element in adaptive mode
2377
+ *
2378
+ * @returns {void}
2379
+ * @private
2380
+ */
2381
+ public removeNewEventElement(): void {
2382
+ const eventClone: HTMLElement = this.element.querySelector('.' + cls.NEW_EVENT_CLASS);
2383
+ if (!isNullOrUndefined(eventClone)) {
2384
+ remove(eventClone);
2385
+ }
2386
+ }
2387
+
2388
+ /**
2389
+ * Method to get start end time from string
2390
+ *
2391
+ * @param {string} startEndTime Accepts the start end time string value
2392
+ * @returns {Date} Returns the date object
2393
+ * @private
2394
+ */
2395
+ public getStartEndTime(startEndTime: string): Date {
2396
+ if (!isNullOrUndefined(startEndTime) && startEndTime !== '') {
2397
+ const startEndDate: Date = util.resetTime(new Date(this.currentTimezoneDate) || this.getCurrentTime());
2398
+ const timeString: string[] = startEndTime.split(':');
2399
+ if (timeString.length === 2) {
2400
+ startEndDate.setHours(parseInt(timeString[0], 10), parseInt(timeString[1], 10), 0);
2401
+ }
2402
+ return startEndDate;
2403
+ }
2404
+ return null;
2405
+ }
2406
+
2407
+ private onDocumentClick(args: Event): void {
2408
+ this.notify(events.documentClick, { event: args });
2409
+ }
2410
+
2411
+ private onDocumentPaste(args: Event): void {
2412
+ this.notify(events.documentPaste, { event: args });
2413
+ }
2414
+
2415
+ private onScheduleResize(): void {
2416
+ if (isNullOrUndefined(this.activeView) || ((this.isAdaptive || util.isMobile()) && document.activeElement
2417
+ && (document.activeElement.classList.contains(cls.SUBJECT_CLASS) ||
2418
+ document.activeElement.classList.contains(cls.INLINE_SUBJECT_CLASS))) || this.uiStateValues.isTapHold) {
2419
+ return;
2420
+ }
2421
+ if (this.virtualScrollModule && this.activeView.isTimelineView()) {
2422
+ this.virtualScrollModule.refreshLayout();
2423
+ }
2424
+ if (this.activeViewOptions.timeScale.enable && this.activeView) {
2425
+ this.activeView.highlightCurrentTime();
2426
+ }
2427
+ if (this.quickPopup) {
2428
+ this.quickPopup.onClosePopup();
2429
+ }
2430
+ util.resetScrollbarWidth();
2431
+ if (this.currentView === 'Month' || ((this.currentView !== 'Agenda' && this.currentView !== 'MonthAgenda')
2432
+ && !this.activeViewOptions.timeScale.enable) || this.activeView.isTimelineView()) {
2433
+ this.activeView.resetColWidth();
2434
+ this.notify(events.scrollUiUpdate, { cssProperties: this.getCssProperties(), isPreventScrollUpdate: true });
2435
+ let isRemoteRefresh: boolean = false;
2436
+ if (this.activeViewOptions.enableLazyLoading && this.virtualScrollModule && this.virtualScrollModule.isRemoteRefresh) {
2437
+ isRemoteRefresh = this.virtualScrollModule.isRemoteRefresh;
2438
+ this.virtualScrollModule.isRemoteRefresh = false;
2439
+ }
2440
+ this.refreshEvents(isRemoteRefresh);
2441
+ if (this.virtualScrollModule && !this.virtualScrollModule.enableTransition) {
2442
+ const resWrap: HTMLElement = this.element.querySelector('.' + cls.RESOURCE_COLUMN_WRAP_CLASS) as HTMLElement;
2443
+ const conWrap: HTMLElement = this.element.querySelector('.' + cls.CONTENT_WRAP_CLASS) as HTMLElement;
2444
+ this.virtualScrollModule.enableTransition = true;
2445
+ addClass([conWrap, resWrap], 'e-transition');
2446
+ }
2447
+ } else {
2448
+ this.notify(events.contentReady, {});
2449
+ }
2450
+ }
2451
+
2452
+ /**
2453
+ * Method to process the templates
2454
+ *
2455
+ * @param {string | Function} template Accepts the template in string
2456
+ * @returns {CallbackFunction} Returns the callback function
2457
+ * @private
2458
+ */
2459
+ public templateParser(template: string | Function): CallbackFunction {
2460
+ if (template) {
2461
+ try {
2462
+ if (typeof template === 'function') {
2463
+ return compile(template);
2464
+ } else {
2465
+ if (document.querySelectorAll(template).length) {
2466
+ return compile(document.querySelector(template).innerHTML.trim());
2467
+ } else {
2468
+ return compile(template);
2469
+ }
2470
+ }
2471
+ } catch (error) {
2472
+ return compile(template);
2473
+ }
2474
+ }
2475
+ return undefined;
2476
+ }
2477
+
2478
+ /**
2479
+ * Retrieves the selected cells.
2480
+ *
2481
+ * @returns {Element[]} The elements of currently selected cells will be returned.
2482
+ * @private
2483
+ */
2484
+ public getSelectedCells(): Element[] {
2485
+ return [].slice.call(this.element.querySelectorAll('.' + cls.SELECTED_CELL_CLASS));
2486
+ }
2487
+
2488
+ /**
2489
+ * Method to generate the announcement string
2490
+ *
2491
+ * @param {Object} event Accepts the event object
2492
+ * @param {string} subject Accepts the subject text
2493
+ * @returns {string} Returns the announcement string
2494
+ * @private
2495
+ */
2496
+ public getAnnouncementString(event: Record<string, any>, subject?: string): string {
2497
+ let resourceName: string;
2498
+ if (this.quickPopup && this.activeViewOptions.group.resources.length > 0) {
2499
+ const constantText: string = '"s event - ';
2500
+ resourceName = this.quickPopup.getResourceText({ event: event } as EventClickArgs, 'event') + constantText;
2501
+ }
2502
+ const recordSubject: string = (subject || (event[this.eventFields.subject] || this.eventSettings.fields.subject.default)) as string;
2503
+ const recordLocation: string = (event[this.eventFields.location] || this.eventSettings.fields.location.default) as string;
2504
+ const skeleton: string = 'full';
2505
+ const startDateText: string = this.globalize.formatDate(event[this.eventFields.startTime] as Date, {
2506
+ type: 'dateTime', skeleton: skeleton, calendar: this.getCalendarMode()
2507
+ });
2508
+ const endDateText: string = this.globalize.formatDate(event[this.eventFields.endTime] as Date, {
2509
+ type: 'dateTime', skeleton: skeleton, calendar: this.getCalendarMode()
2510
+ });
2511
+ let announcementString: string = recordSubject + ' ' + this.localeObj.getConstant('beginFrom') + ' '
2512
+ + startDateText + ' ' + this.localeObj.getConstant('endAt') + ' ' + endDateText;
2513
+ if (resourceName) {
2514
+ announcementString = resourceName + ' ' + announcementString;
2515
+ }
2516
+ if (recordLocation && recordLocation !== '') {
2517
+ announcementString = announcementString + ' ' + this.localeObj.getConstant('location') + ' ' + recordLocation;
2518
+ }
2519
+ if (event[this.eventFields.recurrenceRule] && event[this.eventFields.recurrenceRule] !== ''
2520
+ && event[this.eventFields.id] === event[this.eventFields.recurrenceID]) {
2521
+ announcementString = announcementString + ' ' + this.localeObj.getConstant('recurringEvent');
2522
+ }
2523
+ return announcementString;
2524
+ }
2525
+
2526
+ /**
2527
+ * Method to process the element boundary validation
2528
+ *
2529
+ * @param {number} pageY Accepts the pageY value
2530
+ * @param {number} pageX Accepts the pageX value
2531
+ * @returns {ResizeEdges} Returns the boundary validation object
2532
+ * @private
2533
+ */
2534
+ public boundaryValidation(pageY: number, pageX: number): ResizeEdges {
2535
+ const autoScrollDistance: number = 30;
2536
+ const scrollEdges: ResizeEdges = { left: false, right: false, top: false, bottom: false };
2537
+ const viewBoundaries: ClientRect = this.element.querySelector('.' + cls.CONTENT_WRAP_CLASS).getBoundingClientRect();
2538
+ if ((pageY < viewBoundaries.top + autoScrollDistance + window.pageYOffset) &&
2539
+ (pageY > viewBoundaries.top + window.pageYOffset)) {
2540
+ scrollEdges.top = true;
2541
+ }
2542
+ if ((pageY > (viewBoundaries.bottom - autoScrollDistance) + window.pageYOffset) &&
2543
+ (pageY < viewBoundaries.bottom + window.pageYOffset)) {
2544
+ scrollEdges.bottom = true;
2545
+ }
2546
+ if ((pageX < viewBoundaries.left + autoScrollDistance + window.pageXOffset) &&
2547
+ (pageX > viewBoundaries.left + window.pageXOffset)) {
2548
+ scrollEdges.left = true;
2549
+ }
2550
+ if ((pageX > (viewBoundaries.right - autoScrollDistance) + window.pageXOffset) &&
2551
+ (pageX < viewBoundaries.right + window.pageXOffset)) {
2552
+ scrollEdges.right = true;
2553
+ }
2554
+ return scrollEdges;
2555
+ }
2556
+
2557
+ /**
2558
+ * Method to get the week number.
2559
+ *
2560
+ * @param {Date[]} dates Accepts the date collections
2561
+ * @returns {number} Returns the week number
2562
+ * @private
2563
+ */
2564
+ public getWeekNumberContent(dates: Date[]): string {
2565
+ let weekNumber: string;
2566
+ if (this.weekRule === 'FirstDay') {
2567
+ const weekNumberDate: Date = util.getWeekLastDate(dates.slice(-1)[0], this.firstDayOfWeek);
2568
+ weekNumber = this.globalize.formatNumber(util.getWeekNumber(weekNumberDate));
2569
+ } else if (this.weekRule === 'FirstFourDayWeek') {
2570
+ const weekFirstDate: Date = util.getWeekFirstDate(dates.slice(-1)[0], this.firstDayOfWeek);
2571
+ const weekLastDate: Date = util.getWeekLastDate(dates.slice(-1)[0], this.firstDayOfWeek);
2572
+ const weekMidDate: Date = util.getWeekMiddleDate(weekFirstDate, weekLastDate);
2573
+ weekNumber = this.globalize.formatNumber(util.getWeekNumber(weekMidDate));
2574
+ } else if (this.weekRule === 'FirstFullWeek') {
2575
+ const weekFirstDate: Date = util.getWeekFirstDate(dates.slice(-1)[0], this.firstDayOfWeek);
2576
+ weekNumber = this.globalize.formatNumber(util.getWeekNumber(weekFirstDate));
2577
+ }
2578
+ return weekNumber;
2579
+ }
2580
+
2581
+ /**
2582
+ * Method to render the header indent template.
2583
+ *
2584
+ * @param {TdData} data Accepts the td data
2585
+ * @param {Element} td Accepts the td element
2586
+ * @returns {void}
2587
+ * @private
2588
+ */
2589
+ public renderHeaderIndentTemplate(data: TdData, td: Element): void {
2590
+ if (this.activeViewOptions.headerIndentTemplate) {
2591
+ const scheduleId: string = this.element.id + '_';
2592
+ const viewName: string = this.activeViewOptions.headerIndentTemplateName;
2593
+ const templateId: string = scheduleId + viewName + 'headerIndentTemplate';
2594
+ const indentTemplate: HTMLElement[] = [].slice.call(
2595
+ this.getHeaderIndentTemplate()(data, this, 'headerIndentTemplate', templateId, false, undefined, undefined, this.root));
2596
+ append(indentTemplate, td);
2597
+ }
2598
+ }
2599
+
2600
+ /**
2601
+ * Method to check for refreshing the targeted resource row events.
2602
+ *
2603
+ * @returns {boolean} Returns the boolean value
2604
+ * @private
2605
+ */
2606
+ public isSpecificResourceEvents(): boolean {
2607
+ return this.activeViewOptions.group.resources.length > 0 && !this.activeViewOptions.group.allowGroupEdit &&
2608
+ !this.rowAutoHeight && !this.virtualScrollModule && this.activeViewOptions.group.byGroupID;
2609
+ }
2610
+
2611
+ private unWireEvents(): void {
2612
+ EventHandler.remove(<HTMLElement & Window><unknown>window, 'resize', this.onScheduleResize);
2613
+ EventHandler.remove(<HTMLElement & Window><unknown>window, 'orientationchange', this.onScheduleResize);
2614
+ EventHandler.remove(document, Browser.touchStartEvent, this.onDocumentClick);
2615
+ EventHandler.remove(document, 'paste', this.onDocumentPaste);
2616
+ }
2617
+
2618
+ /**
2619
+ * Core method to return the component name.
2620
+ *
2621
+ * @returns {string} Returns the module name
2622
+ * @private
2623
+ */
2624
+ public getModuleName(): string {
2625
+ return 'schedule';
2626
+ }
2627
+
2628
+ /**
2629
+ * Returns the properties to be maintained in the persisted state.
2630
+ *
2631
+ * @returns {string} Returns the persistance data
2632
+ * @private
2633
+ */
2634
+ protected getPersistData(): string {
2635
+ return this.addOnPersist(['currentView', 'selectedDate', 'scrollTop', 'scrollLeft', 'adaptiveGroupIndex']);
2636
+ }
2637
+
2638
+ /**
2639
+ * Called internally, if any of the property value changed.
2640
+ *
2641
+ * @returns {void}
2642
+ * @private
2643
+ */
2644
+
2645
+ public onPropertyChanged(newProp: ScheduleModel, oldProp: ScheduleModel): void {
2646
+ if ((this as any).isReact && isNullOrUndefined(this.activeView)) {
2647
+ return;
2648
+ }
2649
+ const state: StateArgs = {
2650
+ isRefresh: false, isResource: false, isDate: false, isView: false, isLayout: false, isDataManager: false
2651
+ };
2652
+ for (const prop of Object.keys(newProp)) {
2653
+ switch (prop) {
2654
+ case 'views':
2655
+ this.setViewOptions();
2656
+ if (this.headerModule) {
2657
+ this.headerModule.updateItems();
2658
+ }
2659
+ state.isView = true;
2660
+ break;
2661
+ case 'currentView':
2662
+ state.isView = true;
2663
+ break;
2664
+ case 'minDate':
2665
+ case 'maxDate':
2666
+ case 'selectedDate':
2667
+ state.isDate = true;
2668
+ break;
2669
+ case 'dateFormat':
2670
+ this.activeViewOptions = this.getActiveViewOptions();
2671
+ if (this.headerModule) {
2672
+ this.headerModule.updateDateRange();
2673
+ }
2674
+ break;
2675
+ case 'showHeaderBar':
2676
+ case 'toolbarItems':
2677
+ this.destroyHeaderModule();
2678
+ if (newProp.showHeaderBar) {
2679
+ this.headerModule = new HeaderRenderer(this);
2680
+ this.headerModule.updateDateRange();
2681
+ }
2682
+ this.notify(events.scrollUiUpdate, { cssProperties: this.getCssProperties() });
2683
+ if (this.activeView.isTimelineView()) {
2684
+ this.refreshEvents(false);
2685
+ }
2686
+ break;
2687
+ case 'workDays':
2688
+ if (JSON.stringify(oldProp.workDays) !== JSON.stringify(newProp.workDays)) {
2689
+ state.isLayout = true;
2690
+ }
2691
+ break;
2692
+ case 'showWeekend':
2693
+ case 'startHour':
2694
+ case 'endHour':
2695
+ case 'workHours':
2696
+ case 'readonly':
2697
+ case 'headerRows':
2698
+ case 'showWeekNumber':
2699
+ case 'rowAutoHeight':
2700
+ state.isLayout = true;
2701
+ break;
2702
+ case 'locale':
2703
+ case 'calendarMode':
2704
+ this.globalize = new Internationalization(this.locale);
2705
+ this.localeObj = new L10n(this.getModuleName(), this.defaultLocale, this.locale);
2706
+ this.setCldrTimeFormat();
2707
+ this.setCalendarMode();
2708
+ state.isRefresh = true;
2709
+ break;
2710
+ case 'firstDayOfWeek':
2711
+ this.activeViewOptions.firstDayOfWeek = newProp.firstDayOfWeek;
2712
+ if (this.eventWindow) { this.eventWindow.refreshRecurrenceEditor(); }
2713
+ state.isLayout = true;
2714
+ break;
2715
+ case 'showTimeIndicator':
2716
+ if (this.activeViewOptions.timeScale.enable && this.activeView) {
2717
+ this.activeView.highlightCurrentTime();
2718
+ }
2719
+ break;
2720
+ case 'cellHeaderTemplate':
2721
+ this.activeViewOptions.cellHeaderTemplate = newProp.cellHeaderTemplate;
2722
+ this.cellHeaderTemplateFn = this.templateParser(this.activeViewOptions.cellHeaderTemplate);
2723
+ state.isLayout = true;
2724
+ break;
2725
+ case 'cellTemplate':
2726
+ this.activeViewOptions.cellTemplate = newProp.cellTemplate;
2727
+ this.cellTemplateFn = this.templateParser(this.activeViewOptions.cellTemplate);
2728
+ state.isLayout = true;
2729
+ break;
2730
+ case 'dateHeaderTemplate':
2731
+ this.activeViewOptions.dateHeaderTemplate = newProp.dateHeaderTemplate;
2732
+ this.dateHeaderTemplateFn = this.templateParser(this.activeViewOptions.dateHeaderTemplate);
2733
+ state.isLayout = true;
2734
+ break;
2735
+ case 'dateRangeTemplate':
2736
+ this.activeViewOptions.dateRangeTemplate = newProp.dateRangeTemplate;
2737
+ this.dateRangeTemplateFn = this.templateParser(this.activeViewOptions.dateRangeTemplate);
2738
+ if (this.headerModule) {
2739
+ this.headerModule.updateDateRange();
2740
+ }
2741
+ break;
2742
+ case 'dayHeaderTemplate':
2743
+ this.activeViewOptions.dayHeaderTemplate = newProp.dayHeaderTemplate;
2744
+ this.dayHeaderTemplateFn = this.templateParser(this.activeViewOptions.dayHeaderTemplate);
2745
+ state.isLayout = true;
2746
+ break;
2747
+ case 'monthHeaderTemplate':
2748
+ this.activeViewOptions.monthHeaderTemplate = newProp.monthHeaderTemplate;
2749
+ this.monthHeaderTemplateFn = this.templateParser(this.activeViewOptions.monthHeaderTemplate);
2750
+ state.isLayout = true;
2751
+ break;
2752
+ case 'resourceHeaderTemplate':
2753
+ this.activeViewOptions.resourceHeaderTemplate = newProp.resourceHeaderTemplate;
2754
+ this.resourceHeaderTemplateFn = this.templateParser(this.activeViewOptions.resourceHeaderTemplate);
2755
+ state.isLayout = true;
2756
+ break;
2757
+ case 'timezone':
2758
+ this.eventBase.timezonePropertyChange(oldProp.timezone);
2759
+ if (this.headerModule) {
2760
+ this.headerModule.setCalendarTimezone();
2761
+ }
2762
+ break;
2763
+ case 'enableRtl':
2764
+ this.setRtlClass();
2765
+ state.isRefresh = true;
2766
+ break;
2767
+ default:
2768
+ this.extendedPropertyChange(prop, newProp, oldProp, state);
2769
+ break;
2770
+ }
2771
+ }
2772
+ this.propertyChangeAction(state);
2773
+ }
2774
+
2775
+ private propertyChangeAction(state: StateArgs): void {
2776
+ if (state.isRefresh) {
2777
+ this.refresh();
2778
+ } else if (state.isResource) {
2779
+ this.initializeResources(true);
2780
+ } else if (state.isView) {
2781
+ this.changeView(this.currentView, null, true);
2782
+ } else if (state.isDate) {
2783
+ if (isNullOrUndefined(this.selectedDate)) {
2784
+ this.setProperties({ selectedDate: this.getCurrentTime() }, true);
2785
+ }
2786
+ this.changeDate(this.selectedDate);
2787
+ } else if (state.isLayout) {
2788
+ this.activeCellsData = null;
2789
+ this.initializeView(this.currentView);
2790
+ } else if (state.isDataManager && this.crudModule) {
2791
+ if (this.dragAndDropModule) {
2792
+ this.dragAndDropModule.actionObj.action = '';
2793
+ removeClass([this.element], cls.EVENT_ACTION_CLASS);
2794
+ }
2795
+ this.crudModule.refreshDataManager();
2796
+ }
2797
+ }
2798
+
2799
+ private allDayRowScrollUpdate(): void {
2800
+ const dateHeader: HTMLElement = (this.element.querySelector('.' + cls.DATE_HEADER_WRAP_CLASS) as HTMLElement);
2801
+ const allDayRow: HTMLElement = (this.element.querySelector('.' + cls.ALLDAY_ROW_CLASS) as HTMLElement);
2802
+ if (this.height === 'auto' || !this.enableAllDayScroll) {
2803
+ addClass([dateHeader], cls.ALLDAY_APPOINTMENT_AUTO);
2804
+ if (dateHeader.classList.contains(cls.ALLDAY_APPOINTMENT_SCROLL)) {
2805
+ removeClass([dateHeader], cls.ALLDAY_APPOINTMENT_SCROLL);
2806
+ }
2807
+ if (this.uiStateValues.expand) {
2808
+ const allDayCells: HTMLElement[] = [].slice.call(this.element.querySelectorAll('.' + cls.ALLDAY_CELLS_CLASS));
2809
+ allDayCells[0].style.height = (allDayRow.style.height) ? allDayRow.style.height : allDayCells[1].style.height;
2810
+ }
2811
+ } else {
2812
+ if (dateHeader.classList.contains(cls.ALLDAY_APPOINTMENT_AUTO)) {
2813
+ removeClass([dateHeader], cls.ALLDAY_APPOINTMENT_AUTO);
2814
+ }
2815
+ this.eventBase.allDayExpandScroll(dateHeader);
2816
+ }
2817
+ if (!this.uiStateValues.expand) {
2818
+ allDayRow.style.height = '';
2819
+ }
2820
+ }
2821
+
2822
+ private extendedPropertyChange(prop: string, newProp: ScheduleModel, oldProp: ScheduleModel, state: StateArgs): void {
2823
+ switch (prop) {
2824
+ case 'width':
2825
+ case 'height':
2826
+ case 'enableAllDayScroll':
2827
+ if (['Day', 'Week', 'WorkWeek'].indexOf(this.currentView) > -1) {
2828
+ this.allDayRowScrollUpdate();
2829
+ }
2830
+ this.notify(events.uiUpdate, { module: 'scroll', properties: { width: newProp.width, height: newProp.height } });
2831
+ break;
2832
+ case 'cssClass':
2833
+ if (oldProp.cssClass) { removeClass([this.element], oldProp.cssClass.split(' ')); }
2834
+ if (newProp.cssClass) { addClass([this.element], newProp.cssClass.split(' ')); }
2835
+ break;
2836
+ case 'hideEmptyAgendaDays':
2837
+ case 'agendaDaysCount':
2838
+ this.activeViewOptions = this.getActiveViewOptions();
2839
+ state.isView = true;
2840
+ break;
2841
+ case 'eventSettings':
2842
+ this.onEventSettingsPropertyChanged(newProp.eventSettings, oldProp.eventSettings, state);
2843
+ break;
2844
+ case 'allowKeyboardInteraction':
2845
+ case 'allowClipboard':
2846
+ if (this.keyboardInteractionModule) {
2847
+ this.keyboardInteractionModule.destroy();
2848
+ this.keyboardInteractionModule = null;
2849
+ }
2850
+ if (newProp.allowKeyboardInteraction || newProp.allowClipboard) {
2851
+ this.keyboardInteractionModule = new KeyboardInteraction(this);
2852
+ }
2853
+ if (prop === 'allowClipboard') {
2854
+ if (newProp.allowClipboard) {
2855
+ EventHandler.add(document, 'paste', this.onDocumentPaste, this);
2856
+ }
2857
+ else {
2858
+ EventHandler.remove(document, 'paste', this.onDocumentPaste);
2859
+ }
2860
+ }
2861
+ break;
2862
+ case 'timezoneDataSource':
2863
+ if (this.eventWindow) {
2864
+ this.eventWindow.refresh();
2865
+ }
2866
+ break;
2867
+ case 'editorTemplate':
2868
+ if (!isNullOrUndefined(this.editorTemplate)) {
2869
+ this.editorTemplateFn = this.templateParser(this.editorTemplate);
2870
+ }
2871
+ if (this.eventWindow) { this.eventWindow.setDialogContent(); }
2872
+ break;
2873
+ case 'editorHeaderTemplate':
2874
+ if (!isNullOrUndefined(this.editorHeaderTemplate)) {
2875
+ this.editorHeaderTemplateFn = this.templateParser(this.editorHeaderTemplate);
2876
+ }
2877
+ if (this.eventWindow) { this.eventWindow.setDialogHeader(); }
2878
+ break;
2879
+ case 'editorFooterTemplate':
2880
+ if (!isNullOrUndefined(this.editorFooterTemplate)) {
2881
+ this.editorFooterTemplateFn = this.templateParser(this.editorFooterTemplate);
2882
+ }
2883
+ if (this.eventWindow) { this.eventWindow.setDialogFooter(); }
2884
+ break;
2885
+ case 'quickInfoTemplates':
2886
+ if (this.quickInfoTemplates.header) {
2887
+ this.quickInfoTemplatesHeaderFn = this.templateParser(this.quickInfoTemplates.header);
2888
+ }
2889
+ if (this.quickInfoTemplates.content) {
2890
+ this.quickInfoTemplatesContentFn = this.templateParser(this.quickInfoTemplates.content);
2891
+ }
2892
+ if (this.quickInfoTemplates.footer) {
2893
+ this.quickInfoTemplatesFooterFn = this.templateParser(this.quickInfoTemplates.footer);
2894
+ }
2895
+ break;
2896
+ case 'group':
2897
+ this.onGroupSettingsPropertyChanged(newProp.group, oldProp.group, state);
2898
+ break;
2899
+ case 'resources':
2900
+ state.isResource = true;
2901
+ break;
2902
+ case 'timeScale':
2903
+ this.activeViewOptions.timeScale.interval = newProp.timeScale.interval || this.activeViewOptions.timeScale.interval;
2904
+ this.activeViewOptions.timeScale.slotCount = newProp.timeScale.slotCount || this.activeViewOptions.timeScale.slotCount;
2905
+ if (this.eventWindow) { this.eventWindow.refreshDateTimePicker(); }
2906
+ state.isLayout = true;
2907
+ break;
2908
+ case 'allowDragAndDrop':
2909
+ case 'allowResizing':
2910
+ case 'eventDragArea':
2911
+ case 'allowOverlap':
2912
+ this.refreshEvents(false);
2913
+ break;
2914
+ case 'weekRule':
2915
+ state.isLayout = true;
2916
+ break;
2917
+ case 'firstMonthOfYear':
2918
+ this.activeViewOptions.firstMonthOfYear = newProp.firstMonthOfYear;
2919
+ this.viewIndex = this.activeView.viewIndex;
2920
+ state.isLayout = true;
2921
+ break;
2922
+ case 'monthsCount':
2923
+ this.activeViewOptions.monthsCount = newProp.monthsCount;
2924
+ this.viewIndex = this.activeView.viewIndex;
2925
+ state.isLayout = true;
2926
+ break;
2927
+ case 'timeFormat':
2928
+ this.internalTimeFormat = newProp.timeFormat || this.activeViewOptions.timeFormat;
2929
+ if (this.eventWindow) { this.eventWindow.refreshDateTimePicker(); }
2930
+ state.isLayout = true;
2931
+ break;
2932
+ case 'enableAdaptiveUI':
2933
+ if (this.showHeaderBar && this.headerModule) {
2934
+ this.destroyHeaderModule();
2935
+ this.headerModule = new HeaderRenderer(this);
2936
+ this.headerModule.updateDateRange();
2937
+ }
2938
+ state.isLayout = true;
2939
+ break;
2940
+ case 'headerIndentTemplate':
2941
+ this.activeViewOptions.headerIndentTemplate = newProp.headerIndentTemplate;
2942
+ this.headerIndentTemplateFn = this.templateParser(this.activeViewOptions.headerIndentTemplate);
2943
+ state.isLayout = true;
2944
+ break;
2945
+ }
2946
+ }
2947
+
2948
+ private setRtlClass(): void {
2949
+ if (this.enableRtl) {
2950
+ addClass([this.element], 'e-rtl');
2951
+ } else {
2952
+ removeClass([this.element], 'e-rtl');
2953
+ }
2954
+ }
2955
+
2956
+ private onGroupSettingsPropertyChanged(newProp: GroupModel, oldProp: GroupModel, state: StateArgs): void {
2957
+ for (const prop of Object.keys(newProp)) {
2958
+ if (prop === 'headerTooltipTemplate') {
2959
+ this.headerTooltipTemplateFn = this.templateParser(newProp.headerTooltipTemplate);
2960
+ } else {
2961
+ state.isLayout = true;
2962
+ if (this.eventWindow) { this.eventWindow.refresh(); }
2963
+ }
2964
+ }
2965
+ }
2966
+
2967
+ private onEventSettingsPropertyChanged(newProp: EventSettingsModel, oldProp: EventSettingsModel, state: StateArgs): void {
2968
+ for (const prop of Object.keys(newProp)) {
2969
+ switch (prop) {
2970
+ case 'dataSource':
2971
+ case 'query':
2972
+ case 'fields':
2973
+ case 'includeFiltersInQuery':
2974
+ this.initializeDataModule();
2975
+ state.isDataManager = true;
2976
+ break;
2977
+ case 'template':
2978
+ this.activeViewOptions.eventTemplate = newProp.template;
2979
+ this.appointmentTemplateFn = this.templateParser(this.activeViewOptions.eventTemplate);
2980
+ state.isDataManager = true;
2981
+ break;
2982
+ case 'enableTooltip':
2983
+ if (this.eventTooltip) {
2984
+ this.eventTooltip.destroy();
2985
+ this.eventTooltip = null;
2986
+ }
2987
+ if (newProp.enableTooltip) {
2988
+ this.eventTooltip = new EventTooltip(this);
2989
+ }
2990
+ break;
2991
+ case 'tooltipTemplate':
2992
+ this.eventTooltipTemplateFn = this.templateParser(this.eventSettings.tooltipTemplate);
2993
+ break;
2994
+ case 'resourceColorField':
2995
+ if (this.resourceBase) {
2996
+ this.resourceBase.setResourceCollection();
2997
+ }
2998
+ state.isDataManager = true;
2999
+ break;
3000
+ case 'editFollowingEvents':
3001
+ if (this.quickPopup) { this.quickPopup.refreshQuickDialog(); }
3002
+ break;
3003
+ case 'allowAdding':
3004
+ case 'allowEditing':
3005
+ case 'allowDeleting':
3006
+ if (this.showHeaderBar && this.headerModule) {
3007
+ this.headerModule.updateAddIcon();
3008
+ }
3009
+ if (this.eventWindow) { this.eventWindow.refresh(); }
3010
+ break;
3011
+ case 'spannedEventPlacement':
3012
+ case 'minimumEventDuration':
3013
+ case 'enableMaxHeight':
3014
+ case 'enableIndicator':
3015
+ this.refreshEvents(false);
3016
+ break;
3017
+ case 'ignoreWhitespace':
3018
+ state.isLayout = true;
3019
+ break;
3020
+ }
3021
+ }
3022
+ }
3023
+
3024
+ private destroyHeaderModule(): void {
3025
+ if (this.headerModule) {
3026
+ this.headerModule.destroy();
3027
+ this.headerModule = null;
3028
+ }
3029
+ }
3030
+
3031
+ private destroyPopups(): void {
3032
+ if (this.quickPopup) {
3033
+ this.quickPopup.destroy();
3034
+ this.quickPopup = null;
3035
+ }
3036
+ if (this.eventWindow) {
3037
+ this.eventWindow.destroy();
3038
+ this.eventWindow = null;
3039
+ }
3040
+ }
3041
+
3042
+ /**
3043
+ * Allows to show the spinner on schedule at the required scenarios.
3044
+ *
3045
+ * @function showSpinner
3046
+ * @returns {void}
3047
+ */
3048
+ public showSpinner(): void {
3049
+ showSpinner(this.element);
3050
+ }
3051
+
3052
+ /**
3053
+ * When the spinner is shown manually using `showSpinner` method, it can be hidden using this `hideSpinner` method.
3054
+ *
3055
+ * @function hideSpinner
3056
+ * @returns {void}
3057
+ */
3058
+ public hideSpinner(): void {
3059
+ hideSpinner(this.element);
3060
+ }
3061
+
3062
+ /**
3063
+ * Sets different working hours on the required working days by accepting the required start and end time as well as the date collection
3064
+ * as its parameters.
3065
+ *
3066
+ * @function setWorkHours
3067
+ * @param {Date} dates Collection of dates on which the given start and end hour range needs to be applied.
3068
+ * @param {string} start Defines the work start hour.
3069
+ * @param {string} end Defines the work end hour.
3070
+ * @param {number} groupIndex Defines the resource index from last level.
3071
+ * @returns {void}
3072
+ */
3073
+ public setWorkHours(dates: Date[], start: string, end: string, groupIndex?: number): void {
3074
+ let cells: HTMLTableCellElement[] = [];
3075
+ cells = this.getWorkHourCells(dates, start, end, groupIndex);
3076
+ addClass(cells, cls.WORK_HOURS_CLASS);
3077
+ }
3078
+
3079
+ /**
3080
+ * Removes or resets different working hours on the required working days by accepting the required start and end time as well as the
3081
+ * date collection as its parameters.
3082
+ * if no parameters has been passed to this function, it will remove all the work hours.
3083
+ *
3084
+ * @param {Date} dates Collection of dates on which the given start and end hour range need to be applied.
3085
+ * @param {string} start Defines the work start hour.
3086
+ * @param {string} end Defines the work end hour.
3087
+ * @param {number} groupIndex Defines the resource index from last level.
3088
+ * @returns {void}
3089
+ */
3090
+ public resetWorkHours(dates: Date[] = this.activeView.renderDates, start?: string, end?: string, groupIndex?: number): void {
3091
+ if (dates && start && end) {
3092
+ const cells: HTMLTableCellElement[] = this.getWorkHourCells(dates, start, end, groupIndex);
3093
+ removeClass(cells, cls.WORK_HOURS_CLASS);
3094
+ } else {
3095
+ const workHourCells: HTMLElement[] = [].slice.call(this.element.querySelectorAll('.' + cls.WORK_HOURS_CLASS));
3096
+ removeClass(workHourCells, cls.WORK_HOURS_CLASS);
3097
+ }
3098
+ }
3099
+
3100
+ private getWorkHourCells(dates: Date[], start: string, end: string, groupIndex?: number): HTMLTableCellElement[] {
3101
+ if (['Agenda', 'MonthAgenda', 'Month', 'TimelineMonth'].indexOf(this.currentView) > -1) {
3102
+ return [];
3103
+ }
3104
+ let startHour: Date = this.getStartEndTime(start);
3105
+ let endHour: Date = this.getStartEndTime(end);
3106
+ const tableEle: HTMLTableElement = this.getContentTable() as HTMLTableElement;
3107
+ if (isNullOrUndefined(startHour) || isNullOrUndefined(endHour) || !tableEle) {
3108
+ return [];
3109
+ }
3110
+ startHour.setMilliseconds(0);
3111
+ endHour.setMilliseconds(0);
3112
+ const viewStartHour: Date = this.activeView.getStartHour();
3113
+ if (startHour < viewStartHour) {
3114
+ startHour = viewStartHour;
3115
+ }
3116
+ const viewEndHour: Date = this.activeView.getEndHour();
3117
+ if (endHour > viewEndHour) {
3118
+ endHour = viewEndHour;
3119
+ }
3120
+ const msMajorInterval: number = this.activeViewOptions.timeScale.interval * util.MS_PER_MINUTE;
3121
+ const msInterval: number = msMajorInterval / this.activeViewOptions.timeScale.slotCount;
3122
+ const offsetDiff: number = ((viewStartHour.getTimezoneOffset() - startHour.getTimezoneOffset()) * util.MS_PER_MINUTE);
3123
+ const endOffsetDiff: number = Math.abs((viewStartHour.getTimezoneOffset() - endHour.getTimezoneOffset()) * util.MS_PER_MINUTE);
3124
+ let startIndex: number = Math.round((startHour.getTime() - viewStartHour.getTime() + offsetDiff) / msInterval);
3125
+ let endIndex: number = Math.ceil((endHour.getTime() - viewStartHour.getTime() - endOffsetDiff) / msInterval);
3126
+ const tempStartIndex: number = startIndex;
3127
+ const tempEndIndex: number = endIndex;
3128
+ const cells: HTMLTableCellElement[] = [];
3129
+ for (let date of dates) {
3130
+ date = this.getDateTime(date);
3131
+ util.resetTime(date);
3132
+ let renderDates: Date[] = this.activeView.renderDates;
3133
+ if (!isNullOrUndefined(groupIndex) && this.resourceBase && !this.activeView.isTimelineView()) {
3134
+ renderDates = this.resourceBase.lastResourceLevel[parseInt(groupIndex.toString(), 10)].renderDates;
3135
+ }
3136
+ const colIndex: number = this.getIndexOfDate(renderDates, date);
3137
+ if (colIndex >= 0) {
3138
+ if (this.activeView.isTimelineView()) {
3139
+ const slotsPerDay: number = Math.round((viewEndHour.getTime() - viewStartHour.getTime()) / msInterval);
3140
+ startIndex = tempStartIndex + (colIndex * slotsPerDay);
3141
+ endIndex = tempEndIndex + (colIndex * slotsPerDay);
3142
+ }
3143
+ for (let i: number = startIndex; i < endIndex; i++) {
3144
+ if (this.activeView.isTimelineView()) {
3145
+ const rowIndex: number = (!isNullOrUndefined(groupIndex)) ? groupIndex : 0;
3146
+ cells.push(tableEle.rows[parseInt(rowIndex.toString(), 10)].cells[parseInt(i.toString(), 10)]);
3147
+ } else {
3148
+ if (!isNullOrUndefined(groupIndex)) {
3149
+ const selector: string = '.' + cls.WORK_CELLS_CLASS + '[data-group-index="' + groupIndex + '"]';
3150
+ const tds: HTMLTableCellElement[] =
3151
+ [].slice.call(tableEle.rows[parseInt(i.toString(), 10)].querySelectorAll(selector));
3152
+ cells.push(tds[parseInt(colIndex.toString(), 10)]);
3153
+ } else {
3154
+ cells.push(tableEle.rows[parseInt(i.toString(), 10)].cells[parseInt(colIndex.toString(), 10)]);
3155
+ }
3156
+ }
3157
+ }
3158
+ }
3159
+ }
3160
+ return cells;
3161
+ }
3162
+
3163
+ /**
3164
+ * Retrieves the start and end time information of the specific cell element.
3165
+ *
3166
+ * @function getCellDetails
3167
+ * @param {Element | Element[]} tdCol Accepts the single or collection of elements.
3168
+ * @returns {CellClickEventArgs} Object An object holding the startTime, endTime and all-day information along with the target HTML element will be returned.
3169
+ */
3170
+ public getCellDetails(tdCol: Element | Element[]): CellClickEventArgs {
3171
+ const td: Element[] = (tdCol instanceof Array) ? tdCol : [tdCol];
3172
+ const firstTd: Element = getElement(td[0]);
3173
+ const lastTd: Element = getElement(td.slice(-1)[0]);
3174
+ const startTime: Date = this.getDateFromElement(firstTd);
3175
+ let endTime: Date = this.getDateFromElement(lastTd);
3176
+ if (isNullOrUndefined(startTime) || isNullOrUndefined(endTime)) {
3177
+ return undefined;
3178
+ }
3179
+ const endDateFromColSpan: boolean = this.activeView.isTimelineView() && !isNullOrUndefined(lastTd.getAttribute('colSpan')) &&
3180
+ this.headerRows.length > 0;
3181
+ const duration: number = endDateFromColSpan ? parseInt(lastTd.getAttribute('colSpan'), 10) : 1;
3182
+ if (!this.activeViewOptions.timeScale.enable || endDateFromColSpan || lastTd.classList.contains(cls.ALLDAY_CELLS_CLASS) ||
3183
+ lastTd.classList.contains(cls.HEADER_CELLS_CLASS)) {
3184
+ endTime = util.addDays(new Date(endTime.getTime()), duration);
3185
+ } else {
3186
+ endTime = this.activeView.getEndDateFromStartDate(endTime);
3187
+ }
3188
+ const data: CellClickEventArgs = {
3189
+ startTime: startTime,
3190
+ endTime: endTime,
3191
+ isAllDay: this.isAllDayCell(firstTd),
3192
+ element: tdCol as HTMLElement | HTMLElement[]
3193
+ };
3194
+ const groupIndex: string = firstTd.getAttribute('data-group-index');
3195
+ if (!isNullOrUndefined(groupIndex)) {
3196
+ data.groupIndex = parseInt(groupIndex, 10);
3197
+ }
3198
+ return data;
3199
+ }
3200
+
3201
+ /**
3202
+ * Retrieves the selected cell elements.
3203
+ *
3204
+ * @function getSelectedElements
3205
+ * @returns {Element[]} The elements of currently selected cells will be returned.
3206
+ */
3207
+ public getSelectedElements(): Element[] {
3208
+ if (this.keyboardInteractionModule && this.keyboardInteractionModule.selectedCells.length > 0) {
3209
+ return this.keyboardInteractionModule.selectedCells;
3210
+ }
3211
+ return this.getSelectedCells();
3212
+ }
3213
+
3214
+ /**
3215
+ * To get the resource collection
3216
+ *
3217
+ * @function getResourceCollections
3218
+ * @returns {ResourcesModel[]} Returns the resource collections
3219
+ */
3220
+ public getResourceCollections(): ResourcesModel[] {
3221
+ return this.resourceCollection;
3222
+ }
3223
+
3224
+ /**
3225
+ * To set the resource collection
3226
+ *
3227
+ * @function setResourceCollections
3228
+ * @param {ResourcesModel[]} resourceCol Accepts the resource collections in ResourcesModel type
3229
+ * @param {boolean} isEventDataRefresh Accepts the boolean to refresh the appointment data source from remote or local
3230
+ * @returns {void}
3231
+ */
3232
+ public setResourceCollections(resourceCol: ResourcesModel[], isEventDataRefresh: boolean = true): void {
3233
+ if (!isEventDataRefresh && this.uiStateValues) {
3234
+ this.uiStateValues.isPreventEventRefresh = true;
3235
+ }
3236
+ this.setProperties({ resources: resourceCol }, false);
3237
+ }
3238
+
3239
+ /**
3240
+ * Current View could be change based on the provided parameters.
3241
+ *
3242
+ * @function changeCurrentView
3243
+ * @param {View} viewName Accept the view in the viewCollections.
3244
+ * @param {number} viewIndex Accept the viewIndex in the viewCollections.
3245
+ * @returns {void}
3246
+ */
3247
+ public changeCurrentView(viewName: View, viewIndex?: number): void {
3248
+ let index: number = this.getViewIndex(viewName);
3249
+ const view: string = viewName.charAt(0).toLowerCase() + viewName.slice(1);
3250
+ const viewOptions: ViewsData[] = this.viewOptions[`${view}`];
3251
+ if (viewOptions) {
3252
+ index = this.viewCollections.indexOf(viewOptions[viewIndex || 0]);
3253
+ }
3254
+ if (index === -1 || index === this.viewIndex) {
3255
+ return;
3256
+ }
3257
+ this.changeView(viewName, null, null, index);
3258
+ }
3259
+
3260
+ /**
3261
+ * Return the current view Index.
3262
+ *
3263
+ * @function getCurrentViewIndex
3264
+ * @returns {number} Returns the view index
3265
+ */
3266
+ public getCurrentViewIndex(): number {
3267
+ return this.viewIndex;
3268
+ }
3269
+
3270
+ /**
3271
+ * Retrieves the resource details based on the provided resource index.
3272
+ *
3273
+ * @param {number} index index of the resources at the last level.
3274
+ * @returns {ResourceDetails} Object An object holding the details of resource and resourceData.
3275
+ */
3276
+ public getResourcesByIndex(index: number): ResourceDetails {
3277
+ if (this.resourceBase && this.resourceBase.lastResourceLevel) {
3278
+ if (index < 0 || index >= this.resourceBase.lastResourceLevel.length) {
3279
+ return undefined;
3280
+ }
3281
+ const data: TdData = this.resourceBase.lastResourceLevel[parseInt(index.toString(), 10)];
3282
+ const groupData: Record<string, any> = {};
3283
+ this.resourceBase.setResourceValues(groupData, index);
3284
+ return { resource: data.resource, resourceData: data.resourceData, groupData: groupData };
3285
+ }
3286
+ return undefined;
3287
+ }
3288
+
3289
+ /**
3290
+ * This method allows to expand the resource that available on the scheduler.
3291
+ *
3292
+ * @function expandResource
3293
+ * @param {string | number} resourceId Accepts the resource id in either string or number type
3294
+ * @param {string} name Accepts the name of the resource collection
3295
+ * @returns {void}
3296
+ */
3297
+ public expandResource(resourceId: string | number, name: string): void {
3298
+ if (this.activeView.isTimelineView() && this.resourceBase && this.resourceCollection.length > 1) {
3299
+ this.resourceBase.resourceExpand(resourceId, name, false);
3300
+ }
3301
+ }
3302
+
3303
+ /**
3304
+ * This method allows to collapse the resource that available on the scheduler.
3305
+ *
3306
+ * @function collapseResource
3307
+ * @param {string | number} resourceId Accepts the resource id in either string or number type
3308
+ * @param {string} name Accepts the name of the resource collection
3309
+ * @returns {void}
3310
+ */
3311
+ public collapseResource(resourceId: string | number, name: string): void {
3312
+ if (this.activeView.isTimelineView() && this.resourceBase && this.resourceCollection.length > 1) {
3313
+ this.resourceBase.resourceExpand(resourceId, name, true);
3314
+ }
3315
+ }
3316
+
3317
+ /**
3318
+ * Scrolls the Schedule content area to the specified time.
3319
+ *
3320
+ * @function scrollTo
3321
+ * @param {string} hour Accepts the time value in the skeleton format of 'Hm'.
3322
+ * @param {Date} scrollDate Accepts the date object value.
3323
+ * @returns {void}
3324
+ */
3325
+ public scrollTo(hour: string, scrollDate?: Date): void {
3326
+ if (this.currentView.indexOf('Agenda') < 0 && isNullOrUndefined(this.element.querySelector('.e-work-cells'))) {
3327
+ return;
3328
+ }
3329
+ if (this.activeView.scrollToDate && isNullOrUndefined(hour) && scrollDate) {
3330
+ this.activeView.scrollToDate(scrollDate);
3331
+ } else if (this.activeView.scrollToHour) {
3332
+ this.activeView.scrollToHour(hour, scrollDate);
3333
+ }
3334
+ }
3335
+
3336
+ /**
3337
+ * This method allows scroll to the position of the any resources that available on the scheduler.
3338
+ * This method is applicable for without Agenda and Month agenda views of the schedule.
3339
+ *
3340
+ * @function scrollToResource
3341
+ * @param {string | number} resourceId Accepts the resource id in either string or number type
3342
+ * @param {string} groupName Accepts the name of the resource collection
3343
+ * @returns {void}
3344
+ */
3345
+ public scrollToResource(resourceId: string | number, groupName?: string): void {
3346
+ if (this.resourceBase && this.resourceBase.lastResourceLevel) {
3347
+ this.resourceBase.resourceScroll(resourceId, groupName);
3348
+ }
3349
+ }
3350
+
3351
+ /**
3352
+ * Exports the Scheduler events to a calendar (.ics) file. By default, the calendar is exported with a file name `Calendar.ics`.
3353
+ * To change this file name on export, pass the custom string value as `fileName` to get the file downloaded with this provided name.
3354
+ *
3355
+ * @function exportToICalendar
3356
+ * @param {string} fileName Accepts the string value.
3357
+ * @param {Object[]} customData Accepts the collection of objects.
3358
+ * @returns {void}
3359
+ */
3360
+ public exportToICalendar(fileName?: string, customData?: Record<string, any>[]): void {
3361
+ if (this.iCalendarExportModule) {
3362
+ this.iCalendarExportModule.initializeCalendarExport(fileName, customData);
3363
+ } else {
3364
+ console.warn('[WARNING] :: Module "ICalendarExport" is not available in Schedule component!' +
3365
+ ' You either misspelled the module name or forgot to load it.');
3366
+ throw Error('Inject ICalendarExport module');
3367
+ }
3368
+ }
3369
+
3370
+ /**
3371
+ * Imports the events from an .ics file downloaded from any of the calendars like Google or Outlook into the Scheduler.
3372
+ * This method accepts the blob object or string format of an .ics file to be imported as a mandatory argument.
3373
+ *
3374
+ * @function importICalendar
3375
+ * @param {Blob | string} fileContent Accepts the file object or string format of an .ics file.
3376
+ * @returns {void}
3377
+ */
3378
+ public importICalendar(fileContent: Blob | string): void {
3379
+ if (this.iCalendarImportModule) {
3380
+ this.iCalendarImportModule.initializeCalendarImport(fileContent);
3381
+ } else {
3382
+ console.warn('[WARNING] :: Module "ICalendarImport" is not available in Schedule component!' +
3383
+ ' You either misspelled the module name or forgot to load it.');
3384
+ throw Error('Inject ICalendarImport module');
3385
+ }
3386
+ }
3387
+
3388
+ /**
3389
+ * Adds the newly created event into the Schedule dataSource.
3390
+ *
3391
+ * @function addEvent
3392
+ * @param {Object | Object[]} data Single or collection of event objects to be added into Schedule.
3393
+ * @returns {void}
3394
+ */
3395
+ public addEvent(data: Record<string, any> | Record<string, any>[]): void {
3396
+ this.crudModule.addEvent(data);
3397
+ }
3398
+
3399
+ /**
3400
+ * Generates the occurrences of a single recurrence event based on the provided event.
3401
+ *
3402
+ * @function generateEventOccurrences
3403
+ * @param {Object} event Accepts the parent recurrence event from which the occurrences are generated.
3404
+ * @param {Date} startDate Accepts the start date for the event occurrences. If not provided, the event's start date will be used.
3405
+ * @returns {Object[]} Returns the collection of occurrence event objects.
3406
+ */
3407
+ public generateEventOccurrences(event: Record<string, any>, startDate?: Date): Record<string, any>[] {
3408
+ return (this.eventBase) ? this.eventBase.generateOccurrence(event, startDate) : [];
3409
+ }
3410
+
3411
+ /**
3412
+ * Allows the Scheduler events data to be exported as an Excel file either in .xlsx or .csv file formats.
3413
+ * By default, the whole event collection bound to the Scheduler gets exported as an Excel file.
3414
+ * To export only the specific events of Scheduler, you need to pass the custom data collection as
3415
+ * a parameter to this `exportToExcel` method. This method accepts the export options as arguments such as fileName,
3416
+ * exportType, fields, customData, and includeOccurrences. The `fileName` denotes the name to be given for the exported
3417
+ * file and the `exportType` allows you to set the format of an Excel file to be exported either as .xlsx or .csv.
3418
+ * The custom or specific field collection of event dataSource to be exported can be provided through `fields` option
3419
+ * and the custom data collection can be exported by passing them through the `customData` option. There also exists
3420
+ * option to export each individual instances of the recurring events to an Excel file, by setting true or false to the
3421
+ * `includeOccurrences` option, denoting either to include or exclude the occurrences as separate instances on an exported Excel file.
3422
+ *
3423
+ * @function exportToExcel
3424
+ * @param {ExportOptions} excelExportOptions The export options to be set before start with exporting the Scheduler events to an Excel file.
3425
+ * @returns {void}
3426
+ */
3427
+ public exportToExcel(excelExportOptions?: ExportOptions): void {
3428
+ if (this.excelExportModule) {
3429
+ this.excelExportModule.initializeExcelExport(excelExportOptions);
3430
+ } else {
3431
+ console.warn('[WARNING] :: Module "ExcelExport" is not available in Schedule component!' +
3432
+ ' You either misspelled the module name or forgot to load it.');
3433
+ throw Error('Inject ExcelExport module');
3434
+ }
3435
+ }
3436
+
3437
+ /**
3438
+ * Method allows to print the scheduler.
3439
+ *
3440
+ * @function print
3441
+ * @param {ScheduleModel} printOptions The export options to be set before start with exporting
3442
+ * the Scheduler events to the print window.
3443
+ * @returns {void}
3444
+ */
3445
+ public print(printOptions?: ScheduleModel): void {
3446
+ if (this.printModule) {
3447
+ this.printModule.print(printOptions);
3448
+ } else {
3449
+ console.warn('[WARNING] :: Module "Print" is not available in Schedule component!' +
3450
+ ' You either misspelled the module name or forgot to load it.');
3451
+ throw Error('Inject Print module');
3452
+ }
3453
+ }
3454
+
3455
+ /**
3456
+ * Updates the changes made in the event object by passing it as an parameter into the dataSource.
3457
+ *
3458
+ * @function saveEvent
3459
+ * @param {Object | Object[]} data Single or collection of event objects to be saved into Schedule.
3460
+ * @param {CurrentAction} currentAction Denotes the action that takes place either for editing occurrence or series.
3461
+ * The valid current action names are `EditOccurrence` or `EditSeries`.
3462
+ * @returns {void}
3463
+ */
3464
+ public saveEvent(data: Record<string, any> | Record<string, any>[], currentAction?: CurrentAction): void {
3465
+ this.crudModule.saveEvent(data, currentAction);
3466
+ }
3467
+
3468
+ /**
3469
+ * Deletes the events based on the provided ID or event collection in the argument list.
3470
+ *
3471
+ * @function deleteEvent
3472
+ * @param {string | number | Object | Object[]} id Accepts the ID as string or number type or single or collection of the event object which needs to be removed from the Schedule.
3473
+ * @param {CurrentAction} currentAction Denotes the delete action that takes place either on occurrence or series events.
3474
+ * The valid current action names are `Delete`, `DeleteOccurrence` or `DeleteSeries`.
3475
+ * @returns {void}
3476
+ */
3477
+ public deleteEvent(id: string | number | Record<string, any> | Record<string, any>[], currentAction?: CurrentAction): void {
3478
+ this.crudModule.deleteEvent(id, currentAction);
3479
+ }
3480
+
3481
+ /**
3482
+ * Retrieves the entire collection of events bound to the Schedule.
3483
+ *
3484
+ * @function getEvents
3485
+ * @param {Date} startDate Accepts the start date.
3486
+ * @param {Date} endDate Accepts te end date.
3487
+ * @param {boolean} includeOccurrences Accepts the boolean value to process the occurrence from recurrence series.
3488
+ * @returns {Object[]} Returns the collection of event objects from the Schedule.
3489
+ */
3490
+ public getEvents(startDate?: Date, endDate?: Date, includeOccurrences?: boolean): Record<string, any>[] {
3491
+ let eventCollections: Record<string, any>[] = [];
3492
+ if (includeOccurrences) {
3493
+ eventCollections = this.eventBase.getProcessedEvents();
3494
+ } else {
3495
+ eventCollections = this.eventsData;
3496
+ }
3497
+ if (startDate) {
3498
+ startDate = this.getDateTime(startDate);
3499
+ }
3500
+ if (endDate) {
3501
+ endDate = this.getDateTime(endDate);
3502
+ }
3503
+ eventCollections = this.eventBase.filterEventsByRange(eventCollections, startDate, endDate);
3504
+ return eventCollections;
3505
+ }
3506
+
3507
+ /**
3508
+ * Retrieves the entire collection of block events bound to the Schedule.
3509
+ *
3510
+ * @function getBlockEvents
3511
+ * @param {Date} startDate Accepts the start date.
3512
+ * @param {Date} endDate Accepts te end date.
3513
+ * @param {boolean} includeOccurrences Accepts the boolean value to process the occurrence from recurrence series.
3514
+ * @returns {Object[]} Returns the collection of block event objects from the Schedule.
3515
+ */
3516
+ public getBlockEvents(startDate?: Date, endDate?: Date, includeOccurrences?: boolean): Record<string, any>[] {
3517
+ let eventCollections: Record<string, any>[] = [];
3518
+ if (includeOccurrences) {
3519
+ eventCollections = this.eventBase.getProcessedEvents(this.blockData);
3520
+ } else {
3521
+ eventCollections = this.blockData;
3522
+ }
3523
+ if (startDate) {
3524
+ startDate = this.getDateTime(startDate);
3525
+ }
3526
+ if (endDate) {
3527
+ endDate = this.getDateTime(endDate);
3528
+ }
3529
+ eventCollections = this.eventBase.filterEventsByRange(eventCollections, startDate, endDate);
3530
+ return eventCollections;
3531
+ }
3532
+
3533
+ /**
3534
+ * Retrieves the occurrences of a single recurrence event based on the provided parent ID.
3535
+ *
3536
+ * @function getOccurrencesByID
3537
+ * @param {number} eventID ID of the parent recurrence data from which the occurrences are fetched.
3538
+ * @returns {Object[]} Returns the collection of occurrence event objects.
3539
+ */
3540
+ public getOccurrencesByID(eventID: number | string): Record<string, any>[] {
3541
+ return this.eventBase.getOccurrencesByID(eventID);
3542
+ }
3543
+
3544
+ /**
3545
+ * Retrieves all the occurrences that lies between the specific start and end time range.
3546
+ *
3547
+ * @function getOccurrencesByRange
3548
+ * @param {Date} startTime Denotes the start time range.
3549
+ * @param {Date} endTime Denotes the end time range.
3550
+ * @returns {Object[]} Returns the collection of occurrence event objects that lies between the provided start and end time.
3551
+ */
3552
+ public getOccurrencesByRange(startTime: Date, endTime: Date): Record<string, any>[] {
3553
+ startTime = this.getDateTime(startTime);
3554
+ endTime = this.getDateTime(endTime);
3555
+ return this.eventBase.getOccurrencesByRange(startTime, endTime);
3556
+ }
3557
+
3558
+ /**
3559
+ * Retrieves the dates that lies on active view of Schedule.
3560
+ *
3561
+ * @function getCurrentViewDates
3562
+ * @returns {Date[]} Returns the collection of dates.
3563
+ */
3564
+ public getCurrentViewDates(): Date[] {
3565
+ return this.activeView ? this.activeView.renderDates : [];
3566
+ }
3567
+
3568
+ /**
3569
+ * Set the recurrence editor instance from custom editor template.
3570
+ *
3571
+ * @function setRecurrenceEditor
3572
+ * @param {RecurrenceEditor} recurrenceEditor instance has passed to fetch the instance in event window.
3573
+ * @returns {void}
3574
+ */
3575
+ public setRecurrenceEditor(recurrenceEditor: RecurrenceEditor): void {
3576
+ this.eventWindow.setRecurrenceEditor(recurrenceEditor);
3577
+ }
3578
+
3579
+ /**
3580
+ * Get the maximum id of an event.
3581
+ *
3582
+ * @function getEventMaxID
3583
+ * @returns {number | string} Returns the maximum ID from scheduler data collections.
3584
+ */
3585
+ public getEventMaxID(): number | string {
3586
+ return this.eventBase.getEventMaxID();
3587
+ }
3588
+
3589
+ /**
3590
+ * Get deleted occurrences from given recurrence series.
3591
+ *
3592
+ * @function getDeletedOccurrences
3593
+ * @param {string | number | Object} recurrenceData Accepts the parent ID of the event object or parent event object
3594
+ * @returns {Object[]} Returns the collection of deleted occurrence events.
3595
+ */
3596
+ public getDeletedOccurrences(recurrenceData: string | number | Record<string, any>): Record<string, any>[] {
3597
+ return this.eventBase.getDeletedOccurrences(recurrenceData);
3598
+ }
3599
+
3600
+ /**
3601
+ * Retrieves the events that lies on the current date range of the active view of Schedule.
3602
+ *
3603
+ * @function getCurrentViewEvents
3604
+ * @returns {Object[]} Returns the collection of events.
3605
+ */
3606
+ public getCurrentViewEvents(): Record<string, any>[] {
3607
+ return this.eventsProcessed;
3608
+ }
3609
+
3610
+ /**
3611
+ * Refreshes the event dataSource. This method may be useful when the events alone in the schedule needs to be re-rendered.
3612
+ *
3613
+ * @function refreshEvents
3614
+ * @param {boolean} isRemoteRefresh Accepts the boolean to refresh data from remote or local
3615
+ * @returns {void}
3616
+ */
3617
+ public refreshEvents(isRemoteRefresh: boolean = true): void {
3618
+ if (isRemoteRefresh) {
3619
+ if (this.dragAndDropModule) {
3620
+ this.dragAndDropModule.actionObj.action = '';
3621
+ removeClass([this.element], cls.EVENT_ACTION_CLASS);
3622
+ }
3623
+ this.crudModule.refreshDataManager();
3624
+ } else {
3625
+ if (this.uiStateValues) {
3626
+ this.uiStateValues.isPreventTimezone = true;
3627
+ }
3628
+ if (this.crudModule) {
3629
+ this.crudModule.refreshProcessedData();
3630
+ }
3631
+ if (this.uiStateValues) {
3632
+ this.uiStateValues.isPreventTimezone = false;
3633
+ }
3634
+ }
3635
+ }
3636
+
3637
+ /**
3638
+ * Method to refresh the given Schedule templates
3639
+ *
3640
+ * @param {string} templateName Accepts the template name
3641
+ * @returns {void}
3642
+ */
3643
+ public refreshTemplates(templateName?: string): void {
3644
+ if (templateName) {
3645
+ this.resetTemplates([templateName]);
3646
+ } else {
3647
+ this.resetTemplates();
3648
+ }
3649
+ switch (templateName) {
3650
+ case 'eventTemplate':
3651
+ this.appointmentTemplateFn = this.templateParser(this.activeViewOptions.eventTemplate);
3652
+ this.refreshEvents(false);
3653
+ break;
3654
+ case 'dateHeaderTemplate':
3655
+ this.dateHeaderTemplateFn = this.templateParser(this.activeViewOptions.dateHeaderTemplate);
3656
+ this.activeView.refreshHeader();
3657
+ break;
3658
+ case 'dateRangeTemplate':
3659
+ this.dateRangeTemplateFn = this.templateParser(this.activeViewOptions.dateRangeTemplate);
3660
+ if (this.headerModule) {
3661
+ this.headerModule.refresh();
3662
+ }
3663
+ break;
3664
+ case 'resourceHeaderTemplate':
3665
+ this.resourceHeaderTemplateFn = this.templateParser(this.activeViewOptions.resourceHeaderTemplate);
3666
+ if (this.activeView.isTimelineView()) {
3667
+ this.activeView.refreshResourceHeader();
3668
+ } else {
3669
+ this.activeView.refreshHeader();
3670
+ }
3671
+ break;
3672
+ case 'quickInfoTemplates':
3673
+ if (this.quickPopup) {
3674
+ this.quickPopup.destroy();
3675
+ this.quickPopup = null;
3676
+ }
3677
+ this.quickPopup = new QuickPopups(this);
3678
+ this.quickInfoTemplatesHeaderFn = this.templateParser(this.quickInfoTemplates.header);
3679
+ this.quickInfoTemplatesContentFn = this.templateParser(this.quickInfoTemplates.content);
3680
+ this.quickInfoTemplatesFooterFn = this.templateParser(this.quickInfoTemplates.footer);
3681
+ break;
3682
+ case 'editorTemplate':
3683
+ this.destroyEditorWindow();
3684
+ this.editorTemplateFn = this.templateParser(this.editorTemplate);
3685
+ break;
3686
+ case 'editorHeaderTemplate':
3687
+ this.destroyEditorWindow();
3688
+ this.editorHeaderTemplateFn = this.templateParser(this.editorHeaderTemplate);
3689
+ break;
3690
+ case 'editorFooterTemplate':
3691
+ this.destroyEditorWindow();
3692
+ this.editorFooterTemplateFn = this.templateParser(this.editorFooterTemplate);
3693
+ break;
3694
+ case 'tooltipTemplate':
3695
+ case 'headerTooltipTemplate':
3696
+ if (this.eventTooltip) {
3697
+ this.eventTooltip.destroy();
3698
+ this.eventTooltip = null;
3699
+ }
3700
+ this.eventTooltip = new EventTooltip(this);
3701
+ this.eventTooltipTemplateFn = this.templateParser(this.eventSettings.tooltipTemplate);
3702
+ this.headerTooltipTemplateFn = this.templateParser(this.activeViewOptions.group.headerTooltipTemplate);
3703
+ break;
3704
+ default:
3705
+ this.initializeView(this.currentView);
3706
+ break;
3707
+ }
3708
+ }
3709
+
3710
+ /**
3711
+ * Refreshes the Schedule layout without re-render.
3712
+ *
3713
+ * @function refreshLayout
3714
+ * @returns {void}
3715
+ */
3716
+ public refreshLayout(): void {
3717
+ this.onScheduleResize();
3718
+ if (this.headerModule) {
3719
+ this.headerModule.refresh();
3720
+ }
3721
+ if (this.eventWindow) {
3722
+ this.eventWindow.refresh();
3723
+ }
3724
+ }
3725
+
3726
+ /**
3727
+ * To retrieve the appointment object from element.
3728
+ *
3729
+ * @function getEventDetails
3730
+ * @param {Element} element Denotes the event UI element on the Schedule.
3731
+ * @returns {Object} Returns the event details.
3732
+ */
3733
+ public getEventDetails(element: Element): Record<string, any> {
3734
+ element = getElement(element);
3735
+ const guid: string = element.getAttribute('data-guid');
3736
+ if (guid) {
3737
+ return this.eventBase.getEventByGuid(guid);
3738
+ }
3739
+ return {};
3740
+ }
3741
+
3742
+ /**
3743
+ * To check whether the given time range slots are available for event creation or already occupied by other events.
3744
+ * This method currently focuses on validating appointments within the current view date range.
3745
+ * However, it does not extend this availability check to recurrence occurrences outside of the current date range.
3746
+ *
3747
+ * @function isSlotAvailable
3748
+ * @param {Date | Object} startTime Denotes the start time of the slot.
3749
+ * @param {Date} endTime Denotes the end time of the slot.
3750
+ * @param {number} groupIndex Defines the resource index from last level.
3751
+ * @returns {boolean} Returns true, if the slot that lies in the provided time range does not contain any other events.
3752
+ */
3753
+ public isSlotAvailable(startTime: Date | Record<string, any>, endTime?: Date, groupIndex?: number): boolean {
3754
+ let eventStart: Date;
3755
+ let eventEnd: Date;
3756
+ let eventObj: Record<string, any> = this.activeEventData.event as Record<string, any>;
3757
+ if (startTime instanceof Date || typeof (startTime) === 'string') {
3758
+ eventStart = startTime as Date;
3759
+ eventEnd = endTime;
3760
+ } else {
3761
+ eventObj = startTime as Record<string, any>;
3762
+ eventStart = (<Record<string, any>>startTime)[this.eventFields.startTime] as Date;
3763
+ eventEnd = (<Record<string, any>>startTime)[this.eventFields.endTime] as Date;
3764
+ if (this.resourceBase) {
3765
+ groupIndex = this.eventBase.getGroupIndexFromEvent(startTime as Record<string, any>);
3766
+ }
3767
+ }
3768
+ if (isNullOrUndefined(eventStart) || isNullOrUndefined(eventEnd)) {
3769
+ return true;
3770
+ }
3771
+ eventStart = this.getDateTime(eventStart);
3772
+ eventEnd = this.getDateTime(eventEnd);
3773
+ let eventCollection: Record<string, any>[] = this.eventBase.filterEvents(eventStart, eventEnd);
3774
+ if (!isNullOrUndefined(groupIndex) && this.resourceBase && this.resourceBase.lastResourceLevel.length > 0) {
3775
+ eventCollection =
3776
+ this.eventBase.filterEventsByResource(this.resourceBase.lastResourceLevel[parseInt(groupIndex.toString(), 10)],
3777
+ eventCollection);
3778
+ }
3779
+ if (eventObj) {
3780
+ if (eventObj.Guid) {
3781
+ eventCollection = eventCollection.filter((event: Record<string, any>) => event.Guid !== eventObj.Guid);
3782
+ } else {
3783
+ eventCollection = eventCollection.filter((event: Record<string, any>) =>
3784
+ event[this.eventFields.id] !== eventObj[this.eventFields.id]);
3785
+ }
3786
+ }
3787
+ return (eventCollection.length > 0) ? false : true;
3788
+ }
3789
+
3790
+ /**
3791
+ * Method to copy events from an HTMLElement or an array of HTMLElements.
3792
+ *
3793
+ * @param { HTMLElement[] } elements Accepts an array of HTMLElement
3794
+ * @returns {void} This method does not return a value.
3795
+ */
3796
+ public copy(elements: HTMLElement[]): void {
3797
+ this.processCutCopyActions(elements, false);
3798
+ }
3799
+
3800
+ /**
3801
+ * Method to cut events from an HTMLElement or an array of HTMLElements.
3802
+ *
3803
+ * @param { HTMLElement[] } elements Accepts an array of HTMLElement
3804
+ * @returns {void} This method does not return a value.
3805
+ */
3806
+ public cut(elements: HTMLElement[]): void {
3807
+ this.processCutCopyActions(elements, true);
3808
+ }
3809
+
3810
+ /**
3811
+ * Method to create a paste event with clipboard data
3812
+ *
3813
+ * @param { HTMLElement } targetElement Accepts HTMLElement
3814
+ * @returns {void}
3815
+ */
3816
+ public paste(targetElement: HTMLElement): void {
3817
+ if (!this.allowClipboard || !this.allowKeyboardInteraction || !targetElement) {
3818
+ return;
3819
+ }
3820
+ if (!targetElement.classList.contains('e-work-cells') && !targetElement.classList.contains('e-all-day-cells')) {
3821
+ return;
3822
+ }
3823
+ if (!this.activeCellsData) {
3824
+ const cellData: CellClickEventArgs = this.getCellDetails([targetElement]);
3825
+ if (cellData) {
3826
+ this.activeCellsData = cellData;
3827
+ }
3828
+ }
3829
+ const clipboardData: DataTransfer = new DataTransfer();
3830
+ if (!isNullOrUndefined((navigator as any).clipboard)) {
3831
+ (navigator as any).clipboard.readText()
3832
+ .then((text: string) => {
3833
+ clipboardData.setData('text/plain', text);
3834
+ const pasteEvent: ClipboardEvent = new ClipboardEvent('paste', {
3835
+ bubbles: true,
3836
+ cancelable: true
3837
+ });
3838
+ Object.defineProperty(pasteEvent, 'clipboardData', {
3839
+ value: clipboardData
3840
+ });
3841
+ this.keyboardInteractionModule.pasteHandler(pasteEvent, targetElement);
3842
+ })
3843
+ .catch((err: Error) => {
3844
+ throw err;
3845
+ });
3846
+ }
3847
+ }
3848
+
3849
+ private processCutCopyActions(elements: HTMLElement[], isCut: boolean): void {
3850
+ if (!elements || !this.allowClipboard || !this.allowKeyboardInteraction) {
3851
+ return;
3852
+ }
3853
+ const elementArray: HTMLElement[] = elements;
3854
+ const eventDetailsArray: Record<string, any>[] = [];
3855
+ elementArray.forEach((element: HTMLElement) => {
3856
+ if (element.classList.contains(cls.APPOINTMENT_CLASS)) {
3857
+ const eventDetail: Record<string, any> = this.getEventDetails(element);
3858
+ if (eventDetail) {
3859
+ eventDetailsArray.push(eventDetail);
3860
+ }
3861
+ }
3862
+ });
3863
+ if (eventDetailsArray.length > 0) {
3864
+ this.keyboardInteractionModule.processClipboardAction(isCut, eventDetailsArray);
3865
+ }
3866
+ }
3867
+
3868
+ /**
3869
+ * To manually open the event editor on specific time or on certain events.
3870
+ *
3871
+ * @function openEditor
3872
+ * @param {Object} data It can be either cell data or event data.
3873
+ * @param {CurrentAction} action Defines the action for which the editor needs to be opened such as either for new event creation or
3874
+ * for editing of existing events. The applicable action names that can be used here are `Add`, `Save`, `EditOccurrence`
3875
+ * and `EditSeries`.
3876
+ * @param {boolean} isEventData It allows to decide whether the editor needs to be opened with the clicked cell details or with the
3877
+ * passed event details.
3878
+ * @param {number} repeatType It opens the editor with the recurrence options based on the provided repeat type.
3879
+ * @returns {void}
3880
+ */
3881
+ public openEditor(data: Record<string, any>, action: CurrentAction, isEventData?: boolean, repeatType?: number): void {
3882
+ if (action === 'Add' && !isEventData) {
3883
+ data.startTime = this.getDateTime(<Date>data.startTime);
3884
+ data.endTime = this.getDateTime(<Date>data.endTime);
3885
+ if (!isNullOrUndefined(data.element)) {
3886
+ data.element = getElement(data.element as HTMLElement);
3887
+ }
3888
+ } else {
3889
+ data[this.eventFields.startTime] = this.getDateTime(<Date>data[this.eventFields.startTime]);
3890
+ data[this.eventFields.endTime] = this.getDateTime(<Date>data[this.eventFields.endTime]);
3891
+ }
3892
+ this.currentAction = action;
3893
+ if (action !== 'Add') {
3894
+ this.activeEventData.event = data as Record<string, any>;
3895
+ }
3896
+ this.eventWindow.openEditor(data, action, isEventData, repeatType);
3897
+ }
3898
+
3899
+ /**
3900
+ * To manually close the event editor window
3901
+ *
3902
+ * @function closeEditor
3903
+ * @returns {void}
3904
+ */
3905
+ public closeEditor(): void {
3906
+ if (this.eventWindow) {
3907
+ this.eventWindow.dialogClose();
3908
+ }
3909
+ }
3910
+
3911
+ /**
3912
+ * To manually open the quick info popup based on cell or event details.
3913
+ *
3914
+ * @param {object} data Defines the cell or event data. If the data contains valid ID, it will open event quick info popup,
3915
+ * otherwise cell quick info popup displayed.
3916
+ * @returns {void}
3917
+ */
3918
+ public openQuickInfoPopup(data: Record<string, any>): void {
3919
+ if (this.currentView === 'Year' || isNullOrUndefined(data)) {
3920
+ return;
3921
+ }
3922
+ if (isNullOrUndefined(data[this.eventFields.id])) {
3923
+ if (this.currentView === 'Agenda' || this.currentView === 'MonthAgenda' || isNullOrUndefined(this.activeView)) {
3924
+ return;
3925
+ }
3926
+ const cellData: CellClickEventArgs = {
3927
+ startTime: this.activeCellsData.startTime = this.getDateTime(<Date>data[this.eventFields.startTime]),
3928
+ endTime: this.activeCellsData.endTime = this.getDateTime(<Date>data[this.eventFields.endTime]),
3929
+ isAllDay: this.activeCellsData.isAllDay =
3930
+ !isNullOrUndefined(data[this.eventFields.isAllDay]) ? data[this.eventFields.isAllDay] : false
3931
+ };
3932
+ const startTime: Date = this.activeView.getAdjustedDate(new Date(cellData.startTime));
3933
+ if (startTime) {
3934
+ let query: string = '.' + cls.WORK_CELLS_CLASS + '[data-date="' + startTime.getTime() + '"]';
3935
+ if (this.activeViewOptions.group.resources.length > 0 && !this.uiStateValues.isGroupAdaptive
3936
+ && this.resourceBase && this.eventBase) {
3937
+ cellData.groupIndex = this.eventBase.getGroupIndexFromEvent(data as Record<string, any>);
3938
+ query = '.' + cls.WORK_CELLS_CLASS + '[data-date="' + startTime.getTime() + '"][data-group-index="' + cellData.groupIndex + '"]';
3939
+ }
3940
+ const workCell: HTMLElement = this.element.querySelector(query);
3941
+ if (workCell) {
3942
+ workCell.focus();
3943
+ cellData.element = workCell;
3944
+ this.notify(events.cellClick, cellData);
3945
+ }
3946
+ }
3947
+ }
3948
+ else {
3949
+ const app: Record<string, any>[] = this.getCurrentViewEvents().filter((item: Record<string, any>) =>
3950
+ data[this.eventFields.id] === item[this.eventFields.id]);
3951
+ if (app.length <= 0) {
3952
+ return;
3953
+ }
3954
+ let selectEvent: Record<string, any> = app[0];
3955
+ if (data[this.eventFields.recurrenceRule]) {
3956
+ const occurence: Record<string, any> = app.filter((x: Record<string, any>) =>
3957
+ x[this.eventFields.startTime].getTime() === data[this.eventFields.startTime].getTime());
3958
+ if (occurence.length > 0) {
3959
+ selectEvent = occurence[0];
3960
+ }
3961
+ }
3962
+ const element: HTMLElement = this.element.querySelector('div[data-guid="' + selectEvent.Guid + '"]');
3963
+ if (element) {
3964
+ this.eventBase.removeSelectedAppointmentClass();
3965
+ this.eventBase.addSelectedAppointments([element], false);
3966
+ this.activeEventData = { event: selectEvent, element: element } as EventClickArgs;
3967
+ if (this.currentView === 'Agenda' || this.currentView === 'MonthAgenda') {
3968
+ addClass([this.activeEventData.element as Element], cls.AGENDA_SELECTED_CELL);
3969
+ }
3970
+ this.notify(events.eventClick, this.activeEventData);
3971
+ }
3972
+ }
3973
+ }
3974
+
3975
+ /**
3976
+ * To manually close the quick info popup
3977
+ *
3978
+ * @function closeQuickInfoPopup
3979
+ * @returns {void}
3980
+ */
3981
+ public closeQuickInfoPopup(): void {
3982
+ if (this.quickPopup) {
3983
+ this.quickPopup.quickPopupHide(true);
3984
+ }
3985
+ }
3986
+
3987
+ /**
3988
+ * To manually open the overlap validation Alert.
3989
+ *
3990
+ * @param {PopupOpenEventArgs} args The arguments for opening the popup.
3991
+ * @param {string} args.type Defines the type of overlap alert (e.g., 'OverlapAlert').
3992
+ * @param {Record<string, any>} args.data The data associated with the popup.
3993
+ * @param {Record<string, any>[]} args.overlapEvents The overlap events.
3994
+ * @returns {void}
3995
+ */
3996
+ public openOverlapAlert(args: PopupOpenEventArgs): void {
3997
+ if (this.quickPopup) {
3998
+ const eventProp: PopupOpenEventArgs = {
3999
+ type: 'OverlapAlert',
4000
+ cancel: false,
4001
+ element: this.quickPopup.quickDialog.element,
4002
+ data: args.data,
4003
+ overlapEvents: args.overlapEvents
4004
+ };
4005
+ this.trigger(events.popupOpen, eventProp, (popupArgs: PopupOpenEventArgs) => {
4006
+ if (!popupArgs.cancel) {
4007
+ this.quickPopup.openValidationError('overlapAlert', args.data);
4008
+ }
4009
+ });
4010
+ }
4011
+ }
4012
+
4013
+ /**
4014
+ * To manually close the overlap validation Alert.
4015
+ *
4016
+ * @function closeOverlapValidationAlert
4017
+ * @returns {void}
4018
+ */
4019
+ public closeOverlapAlert(): void {
4020
+ if (this.quickPopup) {
4021
+ const args: PopupCloseEventArgs = {
4022
+ type: 'OverlapAlert',
4023
+ cancel: false,
4024
+ data: this.activeEventData.event,
4025
+ element: this.quickPopup.quickDialog.element
4026
+ };
4027
+ this.trigger(events.popupClose, args, (popupArgs: PopupCloseEventArgs) => {
4028
+ if (!popupArgs.cancel) {
4029
+ this.quickPopup.quickDialog.hide();
4030
+ }
4031
+ });
4032
+ }
4033
+ }
4034
+
4035
+ /**
4036
+ * Closes the tooltip.
4037
+ * For example, when the context menu is opened for an event,
4038
+ * the tooltip can be closed by calling this method.
4039
+ *
4040
+ * @function closeTooltip
4041
+ * @returns {void}
4042
+ */
4043
+ public closeTooltip(): void {
4044
+ if (this.eventTooltip) {
4045
+ this.eventTooltip.close();
4046
+ }
4047
+ }
4048
+
4049
+ /**
4050
+ * Retrieves a formatted string representing the date range of the given date collection.
4051
+ *
4052
+ * @param {Date[]} dates - An array of Date objects representing the date range.
4053
+ * @returns {string} A formatted string describing the date range.
4054
+ * If the dates is empty, returns an empty string.
4055
+ * Otherwise, delegates to the active view to generate the appropriate date range text.
4056
+ *
4057
+ * @example
4058
+ * // Assuming dates contains dates from May 1, 2023 to May 7, 2023
4059
+ * const rangeText = schedule.getDateRangeText(schedule.getViewDates());
4060
+ * // rangeText might be "May 1 - 7, 2023" (actual format depends on the active view)
4061
+ *
4062
+ * @remarks
4063
+ * The actual format of the returned string depends on the implementation
4064
+ * of the getDateRangeText method in the active view.
4065
+ */
4066
+ public getDateRangeText(dates: Date[]): string {
4067
+ if ((isNullOrUndefined(dates) && dates.length === 0) || !this.activeView) {
4068
+ return '';
4069
+ }
4070
+ return this.activeView.getDateRangeText(dates[0], dates);
4071
+ }
4072
+
4073
+ /**
4074
+ * Retrieves an array of dates based on the specified date collection direction.
4075
+ *
4076
+ * @param {NavigationDirection} type - The direction for date collection. Options are:
4077
+ * - 'Previous': Returns the previous date range collection from the current rendered date.
4078
+ * - 'Next': Returns the next date range collection from the current rendered date.
4079
+ * - 'Current': Returns the current rendered date collection.
4080
+ *
4081
+ * @returns {Date[]} An array of Date objects representing the view dates.
4082
+ */
4083
+ public getViewDates(type: NavigationDirection = 'Current'): Date[] {
4084
+ if (!this.activeView) {
4085
+ return [];
4086
+ }
4087
+ switch (type) {
4088
+ case 'Previous':
4089
+ case 'Next':
4090
+ return this.activeView.getRenderDates(undefined, this.activeView.getNextPreviousDate(type));
4091
+ case 'Current':
4092
+ return this.getCurrentViewDates();
4093
+ }
4094
+ }
4095
+
4096
+ /**
4097
+ * Select the resource based on group index in mobile mode.
4098
+ *
4099
+ * @param {number} groupIndex Defines the resource index based on last level.
4100
+ * @returns {void}
4101
+ */
4102
+ public selectResourceByIndex(groupIndex: number): void {
4103
+ if (this.resourceBase && this.uiStateValues.isGroupAdaptive) {
4104
+ this.resourceBase.selectResourceByIndex(groupIndex);
4105
+ }
4106
+ }
4107
+
4108
+ /**
4109
+ * Select the resources to the based on id.
4110
+ *
4111
+ * @param {string | number} id id of the resource defined in resources collection.
4112
+ * @param {string} name Name of the resource defined in resources collection.
4113
+ * @returns {number} Returns the group index
4114
+ */
4115
+ public getIndexFromResourceId(id: string | number, name?: string): number {
4116
+ if (this.resourceBase) {
4117
+ return this.resourceBase.getIndexFromResourceId(id, name);
4118
+ }
4119
+ return null;
4120
+ }
4121
+
4122
+ /**
4123
+ * Adds the resources to the specified index.
4124
+ *
4125
+ * @param {Object | Object[]} resources Accepts the resource data in single or collection of data.
4126
+ * @param {string} name Name of the resource defined in resources collection.
4127
+ * @param {number} index Index or position where the resource should be added.
4128
+ * @returns {void}
4129
+ */
4130
+ public addResource(resources: Record<string, any> | Record<string, any>[], name: string, index: number): void {
4131
+ this.resourceBase.addResource(resources, name, index);
4132
+ }
4133
+
4134
+ /**
4135
+ * Removes the specified resource.
4136
+ *
4137
+ * @param {string | string[] | number | number[]} resourceId Specifies the resource id to be removed.
4138
+ * @param {string} name Specifies the resource name from which the id should be referred.
4139
+ * @returns {void}
4140
+ */
4141
+ public removeResource(resourceId: string | string[] | number | number[], name: string): void {
4142
+ this.resourceBase.removeResource(resourceId, name);
4143
+ }
4144
+
4145
+ /**
4146
+ * Destroys the Schedule component.
4147
+ *
4148
+ * @function destroy
4149
+ * @returns {void}
4150
+ */
4151
+ public destroy(): void {
4152
+ if (this.eventTooltip) {
4153
+ this.eventTooltip.destroy();
4154
+ this.eventTooltip = null;
4155
+ }
4156
+ this.destroyPopups();
4157
+ this.hideSpinner();
4158
+ this.unWireEvents();
4159
+ this.destroyHeaderModule();
4160
+ if (this.eventBase) {
4161
+ this.eventBase.destroy();
4162
+ this.eventBase = null;
4163
+ }
4164
+ if (this.workCellAction) {
4165
+ this.workCellAction.destroy();
4166
+ this.workCellAction = null;
4167
+ }
4168
+ if (this.inlineModule) {
4169
+ this.inlineModule.destroy();
4170
+ this.inlineModule = null;
4171
+ }
4172
+ if (this.keyboardInteractionModule) {
4173
+ this.keyboardInteractionModule.destroy();
4174
+ this.keyboardInteractionModule = null;
4175
+ }
4176
+ if (this.scrollModule) {
4177
+ this.scrollModule.destroy();
4178
+ this.scrollModule = null;
4179
+ }
4180
+ if (this.printModule) {
4181
+ this.printModule.destroy();
4182
+ }
4183
+ if (this.activeView) {
4184
+ this.resetTemplates();
4185
+ this.activeView.removeEventListener();
4186
+ this.activeView.destroy();
4187
+ this.activeView = null;
4188
+ }
4189
+ if (this.scheduleTouchModule) {
4190
+ this.scheduleTouchModule.destroy();
4191
+ this.scheduleTouchModule = null;
4192
+ }
4193
+ if (this.crudModule) {
4194
+ this.crudModule.destroy();
4195
+ this.crudModule = null;
4196
+ }
4197
+ if (this.dataModule) {
4198
+ this.dataModule.destroy();
4199
+ this.dataModule = null;
4200
+ }
4201
+ super.destroy();
4202
+ const modules: string[] = [
4203
+ 'dayModule', 'weekModule', 'workWeekModule', 'monthModule', 'monthAgendaModule', 'yearModule', 'agendaModule',
4204
+ 'timelineViewsModule', 'timelineMonthModule', 'timelineYearModule', 'resizeModule', 'dragAndDropModule',
4205
+ 'excelExportModule', 'printModule', 'iCalendarExportModule', 'iCalendarImportModule', 'tzModule', 'eventsData',
4206
+ 'eventsProcessed', 'blockData', 'blockProcessed', 'uiStateValues', 'viewCollections', 'viewOptions', 'defaultLocale',
4207
+ 'localeObj', 'selectedElements', 'resourceCollection', 'editorTitles', 'eventFields', 'activeViewOptions',
4208
+ 'activeEventData', 'activeCellsData', 'renderModule'
4209
+ ];
4210
+ for (const module of modules) {
4211
+ (this as any)[`${module}`] = null;
4212
+ }
4213
+ util.removeChildren(this.element);
4214
+ let removeClasses: string[] = [cls.ROOT, cls.RTL, cls.DEVICE_CLASS, cls.MULTI_DRAG];
4215
+ if (this.cssClass) {
4216
+ removeClasses = removeClasses.concat(this.cssClass.split(' '));
4217
+ }
4218
+ removeClass([this.element], removeClasses);
4219
+ }
4220
+
4221
+ }