survey-angular-ui 2.5.7 → 2.5.8

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.
@@ -1023,32 +1023,53 @@
1023
1023
  function ModalComponent(popupService) {
1024
1024
  this.popupService = popupService;
1025
1025
  this.functionDefined = false;
1026
+ this.hosts = {};
1027
+ this.modalManager = this.createModalManager();
1026
1028
  }
1027
- ModalComponent.prototype.showDialog = function (dialogOptions, rootElement) {
1029
+ ModalComponent.prototype.createModalManager = function () {
1028
1030
  var _this = this;
1029
- var popupViewModel = this.model = Survey.createPopupModalViewModel(dialogOptions, rootElement);
1030
- var onVisibilityChangedCallback = function (_, options) {
1031
- if (!options.isVisible) {
1032
- _this.portalHost.detach();
1033
- _this.model.dispose();
1031
+ var modalManager = new Survey.PopupModalManager();
1032
+ modalManager.onModalsChangedCallback = function (_, addedModals, removedModals) {
1033
+ var e_1, _a, e_2, _b;
1034
+ try {
1035
+ for (var addedModals_1 = __values(addedModals), addedModals_1_1 = addedModals_1.next(); !addedModals_1_1.done; addedModals_1_1 = addedModals_1.next()) {
1036
+ var modal = addedModals_1_1.value;
1037
+ _this.hosts[modal.uniqueId] = _this.popupService.createComponent(modal);
1038
+ }
1039
+ }
1040
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1041
+ finally {
1042
+ try {
1043
+ if (addedModals_1_1 && !addedModals_1_1.done && (_a = addedModals_1.return)) _a.call(addedModals_1);
1044
+ }
1045
+ finally { if (e_1) throw e_1.error; }
1046
+ }
1047
+ try {
1048
+ for (var removedModals_1 = __values(removedModals), removedModals_1_1 = removedModals_1.next(); !removedModals_1_1.done; removedModals_1_1 = removedModals_1.next()) {
1049
+ var modal = removedModals_1_1.value;
1050
+ if (_this.hosts[modal.uniqueId]) {
1051
+ _this.hosts[modal.uniqueId].detach();
1052
+ delete _this.hosts[modal.uniqueId];
1053
+ }
1054
+ }
1055
+ }
1056
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1057
+ finally {
1058
+ try {
1059
+ if (removedModals_1_1 && !removedModals_1_1.done && (_b = removedModals_1.return)) _b.call(removedModals_1);
1060
+ }
1061
+ finally { if (e_2) throw e_2.error; }
1034
1062
  }
1035
1063
  };
1036
- popupViewModel.onVisibilityChanged.add(onVisibilityChangedCallback);
1037
- this.portalHost = this.popupService.createComponent(this.model);
1038
- this.model.model.isVisible = true;
1039
- return this.model;
1064
+ return modalManager;
1040
1065
  };
1041
1066
  ModalComponent.prototype.ngOnInit = function () {
1042
1067
  var _this = this;
1043
1068
  this.functionDefined = true;
1044
- Survey.settings.showDialog = function (dialogOptions, rootElement) {
1045
- return _this.showDialog(dialogOptions, rootElement);
1046
- };
1069
+ Survey.settings.showDialog = function (dialogOptions, rootElement) { return _this.modalManager.addDialog(dialogOptions, rootElement); };
1047
1070
  };
1048
1071
  ModalComponent.prototype.ngOnDestroy = function () {
1049
- var _a, _b;
1050
- (_a = this.portalHost) === null || _a === void 0 ? void 0 : _a.detach();
1051
- (_b = this.model) === null || _b === void 0 ? void 0 : _b.dispose();
1072
+ this.modalManager.clear();
1052
1073
  if (this.functionDefined) {
1053
1074
  Survey.settings.showDialog = undefined;
1054
1075
  }