@syncfusion/ej2-schedule 20.3.50 → 20.3.56

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.
@@ -365,9 +365,6 @@ let scrollWidth = null;
365
365
  * @private
366
366
  */
367
367
  function getScrollBarWidth() {
368
- if (scrollWidth !== null) {
369
- return scrollWidth;
370
- }
371
368
  const divNode = createElement('div');
372
369
  let value = 0;
373
370
  divNode.style.cssText = 'width:100px;height: 100px;overflow: scroll;position: absolute;top: -9999px;';
@@ -1607,8 +1604,8 @@ class ScheduleTouch {
1607
1604
  }
1608
1605
  scrollHandler(e) {
1609
1606
  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)))) {
1607
+ (e.originalEvent && e.originalEvent.target && (e.originalEvent.target.classList.contains(APPOINTMENT_CLASS) ||
1608
+ closest(e.originalEvent.target, '.' + APPOINTMENT_CLASS)) && !this.parent.isAdaptive)) {
1612
1609
  return;
1613
1610
  }
1614
1611
  if (!this.timeStampStart) {
@@ -1842,6 +1839,7 @@ class KeyboardInteraction {
1842
1839
  enter: 'enter',
1843
1840
  escape: 'escape',
1844
1841
  delete: 'delete',
1842
+ backspace: 'backspace',
1845
1843
  home: 'home',
1846
1844
  pageUp: 'pageup',
1847
1845
  pageDown: 'pagedown',
@@ -1913,6 +1911,7 @@ class KeyboardInteraction {
1913
1911
  this.processTab(e, e.shiftKey);
1914
1912
  break;
1915
1913
  case 'delete':
1914
+ case 'backspace':
1916
1915
  this.processDelete(e);
1917
1916
  break;
1918
1917
  case 'ctrlShiftUpArrow':
@@ -3054,9 +3053,11 @@ class Gregorian {
3054
3053
  }
3055
3054
  }
3056
3055
  setMonth(date, interval, startDate) {
3056
+ date.setDate(1);
3057
3057
  date.setFullYear(date.getFullYear());
3058
3058
  date.setMonth(interval - 1);
3059
- date.setDate(startDate);
3059
+ const maxDay = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
3060
+ date.setDate(Math.min(startDate, maxDay));
3060
3061
  }
3061
3062
  addYears(date, interval) {
3062
3063
  date.setFullYear(date.getFullYear() + interval);
@@ -5944,7 +5945,8 @@ class EventBase {
5944
5945
  }
5945
5946
  if (idType === 'number') {
5946
5947
  const datas = this.parent.eventsData.concat(this.parent.blockData);
5947
- let maxId = Math.max(...datas.map((event) => event[this.parent.eventFields.id]));
5948
+ const appIds = datas.map((event) => event[this.parent.eventFields.id]);
5949
+ let maxId = appIds.reduce((a, b) => Math.max(a, b));
5948
5950
  maxId = isNullOrUndefined(resourceId) ? maxId : maxId + resourceId;
5949
5951
  eventId = maxId + 1;
5950
5952
  }
@@ -7986,7 +7988,13 @@ class TimelineEvent extends MonthEvent {
7986
7988
  eventObj[this.fields.endTime] = eventData[this.fields.endTime];
7987
7989
  const currentDate = resetTime(new Date(this.dateRender[this.day].getTime()));
7988
7990
  const schedule = getStartEndHours(currentDate, this.startHour, this.endHour);
7989
- const isValidEvent = this.isValidEvent(eventObj, startTime, endTime, schedule);
7991
+ let isValidEvent = true;
7992
+ if (this.isDayProcess() || eventObj[this.fields.isAllDay]) {
7993
+ isValidEvent = true;
7994
+ }
7995
+ else {
7996
+ isValidEvent = this.isValidEvent(eventObj, startTime, endTime, schedule);
7997
+ }
7990
7998
  if (startTime <= endTime && isValidEvent) {
7991
7999
  let appWidth = this.getEventWidth(startTime, endTime, event[this.fields.isAllDay], diffInDays);
7992
8000
  appWidth = this.renderType === 'day' ? appWidth - 2 : appWidth;
@@ -8147,14 +8155,19 @@ class TimelineEvent extends MonthEvent {
8147
8155
  getStartTime(event, eventData) {
8148
8156
  let startTime = event[this.fields.startTime];
8149
8157
  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);
8158
+ if (this.isDayProcess()) {
8159
+ startTime = event[this.fields.startTime];
8155
8160
  }
8156
8161
  else {
8157
- startTime = eventData[this.fields.startTime];
8162
+ if (schedule.startHour.getTime() >= eventData[this.fields.startTime]) {
8163
+ startTime = schedule.startHour;
8164
+ }
8165
+ else if (schedule.endHour.getTime() <= eventData[this.fields.startTime]) {
8166
+ startTime = this.getNextDay(schedule.startHour, eventData);
8167
+ }
8168
+ else {
8169
+ startTime = eventData[this.fields.startTime];
8170
+ }
8158
8171
  }
8159
8172
  // To overcome the overflow
8160
8173
  eventData.trimStartTime = (event[this.fields.isAllDay]) ? schedule.startHour : eventData[this.fields.startTime];
@@ -8174,17 +8187,15 @@ class TimelineEvent extends MonthEvent {
8174
8187
  getEndTime(event, eventData) {
8175
8188
  let endTime = event[this.fields.endTime];
8176
8189
  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')) {
8190
+ if (this.isDayProcess()) {
8180
8191
  endTime = eventData[this.fields.endTime];
8181
8192
  }
8182
8193
  else {
8183
8194
  endTime = eventData[this.fields.endTime];
8184
- if (schedule.endHour.getTime() <= eventData[this.fields.endTime]) {
8195
+ if (schedule.endHour.getTime() <= eventData[this.fields.endTime] || event[this.fields.isAllDay]) {
8185
8196
  endTime = schedule.endHour;
8186
8197
  }
8187
- if (schedule.startHour.getTime() >= eventData[this.fields.endTime].getTime() && !event.isAllDay) {
8198
+ if (schedule.startHour.getTime() >= eventData[this.fields.endTime].getTime() && !event[this.fields.isAllDay]) {
8188
8199
  endTime = this.getPreviousDay(schedule.startHour, schedule.endHour, eventData);
8189
8200
  }
8190
8201
  }
@@ -8337,6 +8348,14 @@ class TimelineEvent extends MonthEvent {
8337
8348
  'height': (this.cellHeight - (this.maxHeight ? 0 : EVENT_GAP$1) - (this.maxHeight ? 0 : this.moreIndicatorHeight)) + 'px'
8338
8349
  });
8339
8350
  }
8351
+ isDayProcess() {
8352
+ if (this.parent.currentView === 'TimelineMonth' || !this.parent.activeViewOptions.timeScale.enable ||
8353
+ (this.parent.activeViewOptions.headerRows.length > 0 &&
8354
+ this.parent.activeViewOptions.headerRows.slice(-1)[0].option !== 'Hour')) {
8355
+ return true;
8356
+ }
8357
+ return false;
8358
+ }
8340
8359
  destroy() {
8341
8360
  this.renderType = null;
8342
8361
  this.eventContainers = null;
@@ -8411,21 +8430,27 @@ class InlineEdit {
8411
8430
  }
8412
8431
  else {
8413
8432
  const subEle = args.element.querySelector('.' + SUBJECT_CLASS);
8414
- const timeEle = args.element.querySelector('.' + APPOINTMENT_TIME);
8415
- subject = subEle.innerText;
8433
+ if (!isNullOrUndefined(subEle)) {
8434
+ addClass([subEle], DISABLE_CLASS);
8435
+ subject = subEle.innerText;
8436
+ }
8437
+ else {
8438
+ subject = args.data[this.parent.eventFields.subject];
8439
+ }
8416
8440
  inlineSubject = createElement('input', { className: INLINE_SUBJECT_CLASS, attrs: { value: subject } });
8417
- addClass([subEle], DISABLE_CLASS);
8418
8441
  if (closest(args.element, '.' + MORE_POPUP_WRAPPER_CLASS)) {
8419
8442
  args.element.insertBefore(inlineSubject, subEle);
8420
8443
  }
8421
8444
  else if (['Agenda', 'MonthAgenda'].indexOf(this.parent.currentView) > -1) {
8422
- const subjectWrap = args.element.querySelector('.' + SUBJECT_WRAP);
8445
+ let subjectWrap = args.element.querySelector('.' + SUBJECT_WRAP);
8446
+ if (isNullOrUndefined(subjectWrap)) {
8447
+ subjectWrap = createElement('div', { className: SUBJECT_WRAP });
8448
+ args.element.prepend(subjectWrap);
8449
+ }
8423
8450
  subjectWrap.insertBefore(inlineSubject, subjectWrap.firstChild);
8424
8451
  }
8425
8452
  else {
8426
- const elementSelector = ['TimelineDay', 'TimelineWeek', 'TimelineWorkWeek', 'TimelineMonth'].indexOf(this.parent.currentView) > -1 ?
8427
- '.e-inner-wrap' : '.e-appointment-details';
8428
- args.element.querySelector(elementSelector).insertBefore(inlineSubject, timeEle);
8453
+ args.element.querySelector('.e-appointment-details').prepend(inlineSubject);
8429
8454
  }
8430
8455
  inlineSubject.focus();
8431
8456
  }
@@ -8565,7 +8590,10 @@ class InlineEdit {
8565
8590
  const inlineSubject = this.parent.element.querySelector('.' + INLINE_SUBJECT_CLASS);
8566
8591
  if (inlineSubject) {
8567
8592
  const appointmentSubject = closest(inlineSubject, '.' + APPOINTMENT_CLASS);
8568
- removeClass([appointmentSubject.querySelector('.' + SUBJECT_CLASS)], DISABLE_CLASS);
8593
+ const subject = appointmentSubject.querySelector('.' + SUBJECT_CLASS);
8594
+ if (!isNullOrUndefined(subject)) {
8595
+ removeClass([subject], DISABLE_CLASS);
8596
+ }
8569
8597
  remove(inlineSubject);
8570
8598
  }
8571
8599
  }
@@ -11740,7 +11768,8 @@ class EventWindow {
11740
11768
  const resourceModel = resourceCollection[i + 1];
11741
11769
  // eslint-disable-next-line max-len
11742
11770
  const filter = resourceModel.dataSource.filter((data) => data[resourceModel.groupIDField] === args.value[j])[0];
11743
- const groupId = filter[resourceCollection[i + 1].groupIDField];
11771
+ const groupId = (!isNullOrUndefined(filter)) ?
11772
+ filter[resourceCollection[i + 1].groupIDField] : null;
11744
11773
  const filterRes = this.filterDatasource(i, groupId);
11745
11774
  datasource = datasource.concat(filterRes);
11746
11775
  }
@@ -11753,6 +11782,7 @@ class EventWindow {
11753
11782
  const resourceData = this.parent.resourceBase.resourceCollection[index + 1];
11754
11783
  const resObject = this.element.querySelector('.e-' + resourceData.field).
11755
11784
  ej2_instances[0];
11785
+ resObject.clear();
11756
11786
  return resObject;
11757
11787
  }
11758
11788
  onDropdownResourceChange(args) {
@@ -11767,7 +11797,8 @@ class EventWindow {
11767
11797
  const groupId = args.itemData[resourceCollection[i].idField];
11768
11798
  resObj.dataSource = this.filterDatasource(i, groupId);
11769
11799
  resObj.dataBind();
11770
- const resValue = resObj.dataSource[0][resourceCollection[i + 1].idField];
11800
+ const resValue = (resObj.dataSource.length > 0) ?
11801
+ resObj.dataSource[0][resourceCollection[i + 1].idField] : null;
11771
11802
  resObj.value = (resourceCollection[i + 1].allowMultiple) ? [resValue] : resValue;
11772
11803
  resObj.dataBind();
11773
11804
  }
@@ -13131,7 +13162,9 @@ class VirtualScroll {
13131
13162
  }
13132
13163
  renderEvents() {
13133
13164
  this.setTabIndex();
13134
- this.parent.refreshEvents(false);
13165
+ if (this.parent.crudModule) {
13166
+ this.parent.crudModule.refreshProcessedData(true);
13167
+ }
13135
13168
  if (this.parent.currentView !== 'Month') {
13136
13169
  this.parent.notify(contentReady, {});
13137
13170
  }
@@ -13714,7 +13747,7 @@ class Crud {
13714
13747
  }
13715
13748
  this.parent.trigger(actionFailure, { error: e }, () => this.parent.hideSpinner());
13716
13749
  }
13717
- refreshProcessedData() {
13750
+ refreshProcessedData(isVirtualScrollAction = false) {
13718
13751
  if (this.parent.dragAndDropModule) {
13719
13752
  this.parent.dragAndDropModule.actionObj.action = '';
13720
13753
  removeClass([this.parent.element], 'e-event-action');
@@ -13734,6 +13767,10 @@ class Crud {
13734
13767
  }
13735
13768
  this.parent.resetTemplates(templateNames);
13736
13769
  }
13770
+ if (isVirtualScrollAction) {
13771
+ this.parent.notify(dataReady, { processedData: this.parent.eventsProcessed });
13772
+ return;
13773
+ }
13737
13774
  const eventsData = this.parent.eventsData || [];
13738
13775
  const blockData = this.parent.blockData || [];
13739
13776
  const data = eventsData.concat(blockData);
@@ -17778,11 +17815,11 @@ let Schedule = class Schedule extends Component {
17778
17815
  * @returns {void}
17779
17816
  */
17780
17817
  refreshEvents(isRemoteRefresh = true) {
17781
- if (this.dragAndDropModule) {
17782
- this.dragAndDropModule.actionObj.action = '';
17783
- removeClass([this.element], EVENT_ACTION_CLASS);
17784
- }
17785
17818
  if (isRemoteRefresh) {
17819
+ if (this.dragAndDropModule) {
17820
+ this.dragAndDropModule.actionObj.action = '';
17821
+ removeClass([this.element], EVENT_ACTION_CLASS);
17822
+ }
17786
17823
  this.crudModule.refreshDataManager();
17787
17824
  }
17788
17825
  else {
@@ -25855,9 +25892,9 @@ class ICalendarImport {
25855
25892
  }
25856
25893
  });
25857
25894
  const app = extend([], events, null, true);
25858
- this.parent.addEvent(this.processOccurrence(app));
25895
+ this.parent.addEvent(this.processOccurrence(app, id));
25859
25896
  }
25860
- processOccurrence(app) {
25897
+ processOccurrence(app, maxId) {
25861
25898
  const appoint = [];
25862
25899
  const uId = 'UID';
25863
25900
  const fields = this.parent.eventFields;
@@ -25876,31 +25913,49 @@ class ICalendarImport {
25876
25913
  if (appointmentIds.indexOf(eventObj[fields.id]) < 0) {
25877
25914
  const data = app.filter((data) => data.UID === eventObj[uId]);
25878
25915
  if (data.length > 1 && isNullOrUndefined(eventObj[fields.recurrenceID])) {
25916
+ id = typeof (maxId) === 'number' ? maxId++ : id;
25879
25917
  for (let i = 0; i < data.length; i++) {
25880
25918
  // eslint-disable-next-line no-prototype-builtins
25881
25919
  if (data[i].hasOwnProperty(fields.recurrenceID)) {
25882
25920
  const exdate = data[i][fields.recurrenceID];
25883
- data[i][fields.id] = this.parent.eventBase.generateGuid();
25921
+ data[i][fields.id] = typeof (maxId) === 'number' ? maxId++ : this.parent.eventBase.generateGuid();
25884
25922
  data[i][fields.recurrenceID] = id;
25885
25923
  data[i][fields.recurrenceException] = null;
25886
- parentObj[fields.recurrenceException] = (isNullOrUndefined(parentObj[fields.recurrenceException])) ?
25887
- exdate : parentObj[fields.recurrenceException] + ',' + exdate;
25924
+ parentObj[fields.recurrenceException] =
25925
+ this.getExcludeDateString(parentObj[fields.recurrenceException], exdate);
25888
25926
  delete data[i][uId];
25889
25927
  appoint.push(data[i]);
25890
25928
  }
25891
25929
  }
25892
25930
  delete parentObj[uId];
25931
+ parentObj[fields.id] = id;
25893
25932
  appoint.push(parentObj);
25894
25933
  // eslint-disable-next-line no-prototype-builtins
25895
25934
  }
25896
25935
  else if (!eventObj.hasOwnProperty(fields.recurrenceID)) {
25897
25936
  delete eventObj[uId];
25937
+ eventObj[fields.id] = typeof (maxId) === 'number' ? maxId++ : id;
25898
25938
  appoint.push(eventObj);
25899
25939
  }
25900
25940
  }
25901
25941
  });
25902
25942
  return appoint;
25903
25943
  }
25944
+ getExcludeDateString(parentException, occurrenceException) {
25945
+ if (isNullOrUndefined(parentException)) {
25946
+ return occurrenceException;
25947
+ }
25948
+ else if (isNullOrUndefined(occurrenceException)) {
25949
+ return parentException;
25950
+ }
25951
+ const parentExDate = parentException.split(',').map((x) => x.split('T')[0]);
25952
+ const childExDate = occurrenceException.split(',').map((x) => x.split('T')[0]);
25953
+ const exDate = parentExDate.filter((x) => childExDate.indexOf(x) > -1);
25954
+ if (exDate.length > 0) {
25955
+ return parentException;
25956
+ }
25957
+ return parentException + ',' + occurrenceException;
25958
+ }
25904
25959
  getDateString(value) {
25905
25960
  value = value || '';
25906
25961
  // eslint-disable-next-line no-useless-escape