@seniorsistemas/exclusion-process-component 0.2.1-d6a79e93-16a1-4705-a52d-6a12a465c189 → 0.3.0

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.
@@ -3,9 +3,9 @@ import { CommonModule } from '@angular/common';
3
3
  import { InjectionToken, Inject, Injectable, Output, Component, ViewEncapsulation, NgModule, ChangeDetectorRef, ViewChild } from '@angular/core';
4
4
  import { PanelModule } from 'primeng/panel';
5
5
  import { TableModule } from 'primeng/table';
6
- import { EnumColumnFieldType, EnumBadgeColors, SidebarModule, ButtonModule, TableModule as TableModule$1, LoadingStateModule, LocaleModule, EmptyStateModule, FieldType, FormField, LocaleService, ControlErrorsModule, InfoSignModule, DynamicFormModule, TokenListModule } from '@seniorsistemas/angular-components';
6
+ import { EnumBadgeColors, EnumColumnFieldType, SidebarModule, ButtonModule, TableModule as TableModule$1, LoadingStateModule, LocaleModule, EmptyStateModule, FieldType, FormField, LocaleService, ControlErrorsModule, InfoSignModule, DynamicFormModule, TokenListModule } from '@seniorsistemas/angular-components';
7
7
  import * as moment from 'moment';
8
- import { Router, ActivatedRoute, RouterModule } from '@angular/router';
8
+ import { ActivatedRoute, Router, RouterModule } from '@angular/router';
9
9
  import { TranslateService, TranslateModule } from '@ngx-translate/core';
10
10
  import { throwError, Subject } from 'rxjs';
11
11
  import { catchError, map, takeUntil, finalize } from 'rxjs/operators';
@@ -172,18 +172,36 @@ var LogicalDeleteService = /** @class */ (function () {
172
172
  return LogicalDeleteService;
173
173
  }());
174
174
 
175
+ var EXCLUSION_PROCESS_STATUS_BADGE = [
176
+ {
177
+ enumValue: EnumExclusionProcessStatus.ERROR,
178
+ color: EnumBadgeColors.RED
179
+ },
180
+ {
181
+ enumValue: EnumExclusionProcessStatus.PENDING,
182
+ color: EnumBadgeColors.YELLOW
183
+ },
184
+ {
185
+ enumValue: EnumExclusionProcessStatus.PROCESSING,
186
+ color: EnumBadgeColors.BLUE
187
+ },
188
+ {
189
+ enumValue: EnumExclusionProcessStatus.SUCCESS,
190
+ color: EnumBadgeColors.GREEN
191
+ }
192
+ ];
175
193
  var ExclusionDetailsComponent = /** @class */ (function () {
176
- function ExclusionDetailsComponent(router, route, translate, logicalDeleteService, projectConfigs) {
177
- this.router = router;
194
+ function ExclusionDetailsComponent(route, translate, logicalDeleteService, projectConfigs) {
178
195
  this.route = route;
179
196
  this.translate = translate;
180
197
  this.logicalDeleteService = logicalDeleteService;
181
198
  this.projectConfigs = projectConfigs;
182
- this._entityName = "";
199
+ this.expandedRows = {};
183
200
  this._isVisible = false;
184
201
  this._isLoading = false;
185
- this._processSummaryData = [];
186
- this._processSummaryColumns = [];
202
+ this._processGroupData = [];
203
+ this._processGroupColumns = [];
204
+ this._processStepColumns = [];
187
205
  this.ngUnsubscribe = new Subject();
188
206
  }
189
207
  Object.defineProperty(ExclusionDetailsComponent.prototype, "isVisible", {
@@ -200,16 +218,23 @@ var ExclusionDetailsComponent = /** @class */ (function () {
200
218
  enumerable: true,
201
219
  configurable: true
202
220
  });
203
- Object.defineProperty(ExclusionDetailsComponent.prototype, "processSummaryData", {
221
+ Object.defineProperty(ExclusionDetailsComponent.prototype, "processGroupData", {
222
+ get: function () {
223
+ return this._processGroupData;
224
+ },
225
+ enumerable: true,
226
+ configurable: true
227
+ });
228
+ Object.defineProperty(ExclusionDetailsComponent.prototype, "processGroupColumns", {
204
229
  get: function () {
205
- return this._processSummaryData;
230
+ return this._processGroupColumns;
206
231
  },
207
232
  enumerable: true,
208
233
  configurable: true
209
234
  });
210
- Object.defineProperty(ExclusionDetailsComponent.prototype, "processSummaryColumns", {
235
+ Object.defineProperty(ExclusionDetailsComponent.prototype, "processStepColumns", {
211
236
  get: function () {
212
- return this._processSummaryColumns;
237
+ return this._processStepColumns;
213
238
  },
214
239
  enumerable: true,
215
240
  configurable: true
@@ -221,7 +246,8 @@ var ExclusionDetailsComponent = /** @class */ (function () {
221
246
  .subscribe(function (data) {
222
247
  _this.locale = data.localeConfig;
223
248
  });
224
- this._processSummaryColumns = this.getSummaryColumns();
249
+ this._processGroupColumns = this.getGroupColumns();
250
+ this._processStepColumns = this.getStepColumns();
225
251
  };
226
252
  ExclusionDetailsComponent.prototype.ngOnDestroy = function () {
227
253
  this.ngUnsubscribe.next();
@@ -230,9 +256,8 @@ var ExclusionDetailsComponent = /** @class */ (function () {
230
256
  };
231
257
  ExclusionDetailsComponent.prototype.showDetails = function (details) {
232
258
  this._exclusionDetails = details;
233
- this._entityName = details.entityName;
234
259
  this._isVisible = true;
235
- this._processSummaryData = [];
260
+ this._processGroupData = [];
236
261
  this.processDetails = null;
237
262
  this.entityDescription = details.entityDescription;
238
263
  this.loadProcessDetails(details);
@@ -244,18 +269,9 @@ var ExclusionDetailsComponent = /** @class */ (function () {
244
269
  ExclusionDetailsComponent.prototype.closeDetails = function () {
245
270
  this._isVisible = false;
246
271
  this._exclusionDetails = null;
247
- this._processSummaryData = [];
272
+ this._processGroupData = [];
248
273
  this.disconnectWebSocket();
249
274
  };
250
- ExclusionDetailsComponent.prototype.openExclusions = function () {
251
- this.closeDetails();
252
- this.router.navigate([this._entityName, "exclusions-list"], {
253
- queryParams: {
254
- entityName: this._entityName,
255
- entityDescription: this.entityDescription
256
- }
257
- });
258
- };
259
275
  ExclusionDetailsComponent.prototype.getRecordDescription = function () {
260
276
  var _a;
261
277
  if (!((_a = this.processDetails) === null || _a === void 0 ? void 0 : _a.description)) {
@@ -305,15 +321,15 @@ var ExclusionDetailsComponent = /** @class */ (function () {
305
321
  ExclusionDetailsComponent.prototype.getEmptyStateDescription = function () {
306
322
  return this.translate.instant(this.projectConfigs.getTranslationPrefix() + ".logical_delete_empty_state_description");
307
323
  };
308
- ExclusionDetailsComponent.prototype.getSummaryColumns = function () {
324
+ ExclusionDetailsComponent.prototype.getGroupColumns = function () {
309
325
  return [
310
326
  {
311
327
  field: "description",
312
328
  attributes: ["description"],
313
- header: this.translate.instant(this.projectConfigs.getTranslationPrefix() + ".logical_delete_description"),
329
+ header: this.translate.instant(this.projectConfigs.getTranslationPrefix() + ".logical_delete_group"),
314
330
  type: EnumColumnFieldType.STRING,
315
331
  style: {
316
- width: "300px"
332
+ width: "340px"
317
333
  }
318
334
  },
319
335
  {
@@ -326,24 +342,32 @@ var ExclusionDetailsComponent = /** @class */ (function () {
326
342
  width: "100px"
327
343
  },
328
344
  tooltip: this.getColumnStatusTooltip,
329
- badgeConfigs: [
330
- {
331
- enumValue: EnumExclusionProcessStatus.ERROR,
332
- color: EnumBadgeColors.RED
333
- },
334
- {
335
- enumValue: EnumExclusionProcessStatus.PENDING,
336
- color: EnumBadgeColors.YELLOW
337
- },
338
- {
339
- enumValue: EnumExclusionProcessStatus.PROCESSING,
340
- color: EnumBadgeColors.BLUE
341
- },
342
- {
343
- enumValue: EnumExclusionProcessStatus.SUCCESS,
344
- color: EnumBadgeColors.GREEN
345
- }
346
- ]
345
+ badgeConfigs: EXCLUSION_PROCESS_STATUS_BADGE
346
+ }
347
+ ];
348
+ };
349
+ ExclusionDetailsComponent.prototype.getStepColumns = function () {
350
+ return [
351
+ {
352
+ field: "description",
353
+ attributes: ["description"],
354
+ header: this.translate.instant(this.projectConfigs.getTranslationPrefix() + ".logical_delete_step"),
355
+ type: EnumColumnFieldType.STRING,
356
+ style: {
357
+ width: "340px"
358
+ }
359
+ },
360
+ {
361
+ field: "status",
362
+ attributes: ["status"],
363
+ header: this.translate.instant(this.projectConfigs.getTranslationPrefix() + ".logical_delete_status"),
364
+ type: EnumColumnFieldType.ENUM,
365
+ enumPrefix: this.projectConfigs.getTranslationPrefix() + ".logical_delete_enum_exclusion_process_status_",
366
+ style: {
367
+ width: "100px"
368
+ },
369
+ tooltip: this.getColumnStatusTooltip,
370
+ badgeConfigs: EXCLUSION_PROCESS_STATUS_BADGE
347
371
  }
348
372
  ];
349
373
  };
@@ -367,7 +391,14 @@ var ExclusionDetailsComponent = /** @class */ (function () {
367
391
  return;
368
392
  }
369
393
  _this.processDetails = process;
370
- _this.loadProcessSummary(process);
394
+ _this._processGroupData = _this.sortGroupsByStartDate(process.groups)
395
+ .map(function (p) { return (__assign(__assign({}, p), { steps: _this.sortStepsByStartDate(p.steps) })); });
396
+ _this.expandedRows = {};
397
+ _this._processGroupData
398
+ .filter(function (p) { return p.status !== EnumExclusionProcessStatus.SUCCESS; })
399
+ .forEach(function (p) {
400
+ _this.expandedRows[p.id] = true;
401
+ });
371
402
  });
372
403
  };
373
404
  ExclusionDetailsComponent.prototype.sortByDate = function (startDate, finishDate) {
@@ -387,21 +418,6 @@ var ExclusionDetailsComponent = /** @class */ (function () {
387
418
  var _this = this;
388
419
  return steps.sort(function (a, b) { return _this.sortByDate(a.startDate, b.finishDate); });
389
420
  };
390
- ExclusionDetailsComponent.prototype.loadProcessSummary = function (process) {
391
- var _this = this;
392
- var stepLogs = [];
393
- this.sortGroupsByStartDate(process.groups)
394
- .forEach(function (group) {
395
- var steps = _this.sortStepsByStartDate(group.steps)
396
- .map(function (step) { return ({
397
- description: step.description,
398
- status: step.status,
399
- errorMessage: step.errorMessage
400
- }); });
401
- stepLogs.push.apply(stepLogs, __spread(steps));
402
- });
403
- this._processSummaryData = stepLogs;
404
- };
405
421
  ExclusionDetailsComponent.prototype.disconnectWebSocket = function () {
406
422
  if (this._exclusionProcessStatusChangedSubscribe) {
407
423
  this._exclusionProcessStatusChangedSubscribe.unsubscribe();
@@ -452,7 +468,6 @@ var ExclusionDetailsComponent = /** @class */ (function () {
452
468
  });
453
469
  };
454
470
  ExclusionDetailsComponent.ctorParameters = function () { return [
455
- { type: Router },
456
471
  { type: ActivatedRoute },
457
472
  { type: TranslateService },
458
473
  { type: LogicalDeleteService },
@@ -466,20 +481,26 @@ var ExclusionDetailsComponent = /** @class */ (function () {
466
481
  ], ExclusionDetailsComponent.prototype, "isLoading", null);
467
482
  __decorate([
468
483
  Output()
469
- ], ExclusionDetailsComponent.prototype, "processSummaryData", null);
484
+ ], ExclusionDetailsComponent.prototype, "processGroupData", null);
470
485
  __decorate([
471
486
  Output()
472
- ], ExclusionDetailsComponent.prototype, "processSummaryColumns", null);
487
+ ], ExclusionDetailsComponent.prototype, "processGroupColumns", null);
488
+ __decorate([
489
+ Output()
490
+ ], ExclusionDetailsComponent.prototype, "processStepColumns", null);
473
491
  __decorate([
474
492
  Output()
475
493
  ], ExclusionDetailsComponent.prototype, "processDetails", void 0);
476
494
  __decorate([
477
495
  Output()
478
496
  ], ExclusionDetailsComponent.prototype, "entityDescription", void 0);
497
+ __decorate([
498
+ Output()
499
+ ], ExclusionDetailsComponent.prototype, "expandedRows", void 0);
479
500
  ExclusionDetailsComponent = __decorate([
480
501
  Component({
481
502
  selector: "s-exclusion-details",
482
- 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=\"processSummaryData && !processSummaryData.length\"\n [title]=\"getEmptyStateTitle()\"\n [description]=\"getEmptyStateDescription()\">\n [showPrimaryAction]=\"false\"\n </s-empty-state>\n\n <p-table\n [value]=\"processSummaryData\"\n [columns]=\"processSummaryColumns\"\n dataKey=\"id\"\n [lazy]=\"false\"\n [scrollable]=\"false\"\n [paginator]=\"false\"\n *ngIf=\"processSummaryData && processSummaryData.length\">\n\n <ng-template pTemplate=\"colgroup\" let-columns>\n <colgroup>\n <col *ngFor=\"let col of columns\"\n [style.width]=\"col.width\"\n />\n </colgroup>\n </ng-template>\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 </p-panel>\n </s-loading-state>\n\n <s-footer>\n <div class=\"ui-fluid\">\n <div class=\"ui-g\">\n <s-button [label]=\"getShowExclusionsButtonLabel()\" (onClick)=\"openExclusions()\"></s-button>\n <s-button [label]=\"getCloseButtonLabel()\" priority=\"link\" (onClick)=\"closeDetails()\"></s-button>\n </div>\n </div>\n </s-footer>\n</s-sidebar>\n",
503
+ 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",
483
504
  encapsulation: ViewEncapsulation.None,
484
505
  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}"]
485
506
  })
@@ -619,7 +640,8 @@ var FilterService = /** @class */ (function () {
619
640
  var HTTP_CODE_SERVER_ERROR_START = 500;
620
641
  var HTTP_CODE_SERVER_ERROR_END = 600;
621
642
  var ExclusionsListComponent = /** @class */ (function () {
622
- function ExclusionsListComponent(route, translate, formBuilder, changeDetectorRef, logicalDeleteService, filterService, projectConfigs, cdr) {
643
+ function ExclusionsListComponent(router, route, translate, formBuilder, changeDetectorRef, logicalDeleteService, filterService, projectConfigs, cdr) {
644
+ this.router = router;
623
645
  this.route = route;
624
646
  this.translate = translate;
625
647
  this.formBuilder = formBuilder;
@@ -666,6 +688,13 @@ var ExclusionsListComponent = /** @class */ (function () {
666
688
  }
667
689
  };
668
690
  ExclusionsListComponent.prototype.ngOnDestroy = function () {
691
+ var _a;
692
+ var params = __assign({}, (_a = this.route.snapshot) === null || _a === void 0 ? void 0 : _a.queryParams);
693
+ if (params) {
694
+ delete params.entityName;
695
+ delete params.entityDescription;
696
+ this.router.navigate([], { queryParams: params });
697
+ }
669
698
  this.ngUnsubscribe.next();
670
699
  this.ngUnsubscribe.complete();
671
700
  };
@@ -673,8 +702,8 @@ var ExclusionsListComponent = /** @class */ (function () {
673
702
  return this.formBuilder.group({
674
703
  description: [undefined, Validators.compose([])],
675
704
  status: [undefined, Validators.compose([])],
676
- startDate: [{ value: undefined, disabled: false }, Validators.compose([])],
677
- endDate: [{ value: undefined, disabled: false }, Validators.compose([])]
705
+ startDate: [{ value: null, disabled: false }, Validators.compose([])],
706
+ endDate: [{ value: null, disabled: false }, Validators.compose([])]
678
707
  });
679
708
  };
680
709
  ExclusionsListComponent.prototype.getGridColumns = function () {
@@ -947,6 +976,7 @@ var ExclusionsListComponent = /** @class */ (function () {
947
976
  var ExclusionsListComponent_1;
948
977
  ExclusionsListComponent.DATE_FORMAT = "YYYY-MM-DD";
949
978
  ExclusionsListComponent.ctorParameters = function () { return [
979
+ { type: Router },
950
980
  { type: ActivatedRoute },
951
981
  { type: TranslateService },
952
982
  { type: FormBuilder },