@syncfusion/ej2-schedule 27.1.56 → 27.1.58

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.
@@ -4079,7 +4079,7 @@ function generate(startDate, rule, excludeDate, startDayOfWeek, maximumCount, vi
4079
4079
  dailyType(modifiedDate, ruleObject.until, data, ruleObject);
4080
4080
  break;
4081
4081
  case 'WEEKLY':
4082
- weeklyType(modifiedDate, ruleObject.until, data, ruleObject);
4082
+ weeklyType(modifiedDate, ruleObject.until, data, ruleObject, startDayOfWeek);
4083
4083
  break;
4084
4084
  case 'MONTHLY':
4085
4085
  monthlyType(modifiedDate, ruleObject.until, data, ruleObject);
@@ -4182,10 +4182,11 @@ function dailyType(startDate, endDate, data, ruleObject) {
4182
4182
  * @param {Date} endDate Accepts the end date
4183
4183
  * @param {number[]} data Accepts the collection of dates
4184
4184
  * @param {RecRule} ruleObject Accepts the recurrence rule object
4185
+ * @param {number} startDayOfWeek Accepts the start day index of week
4185
4186
  * @returns {void}
4186
4187
  * @private
4187
4188
  */
4188
- function weeklyType(startDate, endDate, data, ruleObject) {
4189
+ function weeklyType(startDate, endDate, data, ruleObject, startDayOfWeek) {
4189
4190
  var tempDate = new Date(startDate.getTime());
4190
4191
  if (!ruleObject.day.length) {
4191
4192
  ruleObject.day.push(DAYINDEX[startDate.getDay()]);
@@ -4234,7 +4235,7 @@ function weeklyType(startDate, endDate, data, ruleObject) {
4234
4235
  }
4235
4236
  else {
4236
4237
  tempDate = getStartDateForWeek(startDate, ruleObject.day);
4237
- if (interval > 1 && dayIndex.indexOf(ruleObject.day[0]) < startDate.getDay()) {
4238
+ if (interval > 1 && dayIndex.indexOf(ruleObject.day[0]) < (startDate.getDay() - startDayOfWeek)) {
4238
4239
  tempDate.setDate(tempDate.getDate() + ((interval - 1) * 7));
4239
4240
  }
4240
4241
  while (compareDates(tempDate, endDate)) {
@@ -6140,11 +6141,14 @@ var EventBase = /** @__PURE__ @class */ (function () {
6140
6141
  if (eventsData.length > 0) {
6141
6142
  var selectedObject = eventsData[eventsData.length - 1];
6142
6143
  var eventStartTime = selectedObject[this.parent.eventFields.startTime];
6143
- var nearestTime = new Date(+eventStartTime).setMinutes(0, 0, 0);
6144
+ var nearestTime = void 0;
6144
6145
  var isAllDay = this.isAllDayAppointment(selectedObject);
6145
- if (this.parent.currentView === 'Month' || isAllDay) {
6146
+ if (this.parent.currentView === 'Month' || isAllDay || !this.parent.activeViewOptions.timeScale.enable) {
6146
6147
  nearestTime = new Date(+eventStartTime).setHours(0, 0, 0, 0);
6147
6148
  }
6149
+ else {
6150
+ nearestTime = this.findNearestSlot(eventStartTime);
6151
+ }
6148
6152
  var targetArea = void 0;
6149
6153
  if (isAllDay && ['Day', 'Week', 'WorkWeek'].indexOf(this.parent.currentView) !== -1) {
6150
6154
  targetArea = this.parent.getAllDayRow();
@@ -6153,7 +6157,8 @@ var EventBase = /** @__PURE__ @class */ (function () {
6153
6157
  targetArea = this.parent.getContentTable();
6154
6158
  }
6155
6159
  var queryString = '[data-date="' + new Date(nearestTime).getTime() + '"]';
6156
- if (this.parent.activeViewOptions.group.resources.length > 0) {
6160
+ if (!isNullOrUndefined(this.parent.activeViewOptions.group.resources) &&
6161
+ this.parent.activeViewOptions.group.resources.length > 0) {
6157
6162
  queryString += '[data-group-index="' + this.getGroupIndexFromEvent(selectedObject) + '"]';
6158
6163
  }
6159
6164
  target = targetArea.querySelector(queryString);
@@ -6167,6 +6172,25 @@ var EventBase = /** @__PURE__ @class */ (function () {
6167
6172
  }
6168
6173
  return target;
6169
6174
  };
6175
+ EventBase.prototype.findNearestSlot = function (appointmentTime) {
6176
+ var msMajorInterval = this.parent.activeViewOptions.timeScale.interval * MS_PER_MINUTE;
6177
+ var msInterval = msMajorInterval / this.parent.activeViewOptions.timeScale.slotCount;
6178
+ var numberOfSlots = Math.round(MS_PER_DAY / msInterval);
6179
+ var startTime = new Date(appointmentTime);
6180
+ startTime.setHours(0, 0, 0, 0);
6181
+ var slots = Array.from({ length: numberOfSlots }, function (_, i) {
6182
+ var slotTime = new Date(startTime.getTime() + i * msInterval);
6183
+ return slotTime;
6184
+ });
6185
+ var nearestSlot = slots.reduce(function (nearest, slot) {
6186
+ var difference = Math.abs(appointmentTime.getTime() - slot.getTime());
6187
+ if (!nearest || difference < Math.abs(appointmentTime.getTime() - nearest.getTime())) {
6188
+ return slot;
6189
+ }
6190
+ return nearest;
6191
+ }, null);
6192
+ return Math.trunc(nearestSlot.getTime() / 1000) * 1000;
6193
+ };
6170
6194
  EventBase.prototype.getGroupIndexFromEvent = function (eventData) {
6171
6195
  var levelIndex;
6172
6196
  var resource;
@@ -6468,7 +6492,7 @@ var EventBase = /** @__PURE__ @class */ (function () {
6468
6492
  var newTimezone = this.parent.timezone || this.parent.tzModule.getLocalTimezoneName();
6469
6493
  var firstDay = this.parent.activeViewOptions.firstDayOfWeek;
6470
6494
  var calendarMode = this.parent.calendarMode;
6471
- if (event[this.parent.eventFields.recurrenceRule] && event[this.parent.eventFields.recurrenceRule].includes('BYMONTHDAY') &&
6495
+ if (event[this.parent.eventFields.recurrenceRule] && this.isDayBasedRecurrence(event) &&
6472
6496
  this.parent.timezone && event[this.parent.eventFields.startTimezone] && event[this.parent.eventFields.endTimezone]) {
6473
6497
  startDate = this.parent.tzModule.convert(event[this.parent.eventFields.startTime], this.parent.timezone, event[this.parent.eventFields.startTimezone]);
6474
6498
  }
@@ -6488,7 +6512,7 @@ var EventBase = /** @__PURE__ @class */ (function () {
6488
6512
  }
6489
6513
  var isDSTAdjusted = false;
6490
6514
  var convertedDates = [];
6491
- if (event[this.parent.eventFields.recurrenceRule] && event[this.parent.eventFields.recurrenceRule].includes('BYMONTHDAY') &&
6515
+ if (event[this.parent.eventFields.recurrenceRule] && this.isDayBasedRecurrence(event) &&
6492
6516
  this.parent.timezone && event[this.parent.eventFields.startTimezone] && event[this.parent.eventFields.endTimezone]) {
6493
6517
  isDSTAdjusted = true;
6494
6518
  convertedDates.push.apply(convertedDates, dates.map(function (date) {
@@ -6511,6 +6535,10 @@ var EventBase = /** @__PURE__ @class */ (function () {
6511
6535
  }
6512
6536
  return occurrenceCollection;
6513
6537
  };
6538
+ EventBase.prototype.isDayBasedRecurrence = function (event) {
6539
+ return (event[this.parent.eventFields.recurrenceRule].includes('BYMONTHDAY')
6540
+ || event[this.parent.eventFields.recurrenceRule].includes('BYDAY'));
6541
+ };
6514
6542
  EventBase.prototype.getDSTAdjustedTime = function (date, event) {
6515
6543
  var occurDate = date;
6516
6544
  if (this.parent.timezone &&
@@ -29367,10 +29395,12 @@ var Print = /** @__PURE__ @class */ (function () {
29367
29395
  var _this = this;
29368
29396
  this.printWindow = print$1(this.printInstance.element, this.printWindow);
29369
29397
  this.printWindow.onbeforeunload = function () {
29370
- _this.printInstance.off(print, _this.contentReady);
29371
- _this.printInstance.element.remove();
29372
- _this.printInstance.destroy();
29373
- _this.printInstance = null;
29398
+ if (_this.printInstance) {
29399
+ _this.printInstance.off(print, _this.contentReady);
29400
+ _this.printInstance.element.remove();
29401
+ _this.printInstance.destroy();
29402
+ _this.printInstance = null;
29403
+ }
29374
29404
  _this.printWindow = null;
29375
29405
  };
29376
29406
  };