@syncfusion/ej2-schedule 20.2.36 → 20.2.43

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.
@@ -5154,7 +5154,7 @@ class EventBase {
5154
5154
  if (timeZonePropChanged) {
5155
5155
  this.processTimezoneChange(event, oldTimezone);
5156
5156
  }
5157
- else if (!this.parent.isPrinting && !this.parent.uiStateValues.isResize) {
5157
+ else if (!this.parent.isPrinting && !this.parent.uiStateValues.isPreventTimezone) {
5158
5158
  event = this.processTimezone(event);
5159
5159
  }
5160
5160
  for (let level = 0; level < resourceCollection.length; level++) {
@@ -5966,8 +5966,9 @@ class EventBase {
5966
5966
  }
5967
5967
  }
5968
5968
  const occurrenceCollection = [];
5969
- for (const date of dates) {
5969
+ for (let date of dates) {
5970
5970
  const clonedObject = extend({}, event, null, true);
5971
+ date = this.getDSTAdjustedTime(date, clonedObject);
5971
5972
  clonedObject[this.parent.eventFields.startTime] = new Date(date);
5972
5973
  clonedObject[this.parent.eventFields.endTime] = new Date(new Date(date).setMilliseconds(duration));
5973
5974
  clonedObject[this.parent.eventFields.recurrenceID] = clonedObject[this.parent.eventFields.id];
@@ -5978,6 +5979,21 @@ class EventBase {
5978
5979
  }
5979
5980
  return occurrenceCollection;
5980
5981
  }
5982
+ getDSTAdjustedTime(date, event) {
5983
+ let occurDate = date;
5984
+ if (this.parent.timezone &&
5985
+ (event[this.parent.eventFields.startTimezone] || event[this.parent.eventFields.endTimezone])) {
5986
+ const eventOffset = this.getDSTDiff(event[this.parent.eventFields.startTime], new Date(date), event[this.parent.eventFields.startTimezone]);
5987
+ const schOffset = this.getDSTDiff(event[this.parent.eventFields.startTime], new Date(date), this.parent.timezone);
5988
+ occurDate = (new Date(date).getTime() - (eventOffset - schOffset) * 60000);
5989
+ }
5990
+ return occurDate;
5991
+ }
5992
+ getDSTDiff(startDate, occurDate, timezone) {
5993
+ const startOffset = this.parent.tzModule.offset(new Date(startDate), timezone);
5994
+ const occurOffset = this.parent.tzModule.offset(new Date(occurDate), timezone);
5995
+ return startOffset - occurOffset;
5996
+ }
5981
5997
  getParentEvent(eventObj, isParent = false) {
5982
5998
  let parentEvent;
5983
5999
  do {
@@ -11274,6 +11290,7 @@ class EventWindow {
11274
11290
  setDialogContent() {
11275
11291
  this.dialogObject.content = this.getEventWindowContent();
11276
11292
  this.dialogObject.dataBind();
11293
+ this.applyFormValidation();
11277
11294
  }
11278
11295
  preventEventSave(e) {
11279
11296
  if (this.parent && !this.parent.allowKeyboardInteraction && e.code === 'Enter') {
@@ -13385,7 +13402,7 @@ class Crud {
13385
13402
  const resultData = extend([], args.result, null, true);
13386
13403
  this.parent.eventsData = resultData.filter((data) => !data[this.parent.eventFields.isBlock]);
13387
13404
  this.parent.blockData = resultData.filter((data) => data[this.parent.eventFields.isBlock]);
13388
- this.parent.refreshEvents(false);
13405
+ this.refreshProcessedData();
13389
13406
  if (this.parent.dragAndDropModule && this.parent.dragAndDropModule.actionObj.action === 'drag') {
13390
13407
  this.parent.dragAndDropModule.navigationWrapper();
13391
13408
  }
@@ -13403,6 +13420,31 @@ class Crud {
13403
13420
  }
13404
13421
  this.parent.trigger(actionFailure, { error: e }, () => this.parent.hideSpinner());
13405
13422
  }
13423
+ refreshProcessedData() {
13424
+ if (this.parent.dragAndDropModule) {
13425
+ this.parent.dragAndDropModule.actionObj.action = '';
13426
+ removeClass([this.parent.element], 'e-event-action');
13427
+ }
13428
+ if (this.parent.activeViewOptions && this.parent.activeViewOptions.eventTemplate) {
13429
+ let templateNames = ['eventTemplate'];
13430
+ if (this.crudObj.isCrudAction &&
13431
+ ['Agenda', 'MonthAgenda', 'Year', 'TimelineYear'].indexOf(this.parent.currentView) === -1) {
13432
+ templateNames = [];
13433
+ for (let i = 0, len = this.crudObj.sourceEvent.length; i < len; i++) {
13434
+ templateNames.push('eventTemplate_' + this.crudObj.sourceEvent[i].groupIndex);
13435
+ if (this.crudObj.targetEvent[i] && this.crudObj.sourceEvent[i].groupIndex !==
13436
+ this.crudObj.targetEvent[i].groupIndex) {
13437
+ templateNames.push('eventTemplate_' + this.crudObj.targetEvent[i].groupIndex);
13438
+ }
13439
+ }
13440
+ }
13441
+ this.parent.resetTemplates(templateNames);
13442
+ }
13443
+ const eventsData = this.parent.eventsData || [];
13444
+ const blockData = this.parent.blockData || [];
13445
+ const data = eventsData.concat(blockData);
13446
+ this.parent.notify(dataReady, { processedData: this.parent.eventBase ? this.parent.eventBase.processData(data) : [] });
13447
+ }
13406
13448
  refreshData(args) {
13407
13449
  const actionArgs = {
13408
13450
  requestType: args.requestType, cancel: false, data: args.data,
@@ -15902,7 +15944,7 @@ let Schedule = class Schedule extends Component {
15902
15944
  if (this && isNullOrUndefined(this.uiStateValues) || !(this.enablePersistence)) {
15903
15945
  this.uiStateValues = {
15904
15946
  expand: false, isInitial: true, left: 0, top: 0, isGroupAdaptive: false,
15905
- isIgnoreOccurrence: false, groupIndex: 0, action: false, isBlock: false, isCustomMonth: true, isResize: false
15947
+ isIgnoreOccurrence: false, groupIndex: 0, action: false, isBlock: false, isCustomMonth: true, isPreventTimezone: false
15906
15948
  };
15907
15949
  }
15908
15950
  this.activeCellsData = { startTime: this.getCurrentTime(), endTime: this.getCurrentTime(), isAllDay: false };
@@ -16362,11 +16404,9 @@ let Schedule = class Schedule extends Component {
16362
16404
  }
16363
16405
  if (this.currentView === 'Month' || ((this.currentView !== 'Agenda' && this.currentView !== 'MonthAgenda')
16364
16406
  && !this.activeViewOptions.timeScale.enable) || this.activeView.isTimelineView()) {
16365
- this.uiStateValues.isResize = true;
16366
16407
  this.activeView.resetColWidth();
16367
16408
  this.notify(scrollUiUpdate, { cssProperties: this.getCssProperties(), isPreventScrollUpdate: true });
16368
16409
  this.refreshEvents(false);
16369
- this.uiStateValues.isResize = false;
16370
16410
  }
16371
16411
  else {
16372
16412
  this.notify(contentReady, {});
@@ -17432,25 +17472,15 @@ let Schedule = class Schedule extends Component {
17432
17472
  this.crudModule.refreshDataManager();
17433
17473
  }
17434
17474
  else {
17435
- if (this.activeViewOptions && this.activeViewOptions.eventTemplate) {
17436
- let templateNames = ['eventTemplate'];
17437
- if (this.crudModule && this.crudModule.crudObj.isCrudAction &&
17438
- ['Agenda', 'MonthAgenda', 'Year', 'TimelineYear'].indexOf(this.currentView) === -1) {
17439
- templateNames = [];
17440
- for (let i = 0, len = this.crudModule.crudObj.sourceEvent.length; i < len; i++) {
17441
- templateNames.push('eventTemplate_' + this.crudModule.crudObj.sourceEvent[i].groupIndex);
17442
- if (this.crudModule.crudObj.targetEvent[i] && this.crudModule.crudObj.sourceEvent[i].groupIndex !==
17443
- this.crudModule.crudObj.targetEvent[i].groupIndex) {
17444
- templateNames.push('eventTemplate_' + this.crudModule.crudObj.targetEvent[i].groupIndex);
17445
- }
17446
- }
17447
- }
17448
- this.resetTemplates(templateNames);
17475
+ if (this.uiStateValues) {
17476
+ this.uiStateValues.isPreventTimezone = true;
17477
+ }
17478
+ if (this.crudModule) {
17479
+ this.crudModule.refreshProcessedData();
17480
+ }
17481
+ if (this.uiStateValues) {
17482
+ this.uiStateValues.isPreventTimezone = false;
17449
17483
  }
17450
- const eventsData = this.eventsData || [];
17451
- const blockData = this.blockData || [];
17452
- const data = eventsData.concat(blockData);
17453
- this.notify(dataReady, { processedData: this.eventBase ? this.eventBase.processData(data) : [] });
17454
17484
  }
17455
17485
  }
17456
17486
  /**
@@ -23228,6 +23258,14 @@ class Year extends ViewBase {
23228
23258
  EventHandler.add(element, 'scroll', this.onContentScroll, this);
23229
23259
  }
23230
23260
  }
23261
+ scrollToDate(scrollDate) {
23262
+ const date = +new Date(resetTime(scrollDate));
23263
+ let element = this.element.querySelector('.' + WORK_CELLS_CLASS + ':not(.' + OTHERMONTH_CLASS + ')[data-date="' + date + '"]');
23264
+ if (element) {
23265
+ element = closest(element, '.e-month-calendar');
23266
+ this.getContentAreaElement().scrollTop = element.offsetTop;
23267
+ }
23268
+ }
23231
23269
  destroy() {
23232
23270
  if (!this.parent || this.parent && this.parent.isDestroyed) {
23233
23271
  return;
@@ -24020,6 +24058,20 @@ class Agenda extends AgendaBase {
24020
24058
  contentArea.style.height = formatUnit(this.parent.element.offsetHeight - headerHeight);
24021
24059
  }
24022
24060
  }
24061
+ scrollToDate(scrollDate) {
24062
+ const date = new Date(+resetTime(scrollDate));
24063
+ if (this.parent.activeViewOptions.allowVirtualScrolling) {
24064
+ if (!this.parent.hideEmptyAgendaDays || this.parent.getEvents(date, addDays(date, 1), true).length > 0) {
24065
+ this.parent.changeDate(date);
24066
+ }
24067
+ }
24068
+ else {
24069
+ const dateElement = this.element.querySelector('.' + AGENDA_CELLS_CLASS + '[data-date="' + date.getTime() + '"]');
24070
+ if (dateElement) {
24071
+ this.getContentAreaElement().scrollTop = dateElement.offsetTop;
24072
+ }
24073
+ }
24074
+ }
24023
24075
  destroy() {
24024
24076
  if (!this.parent || this.parent && this.parent.isDestroyed) {
24025
24077
  return;
@@ -24339,9 +24391,12 @@ class TimelineViews extends VerticalView {
24339
24391
  if (scrollDate) {
24340
24392
  index = this.parent.getIndexOfDate(this.renderDates, resetTime(scrollDate));
24341
24393
  if (index >= 0) {
24342
- const timeString = hour.split(':');
24343
- if (timeString.length === 2) {
24344
- date = new Date(scrollDate.setHours(parseInt(timeString[0], 10), parseInt(timeString[1], 10), 0));
24394
+ date = scrollDate;
24395
+ if (!isNullOrUndefined(hour)) {
24396
+ const timeString = hour.split(':');
24397
+ if (timeString.length === 2) {
24398
+ date = new Date(scrollDate.setHours(parseInt(timeString[0], 10), parseInt(timeString[1], 10), 0));
24399
+ }
24345
24400
  }
24346
24401
  }
24347
24402
  }
@@ -24349,8 +24404,14 @@ class TimelineViews extends VerticalView {
24349
24404
  if (isNullOrUndefined(date)) {
24350
24405
  return;
24351
24406
  }
24352
- const scrollLeft = isNullOrUndefined(scrollDate) ? this.getLeftFromDateTime(null, date) :
24353
- this.getLeftFromDateTime([index], date);
24407
+ let scrollLeft;
24408
+ if (isNullOrUndefined(hour) || !this.parent.activeViewOptions.timeScale.enable) {
24409
+ scrollLeft = index * this.getWorkCellWidth();
24410
+ }
24411
+ else {
24412
+ scrollLeft = isNullOrUndefined(scrollDate) ? this.getLeftFromDateTime(null, date) :
24413
+ this.getLeftFromDateTime([index], date);
24414
+ }
24354
24415
  this.getScrollableElement().scrollLeft = !this.parent.enableRtl ? scrollLeft : -scrollLeft;
24355
24416
  }
24356
24417
  generateColumnLevels() {
@@ -25107,13 +25168,25 @@ class TimelineYear extends Year {
25107
25168
  append(cellTemplate, td);
25108
25169
  }
25109
25170
  scrollToDate(scrollDate) {
25110
- if (this.parent.activeViewOptions.group.resources.length === 0) {
25111
- const date = +new Date(resetTime(scrollDate));
25112
- const element = this.element.querySelector('[data-date="' + date + '"]');
25113
- if (element) {
25114
- this.getScrollableElement().scrollLeft = element.offsetLeft;
25115
- this.getScrollableElement().scrollTop = element.offsetTop;
25171
+ let date;
25172
+ if (this.parent.activeViewOptions.group.resources !== null && this.parent.activeViewOptions.group.resources.length > 0 &&
25173
+ !this.parent.uiStateValues.isGroupAdaptive) {
25174
+ date = +new Date(resetTime(firstDateOfMonth(scrollDate)));
25175
+ }
25176
+ else {
25177
+ date = +new Date(resetTime(scrollDate));
25178
+ }
25179
+ const element = this.element.querySelector('[data-date="' + date + '"]');
25180
+ if (element) {
25181
+ const wrap = this.getScrollableElement();
25182
+ if (this.parent.enableRtl) {
25183
+ const conTable = this.element.querySelector('.' + CONTENT_TABLE_CLASS);
25184
+ wrap.scrollLeft = -(conTable.offsetWidth - element.offsetLeft - element.offsetWidth);
25185
+ }
25186
+ else {
25187
+ wrap.scrollLeft = element.offsetLeft;
25116
25188
  }
25189
+ wrap.scrollTop = element.offsetTop;
25117
25190
  }
25118
25191
  }
25119
25192
  getScrollableElement() {
@@ -25135,6 +25208,10 @@ class ICalendarExport {
25135
25208
  this.parent = parent;
25136
25209
  }
25137
25210
  initializeCalendarExport(fileName, customData) {
25211
+ const icsString = this.getCalendarString(fileName, customData);
25212
+ this.download(icsString, fileName);
25213
+ }
25214
+ getCalendarString(fileName, customData) {
25138
25215
  let eventsData = (customData) ? customData :
25139
25216
  extend([], this.parent.eventsData, null, true);
25140
25217
  eventsData = this.parent.eventBase.sortByTime(eventsData);
@@ -25144,7 +25221,7 @@ class ICalendarExport {
25144
25221
  const timeZone = this.parent.timezone || this.parent.tzModule.getLocalTimezoneName();
25145
25222
  const fields = this.parent.eventFields;
25146
25223
  eventsData.forEach((eventObj) => {
25147
- let uId = this.parent.eventBase.generateGuid();
25224
+ let uId = eventObj[fields.id] || eventObj.Guid || this.parent.eventBase.generateGuid();
25148
25225
  const editedExDate = [];
25149
25226
  if (eventObj[fields.recurrenceID]) {
25150
25227
  const filter = this.filterEvents(filterCollection, fields.id, eventObj[fields.recurrenceID]);
@@ -25217,7 +25294,7 @@ class ICalendarExport {
25217
25294
  'X-WR-TIMEZONE:' + timeZone
25218
25295
  ].join(SEPARATOR);
25219
25296
  const icsString = iCalendar + SEPARATOR + iCalendarEvents.join(SEPARATOR) + SEPARATOR + 'END:VCALENDAR';
25220
- this.download(icsString, fileName);
25297
+ return icsString;
25221
25298
  }
25222
25299
  customFieldFilter(eventObj, fields) {
25223
25300
  const defaultFields = Object.keys(fields).map((key) => fields[key]);
@@ -25343,8 +25420,16 @@ class ICalendarImport {
25343
25420
  break;
25344
25421
  case 'UID':
25345
25422
  curEvent[uId] = value;
25346
- curEvent[fields.id] = typeof (id) === 'string' ? id + count.toString() : id + count;
25347
- count++;
25423
+ if (typeof (id) == 'number') {
25424
+ curEvent[fields.id] = parseInt(value, 10);
25425
+ if (isNaN(curEvent[fields.id])) {
25426
+ curEvent[fields.id] = id + count;
25427
+ count++;
25428
+ }
25429
+ }
25430
+ else {
25431
+ curEvent[fields.id] = value;
25432
+ }
25348
25433
  break;
25349
25434
  case 'SUMMARY':
25350
25435
  curEvent[fields.subject] = value;
@@ -25380,6 +25465,10 @@ class ICalendarImport {
25380
25465
  const appoint = [];
25381
25466
  const uId = 'UID';
25382
25467
  const fields = this.parent.eventFields;
25468
+ let appointmentIds = [];
25469
+ this.parent.eventsData.forEach((eventObj) => {
25470
+ appointmentIds.push(eventObj[fields.id]);
25471
+ });
25383
25472
  app.forEach((eventObj) => {
25384
25473
  let parentObj;
25385
25474
  let id;
@@ -25388,24 +25477,26 @@ class ICalendarImport {
25388
25477
  parentObj = eventObj;
25389
25478
  id = eventObj[fields.id];
25390
25479
  }
25391
- const data = app.filter((data) => data.UID === eventObj[uId]);
25392
- if (data.length > 1 && isNullOrUndefined(eventObj[fields.recurrenceID])) {
25393
- for (let i = 0; i < data.length; i++) {
25394
- // eslint-disable-next-line no-prototype-builtins
25395
- if (data[i].hasOwnProperty(fields.recurrenceID)) {
25396
- const exdate = data[i][fields.recurrenceID];
25397
- data[i][fields.recurrenceID] = id;
25398
- data[i][fields.recurrenceException] = null;
25399
- parentObj[fields.recurrenceException] = (isNullOrUndefined(parentObj[fields.recurrenceException])) ?
25400
- exdate : parentObj[fields.recurrenceException] + ',' + exdate;
25401
- appoint.push(data[i]);
25480
+ if (appointmentIds.indexOf(eventObj[fields.id]) < 0) {
25481
+ const data = app.filter((data) => data.UID === eventObj[uId]);
25482
+ if (data.length > 1 && isNullOrUndefined(eventObj[fields.recurrenceID])) {
25483
+ for (let i = 0; i < data.length; i++) {
25484
+ // eslint-disable-next-line no-prototype-builtins
25485
+ if (data[i].hasOwnProperty(fields.recurrenceID)) {
25486
+ const exdate = data[i][fields.recurrenceID];
25487
+ data[i][fields.recurrenceID] = id;
25488
+ data[i][fields.recurrenceException] = null;
25489
+ parentObj[fields.recurrenceException] = (isNullOrUndefined(parentObj[fields.recurrenceException])) ?
25490
+ exdate : parentObj[fields.recurrenceException] + ',' + exdate;
25491
+ appoint.push(data[i]);
25492
+ }
25402
25493
  }
25494
+ appoint.push(parentObj);
25495
+ // eslint-disable-next-line no-prototype-builtins
25496
+ }
25497
+ else if (!eventObj.hasOwnProperty(fields.recurrenceID)) {
25498
+ appoint.push(eventObj);
25403
25499
  }
25404
- appoint.push(parentObj);
25405
- // eslint-disable-next-line no-prototype-builtins
25406
- }
25407
- else if (!eventObj.hasOwnProperty(fields.recurrenceID)) {
25408
- appoint.push(eventObj);
25409
25500
  }
25410
25501
  });
25411
25502
  return appoint;