@syncfusion/ej2-schedule 20.3.49 → 20.3.52

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.
@@ -1607,8 +1607,8 @@ class ScheduleTouch {
1607
1607
  }
1608
1608
  scrollHandler(e) {
1609
1609
  if (this.parent.currentView === 'Agenda' || this.parent.uiStateValues.action || !this.parent.allowSwiping ||
1610
- (e.originalEvent && (e.originalEvent.target.classList.contains(APPOINTMENT_CLASS) ||
1611
- closest(e.originalEvent.target, '.' + APPOINTMENT_CLASS)))) {
1610
+ (e.originalEvent && e.originalEvent.target && (e.originalEvent.target.classList.contains(APPOINTMENT_CLASS) ||
1611
+ closest(e.originalEvent.target, '.' + APPOINTMENT_CLASS)) && !this.parent.isAdaptive)) {
1612
1612
  return;
1613
1613
  }
1614
1614
  if (!this.timeStampStart) {
@@ -1842,6 +1842,7 @@ class KeyboardInteraction {
1842
1842
  enter: 'enter',
1843
1843
  escape: 'escape',
1844
1844
  delete: 'delete',
1845
+ backspace: 'backspace',
1845
1846
  home: 'home',
1846
1847
  pageUp: 'pageup',
1847
1848
  pageDown: 'pagedown',
@@ -1913,6 +1914,7 @@ class KeyboardInteraction {
1913
1914
  this.processTab(e, e.shiftKey);
1914
1915
  break;
1915
1916
  case 'delete':
1917
+ case 'backspace':
1916
1918
  this.processDelete(e);
1917
1919
  break;
1918
1920
  case 'ctrlShiftUpArrow':
@@ -3054,9 +3056,11 @@ class Gregorian {
3054
3056
  }
3055
3057
  }
3056
3058
  setMonth(date, interval, startDate) {
3059
+ date.setDate(1);
3057
3060
  date.setFullYear(date.getFullYear());
3058
3061
  date.setMonth(interval - 1);
3059
- date.setDate(startDate);
3062
+ const maxDay = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
3063
+ date.setDate(Math.min(startDate, maxDay));
3060
3064
  }
3061
3065
  addYears(date, interval) {
3062
3066
  date.setFullYear(date.getFullYear() + interval);
@@ -5944,7 +5948,8 @@ class EventBase {
5944
5948
  }
5945
5949
  if (idType === 'number') {
5946
5950
  const datas = this.parent.eventsData.concat(this.parent.blockData);
5947
- let maxId = Math.max(...datas.map((event) => event[this.parent.eventFields.id]));
5951
+ const appIds = datas.map((event) => event[this.parent.eventFields.id]);
5952
+ let maxId = appIds.reduce((a, b) => Math.max(a, b));
5948
5953
  maxId = isNullOrUndefined(resourceId) ? maxId : maxId + resourceId;
5949
5954
  eventId = maxId + 1;
5950
5955
  }
@@ -7986,7 +7991,13 @@ class TimelineEvent extends MonthEvent {
7986
7991
  eventObj[this.fields.endTime] = eventData[this.fields.endTime];
7987
7992
  const currentDate = resetTime(new Date(this.dateRender[this.day].getTime()));
7988
7993
  const schedule = getStartEndHours(currentDate, this.startHour, this.endHour);
7989
- const isValidEvent = this.isValidEvent(eventObj, startTime, endTime, schedule);
7994
+ let isValidEvent = true;
7995
+ if (this.isDayProcess() || eventObj[this.fields.isAllDay]) {
7996
+ isValidEvent = true;
7997
+ }
7998
+ else {
7999
+ isValidEvent = this.isValidEvent(eventObj, startTime, endTime, schedule);
8000
+ }
7990
8001
  if (startTime <= endTime && isValidEvent) {
7991
8002
  let appWidth = this.getEventWidth(startTime, endTime, event[this.fields.isAllDay], diffInDays);
7992
8003
  appWidth = this.renderType === 'day' ? appWidth - 2 : appWidth;
@@ -8147,14 +8158,19 @@ class TimelineEvent extends MonthEvent {
8147
8158
  getStartTime(event, eventData) {
8148
8159
  let startTime = event[this.fields.startTime];
8149
8160
  const schedule = getStartEndHours(startTime, this.startHour, this.endHour);
8150
- if (schedule.startHour.getTime() >= eventData[this.fields.startTime]) {
8151
- startTime = schedule.startHour;
8152
- }
8153
- else if (schedule.endHour.getTime() <= eventData[this.fields.startTime]) {
8154
- startTime = this.getNextDay(schedule.startHour, eventData);
8161
+ if (this.isDayProcess()) {
8162
+ startTime = event[this.fields.startTime];
8155
8163
  }
8156
8164
  else {
8157
- startTime = eventData[this.fields.startTime];
8165
+ if (schedule.startHour.getTime() >= eventData[this.fields.startTime]) {
8166
+ startTime = schedule.startHour;
8167
+ }
8168
+ else if (schedule.endHour.getTime() <= eventData[this.fields.startTime]) {
8169
+ startTime = this.getNextDay(schedule.startHour, eventData);
8170
+ }
8171
+ else {
8172
+ startTime = eventData[this.fields.startTime];
8173
+ }
8158
8174
  }
8159
8175
  // To overcome the overflow
8160
8176
  eventData.trimStartTime = (event[this.fields.isAllDay]) ? schedule.startHour : eventData[this.fields.startTime];
@@ -8174,17 +8190,15 @@ class TimelineEvent extends MonthEvent {
8174
8190
  getEndTime(event, eventData) {
8175
8191
  let endTime = event[this.fields.endTime];
8176
8192
  const schedule = getStartEndHours(endTime, this.startHour, this.endHour);
8177
- if (this.parent.currentView === 'TimelineMonth' || !this.parent.activeViewOptions.timeScale.enable ||
8178
- (this.parent.activeViewOptions.headerRows.length > 0 &&
8179
- this.parent.activeViewOptions.headerRows.slice(-1)[0].option !== 'Hour')) {
8193
+ if (this.isDayProcess()) {
8180
8194
  endTime = eventData[this.fields.endTime];
8181
8195
  }
8182
8196
  else {
8183
8197
  endTime = eventData[this.fields.endTime];
8184
- if (schedule.endHour.getTime() <= eventData[this.fields.endTime]) {
8198
+ if (schedule.endHour.getTime() <= eventData[this.fields.endTime] || event[this.fields.isAllDay]) {
8185
8199
  endTime = schedule.endHour;
8186
8200
  }
8187
- if (schedule.startHour.getTime() >= eventData[this.fields.endTime].getTime() && !event.isAllDay) {
8201
+ if (schedule.startHour.getTime() >= eventData[this.fields.endTime].getTime() && !event[this.fields.isAllDay]) {
8188
8202
  endTime = this.getPreviousDay(schedule.startHour, schedule.endHour, eventData);
8189
8203
  }
8190
8204
  }
@@ -8337,6 +8351,14 @@ class TimelineEvent extends MonthEvent {
8337
8351
  'height': (this.cellHeight - (this.maxHeight ? 0 : EVENT_GAP$1) - (this.maxHeight ? 0 : this.moreIndicatorHeight)) + 'px'
8338
8352
  });
8339
8353
  }
8354
+ isDayProcess() {
8355
+ if (this.parent.currentView === 'TimelineMonth' || !this.parent.activeViewOptions.timeScale.enable ||
8356
+ (this.parent.activeViewOptions.headerRows.length > 0 &&
8357
+ this.parent.activeViewOptions.headerRows.slice(-1)[0].option !== 'Hour')) {
8358
+ return true;
8359
+ }
8360
+ return false;
8361
+ }
8340
8362
  destroy() {
8341
8363
  this.renderType = null;
8342
8364
  this.eventContainers = null;
@@ -11740,7 +11762,8 @@ class EventWindow {
11740
11762
  const resourceModel = resourceCollection[i + 1];
11741
11763
  // eslint-disable-next-line max-len
11742
11764
  const filter = resourceModel.dataSource.filter((data) => data[resourceModel.groupIDField] === args.value[j])[0];
11743
- const groupId = filter[resourceCollection[i + 1].groupIDField];
11765
+ const groupId = (!isNullOrUndefined(filter)) ?
11766
+ filter[resourceCollection[i + 1].groupIDField] : null;
11744
11767
  const filterRes = this.filterDatasource(i, groupId);
11745
11768
  datasource = datasource.concat(filterRes);
11746
11769
  }
@@ -11753,6 +11776,7 @@ class EventWindow {
11753
11776
  const resourceData = this.parent.resourceBase.resourceCollection[index + 1];
11754
11777
  const resObject = this.element.querySelector('.e-' + resourceData.field).
11755
11778
  ej2_instances[0];
11779
+ resObject.clear();
11756
11780
  return resObject;
11757
11781
  }
11758
11782
  onDropdownResourceChange(args) {
@@ -11767,7 +11791,8 @@ class EventWindow {
11767
11791
  const groupId = args.itemData[resourceCollection[i].idField];
11768
11792
  resObj.dataSource = this.filterDatasource(i, groupId);
11769
11793
  resObj.dataBind();
11770
- const resValue = resObj.dataSource[0][resourceCollection[i + 1].idField];
11794
+ const resValue = (resObj.dataSource.length > 0) ?
11795
+ resObj.dataSource[0][resourceCollection[i + 1].idField] : null;
11771
11796
  resObj.value = (resourceCollection[i + 1].allowMultiple) ? [resValue] : resValue;
11772
11797
  resObj.dataBind();
11773
11798
  }
@@ -13131,7 +13156,9 @@ class VirtualScroll {
13131
13156
  }
13132
13157
  renderEvents() {
13133
13158
  this.setTabIndex();
13134
- this.parent.refreshEvents(false);
13159
+ if (this.parent.crudModule) {
13160
+ this.parent.crudModule.refreshProcessedData(true);
13161
+ }
13135
13162
  if (this.parent.currentView !== 'Month') {
13136
13163
  this.parent.notify(contentReady, {});
13137
13164
  }
@@ -13714,7 +13741,7 @@ class Crud {
13714
13741
  }
13715
13742
  this.parent.trigger(actionFailure, { error: e }, () => this.parent.hideSpinner());
13716
13743
  }
13717
- refreshProcessedData() {
13744
+ refreshProcessedData(isVirtualScrollAction = false) {
13718
13745
  if (this.parent.dragAndDropModule) {
13719
13746
  this.parent.dragAndDropModule.actionObj.action = '';
13720
13747
  removeClass([this.parent.element], 'e-event-action');
@@ -13734,6 +13761,10 @@ class Crud {
13734
13761
  }
13735
13762
  this.parent.resetTemplates(templateNames);
13736
13763
  }
13764
+ if (isVirtualScrollAction) {
13765
+ this.parent.notify(dataReady, { processedData: this.parent.eventsProcessed });
13766
+ return;
13767
+ }
13737
13768
  const eventsData = this.parent.eventsData || [];
13738
13769
  const blockData = this.parent.blockData || [];
13739
13770
  const data = eventsData.concat(blockData);
@@ -17778,11 +17809,11 @@ let Schedule = class Schedule extends Component {
17778
17809
  * @returns {void}
17779
17810
  */
17780
17811
  refreshEvents(isRemoteRefresh = true) {
17781
- if (this.dragAndDropModule) {
17782
- this.dragAndDropModule.actionObj.action = '';
17783
- removeClass([this.element], EVENT_ACTION_CLASS);
17784
- }
17785
17812
  if (isRemoteRefresh) {
17813
+ if (this.dragAndDropModule) {
17814
+ this.dragAndDropModule.actionObj.action = '';
17815
+ removeClass([this.element], EVENT_ACTION_CLASS);
17816
+ }
17786
17817
  this.crudModule.refreshDataManager();
17787
17818
  }
17788
17819
  else {
@@ -25855,9 +25886,9 @@ class ICalendarImport {
25855
25886
  }
25856
25887
  });
25857
25888
  const app = extend([], events, null, true);
25858
- this.parent.addEvent(this.processOccurrence(app));
25889
+ this.parent.addEvent(this.processOccurrence(app, id));
25859
25890
  }
25860
- processOccurrence(app) {
25891
+ processOccurrence(app, maxId) {
25861
25892
  const appoint = [];
25862
25893
  const uId = 'UID';
25863
25894
  const fields = this.parent.eventFields;
@@ -25876,31 +25907,49 @@ class ICalendarImport {
25876
25907
  if (appointmentIds.indexOf(eventObj[fields.id]) < 0) {
25877
25908
  const data = app.filter((data) => data.UID === eventObj[uId]);
25878
25909
  if (data.length > 1 && isNullOrUndefined(eventObj[fields.recurrenceID])) {
25910
+ id = typeof (maxId) === 'number' ? maxId++ : id;
25879
25911
  for (let i = 0; i < data.length; i++) {
25880
25912
  // eslint-disable-next-line no-prototype-builtins
25881
25913
  if (data[i].hasOwnProperty(fields.recurrenceID)) {
25882
25914
  const exdate = data[i][fields.recurrenceID];
25883
- data[i][fields.id] = this.parent.eventBase.generateGuid();
25915
+ data[i][fields.id] = typeof (maxId) === 'number' ? maxId++ : this.parent.eventBase.generateGuid();
25884
25916
  data[i][fields.recurrenceID] = id;
25885
25917
  data[i][fields.recurrenceException] = null;
25886
- parentObj[fields.recurrenceException] = (isNullOrUndefined(parentObj[fields.recurrenceException])) ?
25887
- exdate : parentObj[fields.recurrenceException] + ',' + exdate;
25918
+ parentObj[fields.recurrenceException] =
25919
+ this.getExcludeDateString(parentObj[fields.recurrenceException], exdate);
25888
25920
  delete data[i][uId];
25889
25921
  appoint.push(data[i]);
25890
25922
  }
25891
25923
  }
25892
25924
  delete parentObj[uId];
25925
+ parentObj[fields.id] = id;
25893
25926
  appoint.push(parentObj);
25894
25927
  // eslint-disable-next-line no-prototype-builtins
25895
25928
  }
25896
25929
  else if (!eventObj.hasOwnProperty(fields.recurrenceID)) {
25897
25930
  delete eventObj[uId];
25931
+ eventObj[fields.id] = typeof (maxId) === 'number' ? maxId++ : id;
25898
25932
  appoint.push(eventObj);
25899
25933
  }
25900
25934
  }
25901
25935
  });
25902
25936
  return appoint;
25903
25937
  }
25938
+ getExcludeDateString(parentException, occurrenceException) {
25939
+ if (isNullOrUndefined(parentException)) {
25940
+ return occurrenceException;
25941
+ }
25942
+ else if (isNullOrUndefined(occurrenceException)) {
25943
+ return parentException;
25944
+ }
25945
+ const parentExDate = parentException.split(',').map((x) => x.split('T')[0]);
25946
+ const childExDate = occurrenceException.split(',').map((x) => x.split('T')[0]);
25947
+ const exDate = parentExDate.filter((x) => childExDate.indexOf(x) > -1);
25948
+ if (exDate.length > 0) {
25949
+ return parentException;
25950
+ }
25951
+ return parentException + ',' + occurrenceException;
25952
+ }
25904
25953
  getDateString(value) {
25905
25954
  value = value || '';
25906
25955
  // eslint-disable-next-line no-useless-escape