react-big-schedule 4.2.5 → 4.3.0

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.
@@ -1,1157 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _dayjs = _interopRequireDefault(require("dayjs"));
8
- var _quarterOfYear = _interopRequireDefault(require("dayjs/plugin/quarterOfYear"));
9
- var _utc = _interopRequireDefault(require("dayjs/plugin/utc"));
10
- var _weekday = _interopRequireDefault(require("dayjs/plugin/weekday"));
11
- var _rrule = require("rrule");
12
- var _scheduler = _interopRequireDefault(require("../config/scheduler"));
13
- var _behaviors = _interopRequireDefault(require("../helper/behaviors"));
14
- var _index = require("./index");
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
17
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
20
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
22
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
23
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
24
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
25
- var SchedulerData = /*#__PURE__*/function () {
26
- function SchedulerData() {
27
- var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _dayjs["default"])();
28
- var viewType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _index.ViewType.Week;
29
- var showAgenda = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
30
- var isEventPerspective = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
31
- var newConfig = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
32
- var newBehaviors = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : undefined;
33
- _classCallCheck(this, SchedulerData);
34
- this.resources = [];
35
- this.events = [];
36
- this.eventGroups = [];
37
- this.eventGroupsAutoGenerated = true;
38
- this.viewType = viewType;
39
- this.cellUnit = viewType === _index.ViewType.Day ? _index.CellUnit.Hour : _index.CellUnit.Day;
40
- this.showAgenda = showAgenda;
41
- this.isEventPerspective = isEventPerspective;
42
- this.resizing = false;
43
- this.scrollToSpecialDayjs = false;
44
- this.documentWidth = 0;
45
- this._shouldReloadViewType = false;
46
- this.calendarPopoverLocale = undefined;
47
- _dayjs["default"].extend(_quarterOfYear["default"]);
48
- _dayjs["default"].extend(_weekday["default"]);
49
- _dayjs["default"].extend(_utc["default"]);
50
- this.localeDayjs = _dayjs["default"];
51
- this.config = newConfig == undefined ? _scheduler["default"] : _objectSpread(_objectSpread({}, _scheduler["default"]), newConfig);
52
- this._validateMinuteStep(this.config.minuteStep);
53
- this.behaviors = newBehaviors == undefined ? _behaviors["default"] : _objectSpread(_objectSpread({}, _behaviors["default"]), newBehaviors);
54
- this._resolveDate(0, date);
55
- this._createHeaders();
56
- this._createRenderData();
57
- }
58
- _createClass(SchedulerData, [{
59
- key: "setSchedulerLocale",
60
- value: function setSchedulerLocale(preset) {
61
- if (!preset) return;
62
- this.localeDayjs.locale(preset);
63
- this._shouldReloadViewType = true;
64
- this.setViewType(this.viewType, this.showAgenda, this.isEventPerspective);
65
- }
66
- }, {
67
- key: "setCalendarPopoverLocale",
68
- value: function setCalendarPopoverLocale(lang) {
69
- if (!!lang) {
70
- this.calendarPopoverLocale = lang;
71
- }
72
- }
73
- }, {
74
- key: "setResources",
75
- value: function setResources(resources) {
76
- this._validateResource(resources);
77
- this.resources = Array.from(new Set(resources));
78
- this._createRenderData();
79
- this.setScrollToSpecialDayjs(true);
80
- }
81
- }, {
82
- key: "setEventGroupsAutoGenerated",
83
- value: function setEventGroupsAutoGenerated(autoGenerated) {
84
- this.eventGroupsAutoGenerated = autoGenerated;
85
- }
86
-
87
- //optional
88
- }, {
89
- key: "setEventGroups",
90
- value: function setEventGroups(eventGroups) {
91
- this._validateEventGroups(eventGroups);
92
- this.eventGroups = Array.from(new Set(eventGroups));
93
- this.eventGroupsAutoGenerated = false;
94
- this._createRenderData();
95
- this.setScrollToSpecialDayjs(true);
96
- }
97
- }, {
98
- key: "setMinuteStep",
99
- value: function setMinuteStep(minuteStep) {
100
- if (this.config.minuteStep !== minuteStep) {
101
- this._validateMinuteStep(minuteStep);
102
- this.config.minuteStep = minuteStep;
103
- this._createHeaders();
104
- this._createRenderData();
105
- }
106
- }
107
- }, {
108
- key: "setBesidesWidth",
109
- value: function setBesidesWidth(besidesWidth) {
110
- if (besidesWidth >= 0) {
111
- this.config.besidesWidth = besidesWidth;
112
- }
113
- }
114
- }, {
115
- key: "getMinuteStepsInHour",
116
- value: function getMinuteStepsInHour() {
117
- return 60 / this.config.minuteStep;
118
- }
119
- }, {
120
- key: "addResource",
121
- value: function addResource(resource) {
122
- var existedResources = this.resources.filter(function (x) {
123
- return x.id === resource.id;
124
- });
125
- if (existedResources.length === 0) {
126
- this.resources.push(resource);
127
- this._createRenderData();
128
- }
129
- }
130
- }, {
131
- key: "addEventGroup",
132
- value: function addEventGroup(eventGroup) {
133
- var existedEventGroups = this.eventGroups.filter(function (x) {
134
- return x.id === eventGroup.id;
135
- });
136
- if (existedEventGroups.length === 0) {
137
- this.eventGroups.push(eventGroup);
138
- this._createRenderData();
139
- }
140
- }
141
- }, {
142
- key: "removeEventGroupById",
143
- value: function removeEventGroupById(eventGroupId) {
144
- var index = -1;
145
- this.eventGroups.forEach(function (item, idx) {
146
- if (item.id === eventGroupId) index = idx;
147
- });
148
- if (index !== -1) this.eventGroups.splice(index, 1);
149
- }
150
- }, {
151
- key: "containsEventGroupId",
152
- value: function containsEventGroupId(eventGroupId) {
153
- var index = -1;
154
- this.eventGroups.forEach(function (item, idx) {
155
- if (item.id === eventGroupId) index = idx;
156
- });
157
- return index !== -1;
158
- }
159
- }, {
160
- key: "setEvents",
161
- value: function setEvents(events) {
162
- this._validateEvents(events);
163
- this.events = Array.from(events);
164
- if (this.eventGroupsAutoGenerated) this._generateEventGroups();
165
- if (this.config.recurringEventsEnabled) this._handleRecurringEvents();
166
- this._createRenderData();
167
- }
168
- }, {
169
- key: "setScrollToSpecialDayjs",
170
- value: function setScrollToSpecialDayjs(scrollToSpecialDayjs) {
171
- if (this.config.scrollToSpecialDayjsEnabled) this.scrollToSpecialDayjs = scrollToSpecialDayjs;
172
- }
173
- }, {
174
- key: "prev",
175
- value: function prev() {
176
- this._resolveDate(-1);
177
- this.events = [];
178
- this._createHeaders();
179
- this._createRenderData();
180
- }
181
- }, {
182
- key: "next",
183
- value: function next() {
184
- this._resolveDate(1);
185
- this.events = [];
186
- this._createHeaders();
187
- this._createRenderData();
188
- }
189
- }, {
190
- key: "setDate",
191
- value: function setDate() {
192
- var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _dayjs["default"])(new Date());
193
- this._resolveDate(0, date);
194
- this.events = [];
195
- this._createHeaders();
196
- this._createRenderData();
197
- }
198
- }, {
199
- key: "setViewType",
200
- value: function setViewType() {
201
- var viewType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _index.ViewType.Week;
202
- var showAgenda = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
203
- var isEventPerspective = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
204
- this.showAgenda = showAgenda;
205
- this.isEventPerspective = isEventPerspective;
206
- this.cellUnit = _index.CellUnit.Day;
207
- if (this.viewType !== viewType || this._shouldReloadViewType) {
208
- var date = this.startDate;
209
- if (viewType === _index.ViewType.Custom || viewType === _index.ViewType.Custom1 || viewType === _index.ViewType.Custom2) {
210
- this.viewType = viewType;
211
- this._resolveDate(0, date);
212
- } else {
213
- if (this.viewType < viewType) {
214
- if (viewType === _index.ViewType.Week) {
215
- this.startDate = this.localeDayjs(new Date(date)).startOf('week');
216
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('week');
217
- } else if (viewType === _index.ViewType.Month) {
218
- this.startDate = this.localeDayjs(new Date(date)).startOf('month');
219
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('month');
220
- } else if (viewType === _index.ViewType.Quarter) {
221
- this.startDate = this.localeDayjs(new Date(date)).startOf('quarter');
222
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('quarter');
223
- } else if (viewType === _index.ViewType.Year) {
224
- this.startDate = this.localeDayjs(new Date(date)).startOf('year');
225
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('year');
226
- }
227
- } else {
228
- var start = this.localeDayjs(new Date(this.startDate));
229
- var end = this.localeDayjs(new Date(this.endDate)).add(1, 'days');
230
- if (this.selectDate !== undefined) {
231
- var selectDate = this.localeDayjs(new Date(this.selectDate));
232
- if (selectDate >= start && selectDate < end) {
233
- date = this.selectDate;
234
- }
235
- }
236
- var now = this.localeDayjs();
237
- if (now >= start && now < end) {
238
- date = now.startOf('day');
239
- }
240
- if (viewType === _index.ViewType.Day) {
241
- this.startDate = date;
242
- this.endDate = this.startDate;
243
- this.cellUnit = _index.CellUnit.Hour;
244
- } else if (viewType === _index.ViewType.Week) {
245
- this.startDate = this.localeDayjs(new Date(date)).startOf('week');
246
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('week');
247
- } else if (viewType === _index.ViewType.Month) {
248
- this.startDate = this.localeDayjs(new Date(date)).startOf('month');
249
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('month');
250
- } else if (viewType === _index.ViewType.Quarter) {
251
- this.startDate = this.localeDayjs(new Date(date)).startOf('quarter');
252
- this.endDate = this.localeDayjs(new Date(this.startDate)).endOf('quarter');
253
- }
254
- }
255
- this.viewType = viewType;
256
- }
257
- this._shouldReloadViewType = false;
258
- this.events = [];
259
- this._createHeaders();
260
- this._createRenderData();
261
- this.setScrollToSpecialDayjs(true);
262
- }
263
- }
264
- }, {
265
- key: "setSchedulerMaxHeight",
266
- value: function setSchedulerMaxHeight(newSchedulerMaxHeight) {
267
- this.config.schedulerMaxHeight = newSchedulerMaxHeight;
268
- }
269
- }, {
270
- key: "isSchedulerResponsive",
271
- value: function isSchedulerResponsive() {
272
- return !!this.config.schedulerWidth.endsWith && this.config.schedulerWidth.endsWith('%');
273
- }
274
- }, {
275
- key: "toggleExpandStatus",
276
- value: function toggleExpandStatus(slotId) {
277
- var slotEntered = false;
278
- var slotIndent = -1;
279
- var isExpanded = false;
280
- var expandedMap = new Map();
281
- this.renderData.forEach(function (item) {
282
- if (slotEntered === false) {
283
- if (item.slotId === slotId && item.hasChildren) {
284
- slotEntered = true;
285
- isExpanded = !item.expanded;
286
- item.expanded = isExpanded;
287
- slotIndent = item.indent;
288
- expandedMap.set(item.indent, {
289
- expanded: item.expanded,
290
- render: item.render
291
- });
292
- }
293
- } else {
294
- if (item.indent > slotIndent) {
295
- var expandStatus = expandedMap.get(item.indent - 1);
296
- item.render = expandStatus.expanded && expandStatus.render;
297
- if (item.hasChildren) {
298
- expandedMap.set(item.indent, {
299
- expanded: item.expanded,
300
- render: item.render
301
- });
302
- }
303
- } else {
304
- slotEntered = false;
305
- }
306
- }
307
- });
308
- }
309
- }, {
310
- key: "isResourceViewResponsive",
311
- value: function isResourceViewResponsive() {
312
- var resourceTableWidth = this.getResourceTableConfigWidth();
313
- return !!resourceTableWidth.endsWith && resourceTableWidth.endsWith('%');
314
- }
315
- }, {
316
- key: "isContentViewResponsive",
317
- value: function isContentViewResponsive() {
318
- var contentCellWidth = this.getContentCellConfigWidth();
319
- return !!contentCellWidth.endsWith && contentCellWidth.endsWith('%');
320
- }
321
- }, {
322
- key: "getSchedulerWidth",
323
- value: function getSchedulerWidth() {
324
- var baseWidth = this.documentWidth - this.config.besidesWidth > 0 ? this.documentWidth - this.config.besidesWidth : 0;
325
- return this.isSchedulerResponsive() ? parseInt(baseWidth * Number(this.config.schedulerWidth.slice(0, -1)) / 100) : this.config.schedulerWidth;
326
- }
327
- }, {
328
- key: "getResourceTableWidth",
329
- value: function getResourceTableWidth() {
330
- var resourceTableConfigWidth = this.getResourceTableConfigWidth();
331
- var schedulerWidth = this.getSchedulerWidth();
332
- var resourceTableWidth = this.isResourceViewResponsive() ? parseInt(schedulerWidth * Number(resourceTableConfigWidth.slice(0, -1)) / 100) : resourceTableConfigWidth;
333
- if (this.isSchedulerResponsive() && this.getContentTableWidth() + resourceTableWidth < schedulerWidth) resourceTableWidth = schedulerWidth - this.getContentTableWidth();
334
- return resourceTableWidth;
335
- }
336
- }, {
337
- key: "getContentCellWidth",
338
- value: function getContentCellWidth() {
339
- var contentCellConfigWidth = this.getContentCellConfigWidth();
340
- var schedulerWidth = this.getSchedulerWidth();
341
- return this.isContentViewResponsive() ? parseInt(schedulerWidth * Number(contentCellConfigWidth.slice(0, -1)) / 100) : contentCellConfigWidth;
342
- }
343
- }, {
344
- key: "getContentTableWidth",
345
- value: function getContentTableWidth() {
346
- return this.headers.length * this.getContentCellWidth();
347
- }
348
- }, {
349
- key: "getScrollToSpecialDayjs",
350
- value: function getScrollToSpecialDayjs() {
351
- if (this.config.scrollToSpecialDayjsEnabled) return this.scrollToSpecialDayjs;
352
- return false;
353
- }
354
- }, {
355
- key: "getSlots",
356
- value: function getSlots() {
357
- return this.isEventPerspective ? this.eventGroups : this.resources;
358
- }
359
- }, {
360
- key: "getSlotById",
361
- value: function getSlotById(slotId) {
362
- var slots = this.getSlots();
363
- var slot = undefined;
364
- slots.forEach(function (item) {
365
- if (item.id === slotId) slot = item;
366
- });
367
- return slot;
368
- }
369
- }, {
370
- key: "getResourceById",
371
- value: function getResourceById(resourceId) {
372
- var resource = undefined;
373
- this.resources.forEach(function (item) {
374
- if (item.id === resourceId) resource = item;
375
- });
376
- return resource;
377
- }
378
- }, {
379
- key: "getTableHeaderHeight",
380
- value: function getTableHeaderHeight() {
381
- return this.config.tableHeaderHeight;
382
- }
383
- }, {
384
- key: "getSchedulerContentDesiredHeight",
385
- value: function getSchedulerContentDesiredHeight() {
386
- var height = 0;
387
- this.renderData.forEach(function (item) {
388
- if (item.render) height += item.rowHeight;
389
- });
390
- return height;
391
- }
392
- }, {
393
- key: "getCellMaxEvents",
394
- value: function getCellMaxEvents() {
395
- return this.viewType === _index.ViewType.Week ? this.config.weekMaxEvents : this.viewType === _index.ViewType.Day ? this.config.dayMaxEvents : this.viewType === _index.ViewType.Month ? this.config.monthMaxEvents : this.viewType === _index.ViewType.Year ? this.config.yearMaxEvents : this.viewType === _index.ViewType.Quarter ? this.config.quarterMaxEvents : this.config.customMaxEvents;
396
- }
397
- }, {
398
- key: "getCalendarPopoverLocale",
399
- value: function getCalendarPopoverLocale() {
400
- return this.calendarPopoverLocale;
401
- }
402
- }, {
403
- key: "getSelectedDate",
404
- value: function getSelectedDate() {
405
- return this.selectDate.format(_index.DATE_FORMAT);
406
- }
407
- }, {
408
- key: "getViewStartDate",
409
- value: function getViewStartDate() {
410
- return this.startDate;
411
- }
412
- }, {
413
- key: "getViewEndDate",
414
- value: function getViewEndDate() {
415
- return this.endDate;
416
- }
417
- }, {
418
- key: "getViewDates",
419
- value: function getViewDates() {
420
- return {
421
- startDate: this.startDate,
422
- endDate: this.endDate
423
- };
424
- }
425
- }, {
426
- key: "getDateLabel",
427
- value: function getDateLabel() {
428
- var start = this.localeDayjs(new Date(this.startDate));
429
- var end = this.localeDayjs(new Date(this.endDate));
430
- var dateLabel = start.format('LL');
431
- if (start != end) dateLabel = "".concat(start.format('LL'), "-").concat(end.format('LL'));
432
- if (!!this.behaviors.getDateLabelFunc) dateLabel = this.behaviors.getDateLabelFunc(this, this.viewType, this.startDate, this.endDate);
433
- return dateLabel;
434
- }
435
- }, {
436
- key: "addEvent",
437
- value: function addEvent(newEvent) {
438
- this._attachEvent(newEvent);
439
- if (this.eventGroupsAutoGenerated) this._generateEventGroups();
440
- this._createRenderData();
441
- }
442
- }, {
443
- key: "updateEventStart",
444
- value: function updateEventStart(event, newStart) {
445
- this._detachEvent(event);
446
- event.start = newStart;
447
- this._attachEvent(event);
448
- this._createRenderData();
449
- }
450
- }, {
451
- key: "updateEventEnd",
452
- value: function updateEventEnd(event, newEnd) {
453
- event.end = newEnd;
454
- this._createRenderData();
455
- }
456
- }, {
457
- key: "swapEvent",
458
- value: function swapEvent(eventSource, eventDest) {
459
- // Swap group or resource IDs
460
- if (this.isEventPerspective) {
461
- var _ref = [eventDest.groupId, eventSource.groupId];
462
- eventSource.groupId = _ref[0];
463
- eventDest.groupId = _ref[1];
464
- var _ref2 = [eventDest.groupName, eventSource.groupName];
465
- eventSource.groupName = _ref2[0];
466
- eventDest.groupName = _ref2[1];
467
- } else {
468
- var _ref3 = [eventDest.resourceId, eventSource.resourceId];
469
- eventSource.resourceId = _ref3[0];
470
- eventDest.resourceId = _ref3[1];
471
- }
472
-
473
- // Swap start and end times
474
- var _ref4 = [eventDest.start, eventSource.start];
475
- eventSource.start = _ref4[0];
476
- eventDest.start = _ref4[1];
477
- // Update the events
478
- var _ref5 = [eventDest.end, eventSource.end];
479
- eventSource.end = _ref5[0];
480
- eventDest.end = _ref5[1];
481
- this._detachEvent(eventSource);
482
- this._detachEvent(eventDest);
483
- this._attachEvent(eventSource);
484
- this._attachEvent(eventDest);
485
- this._createRenderData();
486
- }
487
- }, {
488
- key: "swapEvent2",
489
- value: function swapEvent2(eventSource, eventDest) {
490
- var tempEventSource = Object.assign({}, eventSource);
491
- var tempEventDest = Object.assign({}, eventDest);
492
- this._detachEvent(eventSource);
493
- this._detachEvent(eventDest);
494
- if (this.isEventPerspective) {
495
- tempEventSource.groupId = eventDest.groupId;
496
- tempEventSource.groupName = eventDest.groupName;
497
- tempEventDest.groupId = eventSource.groupId;
498
- tempEventDest.groupName = eventSource.groupName;
499
- } else {
500
- tempEventSource.resourceId = eventDest.resourceId;
501
- tempEventDest.resourceId = eventSource.resourceId;
502
- }
503
- tempEventSource.end = eventDest.end;
504
- tempEventSource.start = eventDest.start;
505
- tempEventDest.end = eventSource.end;
506
- tempEventDest.start = eventSource.start;
507
- this._attachEvent(tempEventSource);
508
- this._attachEvent(tempEventDest);
509
- this._createRenderData();
510
- }
511
- }, {
512
- key: "moveEvent",
513
- value: function moveEvent(event, newSlotId, newSlotName, newStart, newEnd) {
514
- this._detachEvent(event);
515
- if (this.isEventPerspective) {
516
- event.groupId = newSlotId;
517
- event.groupName = newSlotName;
518
- } else event.resourceId = newSlotId;
519
- event.end = newEnd;
520
- event.start = newStart;
521
- this._attachEvent(event);
522
- this._createRenderData();
523
- }
524
- }, {
525
- key: "isEventInTimeWindow",
526
- value: function isEventInTimeWindow(eventStart, eventEnd, windowStart, windowEnd) {
527
- return eventStart < windowEnd && eventEnd > windowStart;
528
- }
529
- }, {
530
- key: "removeEvent",
531
- value: function removeEvent(event) {
532
- var index = this.events.indexOf(event);
533
- if (index !== -1) {
534
- this.events.splice(index, 1);
535
- this._createRenderData();
536
- }
537
- }
538
- }, {
539
- key: "removeEventById",
540
- value: function removeEventById(eventId) {
541
- var index = -1;
542
- this.events.forEach(function (item, idx) {
543
- if (item.id === eventId) index = idx;
544
- });
545
- if (index !== -1) {
546
- this.events.splice(index, 1);
547
- this._createRenderData();
548
- }
549
- }
550
- }, {
551
- key: "getResourceTableConfigWidth",
552
- value: function getResourceTableConfigWidth() {
553
- if (this.showAgenda) return this.config.agendaResourceTableWidth;
554
- return this.viewType === _index.ViewType.Week ? this.config.weekResourceTableWidth : this.viewType === _index.ViewType.Day ? this.config.dayResourceTableWidth : this.viewType === _index.ViewType.Month ? this.config.monthResourceTableWidth : this.viewType === _index.ViewType.Year ? this.config.yearResourceTableWidth : this.viewType === _index.ViewType.Quarter ? this.config.quarterResourceTableWidth : this.config.customResourceTableWidth;
555
- }
556
- }, {
557
- key: "getContentCellConfigWidth",
558
- value: function getContentCellConfigWidth() {
559
- return this.viewType === _index.ViewType.Week ? this.config.weekCellWidth : this.viewType === _index.ViewType.Day ? this.config.dayCellWidth : this.viewType === _index.ViewType.Month ? this.config.monthCellWidth : this.viewType === _index.ViewType.Year ? this.config.yearCellWidth : this.viewType === _index.ViewType.Quarter ? this.config.quarterCellWidth : this.config.customCellWidth;
560
- }
561
- }, {
562
- key: "_setDocumentWidth",
563
- value: function _setDocumentWidth(documentWidth) {
564
- if (documentWidth >= 0) {
565
- this.documentWidth = documentWidth;
566
- }
567
- }
568
- }, {
569
- key: "_detachEvent",
570
- value: function _detachEvent(event) {
571
- var index = this.events.indexOf(event);
572
- if (index !== -1) this.events.splice(index, 1);
573
- }
574
- }, {
575
- key: "_attachEvent",
576
- value: function _attachEvent(event) {
577
- var _this = this;
578
- var pos = 0;
579
- var eventStart = this.localeDayjs(new Date(event.start));
580
- this.events.forEach(function (item, index) {
581
- var start = _this.localeDayjs(new Date(item.start));
582
- if (eventStart >= start) pos = index + 1;
583
- });
584
- this.events.splice(pos, 0, event);
585
- }
586
- }, {
587
- key: "_handleRecurringEvents",
588
- value: function _handleRecurringEvents() {
589
- var _this2 = this;
590
- var recurringEvents = this.events.filter(function (x) {
591
- return !!x.rrule;
592
- });
593
- recurringEvents.forEach(function (item) {
594
- _this2._detachEvent(item);
595
- });
596
- recurringEvents.forEach(function (item) {
597
- var windowStart = _this2.startDate,
598
- windowEnd = _this2.endDate.add(1, 'days'),
599
- oldStart = _this2.localeDayjs(new Date(item.start)),
600
- oldEnd = _this2.localeDayjs(new Date(item.end)),
601
- rule = (0, _rrule.rrulestr)(item.rrule),
602
- oldDtstart = undefined,
603
- oldUntil = rule.origOptions.until || windowEnd.toDate();
604
- if (!!rule.origOptions.dtstart) {
605
- oldDtstart = _this2.localeDayjs(new Date(rule.origOptions.dtstart));
606
- }
607
- //rule.origOptions.dtstart = oldStart.toDate();
608
- if (windowEnd < oldUntil) {
609
- rule.origOptions.until = windowEnd.toDate();
610
- }
611
-
612
- //reload
613
- rule = (0, _rrule.rrulestr)(rule.toString());
614
- if (item.exdates || item.exrule) {
615
- var rruleSet = new _rrule.RRuleSet();
616
- rruleSet.rrule(rule);
617
- if (item.exrule) {
618
- rruleSet.exrule((0, _rrule.rrulestr)(item.exrule));
619
- }
620
- if (item.exdates) {
621
- item.exdates.forEach(function (exdate) {
622
- rruleSet.exdate(_this2.localeDayjs(exdate).toDate());
623
- });
624
- }
625
- rule = rruleSet;
626
- }
627
- var all = rule.between(new Date(windowStart), new Date(windowEnd));
628
- all.forEach(function (time, index) {
629
- var newEvent = _objectSpread(_objectSpread({}, item), {}, {
630
- recurringEventId: item.id,
631
- recurringEventStart: item.start,
632
- recurringEventEnd: item.end,
633
- id: "".concat(item.id, "-").concat(index),
634
- start: rule.origOptions.tzid ? _this2.localeDayjs.utc(time).utcOffset(_this2.localeDayjs(new Date().utcOffset)(), true).format(_index.DATETIME_FORMAT) : _this2.localeDayjs(new Date(time)).format(_index.DATETIME_FORMAT),
635
- end: rule.origOptions.tzid ? _this2.localeDayjs.utc(time).utcOffset(_this2.localeDayjs(new Date().utcOffset)(), true).add(oldEnd.diff(oldStart), 'ms').add(_this2.localeDayjs(new Date(oldUntil)).utcOffset() - _this2.localeDayjs(new Date(item.start)).utcOffset(), 'm').format(_index.DATETIME_FORMAT) : _this2.localeDayjs(new Date(time)).add(oldEnd.diff(oldStart), 'ms').format(_index.DATETIME_FORMAT)
636
- });
637
- var eventStart = _this2.localeDayjs(newEvent.start),
638
- eventEnd = _this2.localeDayjs(newEvent.end);
639
- if (_this2.isEventInTimeWindow(eventStart, eventEnd, windowStart, windowEnd) && (!oldDtstart || eventStart >= oldDtstart)) {
640
- _this2._attachEvent(newEvent);
641
- }
642
- });
643
- });
644
- }
645
- }, {
646
- key: "_resolveDate",
647
- value: function _resolveDate(num) {
648
- var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
649
- if (date != undefined) this.selectDate = this.localeDayjs(date);
650
- if (this.viewType === _index.ViewType.Week) {
651
- this.startDate = date != undefined ? this.localeDayjs(date).startOf('week') : this.localeDayjs(this.startDate).add(num, 'weeks');
652
- this.endDate = this.localeDayjs(this.startDate).endOf('week');
653
- } else if (this.viewType === _index.ViewType.Day) {
654
- this.startDate = date != undefined ? this.selectDate : this.localeDayjs(this.startDate).add(num, 'days');
655
- this.endDate = this.startDate;
656
- } else if (this.viewType === _index.ViewType.Month) {
657
- this.startDate = date != undefined ? this.localeDayjs(date).startOf('month') : this.localeDayjs(this.startDate).add(num, 'months');
658
- this.endDate = this.localeDayjs(this.startDate).endOf('month');
659
- } else if (this.viewType === _index.ViewType.Quarter) {
660
- this.startDate = date != undefined ? this.localeDayjs(date).startOf('quarter') : this.localeDayjs(this.startDate).add(num, 'quarters');
661
- this.endDate = this.localeDayjs(this.startDate).endOf('quarter');
662
- } else if (this.viewType === _index.ViewType.Year) {
663
- this.startDate = date != undefined ? this.localeDayjs(date).startOf('year') : this.localeDayjs(this.startDate).add(num, 'years');
664
- this.endDate = this.localeDayjs(this.startDate).endOf('year');
665
- } else if (this.viewType === _index.ViewType.Custom || this.viewType === _index.ViewType.Custom1 || this.viewType === _index.ViewType.Custom2) {
666
- if (this.behaviors.getCustomDateFunc != undefined) {
667
- var customDate = this.behaviors.getCustomDateFunc(this, num, date);
668
- this.startDate = this.localeDayjs(customDate.startDate);
669
- this.endDate = this.localeDayjs(customDate.endDate);
670
- if (!!customDate.cellUnit) this.cellUnit = customDate.cellUnit;
671
- } else {
672
- throw new Error('This is custom view type, set behaviors.getCustomDateFunc func to resolve the time window(startDate and endDate) yourself');
673
- }
674
- }
675
- }
676
- }, {
677
- key: "_createHeaders",
678
- value: function _createHeaders() {
679
- var headers = [],
680
- start = this.localeDayjs(new Date(this.startDate)),
681
- end = this.localeDayjs(new Date(this.endDate)),
682
- header = start;
683
- if (this.showAgenda) {
684
- headers.push({
685
- time: header.format(_index.DATETIME_FORMAT),
686
- nonWorkingTime: false
687
- });
688
- } else {
689
- if (this.cellUnit === _index.CellUnit.Hour) {
690
- if (start.hour() == 0) {
691
- start = start.add(this.config.dayStartFrom, 'hours');
692
- }
693
- if (end.hour() == 0) {
694
- end = end.add(this.config.dayStopTo, 'hours');
695
- }
696
- header = start;
697
- var prevHour = -1;
698
- while (header >= start && header <= end) {
699
- // prevent doubled hours on time change
700
- if (header.hour() == prevHour) {
701
- header = header.add(1, 'hours');
702
- continue;
703
- }
704
- prevHour = header.hour();
705
- var minuteSteps = this.getMinuteStepsInHour();
706
- for (var i = 0; i < minuteSteps; i++) {
707
- var hour = header.hour();
708
- if (hour >= this.config.dayStartFrom && hour <= this.config.dayStopTo) {
709
- var time = header.format(_index.DATETIME_FORMAT);
710
- var nonWorkingTime = this.behaviors.isNonWorkingTimeFunc(this, time);
711
- headers.push({
712
- time: time,
713
- nonWorkingTime: nonWorkingTime
714
- });
715
- }
716
- header = header.add(this.config.minuteStep, 'minutes');
717
- }
718
- }
719
- } else if (this.cellUnit === _index.CellUnit.Day) {
720
- while (header >= start && header <= end) {
721
- var _time = header.format(_index.DATETIME_FORMAT);
722
- var dayOfWeek = header.weekday();
723
- if (this.config.displayWeekend || dayOfWeek !== 0 && dayOfWeek !== 6) {
724
- var _nonWorkingTime = this.behaviors.isNonWorkingTimeFunc(this, _time);
725
- headers.push({
726
- time: _time,
727
- nonWorkingTime: _nonWorkingTime
728
- });
729
- }
730
- header = header.add(1, 'days');
731
- }
732
- } else if (this.cellUnit === _index.CellUnit.Week) {
733
- while (header >= start && header <= end) {
734
- var _time2 = header.format(_index.DATE_FORMAT);
735
- headers.push({
736
- time: _time2
737
- });
738
- header = header.add(1, 'weeks').startOf('week');
739
- }
740
- } else if (this.cellUnit === _index.CellUnit.Month) {
741
- while (header >= start && header <= end) {
742
- var _time3 = header.format(_index.DATE_FORMAT);
743
- headers.push({
744
- time: _time3
745
- });
746
- header = header.add(1, 'months').startOf('month');
747
- }
748
- } else if (this.cellUnit === _index.CellUnit.Year) {
749
- while (header >= start && header <= end) {
750
- var _time4 = header.format(_index.DATE_FORMAT);
751
- headers.push({
752
- time: _time4
753
- });
754
- header = header.add(1, 'years').startOf('year');
755
- }
756
- }
757
- }
758
- this.headers = headers;
759
- }
760
- }, {
761
- key: "_createInitHeaderEvents",
762
- value: function _createInitHeaderEvents(header) {
763
- var start = this.localeDayjs(new Date(header.time)),
764
- startValue = start.format(_index.DATETIME_FORMAT);
765
- var endValue = this.showAgenda ? this.viewType === _index.ViewType.Week ? start.add(1, 'weeks').format(_index.DATETIME_FORMAT) : this.viewType === _index.ViewType.Day ? start.add(1, 'days').format(_index.DATETIME_FORMAT) : this.viewType === _index.ViewType.Month ? start.add(1, 'months').format(_index.DATETIME_FORMAT) : this.viewType === _index.ViewType.Year ? start.add(1, 'years').format(_index.DATETIME_FORMAT) : this.viewType === _index.ViewType.Quarter ? start.add(1, 'quarters').format(_index.DATETIME_FORMAT) : this.localeDayjs(new Date(this.endDate)).add(1, 'days').format(_index.DATETIME_FORMAT) : this.cellUnit === _index.CellUnit.Hour ? start.add(this.config.minuteStep, 'minutes').format(_index.DATETIME_FORMAT) : this.cellUnit === _index.CellUnit.Year ? start.add(1, 'years').format(_index.DATE_FORMAT) : this.cellUnit === _index.CellUnit.Month ? start.add(1, 'months').format(_index.DATE_FORMAT) : this.cellUnit === _index.CellUnit.Week ? start.add(1, 'weeks').format(_index.DATE_FORMAT) : start.add(1, 'days').format(_index.DATETIME_FORMAT);
766
- return {
767
- time: header.time,
768
- nonWorkingTime: header.nonWorkingTime,
769
- start: startValue,
770
- end: endValue,
771
- count: 0,
772
- addMore: 0,
773
- addMoreIndex: 0,
774
- events: [,,,]
775
- };
776
- }
777
- }, {
778
- key: "_createHeaderEvent",
779
- value: function _createHeaderEvent(render, span, eventItem) {
780
- return {
781
- render: render,
782
- span: span,
783
- eventItem: eventItem
784
- };
785
- }
786
- }, {
787
- key: "_getEventSlotId",
788
- value: function _getEventSlotId(event) {
789
- return this.isEventPerspective ? this._getEventGroupId(event) : event.resourceId;
790
- }
791
- }, {
792
- key: "_getEventGroupId",
793
- value: function _getEventGroupId(event) {
794
- return !!event.groupId ? event.groupId.toString() : event.id.toString();
795
- }
796
- }, {
797
- key: "_getEventGroupName",
798
- value: function _getEventGroupName(event) {
799
- return !!event.groupName ? event.groupName : event.title;
800
- }
801
- }, {
802
- key: "_generateEventGroups",
803
- value: function _generateEventGroups() {
804
- var _this3 = this;
805
- var eventGroups = [];
806
- var set = new Set();
807
- this.events.forEach(function (item) {
808
- var groupId = _this3._getEventGroupId(item);
809
- var groupName = _this3._getEventGroupName(item);
810
- if (!set.has(groupId)) {
811
- eventGroups.push({
812
- id: groupId,
813
- name: groupName,
814
- state: item
815
- });
816
- set.add(groupId);
817
- }
818
- });
819
- this.eventGroups = eventGroups;
820
- }
821
- }, {
822
- key: "_createInitRenderData",
823
- value: function _createInitRenderData(isEventPerspective, eventGroups, resources, headers) {
824
- var _this4 = this;
825
- var slots = isEventPerspective ? eventGroups : resources;
826
- var slotTree = [],
827
- slotMap = new Map();
828
- slots.forEach(function (slot) {
829
- var headerEvents = headers.map(function (header) {
830
- return _this4._createInitHeaderEvents(header);
831
- });
832
- var slotRenderData = {
833
- slotId: slot.id,
834
- slotName: slot.name,
835
- parentId: slot.parentId,
836
- groupOnly: slot.groupOnly,
837
- hasSummary: false,
838
- rowMaxCount: 0,
839
- rowHeight: _this4.config.nonAgendaSlotMinHeight !== 0 ? _this4.config.nonAgendaSlotMinHeight : _this4.config.eventItemLineHeight + 2,
840
- headerItems: headerEvents,
841
- indent: 0,
842
- hasChildren: false,
843
- expanded: true,
844
- render: true
845
- };
846
- var id = slot.id;
847
- var value = undefined;
848
- if (slotMap.has(id)) {
849
- value = slotMap.get(id);
850
- value.data = slotRenderData;
851
- } else {
852
- value = {
853
- data: slotRenderData,
854
- children: []
855
- };
856
- slotMap.set(id, value);
857
- }
858
- var parentId = slot.parentId;
859
- if (!parentId || parentId === id) {
860
- slotTree.push(value);
861
- } else {
862
- var parentValue = undefined;
863
- if (slotMap.has(parentId)) {
864
- parentValue = slotMap.get(parentId);
865
- } else {
866
- parentValue = {
867
- data: undefined,
868
- children: []
869
- };
870
- slotMap.set(parentId, parentValue);
871
- }
872
- parentValue.children.push(value);
873
- }
874
- });
875
- var slotStack = [];
876
- var i;
877
- for (i = slotTree.length - 1; i >= 0; i--) {
878
- slotStack.push(slotTree[i]);
879
- }
880
- var initRenderData = [];
881
- var currentNode = undefined;
882
- while (slotStack.length > 0) {
883
- currentNode = slotStack.pop();
884
- if (currentNode.data.indent > 0) {
885
- currentNode.data.render = this.config.defaultExpanded;
886
- }
887
- if (currentNode.children.length > 0) {
888
- currentNode.data.hasChildren = true;
889
- currentNode.data.expanded = this.config.defaultExpanded;
890
- }
891
- initRenderData.push(currentNode.data);
892
- for (i = currentNode.children.length - 1; i >= 0; i--) {
893
- currentNode.children[i].data.indent = currentNode.data.indent + 1;
894
- slotStack.push(currentNode.children[i]);
895
- }
896
- }
897
- return initRenderData;
898
- }
899
- }, {
900
- key: "_getSpan",
901
- value: function _getSpan(startTime, endTime, headers) {
902
- if (this.showAgenda) return 1;
903
- function startOfWeek(date) {
904
- var day = date.getDay();
905
- var diff = date.getDate() - day;
906
- return new Date(date.getFullYear(), date.getMonth(), diff);
907
- }
908
- var timeBetween = function timeBetween(date1, date2, timeIn) {
909
- if (timeIn === 'days' || timeIn === 'day') {
910
- if (date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth()) {
911
- return 1;
912
- }
913
- }
914
- var one;
915
- switch (timeIn) {
916
- case 'days':
917
- case 'day':
918
- one = 1000 * 60 * 60 * 24;
919
- break;
920
- case 'minutes':
921
- case 'minute':
922
- one = 1000 * 60;
923
- break;
924
- default:
925
- return 0;
926
- }
927
- var date1_ms = date1.getTime();
928
- var date2_ms = date2.getTime();
929
- var diff = (date2_ms - date1_ms) / one;
930
- return diff < 0 ? 0 : diff;
931
- };
932
- var eventStart = new Date(startTime),
933
- eventEnd = new Date(endTime),
934
- span = 0,
935
- windowStart = new Date(this.startDate),
936
- windowEnd = new Date(this.endDate);
937
- windowStart.setHours(0, 0, 0, 0);
938
- windowEnd.setHours(23, 59, 59);
939
- if (this.viewType === _index.ViewType.Day) {
940
- if (headers.length > 0) {
941
- var day = new Date(headers[0].time);
942
- if (day.getDate() > eventStart.getDate() && day.getDate() < eventEnd.getDate()) {
943
- span = 1440 / this.config.minuteStep;
944
- } else if (day.getDate() > eventStart.getDate() && day.getDate() === eventEnd.getDate()) {
945
- span = Math.ceil(timeBetween(day, eventEnd, 'minutes') / this.config.minuteStep);
946
- } else if (day.getDate() === eventStart.getDate() && day.getDate() < eventEnd.getDate()) {
947
- day.setHours(23, 59, 59);
948
- span = Math.ceil(timeBetween(eventStart, day, 'minutes') / this.config.minuteStep);
949
- } else if (day.getDate() === eventStart.getDate() && day.getDate() === eventEnd.getDate() || eventEnd.getDate() === eventStart.getDate()) {
950
- span = Math.ceil(timeBetween(eventStart, eventEnd, 'minutes') / this.config.minuteStep);
951
- }
952
- }
953
- } else if (this.viewType === _index.ViewType.Week || this.viewType === _index.ViewType.Month || this.viewType === _index.ViewType.Quarter || this.viewType === _index.ViewType.Year) {
954
- var startDate = windowStart < eventStart ? eventStart : windowStart;
955
- var endDate = windowEnd > eventEnd ? eventEnd : windowEnd;
956
- span = Math.ceil(timeBetween(startDate, endDate, 'days'));
957
- } else {
958
- if (this.cellUnit === _index.CellUnit.Day) {
959
- eventEnd.setHours(23, 59, 59);
960
- eventStart.setHours(0, 0, 0, 0);
961
- }
962
- var timeIn = this.cellUnit === _index.CellUnit.Day ? 'days' : 'minutes';
963
- var dividedBy = this.cellUnit === _index.CellUnit.Day ? 1 : this.config.minuteStep;
964
- if (windowStart >= eventStart && eventEnd <= windowEnd) {
965
- span = Math.ceil(timeBetween(windowStart, eventEnd, timeIn) / dividedBy);
966
- } else if (windowStart > eventStart && eventEnd > windowEnd) {
967
- span = Math.ceil(timeBetween(windowStart, windowEnd, timeIn) / dividedBy);
968
- } else if (windowStart <= eventStart && eventEnd >= windowEnd) {
969
- span = Math.ceil(timeBetween(eventStart, windowEnd, timeIn) / dividedBy);
970
- } else {
971
- span = Math.ceil(timeBetween(eventStart, eventEnd, timeIn) / dividedBy);
972
- }
973
- }
974
- return span;
975
- }
976
- }, {
977
- key: "_validateResource",
978
- value: function _validateResource(resources) {
979
- if (Object.prototype.toString.call(resources) !== '[object Array]') {
980
- throw new Error('Resources should be Array object');
981
- }
982
- resources.forEach(function (item, index) {
983
- if (item == undefined) {
984
- console.error("Resource undefined: ".concat(index));
985
- throw new Error("Resource undefined: ".concat(index));
986
- }
987
- if (item.id == undefined || item.name == undefined) {
988
- console.error('Resource property missed', index, item);
989
- throw new Error("Resource property undefined: ".concat(index));
990
- }
991
- });
992
- }
993
- }, {
994
- key: "_validateEventGroups",
995
- value: function _validateEventGroups(eventGroups) {
996
- if (Object.prototype.toString.call(eventGroups) !== '[object Array]') {
997
- throw new Error('Event groups should be Array object');
998
- }
999
- eventGroups.forEach(function (item, index) {
1000
- if (item == undefined) {
1001
- console.error("Event group undefined: ".concat(index));
1002
- throw new Error("Event group undefined: ".concat(index));
1003
- }
1004
- if (item.id == undefined || item.name == undefined) {
1005
- console.error('Event group property missed', index, item);
1006
- throw new Error("Event group property undefined: ".concat(index));
1007
- }
1008
- });
1009
- }
1010
- }, {
1011
- key: "_validateEvents",
1012
- value: function _validateEvents(events) {
1013
- if (Object.prototype.toString.call(events) !== '[object Array]') {
1014
- throw new Error('Events should be Array object');
1015
- }
1016
- events.forEach(function (e, index) {
1017
- if (e == undefined) {
1018
- console.error("Event undefined: ".concat(index));
1019
- throw new Error("Event undefined: ".concat(index));
1020
- }
1021
- if (e.id == undefined || e.resourceId == undefined || e.title == undefined || e.start == undefined || e.end == undefined) {
1022
- console.error('Event property missed', index, e);
1023
- throw new Error("Event property undefined: ".concat(index));
1024
- }
1025
- });
1026
- }
1027
- }, {
1028
- key: "_validateMinuteStep",
1029
- value: function _validateMinuteStep(minuteStep) {
1030
- if (60 % minuteStep !== 0) {
1031
- console.error('Minute step is not set properly - 60 minutes must be divisible without remainder by this number');
1032
- throw new Error('Minute step is not set properly - 60 minutes must be divisible without remainder by this number');
1033
- }
1034
- }
1035
- }, {
1036
- key: "_compare",
1037
- value: function _compare(event1, event2) {
1038
- var start1 = this.localeDayjs(event1.start),
1039
- start2 = this.localeDayjs(event2.start);
1040
- if (start1 !== start2) return start1 < start2 ? -1 : 1;
1041
- var end1 = this.localeDayjs(event1.end),
1042
- end2 = this.localeDayjs(event2.end);
1043
- if (end1 !== end2) return end1 < end2 ? -1 : 1;
1044
- return event1.id < event2.id ? -1 : 1;
1045
- }
1046
- }, {
1047
- key: "_createRenderData",
1048
- value: function _createRenderData() {
1049
- var _this5 = this;
1050
- var initRenderData = this._createInitRenderData(this.isEventPerspective, this.eventGroups, this.resources, this.headers);
1051
- //this.events.sort(this._compare);
1052
- var cellMaxEventsCount = this.getCellMaxEvents();
1053
- var cellMaxEventsCountValue = 30;
1054
- this.events.forEach(function (item) {
1055
- var resourceEventsList = initRenderData.filter(function (x) {
1056
- return x.slotId === _this5._getEventSlotId(item);
1057
- });
1058
- if (resourceEventsList.length > 0) {
1059
- var resourceEvents = resourceEventsList[0];
1060
- var span = _this5._getSpan(item.start, item.end, _this5.headers);
1061
- var eventStart = new Date(item.start),
1062
- eventEnd = new Date(item.end);
1063
- var pos = -1;
1064
- resourceEvents.headerItems.forEach(function (header, index) {
1065
- var headerStart = new Date(header.start),
1066
- headerEnd = new Date(header.end);
1067
- if (headerEnd > eventStart && headerStart < eventEnd) {
1068
- header.count = header.count + 1;
1069
- if (header.count > resourceEvents.rowMaxCount) {
1070
- resourceEvents.rowMaxCount = header.count;
1071
- var rowsCount = cellMaxEventsCount <= cellMaxEventsCountValue && resourceEvents.rowMaxCount > cellMaxEventsCount ? cellMaxEventsCount : resourceEvents.rowMaxCount;
1072
- var newRowHeight = rowsCount * _this5.config.eventItemLineHeight + (_this5.config.creatable && _this5.config.checkConflict === false ? 20 : 2);
1073
- if (newRowHeight > resourceEvents.rowHeight) resourceEvents.rowHeight = newRowHeight;
1074
- }
1075
- if (pos === -1) {
1076
- var tmp = 0;
1077
- while (header.events[tmp] !== undefined) tmp++;
1078
- pos = tmp;
1079
- }
1080
- var render = headerStart <= eventStart || index === 0;
1081
- if (render === false) {
1082
- var previousHeader = resourceEvents.headerItems[index - 1];
1083
- var previousHeaderStart = new Date(previousHeader.start),
1084
- previousHeaderEnd = new Date(previousHeader.end);
1085
- if (previousHeaderEnd <= eventStart || previousHeaderStart >= eventEnd) render = true;
1086
- }
1087
- // console.log(`span: ${span}`)
1088
- header.events[pos] = _this5._createHeaderEvent(render, span, item);
1089
- }
1090
- });
1091
- }
1092
- });
1093
- if (cellMaxEventsCount <= cellMaxEventsCountValue || this.behaviors.getSummaryFunc !== undefined) {
1094
- initRenderData.forEach(function (resourceEvents) {
1095
- var hasSummary = false;
1096
- resourceEvents.headerItems.forEach(function (headerItem) {
1097
- if (cellMaxEventsCount <= cellMaxEventsCountValue) {
1098
- var renderItemsCount = 0,
1099
- addMoreIndex = 0,
1100
- index = 0;
1101
- while (index < cellMaxEventsCount - 1) {
1102
- if (headerItem.events[index] !== undefined) {
1103
- renderItemsCount++;
1104
- addMoreIndex = index + 1;
1105
- }
1106
- index++;
1107
- }
1108
- if (headerItem.events[index] !== undefined) {
1109
- if (renderItemsCount + 1 < headerItem.count) {
1110
- headerItem.addMore = headerItem.count - renderItemsCount;
1111
- headerItem.addMoreIndex = addMoreIndex;
1112
- }
1113
- } else {
1114
- if (renderItemsCount < headerItem.count) {
1115
- headerItem.addMore = headerItem.count - renderItemsCount;
1116
- headerItem.addMoreIndex = addMoreIndex;
1117
- }
1118
- }
1119
- }
1120
- if (_this5.behaviors.getSummaryFunc !== undefined) {
1121
- var events = [];
1122
- headerItem.events.forEach(function (e) {
1123
- if (!!e && !!e.eventItem) events.push(e.eventItem);
1124
- });
1125
- headerItem.summary = _this5.behaviors.getSummaryFunc(_this5, events, resourceEvents.slotId, resourceEvents.slotName, headerItem.start, headerItem.end);
1126
- if (!!headerItem.summary && headerItem.summary.text != undefined) hasSummary = true;
1127
- }
1128
- });
1129
- resourceEvents.hasSummary = hasSummary;
1130
- if (hasSummary) {
1131
- var rowsCount = cellMaxEventsCount <= cellMaxEventsCountValue && resourceEvents.rowMaxCount > cellMaxEventsCount ? cellMaxEventsCount : resourceEvents.rowMaxCount;
1132
- var newRowHeight = (rowsCount + 1) * _this5.config.eventItemLineHeight + (_this5.config.creatable && _this5.config.checkConflict === false ? 20 : 2);
1133
- if (newRowHeight > resourceEvents.rowHeight) resourceEvents.rowHeight = newRowHeight;
1134
- }
1135
- });
1136
- }
1137
- this.renderData = initRenderData;
1138
- }
1139
- }, {
1140
- key: "_startResizing",
1141
- value: function _startResizing() {
1142
- this.resizing = true;
1143
- }
1144
- }, {
1145
- key: "_stopResizing",
1146
- value: function _stopResizing() {
1147
- this.resizing = false;
1148
- }
1149
- }, {
1150
- key: "_isResizing",
1151
- value: function _isResizing() {
1152
- return this.resizing;
1153
- }
1154
- }]);
1155
- return SchedulerData;
1156
- }();
1157
- exports["default"] = SchedulerData;