@syncfusion/ej2-schedule 32.1.20 → 32.1.22

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.
@@ -9788,7 +9788,9 @@ class QuickPopups {
9788
9788
  render() {
9789
9789
  this.renderQuickPopup();
9790
9790
  this.renderMorePopup();
9791
- this.renderQuickDialog();
9791
+ if (this.parent.prerenderDialogs) {
9792
+ this.renderQuickDialog();
9793
+ }
9792
9794
  }
9793
9795
  renderQuickPopup() {
9794
9796
  const quickPopupWrapper = createElement('div', { className: POPUP_WRAPPER_CLASS + ' e-popup-close', attrs: { role: 'dialog' } });
@@ -9948,6 +9950,9 @@ class QuickPopups {
9948
9950
  this.fieldValidator.renderFormValidator(form, rules, this.quickPopup.element, this.parent.locale);
9949
9951
  }
9950
9952
  openRecurrenceAlert() {
9953
+ if (!this.parent.prerenderDialogs) {
9954
+ this.renderQuickDialog();
9955
+ }
9951
9956
  const editDeleteOnly = this.quickDialog.element.querySelector('.' + QUICK_DIALOG_ALERT_OK);
9952
9957
  if (editDeleteOnly) {
9953
9958
  editDeleteOnly.innerHTML = this.l10n.getConstant(this.parent.currentAction === 'Delete' ? 'deleteEvent' : 'editEvent');
@@ -9969,6 +9974,9 @@ class QuickPopups {
9969
9974
  this.showQuickDialog('RecurrenceAlert');
9970
9975
  }
9971
9976
  openRecurrenceValidationAlert(type) {
9977
+ if (!this.parent.prerenderDialogs) {
9978
+ this.renderQuickDialog();
9979
+ }
9972
9980
  this.quickDialogClass('Alert');
9973
9981
  const okButton = this.quickDialog.element.querySelector('.' + QUICK_DIALOG_ALERT_OK);
9974
9982
  okButton.innerHTML = this.l10n.getConstant('ok');
@@ -10012,6 +10020,9 @@ class QuickPopups {
10012
10020
  if (this.parent.activeViewOptions.readonly) {
10013
10021
  return;
10014
10022
  }
10023
+ if (!this.parent.prerenderDialogs) {
10024
+ this.renderQuickDialog();
10025
+ }
10015
10026
  const okButton = this.quickDialog.element.querySelector('.' + QUICK_DIALOG_ALERT_OK);
10016
10027
  if (okButton) {
10017
10028
  okButton.innerHTML = this.l10n.getConstant('delete');
@@ -10030,6 +10041,9 @@ class QuickPopups {
10030
10041
  this.showQuickDialog('DeleteAlert');
10031
10042
  }
10032
10043
  openValidationError(type, eventData) {
10044
+ if (!this.parent.prerenderDialogs) {
10045
+ this.renderQuickDialog();
10046
+ }
10033
10047
  this.quickDialog.header = this.l10n.getConstant('alert');
10034
10048
  this.quickDialog.content = this.l10n.getConstant(type);
10035
10049
  const okButton = this.quickDialog.element.querySelector('.' + QUICK_DIALOG_ALERT_OK);
@@ -10058,6 +10072,9 @@ class QuickPopups {
10058
10072
  if (!popupArgs.cancel) {
10059
10073
  this.quickDialog.show();
10060
10074
  }
10075
+ if (!this.parent.prerenderDialogs && popupArgs.cancel) {
10076
+ this.destroyQuickDialog();
10077
+ }
10061
10078
  });
10062
10079
  }
10063
10080
  createMoreEventList(eventCollection, groupOrder, groupIndex) {
@@ -10369,6 +10386,7 @@ class QuickPopups {
10369
10386
  let cellDetails;
10370
10387
  let argsData;
10371
10388
  const resourceText = this.getResourceText(args, type.toLowerCase());
10389
+ const isResourceEmpty = this.parent.isResourceCollectionEmpty();
10372
10390
  switch (type) {
10373
10391
  case 'Cell':
10374
10392
  cellDetails = this.getFormattedString(data);
@@ -10404,7 +10422,7 @@ class QuickPopups {
10404
10422
  content += '<div class="' + DESCRIPTION_CLASS + '"><div class="' + DESCRIPTION_ICON_CLASS + ' ' + ICON +
10405
10423
  '"></div><div class="' + DESCRIPTION_DETAILS_CLASS + ' ' + TEXT_ELLIPSIS + '"></div></div>';
10406
10424
  }
10407
- if (this.parent.resourceCollection.length > 0) {
10425
+ if (this.parent.resourceCollection.length > 0 && !isResourceEmpty) {
10408
10426
  content += '<div class="' + RESOURCE_CLASS + '"><div class="' + RESOURCE_ICON_CLASS + ' ' + ICON +
10409
10427
  '"></div><div class="' + RESOURCE_DETAILS_CLASS + ' ' + TEXT_ELLIPSIS + '"></div></div>';
10410
10428
  }
@@ -10467,7 +10485,8 @@ class QuickPopups {
10467
10485
  return footerTemplate;
10468
10486
  }
10469
10487
  getResourceText(args, type) {
10470
- if (this.parent.resourceCollection.length === 0) {
10488
+ const isResourceEmpty = this.parent.isResourceCollectionEmpty();
10489
+ if (this.parent.resourceCollection.length === 0 || isResourceEmpty) {
10471
10490
  return null;
10472
10491
  }
10473
10492
  let resourceValue = '';
@@ -10700,7 +10719,6 @@ class QuickPopups {
10700
10719
  }
10701
10720
  dialogButtonClick(event) {
10702
10721
  this.dialogEvent = event;
10703
- this.quickDialog.hide();
10704
10722
  const target = event.target;
10705
10723
  const cancelBtn = this.quickDialog.element.querySelector('.' + QUICK_DIALOG_ALERT_CANCEL);
10706
10724
  const eventData = this.parent.activeEventData.event;
@@ -10745,6 +10763,9 @@ class QuickPopups {
10745
10763
  this.parent.uiStateValues.isIgnoreOccurrence = target.classList.contains(QUICK_DIALOG_ALERT_CANCEL);
10746
10764
  this.parent.eventWindow.eventSave(event, this.l10n.getConstant('ok'));
10747
10765
  }
10766
+ if (!isNullOrUndefined(this.quickDialog)) {
10767
+ this.quickDialog.hide();
10768
+ }
10748
10769
  }
10749
10770
  updateTapHoldEventPopup(target) {
10750
10771
  const selectedElements = this.parent.eventBase.getSelectedEventElements(target);
@@ -10811,6 +10832,9 @@ class QuickPopups {
10811
10832
  this.parent.trigger(popupClose, args, (popupCloseArgs) => {
10812
10833
  if (!popupCloseArgs.cancel) {
10813
10834
  this.parent.eventBase.focusElement(true);
10835
+ if (!this.parent.prerenderDialogs) {
10836
+ this.destroyQuickDialog();
10837
+ }
10814
10838
  }
10815
10839
  });
10816
10840
  }
@@ -11134,7 +11158,9 @@ class QuickPopups {
11134
11158
  }
11135
11159
  refreshQuickDialog() {
11136
11160
  this.destroyQuickDialog();
11137
- this.renderQuickDialog();
11161
+ if (this.parent.prerenderDialogs) {
11162
+ this.renderQuickDialog();
11163
+ }
11138
11164
  }
11139
11165
  refreshQuickPopup() {
11140
11166
  this.destroyQuickPopup();
@@ -11145,7 +11171,7 @@ class QuickPopups {
11145
11171
  this.renderMorePopup();
11146
11172
  }
11147
11173
  destroyQuickDialog() {
11148
- if (this.quickDialog.element) {
11174
+ if (this.quickDialog && this.quickDialog.element) {
11149
11175
  this.quickDialog.destroy();
11150
11176
  remove(this.quickDialog.element);
11151
11177
  this.quickDialog = null;
@@ -12514,7 +12540,9 @@ class EventWindow {
12514
12540
  this.l10n = this.parent.localeObj;
12515
12541
  this.fields = this.parent.eventFields;
12516
12542
  this.eventWindowTime = { startTime: new Date(), endTime: new Date() };
12517
- this.renderEventWindow();
12543
+ if (this.parent.prerenderDialogs) {
12544
+ this.renderEventWindow();
12545
+ }
12518
12546
  }
12519
12547
  renderEventWindow() {
12520
12548
  this.element = createElement('div', { id: this.parent.element.id + '_dialog_wrapper' });
@@ -12602,6 +12630,9 @@ class EventWindow {
12602
12630
  }
12603
12631
  }
12604
12632
  openEditor(data, type, isEventData, repeatType) {
12633
+ if (!this.parent.prerenderDialogs) {
12634
+ this.renderEventWindow();
12635
+ }
12605
12636
  this.parent.currentAction = type;
12606
12637
  this.parent.removeNewEventElement();
12607
12638
  if (this.parent.quickPopup) {
@@ -12789,6 +12820,9 @@ class EventWindow {
12789
12820
  }
12790
12821
  callBackPromise.resolve(args);
12791
12822
  });
12823
+ if (!this.parent.prerenderDialogs && args.cancel) {
12824
+ this.destroy(true);
12825
+ }
12792
12826
  return callBackPromise;
12793
12827
  }
12794
12828
  onBeforeClose(args) {
@@ -12815,6 +12849,9 @@ class EventWindow {
12815
12849
  this.resetForm();
12816
12850
  this.parent.eventBase.focusElement(true);
12817
12851
  this.eventCrudData = null;
12852
+ if (!this.parent.prerenderDialogs) {
12853
+ this.destroy(true);
12854
+ }
12818
12855
  }
12819
12856
  }
12820
12857
  callBackPromise.resolve(args);
@@ -12909,7 +12946,8 @@ class EventWindow {
12909
12946
  else {
12910
12947
  this.createRecurrenceEditor(parentDiv);
12911
12948
  }
12912
- if (this.parent.resourceCollection.length > 0) {
12949
+ const isResourceEmpty = this.parent.isResourceCollectionEmpty();
12950
+ if (this.parent.resourceCollection.length > 0 && !isResourceEmpty) {
12913
12951
  const resourceParentDiv = this.createDivElement(EVENT_WINDOW_RESOURCES_DIV_CLASS);
12914
12952
  for (const resource of this.parent.resourceBase.resourceCollection) {
12915
12953
  resourceParentDiv.appendChild(this.renderResourceDetails(resource));
@@ -13444,7 +13482,8 @@ class EventWindow {
13444
13482
  if (cellsData.RecurrenceRule) {
13445
13483
  eventObj[this.fields.recurrenceRule] = cellsData.RecurrenceRule;
13446
13484
  }
13447
- if (this.parent.resourceCollection.length > 0 || this.parent.activeViewOptions.group.resources.length > 0) {
13485
+ const isResourceEmpty = this.parent.isResourceCollectionEmpty();
13486
+ if ((this.parent.resourceCollection.length > 0 && !isResourceEmpty) || this.parent.activeViewOptions.group.resources.length > 0) {
13448
13487
  this.parent.resourceBase.setResourceValues(eventObj);
13449
13488
  }
13450
13489
  }
@@ -14043,7 +14082,7 @@ class EventWindow {
14043
14082
  if (endDate.getTime() >= new Date(+startDate).setMonth(startDate.getMonth() + interval)) {
14044
14083
  alertMessage = 'createError';
14045
14084
  }
14046
- if (isNullOrUndefined(alertMessage)) {
14085
+ if (isNullOrUndefined(alertMessage) && !isNullOrUndefined(this.parent.quickPopup.quickDialog)) {
14047
14086
  this.parent.quickPopup.quickDialog.hide();
14048
14087
  }
14049
14088
  }
@@ -17311,10 +17350,13 @@ class ResourceBase {
17311
17350
  if (isNullOrUndefined(groupOrder) && this.parent.activeViewOptions.group.allowGroupEdit && resource.allowMultiple) {
17312
17351
  return undefined;
17313
17352
  }
17314
- const id = isNullOrUndefined(groupOrder) ? eventObj[resource.field] : groupOrder[parseInt(colorFieldIndex.toString(), 10)];
17315
- const data = this.filterData(resource.dataSource, resource.idField, id);
17316
- if (data.length > 0) {
17317
- return data[0][resource.colorField];
17353
+ const isResourceEmpty = this.parent.isResourceCollectionEmpty();
17354
+ if (!isResourceEmpty) {
17355
+ const id = isNullOrUndefined(groupOrder) ? eventObj[resource.field] : groupOrder[parseInt(colorFieldIndex.toString(), 10)];
17356
+ const data = this.filterData(resource.dataSource, resource.idField, id);
17357
+ if (data.length > 0) {
17358
+ return data[0][resource.colorField];
17359
+ }
17318
17360
  }
17319
17361
  return undefined;
17320
17362
  }
@@ -17905,6 +17947,19 @@ let Schedule = class Schedule extends Component {
17905
17947
  (currentIndex === -1) ? 0 : currentIndex;
17906
17948
  }
17907
17949
  }
17950
+ /**
17951
+ * Checks if resources have empty dataSource
17952
+ *
17953
+ * @returns {boolean} Returns true if resources have empty dataSource, otherwise false
17954
+ * @private
17955
+ */
17956
+ isResourceCollectionEmpty() {
17957
+ return this.resourceCollection.length > 0 &&
17958
+ this.resourceCollection.some((res) => {
17959
+ const ds = res && res.dataSource;
17960
+ return Array.isArray(ds) ? ds.length === 0 : !ds;
17961
+ });
17962
+ }
17908
17963
  getActiveViewOptions() {
17909
17964
  const timeScale = {
17910
17965
  enable: this.timeScale.enable,
@@ -17913,12 +17968,20 @@ let Schedule = class Schedule extends Component {
17913
17968
  majorSlotTemplate: this.timeScale.majorSlotTemplate,
17914
17969
  minorSlotTemplate: this.timeScale.minorSlotTemplate
17915
17970
  };
17971
+ const isResourceEmpty = this.isResourceCollectionEmpty();
17916
17972
  const isYearView = this.viewCollections[this.viewIndex].option.indexOf('Year') > -1;
17973
+ let groupResources = [];
17974
+ if ((!isNullOrUndefined(this.group.resources) && this.group.resources.length > 0) && !isResourceEmpty) {
17975
+ groupResources = this.group.resources;
17976
+ }
17977
+ else if (this.resources.length > 0 && !isResourceEmpty) {
17978
+ groupResources = [];
17979
+ }
17917
17980
  const group = {
17918
- byDate: isYearView ? false : this.group.byDate,
17981
+ byDate: (isYearView || isResourceEmpty) ? false : this.group.byDate,
17919
17982
  byGroupID: this.group.byGroupID,
17920
17983
  allowGroupEdit: this.group.allowGroupEdit,
17921
- resources: isNullOrUndefined(this.group.resources) ? [] : this.group.resources,
17984
+ resources: groupResources,
17922
17985
  headerTooltipTemplate: this.group.headerTooltipTemplate,
17923
17986
  enableCompactView: this.group.enableCompactView,
17924
17987
  hideNonWorkingDays: ['Day', 'Week', 'WorkWeek', 'Month'].indexOf(this.currentView) > -1 ? this.group.hideNonWorkingDays : false
@@ -18427,7 +18490,7 @@ let Schedule = class Schedule extends Component {
18427
18490
  * @private
18428
18491
  */
18429
18492
  removeSelectedClass() {
18430
- const selectedCells = this.getSelectedCells();
18493
+ const selectedCells = [].slice.call(this.element.querySelectorAll('.' + SELECTED_CELL_CLASS));
18431
18494
  for (const cell of selectedCells) {
18432
18495
  cell.removeAttribute('tabindex');
18433
18496
  }
@@ -18859,7 +18922,23 @@ let Schedule = class Schedule extends Component {
18859
18922
  * @private
18860
18923
  */
18861
18924
  getSelectedCells() {
18862
- return [].slice.call(this.element.querySelectorAll('.' + SELECTED_CELL_CLASS));
18925
+ const selectedCells = [].slice.call(this.element.querySelectorAll('.' + SELECTED_CELL_CLASS));
18926
+ if (!selectedCells || selectedCells.length === 0) {
18927
+ return [];
18928
+ }
18929
+ else if (selectedCells.length === 1) {
18930
+ return selectedCells;
18931
+ }
18932
+ if (selectedCells && selectedCells.length > 1) {
18933
+ const hasAnyWorkCells = selectedCells.some((cell) => cell.classList.contains(WORK_CELLS_CLASS));
18934
+ const workCells = hasAnyWorkCells ?
18935
+ selectedCells.filter((cell) => !cell.classList.contains(ALLDAY_CELLS_CLASS)) : selectedCells;
18936
+ if (!workCells || workCells.length === 0) {
18937
+ return [];
18938
+ }
18939
+ return [...workCells].sort((a, b) => (+a.dataset.date || 0) - (+b.dataset.date || 0));
18940
+ }
18941
+ return selectedCells;
18863
18942
  }
18864
18943
  /**
18865
18944
  * Method to generate the announcement string
@@ -19057,6 +19136,17 @@ let Schedule = class Schedule extends Component {
19057
19136
  state.isLayout = true;
19058
19137
  }
19059
19138
  break;
19139
+ case 'prerenderDialogs': {
19140
+ if (newProp.prerenderDialogs) {
19141
+ this.eventWindow.renderEventWindow();
19142
+ this.quickPopup.renderQuickDialog();
19143
+ }
19144
+ else {
19145
+ this.eventWindow.destroy(true);
19146
+ this.quickPopup.destroyQuickDialog();
19147
+ }
19148
+ break;
19149
+ }
19060
19150
  case 'showWeekend':
19061
19151
  case 'startHour':
19062
19152
  case 'endHour':
@@ -20349,6 +20439,9 @@ let Schedule = class Schedule extends Component {
20349
20439
  * @returns {void}
20350
20440
  */
20351
20441
  openOverlapAlert(args) {
20442
+ if (!this.prerenderDialogs) {
20443
+ return;
20444
+ }
20352
20445
  if (this.quickPopup) {
20353
20446
  const eventProp = {
20354
20447
  type: 'OverlapAlert',
@@ -20371,6 +20464,9 @@ let Schedule = class Schedule extends Component {
20371
20464
  * @returns {void}
20372
20465
  */
20373
20466
  closeOverlapAlert() {
20467
+ if (!this.prerenderDialogs) {
20468
+ return;
20469
+ }
20374
20470
  if (this.quickPopup) {
20375
20471
  const args = {
20376
20472
  type: 'OverlapAlert',
@@ -20681,6 +20777,9 @@ __decorate$b([
20681
20777
  __decorate$b([
20682
20778
  Property(true)
20683
20779
  ], Schedule.prototype, "showQuickInfo", void 0);
20780
+ __decorate$b([
20781
+ Property(true)
20782
+ ], Schedule.prototype, "prerenderDialogs", void 0);
20684
20783
  __decorate$b([
20685
20784
  Property(false)
20686
20785
  ], Schedule.prototype, "allowInline", void 0);