@seniorsistemas/exclusion-process-component 0.3.0 → 0.3.1

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.
@@ -402,6 +402,7 @@
402
402
  this.logicalDeleteService = logicalDeleteService;
403
403
  this.projectConfigs = projectConfigs;
404
404
  this.expandedRows = {};
405
+ this.onProcessFinishedSuccessfully = new core.EventEmitter();
405
406
  this._isVisible = false;
406
407
  this._isLoading = false;
407
408
  this._processGroupData = [];
@@ -465,7 +466,7 @@
465
466
  this._processGroupData = [];
466
467
  this.processDetails = null;
467
468
  this.entityDescription = details.entityDescription;
468
- this.loadProcessDetails(details);
469
+ this.loadProcessDetails(details, true);
469
470
  this.connectWebSocket();
470
471
  };
471
472
  ExclusionDetailsComponent.prototype.onVisibilityChanged = function (event) {
@@ -582,8 +583,9 @@
582
583
  }
583
584
  return null;
584
585
  };
585
- ExclusionDetailsComponent.prototype.loadProcessDetails = function (details) {
586
+ ExclusionDetailsComponent.prototype.loadProcessDetails = function (details, firstLoad) {
586
587
  var _this = this;
588
+ if (firstLoad === void 0) { firstLoad = false; }
587
589
  this._isLoading = true;
588
590
  var processObservable = details.processId
589
591
  ? this.logicalDeleteService.getProcessDetails(details.processId)
@@ -604,24 +606,51 @@
604
606
  .forEach(function (p) {
605
607
  _this.expandedRows[p.id] = true;
606
608
  });
609
+ _this.checkIfProcessDone();
610
+ if (!firstLoad) {
611
+ _this.checkIfProcessWasSuccessuful();
612
+ }
607
613
  });
608
614
  };
609
- ExclusionDetailsComponent.prototype.sortByDate = function (startDate, finishDate) {
610
- if (startDate.getTime() > finishDate.getTime()) {
615
+ ExclusionDetailsComponent.prototype.checkIfProcessDone = function () {
616
+ if (!this._processGroupData.length) {
617
+ return;
618
+ }
619
+ var isProcessFinished = this._processGroupData
620
+ .every(function (p) { return p.status === EnumExclusionProcessStatus.ERROR || p.status === EnumExclusionProcessStatus.SUCCESS; });
621
+ if (isProcessFinished) {
622
+ this.disconnectWebSocket();
623
+ }
624
+ };
625
+ ExclusionDetailsComponent.prototype.checkIfProcessWasSuccessuful = function () {
626
+ var isProcessSuccessful = this._processGroupData
627
+ .every(function (p) { return p.status === EnumExclusionProcessStatus.SUCCESS; });
628
+ if (isProcessSuccessful) {
629
+ this.notifyProcessFinishedSuccessfully();
630
+ }
631
+ };
632
+ ExclusionDetailsComponent.prototype.notifyProcessFinishedSuccessfully = function () {
633
+ this.onProcessFinishedSuccessfully.emit(this.processDetails);
634
+ };
635
+ ExclusionDetailsComponent.prototype.sortByDate = function (firstDate, secondDate) {
636
+ if (!firstDate || !secondDate) {
611
637
  return 1;
612
638
  }
613
- if (startDate.getTime() < finishDate.getTime()) {
639
+ if (firstDate.getTime() > secondDate.getTime()) {
640
+ return 1;
641
+ }
642
+ if (firstDate.getTime() < secondDate.getTime()) {
614
643
  return -1;
615
644
  }
616
645
  return 0;
617
646
  };
618
647
  ExclusionDetailsComponent.prototype.sortGroupsByStartDate = function (groups) {
619
648
  var _this = this;
620
- return groups.sort(function (a, b) { return _this.sortByDate(a.startDate, b.finishDate); });
649
+ return groups.sort(function (a, b) { return _this.sortByDate(a.startDate, b.startDate); });
621
650
  };
622
651
  ExclusionDetailsComponent.prototype.sortStepsByStartDate = function (steps) {
623
652
  var _this = this;
624
- return steps.sort(function (a, b) { return _this.sortByDate(a.startDate, b.finishDate); });
653
+ return steps.sort(function (a, b) { return _this.sortByDate(a.startDate, b.startDate); });
625
654
  };
626
655
  ExclusionDetailsComponent.prototype.disconnectWebSocket = function () {
627
656
  if (this._exclusionProcessStatusChangedSubscribe) {
@@ -702,6 +731,9 @@
702
731
  __decorate([
703
732
  core.Output()
704
733
  ], ExclusionDetailsComponent.prototype, "expandedRows", void 0);
734
+ __decorate([
735
+ core.Output()
736
+ ], ExclusionDetailsComponent.prototype, "onProcessFinishedSuccessfully", void 0);
705
737
  ExclusionDetailsComponent = __decorate([
706
738
  core.Component({
707
739
  selector: "s-exclusion-details",
@@ -1217,23 +1249,6 @@
1217
1249
  ], ExclusionsListFeatureRoutingGuard);
1218
1250
  return ExclusionsListFeatureRoutingGuard;
1219
1251
  }());
1220
- var ExclusionsListFeatureRoutingListTitleResolver = /** @class */ (function () {
1221
- function ExclusionsListFeatureRoutingListTitleResolver(translate, projectConfigs) {
1222
- this.translate = translate;
1223
- this.projectConfigs = projectConfigs;
1224
- }
1225
- ExclusionsListFeatureRoutingListTitleResolver.prototype.resolve = function () {
1226
- return this.translate.get(this.projectConfigs.getTranslationPrefix() + ".logical_delete_list_title");
1227
- };
1228
- ExclusionsListFeatureRoutingListTitleResolver.ctorParameters = function () { return [
1229
- { type: core$1.TranslateService },
1230
- { type: LogicalDeleteConfigService }
1231
- ]; };
1232
- ExclusionsListFeatureRoutingListTitleResolver = __decorate([
1233
- core.Injectable()
1234
- ], ExclusionsListFeatureRoutingListTitleResolver);
1235
- return ExclusionsListFeatureRoutingListTitleResolver;
1236
- }());
1237
1252
  var ExclusionsListFeatureRoutingPermissionResolver = /** @class */ (function () {
1238
1253
  function ExclusionsListFeatureRoutingPermissionResolver(permissionsService) {
1239
1254
  this.permissionsService = permissionsService;
@@ -1283,8 +1298,7 @@
1283
1298
  ],
1284
1299
  resolve: {
1285
1300
  allPermissions: ExclusionsListFeatureRoutingPermissionResolver,
1286
- localeConfig: ExclusionsListFeatureRoutingLocaleResolver,
1287
- routeTitle: ExclusionsListFeatureRoutingListTitleResolver
1301
+ localeConfig: ExclusionsListFeatureRoutingLocaleResolver
1288
1302
  },
1289
1303
  children: [
1290
1304
  {
@@ -1308,8 +1322,7 @@
1308
1322
  providers: [
1309
1323
  ExclusionsListFeatureRoutingGuard,
1310
1324
  ExclusionsListFeatureRoutingPermissionResolver,
1311
- ExclusionsListFeatureRoutingLocaleResolver,
1312
- ExclusionsListFeatureRoutingListTitleResolver
1325
+ ExclusionsListFeatureRoutingLocaleResolver
1313
1326
  ],
1314
1327
  declarations: [
1315
1328
  EmptyComponent
@@ -1384,7 +1397,6 @@
1384
1397
  exports.ExclusionsListComponent = ExclusionsListComponent;
1385
1398
  exports.ExclusionsListFeatureRouting = ExclusionsListFeatureRouting;
1386
1399
  exports.ExclusionsListFeatureRoutingGuard = ExclusionsListFeatureRoutingGuard;
1387
- exports.ExclusionsListFeatureRoutingListTitleResolver = ExclusionsListFeatureRoutingListTitleResolver;
1388
1400
  exports.ExclusionsListFeatureRoutingLocaleResolver = ExclusionsListFeatureRoutingLocaleResolver;
1389
1401
  exports.ExclusionsListFeatureRoutingPermissionResolver = ExclusionsListFeatureRoutingPermissionResolver;
1390
1402
  exports.ExclusionsListModule = ExclusionsListModule;