@seniorsistemas/exclusion-process-component 0.3.0 → 0.4.0-4e5ffad5-8c1e-4b6f-b6fa-2d786d5a4d80

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,12 +402,14 @@
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 = [];
408
409
  this._processGroupColumns = [];
409
410
  this._processStepColumns = [];
410
411
  this.ngUnsubscribe = new rxjs.Subject();
412
+ this.subscriptionLoadProcess = null;
411
413
  }
412
414
  Object.defineProperty(ExclusionDetailsComponent.prototype, "isVisible", {
413
415
  get: function () {
@@ -465,7 +467,7 @@
465
467
  this._processGroupData = [];
466
468
  this.processDetails = null;
467
469
  this.entityDescription = details.entityDescription;
468
- this.loadProcessDetails(details);
470
+ this.loadProcessDetails(details, true);
469
471
  this.connectWebSocket();
470
472
  };
471
473
  ExclusionDetailsComponent.prototype.onVisibilityChanged = function (event) {
@@ -508,6 +510,9 @@
508
510
  ExclusionDetailsComponent.prototype.getCloseButtonLabel = function () {
509
511
  return this.translate.instant(this.projectConfigs.getTranslationPrefix() + ".logical_delete_close");
510
512
  };
513
+ ExclusionDetailsComponent.prototype.getUpdateButtonLabel = function () {
514
+ return this.translate.instant(this.projectConfigs.getTranslationPrefix() + ".logical_delete_update");
515
+ };
511
516
  ExclusionDetailsComponent.prototype.getSummaryLabel = function () {
512
517
  return this.translate.instant(this.projectConfigs.getTranslationPrefix() + ".logical_delete_summary");
513
518
  };
@@ -582,13 +587,32 @@
582
587
  }
583
588
  return null;
584
589
  };
585
- ExclusionDetailsComponent.prototype.loadProcessDetails = function (details) {
590
+ ExclusionDetailsComponent.prototype.updateDetails = function () {
591
+ if (!this._exclusionDetails) {
592
+ return;
593
+ }
594
+ this.loadProcessDetails(this._exclusionDetails);
595
+ };
596
+ ExclusionDetailsComponent.prototype.abortRunningLoadProcessCall = function () {
597
+ if (this.subscriptionLoadProcess) {
598
+ if (this.subscriptionLoadProcess.closed) {
599
+ this.subscriptionLoadProcess = null;
600
+ }
601
+ else {
602
+ this.subscriptionLoadProcess.unsubscribe();
603
+ this.subscriptionLoadProcess = null;
604
+ }
605
+ }
606
+ };
607
+ ExclusionDetailsComponent.prototype.loadProcessDetails = function (details, firstLoad) {
586
608
  var _this = this;
609
+ if (firstLoad === void 0) { firstLoad = false; }
587
610
  this._isLoading = true;
611
+ this.abortRunningLoadProcessCall();
588
612
  var processObservable = details.processId
589
613
  ? this.logicalDeleteService.getProcessDetails(details.processId)
590
614
  : this.logicalDeleteService.getLatestProcessDetails(details.recordId);
591
- processObservable
615
+ this.subscriptionLoadProcess = processObservable
592
616
  .pipe(operators.takeUntil(this.ngUnsubscribe))
593
617
  .pipe(operators.finalize(function () { return _this._isLoading = false; }))
594
618
  .subscribe(function (process) {
@@ -604,24 +628,50 @@
604
628
  .forEach(function (p) {
605
629
  _this.expandedRows[p.id] = true;
606
630
  });
631
+ if (_this.isProcessFinished()) {
632
+ _this.disconnectWebSocket();
633
+ }
634
+ if (!firstLoad) {
635
+ _this.checkIfProcessWasSuccessuful();
636
+ }
607
637
  });
608
638
  };
609
- ExclusionDetailsComponent.prototype.sortByDate = function (startDate, finishDate) {
610
- if (startDate.getTime() > finishDate.getTime()) {
639
+ ExclusionDetailsComponent.prototype.isProcessFinished = function () {
640
+ if (!this._processGroupData.length) {
641
+ return false;
642
+ }
643
+ return this._processGroupData
644
+ .every(function (p) { return p.status === EnumExclusionProcessStatus.ERROR || p.status === EnumExclusionProcessStatus.SUCCESS; });
645
+ };
646
+ ExclusionDetailsComponent.prototype.checkIfProcessWasSuccessuful = function () {
647
+ var isProcessSuccessful = this._processGroupData
648
+ .every(function (p) { return p.status === EnumExclusionProcessStatus.SUCCESS; });
649
+ if (isProcessSuccessful) {
650
+ this.notifyProcessFinishedSuccessfully();
651
+ }
652
+ };
653
+ ExclusionDetailsComponent.prototype.notifyProcessFinishedSuccessfully = function () {
654
+ this.onProcessFinishedSuccessfully.emit(this.processDetails);
655
+ };
656
+ ExclusionDetailsComponent.prototype.sortByDate = function (firstDate, secondDate) {
657
+ if (!firstDate || !secondDate) {
658
+ return 1;
659
+ }
660
+ if (firstDate.getTime() > secondDate.getTime()) {
611
661
  return 1;
612
662
  }
613
- if (startDate.getTime() < finishDate.getTime()) {
663
+ if (firstDate.getTime() < secondDate.getTime()) {
614
664
  return -1;
615
665
  }
616
666
  return 0;
617
667
  };
618
668
  ExclusionDetailsComponent.prototype.sortGroupsByStartDate = function (groups) {
619
669
  var _this = this;
620
- return groups.sort(function (a, b) { return _this.sortByDate(a.startDate, b.finishDate); });
670
+ return (groups === null || groups === void 0 ? void 0 : groups.length) ? groups.sort(function (a, b) { return _this.sortByDate(a.startDate, b.startDate); }) : groups;
621
671
  };
622
672
  ExclusionDetailsComponent.prototype.sortStepsByStartDate = function (steps) {
623
673
  var _this = this;
624
- return steps.sort(function (a, b) { return _this.sortByDate(a.startDate, b.finishDate); });
674
+ return (steps === null || steps === void 0 ? void 0 : steps.length) ? steps.sort(function (a, b) { return _this.sortByDate(a.startDate, b.startDate); }) : steps;
625
675
  };
626
676
  ExclusionDetailsComponent.prototype.disconnectWebSocket = function () {
627
677
  if (this._exclusionProcessStatusChangedSubscribe) {
@@ -644,6 +694,9 @@
644
694
  .pipe(operators.takeUntil(this.ngUnsubscribe))
645
695
  .subscribe(function () {
646
696
  _this.startListeningWebhookEvents();
697
+ if (_this.processDetails && !_this.isProcessFinished()) {
698
+ _this.loadProcessDetails(_this._exclusionDetails);
699
+ }
647
700
  });
648
701
  };
649
702
  ExclusionDetailsComponent.prototype.startListeningWebhookEvents = function () {
@@ -651,9 +704,7 @@
651
704
  this._websocketService
652
705
  .onError()
653
706
  .pipe(operators.takeUntil(this.ngUnsubscribe))
654
- .subscribe(function (data) {
655
- console.error('onError', data);
656
- });
707
+ .subscribe(function (data) { return console.error('onWSError', data); });
657
708
  this._exclusionProcessStatusChangedSubscribe = this._websocketService
658
709
  .onEvent({
659
710
  domain: this.projectConfigs.getDomain(),
@@ -702,12 +753,15 @@
702
753
  __decorate([
703
754
  core.Output()
704
755
  ], ExclusionDetailsComponent.prototype, "expandedRows", void 0);
756
+ __decorate([
757
+ core.Output()
758
+ ], ExclusionDetailsComponent.prototype, "onProcessFinishedSuccessfully", void 0);
705
759
  ExclusionDetailsComponent = __decorate([
706
760
  core.Component({
707
761
  selector: "s-exclusion-details",
708
- template: "<s-sidebar [visible]=\"isVisible\" (visibleChange)=\"onVisibilityChanged($event)\" [header]=\"getSidebarTitle()\">\n <s-loading-state [loading]=\"isLoading\">\n <p-panel [showHeader]=\"false\" styleClass=\"s-exclusion-details-record-details-panel\">\n <div class=\"s-exclusion-details-record-details-container\">\n <div class=\"s-exclusion-details-record-icon-background\">\n <em class=\"far fa-file-alt s-exclusion-details-record-icon\"></em>\n </div>\n\n <div class=\"s-exclusion-details-record-details-recordinfo\">\n <span class=\"s-exclusion-details-record-details-type\">\n {{entityDescription}}\n </span>\n <span>\n {{getRecordDescription()}}\n </span>\n </div>\n\n <div class=\"s-exclusion-details-record-details-dateinfo\">\n <span>\n {{getStartDateLabel()}}: {{getInicialDate()}}\n </span>\n <span *ngIf=\"isFinished()\">\n {{getFinishDateLabel()}}: {{getFinishDate()}}\n </span>\n </div>\n </div>\n </p-panel>\n\n <p-panel>\n <p-header>\n {{getSummaryLabel()}}\n </p-header>\n\n <s-empty-state\n *ngIf=\"processGroupData && !processGroupData.length\"\n [title]=\"getEmptyStateTitle()\"\n [description]=\"getEmptyStateDescription()\">\n [showPrimaryAction]=\"false\"\n </s-empty-state>\n\n <p-table\n [value]=\"processGroupData\"\n [columns]=\"processGroupColumns\"\n dataKey=\"id\"\n [lazy]=\"false\"\n [scrollable]=\"false\"\n [paginator]=\"false\"\n *ngIf=\"processGroupData && processGroupData.length\"\n [expandedRowKeys]=\"expandedRows\">\n\n <ng-template pTemplate=\"header\" let-columns>\n <tr>\n <th id=\"expend-column\" style=\"width: 40px;\"></th>\n <th *ngFor=\"let col of columns\"\n [id]=\"col.field\"\n [ngStyle]=\"col.style\"\n [pSortableColumn]=\"col.field\">\n <div class=\"senior-header\">\n <span class=\"senior-header-title\">{{ col.header }}</span>\n <p-sortIcon [field]=\"col.field\" ></p-sortIcon>\n </div>\n </th>\n </tr>\n </ng-template>\n\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\" let-expanded=\"expanded\">\n <tr sNavigation [sRowToggler]=\"rowData\">\n <td style=\"width: 40px;\" tabindex=\"0\">\n <em class=\"fa fa-{{ expanded ? 'minus' : 'plus' }}\"></em>\n </td>\n <s-table-columns\n [columns]=\"columns\"\n [rowValue]=\"rowData\"\n [locale]=\"locale\">\n </s-table-columns>\n </tr>\n </ng-template>\n\n <ng-template pTemplate=\"rowexpansion\" let-rowData let-columns=\"columns\">\n <tr class=\"sds-expanded-row\">\n <td [attr.colspan]=\"columns.length + 1\">\n <p-table \n [value]=\"rowData.steps\"\n [columns]=\"processStepColumns\"\n dataKey=\"id\"\n [paginator]=\"false\"\n [responsive]=\"true\"\n [scrollable]=\"false\"\n [lazy]=\"false\">\n\n <ng-template pTemplate=\"header\" let-columns>\n <tr>\n <th *ngFor=\"let col of columns\"\n [id]=\"col.field\"\n [ngStyle]=\"col.style\"\n [pSortableColumn]=\"col.field\">\n <div class=\"senior-header\">\n <span class=\"senior-header-title\">{{ col.header }}</span>\n <p-sortIcon [field]=\"col.field\" ></p-sortIcon>\n </div>\n </th>\n </tr>\n </ng-template>\n \n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\">\n <tr>\n <s-table-columns\n [columns]=\"columns\"\n [rowValue]=\"rowData\"\n [locale]=\"locale\">\n </s-table-columns>\n </tr>\n </ng-template>\n </p-table>\n </td>\n </tr>\n </ng-template>\n </p-table>\n </p-panel>\n </s-loading-state>\n\n <s-footer>\n <div class=\"ui-fluid\">\n <div class=\"ui-g\">\n <s-button [label]=\"getCloseButtonLabel()\" priority=\"link\" (onClick)=\"closeDetails()\"></s-button>\n </div>\n </div>\n </s-footer>\n</s-sidebar>\n",
762
+ template: "<s-sidebar [visible]=\"isVisible\" (visibleChange)=\"onVisibilityChanged($event)\" [header]=\"getSidebarTitle()\">\n <s-loading-state [loading]=\"isLoading\">\n <p-panel [showHeader]=\"false\" styleClass=\"s-exclusion-details-record-details-panel\">\n <div class=\"s-exclusion-details-record-details-container\">\n <div class=\"s-exclusion-details-record-icon-background\">\n <em class=\"far fa-file-alt s-exclusion-details-record-icon\"></em>\n </div>\n\n <div class=\"s-exclusion-details-record-details-recordinfo\">\n <span class=\"s-exclusion-details-record-details-type\">\n {{entityDescription}}\n </span>\n <span>\n {{getRecordDescription()}}\n </span>\n </div>\n\n <div class=\"s-exclusion-details-record-details-dateinfo\">\n <span>\n {{getStartDateLabel()}}: {{getInicialDate()}}\n </span>\n <span *ngIf=\"isFinished()\">\n {{getFinishDateLabel()}}: {{getFinishDate()}}\n </span>\n </div>\n </div>\n </p-panel>\n\n <p-panel>\n <p-header>\n {{getSummaryLabel()}}\n </p-header>\n\n <s-empty-state\n *ngIf=\"processGroupData && !processGroupData.length\"\n [title]=\"getEmptyStateTitle()\"\n [description]=\"getEmptyStateDescription()\">\n [showPrimaryAction]=\"false\"\n </s-empty-state>\n\n <p-table\n [value]=\"processGroupData\"\n [columns]=\"processGroupColumns\"\n dataKey=\"id\"\n [lazy]=\"false\"\n [scrollable]=\"false\"\n [paginator]=\"false\"\n *ngIf=\"processGroupData && processGroupData.length\"\n [expandedRowKeys]=\"expandedRows\">\n\n <ng-template pTemplate=\"header\" let-columns>\n <tr>\n <th id=\"expend-column\" style=\"width: 40px;\"></th>\n <th *ngFor=\"let col of columns\"\n [id]=\"col.field\"\n [ngStyle]=\"col.style\"\n [pSortableColumn]=\"col.field\">\n <div class=\"senior-header\">\n <span class=\"senior-header-title\">{{ col.header }}</span>\n <p-sortIcon [field]=\"col.field\" ></p-sortIcon>\n </div>\n </th>\n </tr>\n </ng-template>\n\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\" let-expanded=\"expanded\">\n <tr sNavigation [sRowToggler]=\"rowData\">\n <td style=\"width: 40px;\" tabindex=\"0\">\n <em class=\"fa fa-{{ expanded ? 'minus' : 'plus' }}\"></em>\n </td>\n <s-table-columns\n [columns]=\"columns\"\n [rowValue]=\"rowData\"\n [locale]=\"locale\">\n </s-table-columns>\n </tr>\n </ng-template>\n\n <ng-template pTemplate=\"rowexpansion\" let-rowData let-columns=\"columns\">\n <tr class=\"sds-expanded-row\">\n <td [attr.colspan]=\"columns.length + 1\">\n <p-table \n [value]=\"rowData.steps\"\n [columns]=\"processStepColumns\"\n dataKey=\"id\"\n [paginator]=\"false\"\n [responsive]=\"true\"\n [scrollable]=\"false\"\n [lazy]=\"false\">\n\n <ng-template pTemplate=\"header\" let-columns>\n <tr>\n <th *ngFor=\"let col of columns\"\n [id]=\"col.field\"\n [ngStyle]=\"col.style\"\n [pSortableColumn]=\"col.field\">\n <div class=\"senior-header\">\n <span class=\"senior-header-title\">{{ col.header }}</span>\n <p-sortIcon [field]=\"col.field\" ></p-sortIcon>\n </div>\n </th>\n </tr>\n </ng-template>\n \n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\">\n <tr>\n <s-table-columns\n [columns]=\"columns\"\n [rowValue]=\"rowData\"\n [locale]=\"locale\">\n </s-table-columns>\n </tr>\n </ng-template>\n </p-table>\n </td>\n </tr>\n </ng-template>\n </p-table>\n </p-panel>\n </s-loading-state>\n\n <s-footer>\n <div class=\"ui-fluid\">\n <div class=\"ui-g-12 s-exclusion-details-footer\">\n <s-button [label]=\"getUpdateButtonLabel()\" priority=\"link\" (onClick)=\"updateDetails()\"></s-button>\n <s-button [label]=\"getCloseButtonLabel()\" priority=\"link\" (onClick)=\"closeDetails()\"></s-button>\n </div>\n </div>\n </s-footer>\n</s-sidebar>\n",
709
763
  encapsulation: core.ViewEncapsulation.None,
710
- styles: [".s-exclusion-details-record-details-panel{margin-bottom:10px}.s-exclusion-details-record-details-container{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center}.s-exclusion-details-record-details-recordinfo{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;margin-left:10px;-ms-flex:1;flex:1}.s-exclusion-details-record-details-dateinfo{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;margin-left:10px;-ms-flex-align:end;align-items:flex-end;font-size:12px}.s-exclusion-details-record-details-type{color:#999}.s-exclusion-details-record-icon{font-size:22pt;color:#7e8d95}.s-exclusion-details-record-icon-background{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:16px;background-color:#c1cad1;border-radius:50%;height:60px;width:60px}"]
764
+ styles: [".s-exclusion-details-record-details-panel{margin-bottom:10px}.s-exclusion-details-record-details-container{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-align:center;align-items:center}.s-exclusion-details-record-details-recordinfo{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;margin-left:10px;-ms-flex:1;flex:1}.s-exclusion-details-record-details-dateinfo{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;margin-left:10px;-ms-flex-align:end;align-items:flex-end;font-size:12px}.s-exclusion-details-record-details-type{color:#999}.s-exclusion-details-record-icon{font-size:22pt;color:#7e8d95}.s-exclusion-details-record-icon-background{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:16px;background-color:#c1cad1;border-radius:50%;height:60px;width:60px}.s-exclusion-details-footer{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:justify;justify-content:space-between}"]
711
765
  })
712
766
  ], ExclusionDetailsComponent);
713
767
  return ExclusionDetailsComponent;
@@ -879,7 +933,7 @@
879
933
  .subscribe(function (queryParams) {
880
934
  _this.entityName = queryParams.entityName;
881
935
  _this.entityDescription = queryParams.entityDescription;
882
- _this.processId = queryParams.processId;
936
+ _this.processId = queryParams.processId || queryParams.pid;
883
937
  });
884
938
  };
885
939
  ExclusionsListComponent.prototype.ngAfterViewInit = function () {
@@ -1217,23 +1271,6 @@
1217
1271
  ], ExclusionsListFeatureRoutingGuard);
1218
1272
  return ExclusionsListFeatureRoutingGuard;
1219
1273
  }());
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
1274
  var ExclusionsListFeatureRoutingPermissionResolver = /** @class */ (function () {
1238
1275
  function ExclusionsListFeatureRoutingPermissionResolver(permissionsService) {
1239
1276
  this.permissionsService = permissionsService;
@@ -1283,8 +1320,7 @@
1283
1320
  ],
1284
1321
  resolve: {
1285
1322
  allPermissions: ExclusionsListFeatureRoutingPermissionResolver,
1286
- localeConfig: ExclusionsListFeatureRoutingLocaleResolver,
1287
- routeTitle: ExclusionsListFeatureRoutingListTitleResolver
1323
+ localeConfig: ExclusionsListFeatureRoutingLocaleResolver
1288
1324
  },
1289
1325
  children: [
1290
1326
  {
@@ -1308,8 +1344,7 @@
1308
1344
  providers: [
1309
1345
  ExclusionsListFeatureRoutingGuard,
1310
1346
  ExclusionsListFeatureRoutingPermissionResolver,
1311
- ExclusionsListFeatureRoutingLocaleResolver,
1312
- ExclusionsListFeatureRoutingListTitleResolver
1347
+ ExclusionsListFeatureRoutingLocaleResolver
1313
1348
  ],
1314
1349
  declarations: [
1315
1350
  EmptyComponent
@@ -1384,7 +1419,6 @@
1384
1419
  exports.ExclusionsListComponent = ExclusionsListComponent;
1385
1420
  exports.ExclusionsListFeatureRouting = ExclusionsListFeatureRouting;
1386
1421
  exports.ExclusionsListFeatureRoutingGuard = ExclusionsListFeatureRoutingGuard;
1387
- exports.ExclusionsListFeatureRoutingListTitleResolver = ExclusionsListFeatureRoutingListTitleResolver;
1388
1422
  exports.ExclusionsListFeatureRoutingLocaleResolver = ExclusionsListFeatureRoutingLocaleResolver;
1389
1423
  exports.ExclusionsListFeatureRoutingPermissionResolver = ExclusionsListFeatureRoutingPermissionResolver;
1390
1424
  exports.ExclusionsListModule = ExclusionsListModule;