@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.
@@ -10043,7 +10043,9 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
10043
10043
  QuickPopups.prototype.render = function () {
10044
10044
  this.renderQuickPopup();
10045
10045
  this.renderMorePopup();
10046
- this.renderQuickDialog();
10046
+ if (this.parent.prerenderDialogs) {
10047
+ this.renderQuickDialog();
10048
+ }
10047
10049
  };
10048
10050
  QuickPopups.prototype.renderQuickPopup = function () {
10049
10051
  var quickPopupWrapper = createElement('div', { className: POPUP_WRAPPER_CLASS + ' e-popup-close', attrs: { role: 'dialog' } });
@@ -10203,6 +10205,9 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
10203
10205
  this.fieldValidator.renderFormValidator(form, rules, this.quickPopup.element, this.parent.locale);
10204
10206
  };
10205
10207
  QuickPopups.prototype.openRecurrenceAlert = function () {
10208
+ if (!this.parent.prerenderDialogs) {
10209
+ this.renderQuickDialog();
10210
+ }
10206
10211
  var editDeleteOnly = this.quickDialog.element.querySelector('.' + QUICK_DIALOG_ALERT_OK);
10207
10212
  if (editDeleteOnly) {
10208
10213
  editDeleteOnly.innerHTML = this.l10n.getConstant(this.parent.currentAction === 'Delete' ? 'deleteEvent' : 'editEvent');
@@ -10224,6 +10229,9 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
10224
10229
  this.showQuickDialog('RecurrenceAlert');
10225
10230
  };
10226
10231
  QuickPopups.prototype.openRecurrenceValidationAlert = function (type) {
10232
+ if (!this.parent.prerenderDialogs) {
10233
+ this.renderQuickDialog();
10234
+ }
10227
10235
  this.quickDialogClass('Alert');
10228
10236
  var okButton = this.quickDialog.element.querySelector('.' + QUICK_DIALOG_ALERT_OK);
10229
10237
  okButton.innerHTML = this.l10n.getConstant('ok');
@@ -10267,6 +10275,9 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
10267
10275
  if (this.parent.activeViewOptions.readonly) {
10268
10276
  return;
10269
10277
  }
10278
+ if (!this.parent.prerenderDialogs) {
10279
+ this.renderQuickDialog();
10280
+ }
10270
10281
  var okButton = this.quickDialog.element.querySelector('.' + QUICK_DIALOG_ALERT_OK);
10271
10282
  if (okButton) {
10272
10283
  okButton.innerHTML = this.l10n.getConstant('delete');
@@ -10285,6 +10296,9 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
10285
10296
  this.showQuickDialog('DeleteAlert');
10286
10297
  };
10287
10298
  QuickPopups.prototype.openValidationError = function (type, eventData) {
10299
+ if (!this.parent.prerenderDialogs) {
10300
+ this.renderQuickDialog();
10301
+ }
10288
10302
  this.quickDialog.header = this.l10n.getConstant('alert');
10289
10303
  this.quickDialog.content = this.l10n.getConstant(type);
10290
10304
  var okButton = this.quickDialog.element.querySelector('.' + QUICK_DIALOG_ALERT_OK);
@@ -10314,6 +10328,9 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
10314
10328
  if (!popupArgs.cancel) {
10315
10329
  _this.quickDialog.show();
10316
10330
  }
10331
+ if (!_this.parent.prerenderDialogs && popupArgs.cancel) {
10332
+ _this.destroyQuickDialog();
10333
+ }
10317
10334
  });
10318
10335
  };
10319
10336
  QuickPopups.prototype.createMoreEventList = function (eventCollection, groupOrder, groupIndex) {
@@ -10631,6 +10648,7 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
10631
10648
  var cellDetails = void 0;
10632
10649
  var argsData = void 0;
10633
10650
  var resourceText = this.getResourceText(args, type.toLowerCase());
10651
+ var isResourceEmpty = this.parent.isResourceCollectionEmpty();
10634
10652
  switch (type) {
10635
10653
  case 'Cell':
10636
10654
  cellDetails = this.getFormattedString(data);
@@ -10665,7 +10683,7 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
10665
10683
  content += '<div class="' + DESCRIPTION_CLASS + '"><div class="' + DESCRIPTION_ICON_CLASS + ' ' + ICON +
10666
10684
  '"></div><div class="' + DESCRIPTION_DETAILS_CLASS + ' ' + TEXT_ELLIPSIS + '"></div></div>';
10667
10685
  }
10668
- if (this.parent.resourceCollection.length > 0) {
10686
+ if (this.parent.resourceCollection.length > 0 && !isResourceEmpty) {
10669
10687
  content += '<div class="' + RESOURCE_CLASS + '"><div class="' + RESOURCE_ICON_CLASS + ' ' + ICON +
10670
10688
  '"></div><div class="' + RESOURCE_DETAILS_CLASS + ' ' + TEXT_ELLIPSIS + '"></div></div>';
10671
10689
  }
@@ -10728,7 +10746,8 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
10728
10746
  return footerTemplate;
10729
10747
  };
10730
10748
  QuickPopups.prototype.getResourceText = function (args, type) {
10731
- if (this.parent.resourceCollection.length === 0) {
10749
+ var isResourceEmpty = this.parent.isResourceCollectionEmpty();
10750
+ if (this.parent.resourceCollection.length === 0 || isResourceEmpty) {
10732
10751
  return null;
10733
10752
  }
10734
10753
  var resourceValue = '';
@@ -10968,7 +10987,6 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
10968
10987
  };
10969
10988
  QuickPopups.prototype.dialogButtonClick = function (event) {
10970
10989
  this.dialogEvent = event;
10971
- this.quickDialog.hide();
10972
10990
  var target = event.target;
10973
10991
  var cancelBtn = this.quickDialog.element.querySelector('.' + QUICK_DIALOG_ALERT_CANCEL);
10974
10992
  var eventData = this.parent.activeEventData.event;
@@ -11013,6 +11031,9 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
11013
11031
  this.parent.uiStateValues.isIgnoreOccurrence = target.classList.contains(QUICK_DIALOG_ALERT_CANCEL);
11014
11032
  this.parent.eventWindow.eventSave(event, this.l10n.getConstant('ok'));
11015
11033
  }
11034
+ if (!isNullOrUndefined(this.quickDialog)) {
11035
+ this.quickDialog.hide();
11036
+ }
11016
11037
  };
11017
11038
  QuickPopups.prototype.updateTapHoldEventPopup = function (target) {
11018
11039
  var selectedElements = this.parent.eventBase.getSelectedEventElements(target);
@@ -11080,6 +11101,9 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
11080
11101
  this.parent.trigger(popupClose, args, function (popupCloseArgs) {
11081
11102
  if (!popupCloseArgs.cancel) {
11082
11103
  _this.parent.eventBase.focusElement(true);
11104
+ if (!_this.parent.prerenderDialogs) {
11105
+ _this.destroyQuickDialog();
11106
+ }
11083
11107
  }
11084
11108
  });
11085
11109
  };
@@ -11406,7 +11430,9 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
11406
11430
  };
11407
11431
  QuickPopups.prototype.refreshQuickDialog = function () {
11408
11432
  this.destroyQuickDialog();
11409
- this.renderQuickDialog();
11433
+ if (this.parent.prerenderDialogs) {
11434
+ this.renderQuickDialog();
11435
+ }
11410
11436
  };
11411
11437
  QuickPopups.prototype.refreshQuickPopup = function () {
11412
11438
  this.destroyQuickPopup();
@@ -11417,7 +11443,7 @@ var QuickPopups = /** @__PURE__ @class */ (function () {
11417
11443
  this.renderMorePopup();
11418
11444
  };
11419
11445
  QuickPopups.prototype.destroyQuickDialog = function () {
11420
- if (this.quickDialog.element) {
11446
+ if (this.quickDialog && this.quickDialog.element) {
11421
11447
  this.quickDialog.destroy();
11422
11448
  remove(this.quickDialog.element);
11423
11449
  this.quickDialog = null;
@@ -12823,7 +12849,9 @@ var EventWindow = /** @__PURE__ @class */ (function () {
12823
12849
  this.l10n = this.parent.localeObj;
12824
12850
  this.fields = this.parent.eventFields;
12825
12851
  this.eventWindowTime = { startTime: new Date(), endTime: new Date() };
12826
- this.renderEventWindow();
12852
+ if (this.parent.prerenderDialogs) {
12853
+ this.renderEventWindow();
12854
+ }
12827
12855
  }
12828
12856
  EventWindow.prototype.renderEventWindow = function () {
12829
12857
  this.element = createElement('div', { id: this.parent.element.id + '_dialog_wrapper' });
@@ -12911,6 +12939,9 @@ var EventWindow = /** @__PURE__ @class */ (function () {
12911
12939
  }
12912
12940
  };
12913
12941
  EventWindow.prototype.openEditor = function (data, type, isEventData, repeatType) {
12942
+ if (!this.parent.prerenderDialogs) {
12943
+ this.renderEventWindow();
12944
+ }
12914
12945
  this.parent.currentAction = type;
12915
12946
  this.parent.removeNewEventElement();
12916
12947
  if (this.parent.quickPopup) {
@@ -13099,6 +13130,9 @@ var EventWindow = /** @__PURE__ @class */ (function () {
13099
13130
  }
13100
13131
  callBackPromise.resolve(args);
13101
13132
  });
13133
+ if (!this.parent.prerenderDialogs && args.cancel) {
13134
+ this.destroy(true);
13135
+ }
13102
13136
  return callBackPromise;
13103
13137
  };
13104
13138
  EventWindow.prototype.onBeforeClose = function (args) {
@@ -13126,6 +13160,9 @@ var EventWindow = /** @__PURE__ @class */ (function () {
13126
13160
  _this.resetForm();
13127
13161
  _this.parent.eventBase.focusElement(true);
13128
13162
  _this.eventCrudData = null;
13163
+ if (!_this.parent.prerenderDialogs) {
13164
+ _this.destroy(true);
13165
+ }
13129
13166
  }
13130
13167
  }
13131
13168
  callBackPromise.resolve(args);
@@ -13222,7 +13259,8 @@ var EventWindow = /** @__PURE__ @class */ (function () {
13222
13259
  else {
13223
13260
  this.createRecurrenceEditor(parentDiv);
13224
13261
  }
13225
- if (this.parent.resourceCollection.length > 0) {
13262
+ var isResourceEmpty = this.parent.isResourceCollectionEmpty();
13263
+ if (this.parent.resourceCollection.length > 0 && !isResourceEmpty) {
13226
13264
  var resourceParentDiv = this.createDivElement(EVENT_WINDOW_RESOURCES_DIV_CLASS);
13227
13265
  for (var _i = 0, _a = this.parent.resourceBase.resourceCollection; _i < _a.length; _i++) {
13228
13266
  var resource = _a[_i];
@@ -13767,7 +13805,8 @@ var EventWindow = /** @__PURE__ @class */ (function () {
13767
13805
  if (cellsData.RecurrenceRule) {
13768
13806
  eventObj[this.fields.recurrenceRule] = cellsData.RecurrenceRule;
13769
13807
  }
13770
- if (this.parent.resourceCollection.length > 0 || this.parent.activeViewOptions.group.resources.length > 0) {
13808
+ var isResourceEmpty = this.parent.isResourceCollectionEmpty();
13809
+ if ((this.parent.resourceCollection.length > 0 && !isResourceEmpty) || this.parent.activeViewOptions.group.resources.length > 0) {
13771
13810
  this.parent.resourceBase.setResourceValues(eventObj);
13772
13811
  }
13773
13812
  };
@@ -14376,7 +14415,7 @@ var EventWindow = /** @__PURE__ @class */ (function () {
14376
14415
  if (endDate.getTime() >= new Date(+startDate).setMonth(startDate.getMonth() + interval)) {
14377
14416
  alertMessage = 'createError';
14378
14417
  }
14379
- if (isNullOrUndefined(alertMessage)) {
14418
+ if (isNullOrUndefined(alertMessage) && !isNullOrUndefined(this.parent.quickPopup.quickDialog)) {
14380
14419
  this.parent.quickPopup.quickDialog.hide();
14381
14420
  }
14382
14421
  }
@@ -17937,10 +17976,13 @@ var ResourceBase = /** @__PURE__ @class */ (function () {
17937
17976
  if (isNullOrUndefined(groupOrder) && this.parent.activeViewOptions.group.allowGroupEdit && resource.allowMultiple) {
17938
17977
  return undefined;
17939
17978
  }
17940
- var id = isNullOrUndefined(groupOrder) ? eventObj[resource.field] : groupOrder[parseInt(colorFieldIndex.toString(), 10)];
17941
- var data = this.filterData(resource.dataSource, resource.idField, id);
17942
- if (data.length > 0) {
17943
- return data[0][resource.colorField];
17979
+ var isResourceEmpty = this.parent.isResourceCollectionEmpty();
17980
+ if (!isResourceEmpty) {
17981
+ var id = isNullOrUndefined(groupOrder) ? eventObj[resource.field] : groupOrder[parseInt(colorFieldIndex.toString(), 10)];
17982
+ var data = this.filterData(resource.dataSource, resource.idField, id);
17983
+ if (data.length > 0) {
17984
+ return data[0][resource.colorField];
17985
+ }
17944
17986
  }
17945
17987
  return undefined;
17946
17988
  };
@@ -18591,6 +18633,19 @@ var Schedule = /** @__PURE__ @class */ (function (_super) {
18591
18633
  (currentIndex === -1) ? 0 : currentIndex;
18592
18634
  }
18593
18635
  };
18636
+ /**
18637
+ * Checks if resources have empty dataSource
18638
+ *
18639
+ * @returns {boolean} Returns true if resources have empty dataSource, otherwise false
18640
+ * @private
18641
+ */
18642
+ Schedule.prototype.isResourceCollectionEmpty = function () {
18643
+ return this.resourceCollection.length > 0 &&
18644
+ this.resourceCollection.some(function (res) {
18645
+ var ds = res && res.dataSource;
18646
+ return Array.isArray(ds) ? ds.length === 0 : !ds;
18647
+ });
18648
+ };
18594
18649
  Schedule.prototype.getActiveViewOptions = function () {
18595
18650
  var timeScale = {
18596
18651
  enable: this.timeScale.enable,
@@ -18599,12 +18654,20 @@ var Schedule = /** @__PURE__ @class */ (function (_super) {
18599
18654
  majorSlotTemplate: this.timeScale.majorSlotTemplate,
18600
18655
  minorSlotTemplate: this.timeScale.minorSlotTemplate
18601
18656
  };
18657
+ var isResourceEmpty = this.isResourceCollectionEmpty();
18602
18658
  var isYearView = this.viewCollections[this.viewIndex].option.indexOf('Year') > -1;
18659
+ var groupResources = [];
18660
+ if ((!isNullOrUndefined(this.group.resources) && this.group.resources.length > 0) && !isResourceEmpty) {
18661
+ groupResources = this.group.resources;
18662
+ }
18663
+ else if (this.resources.length > 0 && !isResourceEmpty) {
18664
+ groupResources = [];
18665
+ }
18603
18666
  var group = {
18604
- byDate: isYearView ? false : this.group.byDate,
18667
+ byDate: (isYearView || isResourceEmpty) ? false : this.group.byDate,
18605
18668
  byGroupID: this.group.byGroupID,
18606
18669
  allowGroupEdit: this.group.allowGroupEdit,
18607
- resources: isNullOrUndefined(this.group.resources) ? [] : this.group.resources,
18670
+ resources: groupResources,
18608
18671
  headerTooltipTemplate: this.group.headerTooltipTemplate,
18609
18672
  enableCompactView: this.group.enableCompactView,
18610
18673
  hideNonWorkingDays: ['Day', 'Week', 'WorkWeek', 'Month'].indexOf(this.currentView) > -1 ? this.group.hideNonWorkingDays : false
@@ -19119,7 +19182,7 @@ var Schedule = /** @__PURE__ @class */ (function (_super) {
19119
19182
  * @private
19120
19183
  */
19121
19184
  Schedule.prototype.removeSelectedClass = function () {
19122
- var selectedCells = this.getSelectedCells();
19185
+ var selectedCells = [].slice.call(this.element.querySelectorAll('.' + SELECTED_CELL_CLASS));
19123
19186
  for (var _i = 0, selectedCells_1 = selectedCells; _i < selectedCells_1.length; _i++) {
19124
19187
  var cell = selectedCells_1[_i];
19125
19188
  cell.removeAttribute('tabindex');
@@ -19552,7 +19615,23 @@ var Schedule = /** @__PURE__ @class */ (function (_super) {
19552
19615
  * @private
19553
19616
  */
19554
19617
  Schedule.prototype.getSelectedCells = function () {
19555
- return [].slice.call(this.element.querySelectorAll('.' + SELECTED_CELL_CLASS));
19618
+ var selectedCells = [].slice.call(this.element.querySelectorAll('.' + SELECTED_CELL_CLASS));
19619
+ if (!selectedCells || selectedCells.length === 0) {
19620
+ return [];
19621
+ }
19622
+ else if (selectedCells.length === 1) {
19623
+ return selectedCells;
19624
+ }
19625
+ if (selectedCells && selectedCells.length > 1) {
19626
+ var hasAnyWorkCells = selectedCells.some(function (cell) { return cell.classList.contains(WORK_CELLS_CLASS); });
19627
+ var workCells = hasAnyWorkCells ?
19628
+ selectedCells.filter(function (cell) { return !cell.classList.contains(ALLDAY_CELLS_CLASS); }) : selectedCells;
19629
+ if (!workCells || workCells.length === 0) {
19630
+ return [];
19631
+ }
19632
+ return workCells.slice().sort(function (a, b) { return (+a.dataset.date || 0) - (+b.dataset.date || 0); });
19633
+ }
19634
+ return selectedCells;
19556
19635
  };
19557
19636
  /**
19558
19637
  * Method to generate the announcement string
@@ -19751,6 +19830,17 @@ var Schedule = /** @__PURE__ @class */ (function (_super) {
19751
19830
  state.isLayout = true;
19752
19831
  }
19753
19832
  break;
19833
+ case 'prerenderDialogs': {
19834
+ if (newProp.prerenderDialogs) {
19835
+ this.eventWindow.renderEventWindow();
19836
+ this.quickPopup.renderQuickDialog();
19837
+ }
19838
+ else {
19839
+ this.eventWindow.destroy(true);
19840
+ this.quickPopup.destroyQuickDialog();
19841
+ }
19842
+ break;
19843
+ }
19754
19844
  case 'showWeekend':
19755
19845
  case 'startHour':
19756
19846
  case 'endHour':
@@ -21060,6 +21150,9 @@ var Schedule = /** @__PURE__ @class */ (function (_super) {
21060
21150
  */
21061
21151
  Schedule.prototype.openOverlapAlert = function (args) {
21062
21152
  var _this = this;
21153
+ if (!this.prerenderDialogs) {
21154
+ return;
21155
+ }
21063
21156
  if (this.quickPopup) {
21064
21157
  var eventProp = {
21065
21158
  type: 'OverlapAlert',
@@ -21083,6 +21176,9 @@ var Schedule = /** @__PURE__ @class */ (function (_super) {
21083
21176
  */
21084
21177
  Schedule.prototype.closeOverlapAlert = function () {
21085
21178
  var _this = this;
21179
+ if (!this.prerenderDialogs) {
21180
+ return;
21181
+ }
21086
21182
  if (this.quickPopup) {
21087
21183
  var args = {
21088
21184
  type: 'OverlapAlert',
@@ -21394,6 +21490,9 @@ var Schedule = /** @__PURE__ @class */ (function (_super) {
21394
21490
  __decorate$b([
21395
21491
  Property(true)
21396
21492
  ], Schedule.prototype, "showQuickInfo", void 0);
21493
+ __decorate$b([
21494
+ Property(true)
21495
+ ], Schedule.prototype, "prerenderDialogs", void 0);
21397
21496
  __decorate$b([
21398
21497
  Property(false)
21399
21498
  ], Schedule.prototype, "allowInline", void 0);