dhtmlx-scheduler 7.2.0 → 7.2.2

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,6 +1,6 @@
1
1
  /** @license
2
2
 
3
- dhtmlxScheduler v.7.2.0 Standard
3
+ dhtmlxScheduler v.7.2.2 Standard
4
4
 
5
5
  To use dhtmlxScheduler in non-GPL projects (and get Pro version of the product), please obtain Commercial/Enterprise or Ultimate license on our site https://dhtmlx.com/docs/products/dhtmlxScheduler/#licensing or contact us at sales@dhtmlx.com
6
6
 
@@ -78,6 +78,14 @@ function dragHighlightPos(scheduler2) {
78
78
  setRequiredStylesToMarker(eventNode2, layout);
79
79
  const sections = {};
80
80
  let markerObject = { start_date: event3.start_date, end_date: event3.end_date, css: "dhx_scheduler_dnd_marker", html: eventNode2 };
81
+ if (layout == "timeline") {
82
+ const viewObj = scheduler2.getView(viewName);
83
+ if (viewObj.round_position) {
84
+ const index = scheduler2._get_date_index(viewObj, event3.start_date);
85
+ const rounded_date = viewObj._trace_x[index];
86
+ markerObject.start_date = rounded_date;
87
+ }
88
+ }
81
89
  if (layout == "timeline" || layout == "month") {
82
90
  markerObject = { ...markerObject, end_date: scheduler2.date.add(event3.start_date, 1, "minute") };
83
91
  }
@@ -9015,7 +9023,7 @@ class DatePicker {
9015
9023
  const dayElement = document.createElement("div");
9016
9024
  dayElement.setAttribute("data-cell-date", scheduler2.templates.format_date(currDate));
9017
9025
  dayElement.setAttribute("data-day", currDate.getDay());
9018
- dayElement.innerHTML = currDate.getDate();
9026
+ dayElement.innerHTML = scheduler2.templates.month_day(currDate);
9019
9027
  if (currDate.valueOf() < monthStart.valueOf()) {
9020
9028
  dayElement.classList.add("dhx_before");
9021
9029
  } else if (currDate.valueOf() >= monthEnd.valueOf()) {
@@ -9120,7 +9128,7 @@ class DatePicker {
9120
9128
  }
9121
9129
  }
9122
9130
  function factoryMethod(extensionManager) {
9123
- const scheduler2 = { version: "7.2.0" };
9131
+ const scheduler2 = { version: "7.2.2" };
9124
9132
  scheduler2.$stateProvider = StateService();
9125
9133
  scheduler2.getState = scheduler2.$stateProvider.getState;
9126
9134
  extend$n(scheduler2);
@@ -15396,22 +15404,7 @@ function readonly(scheduler2) {
15396
15404
  scheduler2.form_blocks.recurring.set_value = originalRecurringSetValue;
15397
15405
  }
15398
15406
  }
15399
- var sns = this.config.lightbox.sections;
15400
15407
  if (this.config.readonly_active) {
15401
- for (var i = 0; i < sns.length; i++) {
15402
- if (sns[i].type == "recurring") {
15403
- if (this.config.readonly_active && scheduler2.form_blocks.recurring) {
15404
- scheduler2.form_blocks.recurring.set_value = function(node, value, ev) {
15405
- var wrapper = scheduler2.$domHelpers.closest(node, ".dhx_wrap_section");
15406
- var style = "none";
15407
- wrapper.querySelector(".dhx_cal_lsection").display = style;
15408
- wrapper.querySelector(".dhx_form_repeat").display = style;
15409
- wrapper.style.display = style;
15410
- scheduler2.setLightboxSize();
15411
- };
15412
- }
15413
- }
15414
- }
15415
15408
  var forbidden_buttons = ["dhx_delete_btn", "dhx_save_btn"];
15416
15409
  var button_arrays = [scheduler2.config.buttons_left, scheduler2.config.buttons_right];
15417
15410
  for (var i = 0; i < forbidden_buttons.length; i++) {
@@ -18096,7 +18089,16 @@ function recurring(scheduler2) {
18096
18089
  scheduler2.addEvent(nev);
18097
18090
  scheduler2._not_render = false;
18098
18091
  }
18092
+ function toUTCDate(date) {
18093
+ return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
18094
+ }
18095
+ function setUTCPartsToDate(d) {
18096
+ return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds());
18097
+ }
18099
18098
  function updateFollowingEventsRRULE(ev) {
18099
+ if (ev.rrule.includes(";UNTIL=")) {
18100
+ ev.rrule = ev.rrule.split(";UNTIL=")[0];
18101
+ }
18100
18102
  let parsedRRule = rrulestr(`RRULE:${ev.rrule};UNTIL=${toIcalString(ev._end_date || ev.end_date)}`, { dtstart: ev.start_date });
18101
18103
  let newRRULE = new RRule(parsedRRule.origOptions).toString().replace("RRULE:", "");
18102
18104
  newRRULE = newRRULE.split("\n")[1];
@@ -18127,6 +18129,20 @@ function recurring(scheduler2) {
18127
18129
  let ev = scheduler2.getEvent(id2);
18128
18130
  return !!(ev && ev._thisAndFollowing);
18129
18131
  };
18132
+ scheduler2._isFirstOccurrence = function(ev) {
18133
+ if (scheduler2._is_virtual_event(ev.id)) {
18134
+ let pid = ev.id.split("#")[0];
18135
+ let recEvent = scheduler2.getEvent(pid);
18136
+ return !!(recEvent.start_date.valueOf() === ev.start_date.valueOf());
18137
+ }
18138
+ };
18139
+ scheduler2._isExceptionFirstOccurrence = function(ev) {
18140
+ if (scheduler2._is_modified_occurrence(ev)) {
18141
+ let pid = ev.recurring_event_id;
18142
+ let recEvent = scheduler2.getEvent(pid);
18143
+ return !!(ev.original_start.valueOf() && ev.original_start.valueOf() === recEvent.start_date.valueOf());
18144
+ }
18145
+ };
18130
18146
  scheduler2._rec_temp = [];
18131
18147
  scheduler2._rec_markers_pull = {};
18132
18148
  scheduler2._rec_markers = {};
@@ -18206,19 +18222,51 @@ function recurring(scheduler2) {
18206
18222
  }
18207
18223
  delete this._ignore_call;
18208
18224
  });
18209
- function moveToFollowingEvents(copy2, newEv) {
18210
- copy2.recurring_event_id = newEv.id;
18211
- copy2.text = newEv.text;
18212
- scheduler2._not_render = true;
18213
- scheduler2._add_rec_marker(copy2, copy2._pid_time);
18214
- scheduler2.addEvent(copy2);
18215
- scheduler2._not_render = false;
18225
+ function setPropsForFirstOccurrence(ev, occurrence) {
18226
+ ev._end_date = ev.end_date;
18227
+ if (scheduler2._isExceptionFirstOccurrence(occurrence)) {
18228
+ ev.start_date = occurrence.start_date;
18229
+ ev.end_date = new Date(occurrence.start_date.valueOf() + ev.duration * 1e3);
18230
+ ev._start_date = occurrence.original_start;
18231
+ ev._modified = true;
18232
+ } else {
18233
+ ev.end_date = new Date(occurrence.start_date.valueOf() + ev.duration * 1e3);
18234
+ ev.start_date = occurrence.start_date;
18235
+ ev._firstOccurrence = true;
18236
+ }
18237
+ ev._thisAndFollowing = occurrence.id;
18238
+ }
18239
+ function setPropsForStorageEvent(index, data, ev, tempEvent) {
18240
+ const targetIndex = ev._modified ? tempEvent.id : index;
18241
+ scheduler2._events[targetIndex] = { ...tempEvent, text: data.text, duration: data.duration, start_date: data.start_date, rrule: data.rrule, end_date: tempEvent._end_date, _start_date: tempEvent.start_date, _thisAndFollowing: null, _end_date: null };
18242
+ if (ev._modified) {
18243
+ delete scheduler2._events[index];
18244
+ }
18245
+ scheduler2.callEvent("onEventChanged", [scheduler2._events[targetIndex].id, scheduler2._events[targetIndex]]);
18246
+ }
18247
+ function deleteExceptionFromStorage(exception) {
18248
+ for (const i in scheduler2._events) {
18249
+ let tev = scheduler2._events[i];
18250
+ if (tev.id == exception.id) {
18251
+ delete scheduler2._events[i];
18252
+ }
18253
+ }
18254
+ }
18255
+ function updateTextEvents(id2, data) {
18256
+ for (let i in scheduler2._events) {
18257
+ let tev = scheduler2._events[i];
18258
+ if (tev.recurring_event_id == id2 || scheduler2._is_virtual_event(tev.id) && tev.id.split("#")[0] == id2) {
18259
+ tev.text = data.text;
18260
+ scheduler2.updateEvent(tev.id);
18261
+ }
18262
+ }
18216
18263
  }
18217
18264
  function deleteEventFromSeries(idTimestamp, ev) {
18218
18265
  let id2 = idTimestamp;
18219
- idTimestamp = String(id2).split("#") || ev._pid_time;
18266
+ let originalStartTimestamp = new Date(ev.original_start).valueOf();
18267
+ idTimestamp = String(id2).split("#") || ev._pid_time || originalStartTimestamp;
18220
18268
  let nid = scheduler2.uid();
18221
- let tid = idTimestamp[1] ? idTimestamp[1] : ev._pid_time;
18269
+ let tid = idTimestamp[1] ? idTimestamp[1] : ev._pid_time || originalStartTimestamp;
18222
18270
  let nev = scheduler2._copy_event(ev);
18223
18271
  nev.id = nid;
18224
18272
  nev.recurring_event_id = ev.recurring_event_id || idTimestamp[0];
@@ -18263,17 +18311,15 @@ function recurring(scheduler2) {
18263
18311
  }
18264
18312
  scheduler2.attachEvent("onBeforeEventChanged", function(ev, e, is_new, original) {
18265
18313
  if (!is_new && ev && (scheduler2._is_virtual_event(ev.id) || scheduler2._is_modified_occurrence(ev))) {
18266
- if (original && (original.start_date.valueOf() !== ev.start_date.valueOf() || original.end_date.valueOf() !== ev.end_date.valueOf())) {
18267
- if (original.start_date.getDate() !== ev.start_date.getDate()) {
18268
- ev._beforeEventChangedFlag = "edit";
18269
- } else {
18270
- ev._beforeEventChangedFlag = "ask";
18271
- }
18272
- if (!scheduler2.config.collision_limit || scheduler2.checkCollision(ev)) {
18273
- scheduler2._events["$dnd_recurring_placeholder"] = scheduler2._lame_clone(ev);
18274
- scheduler2._showRequiredModalBox(ev.id, ev._beforeEventChangedFlag);
18275
- return false;
18276
- }
18314
+ if (original.start_date.getDate() !== ev.start_date.getDate()) {
18315
+ ev._beforeEventChangedFlag = "edit";
18316
+ } else {
18317
+ ev._beforeEventChangedFlag = "ask";
18318
+ }
18319
+ if (!scheduler2.config.collision_limit || scheduler2.checkCollision(ev)) {
18320
+ scheduler2._events["$dnd_recurring_placeholder"] = scheduler2._lame_clone(ev);
18321
+ scheduler2._showRequiredModalBox(ev.id, ev._beforeEventChangedFlag);
18322
+ return false;
18277
18323
  }
18278
18324
  }
18279
18325
  return true;
@@ -18281,8 +18327,8 @@ function recurring(scheduler2) {
18281
18327
  scheduler2.attachEvent("onEventChanged", function(id2, event2) {
18282
18328
  if (this._loading)
18283
18329
  return true;
18284
- var ev = this.getEvent(id2);
18285
- if (this._is_virtual_event(id2) && !this._isFollowing(id2)) {
18330
+ let ev = this.getEvent(id2);
18331
+ if (this._is_virtual_event(id2)) {
18286
18332
  createException(ev);
18287
18333
  } else {
18288
18334
  if (ev.start_date) {
@@ -18327,30 +18373,32 @@ function recurring(scheduler2) {
18327
18373
  return true;
18328
18374
  });
18329
18375
  scheduler2.attachEvent("onEventSave", function(id2, data, is_new_event) {
18330
- let tempData = { ...data };
18331
18376
  let ev = this.getEvent(id2);
18377
+ let tempEvent = scheduler2._lame_clone(ev);
18378
+ let tempDataRRULE = data.rrule;
18332
18379
  if (ev && isSeries(ev)) {
18333
18380
  if (!is_new_event && this._isFollowing(id2)) {
18334
18381
  if (ev._removeFollowing) {
18335
- ev.end_date = new Date(ev.start_date.valueOf() - 1e3);
18336
- ev._end_date = ev._shorten_end_date;
18337
- ev.start_date = ev._start_date;
18338
- if (ev.end_date.valueOf() <= ev.start_date.valueOf()) {
18382
+ let occurrence = scheduler2.getEvent(ev._thisAndFollowing);
18383
+ if (occurrence && (ev._firstOccurrence || ev._modified)) {
18339
18384
  scheduler2.hideLightbox();
18340
18385
  scheduler2.deleteEvent(ev.id);
18341
18386
  return false;
18342
- }
18343
- ev._shorten = true;
18344
- updateFollowingEventsRRULE(ev);
18345
- scheduler2.updateEvent(ev.id);
18346
- scheduler2.callEvent("onEventChanged", [ev.id, ev]);
18347
- let occurrence = scheduler2.getEvent(ev._thisAndFollowing);
18348
- if (occurrence) {
18349
- for (const i in scheduler2._events) {
18350
- let tev = scheduler2._events[i];
18351
- if (tev.recurring_event_id === id2) {
18352
- if (tev.start_date.valueOf() > tempData.start_date.valueOf()) {
18353
- deleteEventFromSeries(tev.id, tev);
18387
+ } else {
18388
+ ev.end_date = new Date(ev.start_date.valueOf() - 1e3);
18389
+ ev._end_date = ev._shorten_end_date;
18390
+ ev.start_date = ev._start_date;
18391
+ ev._shorten = true;
18392
+ updateFollowingEventsRRULE(ev);
18393
+ scheduler2.callEvent("onEventChanged", [ev.id, ev]);
18394
+ let occurrence2 = scheduler2.getEvent(ev._thisAndFollowing);
18395
+ if (occurrence2) {
18396
+ for (const i in scheduler2._events) {
18397
+ let tev = scheduler2._events[i];
18398
+ if (tev.recurring_event_id === id2) {
18399
+ if (tev.start_date.valueOf() > tempEvent.start_date.valueOf()) {
18400
+ deleteEventFromSeries(tev.id, tev);
18401
+ }
18354
18402
  }
18355
18403
  }
18356
18404
  }
@@ -18359,61 +18407,54 @@ function recurring(scheduler2) {
18359
18407
  return false;
18360
18408
  } else {
18361
18409
  let occurrence = scheduler2.getEvent(ev._thisAndFollowing);
18362
- let futureOcurrences = [];
18363
- for (const i in scheduler2._events) {
18364
- let tev = scheduler2._events[i];
18365
- if (tev.recurring_event_id == id2) {
18366
- if (tev.start_date.valueOf() > tempData.start_date.valueOf()) {
18367
- futureOcurrences.push(tev);
18410
+ if (occurrence && ev._firstOccurrence) {
18411
+ for (const i in scheduler2._events) {
18412
+ let tev = scheduler2._events[i];
18413
+ if (tev.id == ev.id) {
18414
+ setPropsForStorageEvent(i, data, ev, tempEvent);
18368
18415
  }
18369
18416
  }
18370
- }
18371
- ev.end_date = ev._shorten_end_date;
18372
- ev._end_date = ev._shorten_end_date;
18373
- ev.start_date = ev._start_date;
18374
- ev._shorten = true;
18375
- updateFollowingEventsRRULE(ev);
18376
- scheduler2.updateEvent(ev.id);
18377
- scheduler2.callEvent("onEventChanged", [ev.id, ev]);
18378
- let followingEv = { ...tempData };
18379
- followingEv._start_date = followingEv.start_date;
18380
- followingEv._thisAndFollowing = occurrence.id;
18381
- followingEv.id = scheduler2.uid();
18382
- scheduler2.addEvent(followingEv.start_date, followingEv.end_date, followingEv.text, followingEv.id, followingEv);
18383
- for (let i = 0; i < futureOcurrences.length; i++) {
18384
- const ocr = futureOcurrences[i];
18385
- moveToFollowingEvents(ocr, followingEv);
18386
- scheduler2.callEvent("onEventChanged", [ocr.id, ocr]);
18387
- }
18388
- if (occurrence && ev._beforeEventChangedFlag) {
18389
- for (let i in scheduler2._events) {
18417
+ } else if (occurrence && ev._modified) {
18418
+ for (const i in scheduler2._events) {
18390
18419
  let tev = scheduler2._events[i];
18391
- if (tev.recurring_event_id == id2) {
18392
- if (tev.start_date.valueOf() >= tempData.start_date.valueOf()) {
18393
- deleteEventFromSeries(tev.id, tev);
18394
- }
18420
+ if (tev.recurring_event_id == id2 && tev.id == tempEvent._thisAndFollowing) {
18421
+ setPropsForStorageEvent(i, data, ev, tempEvent);
18395
18422
  }
18396
18423
  }
18424
+ } else {
18425
+ if (scheduler2._is_modified_occurrence(occurrence)) {
18426
+ deleteExceptionFromStorage(occurrence);
18427
+ }
18428
+ ev.end_date = ev._shorten_end_date;
18429
+ ev._end_date = ev._shorten_end_date;
18430
+ ev.start_date = ev._start_date;
18431
+ ev._shorten = true;
18432
+ updateFollowingEventsRRULE(ev);
18433
+ scheduler2.callEvent("onEventChanged", [ev.id, ev]);
18434
+ let followingEv = { ...tempEvent };
18435
+ followingEv.text = data.text;
18436
+ followingEv.duration = data.duration;
18437
+ followingEv.rrule = tempDataRRULE;
18438
+ followingEv._start_date = null;
18439
+ followingEv.id = scheduler2.uid();
18440
+ scheduler2.addEvent(followingEv.start_date, followingEv.end_date, followingEv.text, followingEv.id, followingEv);
18441
+ }
18442
+ if (!is_new_event) {
18443
+ updateTextEvents(id2, data);
18397
18444
  }
18398
18445
  scheduler2.hideLightbox();
18399
18446
  return false;
18400
18447
  }
18401
18448
  }
18402
- if (!is_new_event) {
18403
- for (let i in scheduler2._events) {
18404
- let tev = scheduler2._events[i];
18405
- if (tev.recurring_event_id == id2) {
18406
- tev.text = tempData.text;
18407
- scheduler2.updateEvent(tev.id);
18408
- }
18409
- }
18410
- }
18411
18449
  }
18412
- if (tempData._ocr && tempData._beforeEventChangedFlag) {
18413
- ev.start_date = tempData.start_date;
18414
- ev.end_date = tempData.end_date;
18415
- ev._start_date = tempData._start_date;
18416
- ev._end_date = tempData._end_date;
18450
+ if (!is_new_event) {
18451
+ updateTextEvents(id2, data);
18452
+ }
18453
+ if (tempEvent._ocr && tempEvent._beforeEventChangedFlag) {
18454
+ ev.start_date = tempEvent.start_date;
18455
+ ev.end_date = tempEvent.end_date;
18456
+ ev._start_date = tempEvent._start_date;
18457
+ ev._end_date = tempEvent._end_date;
18417
18458
  scheduler2.updateEvent(ev.id);
18418
18459
  return true;
18419
18460
  }
@@ -18465,6 +18506,10 @@ function recurring(scheduler2) {
18465
18506
  ev._shorten_end_date = null;
18466
18507
  if (ev._removeFollowing)
18467
18508
  ev._removeFollowing = null;
18509
+ if (ev._firstOccurrence)
18510
+ ev._firstOccurrence = null;
18511
+ if (ev._modified)
18512
+ ev._modified = null;
18468
18513
  };
18469
18514
  scheduler2._is_virtual_event = function(id2) {
18470
18515
  return id2.toString().indexOf("#") != -1;
@@ -18485,13 +18530,23 @@ function recurring(scheduler2) {
18485
18530
  const showRequiredLightbox = function(id3, type) {
18486
18531
  const occurrence = scheduler2.getEvent(id3);
18487
18532
  const event2 = scheduler2.getEvent(pid);
18533
+ const view = scheduler2.getView();
18534
+ if (view && occurrence[view.y_property]) {
18535
+ event2[view.y_property] = occurrence[view.y_property];
18536
+ }
18537
+ if (view && occurrence[view.property]) {
18538
+ event2[view.property] = occurrence[view.property];
18539
+ }
18488
18540
  if (type === "Occurrence") {
18489
18541
  return scheduler2.showLightbox_rec(id3);
18490
18542
  }
18491
18543
  if (type === "Following") {
18492
- if (+occurrence.start_date === +event2.start_date) {
18493
- event2._end_date = event2.end_date;
18494
- event2.end_date = new Date(occurrence.start_date.valueOf() + event2.duration * 1e3);
18544
+ if (scheduler2._isExceptionFirstOccurrence(occurrence)) {
18545
+ setPropsForFirstOccurrence(event2, occurrence);
18546
+ return scheduler2.showLightbox_rec(pid);
18547
+ }
18548
+ if (scheduler2._isFirstOccurrence(occurrence)) {
18549
+ setPropsForFirstOccurrence(event2, occurrence);
18495
18550
  return scheduler2.showLightbox_rec(pid);
18496
18551
  } else {
18497
18552
  event2._end_date = event2.end_date;
@@ -18501,9 +18556,6 @@ function recurring(scheduler2) {
18501
18556
  event2._start_date = event2.start_date;
18502
18557
  event2.start_date = occurrence.start_date;
18503
18558
  event2._thisAndFollowing = occurrence.id;
18504
- if (event2.rrule) {
18505
- updateFollowingWithWEEKLY(pid);
18506
- }
18507
18559
  if (ev._beforeEventChangedFlag) {
18508
18560
  event2._beforeEventChangedFlag = ev._beforeEventChangedFlag;
18509
18561
  event2._shorten_end_date = new Date(originalStart.valueOf() - 1e3);
@@ -18512,6 +18564,14 @@ function recurring(scheduler2) {
18512
18564
  }
18513
18565
  }
18514
18566
  if (type === "AllEvents") {
18567
+ if (scheduler2._isExceptionFirstOccurrence(occurrence)) {
18568
+ setPropsForFirstOccurrence(event2, occurrence);
18569
+ return scheduler2.showLightbox_rec(pid);
18570
+ }
18571
+ if (scheduler2._isFirstOccurrence(occurrence)) {
18572
+ setPropsForFirstOccurrence(event2, occurrence);
18573
+ return scheduler2.showLightbox_rec(pid);
18574
+ }
18515
18575
  const tempStart = new Date(event2.start_date);
18516
18576
  event2._end_date = event2.end_date;
18517
18577
  event2._start_date = tempStart;
@@ -18519,6 +18579,7 @@ function recurring(scheduler2) {
18519
18579
  event2.start_date.setMinutes(occurrence.start_date.getMinutes());
18520
18580
  event2.start_date.setSeconds(occurrence.start_date.getSeconds());
18521
18581
  event2.end_date = new Date(event2.start_date.valueOf() + event2.duration * 1e3);
18582
+ event2._thisAndFollowing = null;
18522
18583
  return scheduler2.showLightbox_rec(pid);
18523
18584
  }
18524
18585
  };
@@ -18576,6 +18637,14 @@ function recurring(scheduler2) {
18576
18637
  pid = occurrence.id.split("#")[0];
18577
18638
  }
18578
18639
  let event2 = scheduler2.getEvent(pid);
18640
+ const view = scheduler2.getView();
18641
+ let tempEvent = scheduler2._lame_clone(event2);
18642
+ if (view && occurrence[view.y_property]) {
18643
+ tempEvent[view.y_property] = occurrence[view.y_property];
18644
+ }
18645
+ if (view && occurrence[view.property]) {
18646
+ tempEvent[view.property] = occurrence[view.property];
18647
+ }
18579
18648
  let tempStartDate;
18580
18649
  let tempEndDate;
18581
18650
  if (occurrence && occurrence._beforeEventChangedFlag) {
@@ -18583,34 +18652,53 @@ function recurring(scheduler2) {
18583
18652
  tempEndDate = occurrence.end_date;
18584
18653
  }
18585
18654
  const handleOccurrence = function(occurrence2) {
18586
- let tempEvent = scheduler2.getEvent("$dnd_recurring_placeholder");
18655
+ let tempEvent2 = { ...event2, ...scheduler2.getEvent("$dnd_recurring_placeholder") };
18587
18656
  if (tempEndDate && tempStartDate) {
18588
- tempEvent.start_date = tempStartDate;
18589
- tempEvent.end_date = tempEndDate;
18590
- tempEvent._beforeEventChangedFlag = occurrence2._beforeEventChangedFlag;
18591
- tempEvent._ocr = true;
18657
+ tempEvent2.start_date = tempStartDate;
18658
+ tempEvent2.end_date = tempEndDate;
18659
+ tempEvent2._beforeEventChangedFlag = occurrence2._beforeEventChangedFlag;
18660
+ tempEvent2._ocr = true;
18592
18661
  }
18593
- if (!scheduler2.config.collision_limit || scheduler2.checkCollision(tempEvent)) {
18662
+ if (!scheduler2.config.collision_limit || scheduler2.checkCollision(tempEvent2)) {
18594
18663
  for (const i in scheduler2._events) {
18595
18664
  let tev = scheduler2._events[i];
18596
- if (tev.id == tempEvent.id) {
18597
- scheduler2._events[i] = { ...tempEvent };
18598
- scheduler2.callEvent("onEventSave", [scheduler2._events[i].id, scheduler2._events[i], scheduler2._new_event]);
18599
- scheduler2.callEvent("onEventChanged", [occurrence2.id, occurrence2]);
18665
+ if (i === "$dnd_recurring_placeholder") {
18666
+ continue;
18667
+ }
18668
+ if (tev.id == tempEvent2.id) {
18669
+ scheduler2._events[i] = { ...tempEvent2 };
18670
+ scheduler2.callEvent("onEventChanged", [scheduler2._events[i].id, scheduler2._events[i]]);
18600
18671
  }
18601
18672
  }
18602
18673
  }
18603
18674
  };
18604
18675
  const handleFollowing = function(occurrence2) {
18605
- let tempEvent = scheduler2._lame_clone(event2);
18676
+ let initialOccurrence = scheduler2._lame_clone(occurrence2);
18606
18677
  if (tempEndDate && tempStartDate) {
18607
18678
  occurrence2._start_date = occurrence2.start_date;
18608
18679
  occurrence2.start_date = tempStartDate;
18609
18680
  occurrence2.end_date = tempEndDate;
18610
18681
  }
18611
- if (+occurrence2.start_date === +event2.start_date) {
18612
- tempEvent._end_date = event2.end_date;
18613
- tempEvent.end_date = new Date(occurrence2.start_date.valueOf() + event2.duration * 1e3);
18682
+ if (scheduler2._isFirstOccurrence(initialOccurrence) || scheduler2._isExceptionFirstOccurrence(initialOccurrence)) {
18683
+ if (scheduler2._isExceptionFirstOccurrence(initialOccurrence)) {
18684
+ deleteExceptionFromStorage(initialOccurrence);
18685
+ }
18686
+ tempEvent._start_date = event2.start_date;
18687
+ tempEvent.start_date = occurrence2.start_date;
18688
+ tempEvent.duration = (+occurrence2.end_date - +occurrence2.start_date) / 1e3;
18689
+ tempEvent._beforeEventChangedFlag = occurrence2._beforeEventChangedFlag;
18690
+ if (tempEvent.rrule) {
18691
+ updateFollowingWithWEEKLY(tempEvent.id, tempEvent);
18692
+ }
18693
+ if (!scheduler2.config.collision_limit || scheduler2.checkCollision(tempEvent)) {
18694
+ for (const i in scheduler2._events) {
18695
+ let tev = scheduler2._events[i];
18696
+ if (tev.id == tempEvent.id) {
18697
+ scheduler2._events[i] = { ...tempEvent };
18698
+ scheduler2.callEvent("onEventChanged", [scheduler2._events[i].id, scheduler2._events[i]]);
18699
+ }
18700
+ }
18701
+ }
18614
18702
  } else {
18615
18703
  tempEvent._end_date = event2.end_date;
18616
18704
  const originalStart = occurrence2.original_start || scheduler2.date.date_part(new Date(occurrence2._start_date));
@@ -18622,29 +18710,34 @@ function recurring(scheduler2) {
18622
18710
  if (tempEvent.rrule) {
18623
18711
  updateFollowingWithWEEKLY(tempEvent.id, tempEvent);
18624
18712
  }
18625
- }
18626
- let tempEnd = tempEvent.end_date;
18627
- tempEvent.end_date = tempEvent._end_date;
18628
- if (!scheduler2.config.collision_limit || scheduler2.checkCollision(tempEvent)) {
18629
- tempEvent.end_date = tempEnd;
18630
- for (const i in scheduler2._events) {
18631
- let tev = scheduler2._events[i];
18632
- if (tev.id == tempEvent.id) {
18633
- scheduler2._events[i] = { ...tempEvent };
18634
- scheduler2.callEvent("onEventSave", [scheduler2._events[i].id, scheduler2._events[i], scheduler2._new_event]);
18635
- scheduler2.callEvent("onEventChanged", [scheduler2._events[i].id, scheduler2._events[i]]);
18713
+ let tempEnd = tempEvent.end_date;
18714
+ tempEvent.end_date = tempEvent._end_date;
18715
+ if (!scheduler2.config.collision_limit || scheduler2.checkCollision(tempEvent)) {
18716
+ tempEvent.end_date = tempEnd;
18717
+ for (const i in scheduler2._events) {
18718
+ let tev = scheduler2._events[i];
18719
+ if (tev.id == tempEvent.id) {
18720
+ scheduler2._events[i] = { ...tempEvent };
18721
+ scheduler2.callEvent("onEventSave", [scheduler2._events[i].id, scheduler2._events[i], scheduler2._new_event]);
18722
+ scheduler2.callEvent("onEventChanged", [scheduler2._events[i].id, scheduler2._events[i]]);
18723
+ }
18636
18724
  }
18637
18725
  }
18638
18726
  }
18639
18727
  };
18640
18728
  const handleAllEvents = function(occurrence2) {
18641
- let tempEvent = scheduler2._lame_clone(event2);
18729
+ let initialOccurrence = scheduler2._lame_clone(occurrence2);
18730
+ if (scheduler2._isExceptionFirstOccurrence(initialOccurrence)) {
18731
+ deleteExceptionFromStorage(initialOccurrence);
18732
+ }
18642
18733
  if (tempEndDate && tempStartDate) {
18643
18734
  tempEvent.start_date.setHours(tempStartDate.getHours());
18644
18735
  tempEvent.start_date.setMinutes(tempStartDate.getMinutes());
18645
18736
  tempEvent.start_date.setSeconds(tempStartDate.getSeconds());
18737
+ tempEvent.duration = (+tempEndDate - +tempStartDate) / 1e3;
18646
18738
  }
18647
18739
  tempEvent._beforeEventChangedFlag = occurrence2._beforeEventChangedFlag;
18740
+ tempEvent._thisAndFollowing = null;
18648
18741
  if (!scheduler2.config.collision_limit || scheduler2.checkCollision(tempEvent)) {
18649
18742
  for (const i in scheduler2._events) {
18650
18743
  let tev = scheduler2._events[i];
@@ -18739,22 +18832,17 @@ function recurring(scheduler2) {
18739
18832
  if (!seriesExceptions) {
18740
18833
  seriesExceptions = {};
18741
18834
  }
18742
- if (!from) {
18743
- from = scheduler2._min_date;
18744
- }
18745
- if (!to) {
18746
- to = scheduler2._max_date;
18747
- }
18748
- const utcStart = new Date(Date.UTC(ev.start_date.getFullYear(), ev.start_date.getMonth(), ev.start_date.getDate(), ev.start_date.getHours(), ev.start_date.getMinutes(), ev.start_date.getSeconds()));
18835
+ from = toUTCDate(from || new Date(scheduler2._min_date.valueOf() - 7 * 24 * 60 * 60 * 1e3));
18836
+ to = toUTCDate(to || new Date(scheduler2._max_date.valueOf() - 1e3));
18837
+ const utcStart = toUTCDate(ev.start_date);
18749
18838
  let parsedRRule;
18750
18839
  if (maxCount) {
18751
18840
  parsedRRule = rrulestr(`RRULE:${ev.rrule};UNTIL=${toIcalString(ev.end_date)};COUNT=${maxCount}`, { dtstart: utcStart });
18752
18841
  } else {
18753
18842
  parsedRRule = rrulestr(`RRULE:${ev.rrule};UNTIL=${toIcalString(ev.end_date)}`, { dtstart: utcStart });
18754
18843
  }
18755
- const utcTo = new Date(Date.UTC(to.getFullYear(), to.getMonth(), to.getDate(), to.getHours(), to.getMinutes(), to.getSeconds()));
18756
- const repeatedDates = parsedRRule.between(from, utcTo).map((date) => {
18757
- const adjustedDate = new Date(date);
18844
+ const repeatedDates = parsedRRule.between(from, to, true).map((date) => {
18845
+ const adjustedDate = setUTCPartsToDate(date);
18758
18846
  adjustedDate.setHours(ev.start_date.getHours());
18759
18847
  adjustedDate.setMinutes(ev.start_date.getMinutes());
18760
18848
  adjustedDate.setSeconds(ev.start_date.getSeconds());
@@ -18769,7 +18857,7 @@ function recurring(scheduler2) {
18769
18857
  const date = repeatedDates[i];
18770
18858
  let exception = seriesExceptions[date.valueOf()];
18771
18859
  if (exception) {
18772
- if (exception.deleted) {
18860
+ if (exception.deleted || exception.end_date.valueOf() < scheduler2._min_date.valueOf()) {
18773
18861
  continue;
18774
18862
  } else {
18775
18863
  visibleCount++;
@@ -18781,6 +18869,9 @@ function recurring(scheduler2) {
18781
18869
  copy2.start_date = date;
18782
18870
  copy2.id = ev.id + "#" + Math.ceil(date.valueOf());
18783
18871
  copy2.end_date = new Date(date.valueOf() + eventDuration * 1e3);
18872
+ if (copy2.end_date.valueOf() < scheduler2._min_date.valueOf()) {
18873
+ continue;
18874
+ }
18784
18875
  copy2.end_date = scheduler2._fix_daylight_saving_date(copy2.start_date, copy2.end_date, ev, date, copy2.end_date);
18785
18876
  copy2._timed = scheduler2.isOneDayEvent(copy2);
18786
18877
  if (!copy2._timed && !scheduler2._table_view && !scheduler2.config.multi_day)
@@ -18797,7 +18888,7 @@ function recurring(scheduler2) {
18797
18888
  for (let a in seriesExceptions) {
18798
18889
  let exception = seriesExceptions[a];
18799
18890
  if (exception) {
18800
- if (exception.deleted) {
18891
+ if (exception.deleted || exception.end_date.valueOf() < scheduler2._min_date.valueOf()) {
18801
18892
  continue;
18802
18893
  } else if (from && to && exception.start_date < to && exception.end_date > from) {
18803
18894
  stack.push(exception);
@@ -20935,69 +21026,6 @@ function year_view(scheduler2) {
20935
21026
  scheduler2._hideToolTip();
20936
21027
  }
20937
21028
  };
20938
- scheduler2._reset_year_scale = function() {
20939
- this._cols = [];
20940
- this._colsS = {};
20941
- var week_starts = [];
20942
- var dataArea = this._els["dhx_cal_data"][0];
20943
- var c = this.config;
20944
- dataArea.scrollTop = 0;
20945
- dataArea.innerHTML = "";
20946
- Math.floor((parseInt(dataArea.style.height) - scheduler2.xy.year_top) / c.year_y);
20947
- var week_template = document.createElement("div");
20948
- var dummy_date = this.date.week_start(scheduler2._currentDate());
20949
- this._process_ignores(dummy_date, 7, "day", 1);
20950
- for (var i = 0; i < 7; i++) {
20951
- if (!(this._ignores && this._ignores[i])) {
20952
- this._cols[i] = "var(--dhx-scheduler-datepicker-cell-size)";
20953
- this._render_x_header(i, 0, dummy_date, week_template);
20954
- }
20955
- dummy_date = this.date.add(dummy_date, 1, "day");
20956
- }
20957
- week_template.lastChild.className += " dhx_scale_bar_last";
20958
- for (var i = 0; i < week_template.childNodes.length; i++) {
20959
- this._waiAria.yearHeadCell(week_template.childNodes[i]);
20960
- }
20961
- var sd = this.date[this._mode + "_start"](this.date.copy(this._date));
20962
- var ssd = sd;
20963
- var yearBox = null;
20964
- const wrapper = document.createElement("div");
20965
- wrapper.classList.add("dhx_year_wrapper");
20966
- for (var i = 0; i < c.year_y; i++) {
20967
- for (var j = 0; j < c.year_x; j++) {
20968
- yearBox = document.createElement("div");
20969
- yearBox.className = "dhx_year_box";
20970
- yearBox.setAttribute("date", this._helpers.formatDate(sd));
20971
- yearBox.setAttribute("data-month-date", this._helpers.formatDate(sd));
20972
- yearBox.innerHTML = "<div class='dhx_year_month'></div><div class='dhx_year_grid'><div class='dhx_year_week'>" + week_template.innerHTML + "</div><div class='dhx_year_body'></div></div>";
20973
- var header = yearBox.querySelector(".dhx_year_month");
20974
- var grid = yearBox.querySelector(".dhx_year_grid");
20975
- var body = yearBox.querySelector(".dhx_year_body");
20976
- var headerId = scheduler2.uid();
20977
- this._waiAria.yearHeader(header, headerId);
20978
- this._waiAria.yearGrid(grid, headerId);
20979
- header.innerHTML = this.templates.year_month(sd);
20980
- var dd = this.date.week_start(sd);
20981
- this._reset_month_scale(body, sd, dd, 6);
20982
- var days = body.querySelectorAll("td");
20983
- for (var day = 0; day < days.length; day++) {
20984
- this._waiAria.yearDayCell(days[day]);
20985
- }
20986
- wrapper.appendChild(yearBox);
20987
- week_starts[i * c.year_x + j] = (sd.getDay() - (this.config.start_on_monday ? 1 : 0) + 7) % 7;
20988
- sd = this.date.add(sd, 1, "month");
20989
- }
20990
- }
20991
- dataArea.appendChild(wrapper);
20992
- var dateElement = this._getNavDateElement();
20993
- if (dateElement) {
20994
- dateElement.innerHTML = this.templates[this._mode + "_date"](ssd, sd, this._mode);
20995
- }
20996
- this.week_starts = week_starts;
20997
- week_starts._month = ssd.getMonth();
20998
- this._min_date = ssd;
20999
- this._max_date = sd;
21000
- };
21001
21029
  scheduler2._reset_year_scale = function() {
21002
21030
  var dataArea = this._els["dhx_cal_data"][0];
21003
21031
  dataArea.scrollTop = 0;