@seniorsistemas/exclusion-process-component 0.0.1-c049d10c-e93a-4d63-9c2a-b17bca40c324 → 0.1.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.
Files changed (44) hide show
  1. package/bundles/seniorsistemas-exclusion-process-component.umd.js +554 -18
  2. package/bundles/seniorsistemas-exclusion-process-component.umd.js.map +1 -1
  3. package/bundles/seniorsistemas-exclusion-process-component.umd.min.js +2 -2
  4. package/bundles/seniorsistemas-exclusion-process-component.umd.min.js.map +1 -1
  5. package/esm2015/exclusion-details/exclusion-details.component.js +15 -5
  6. package/esm2015/exclusion-details/exclusion-details.module.js +4 -3
  7. package/esm2015/exclusion-details/protocols/show-details-information.js +1 -1
  8. package/esm2015/exclusions-list/exclusions-list.component.js +347 -0
  9. package/esm2015/exclusions-list/exclusions-list.module.js +47 -0
  10. package/esm2015/exclusions-list/exclusions-list.routing.js +115 -0
  11. package/esm2015/exclusions-list/index.js +4 -0
  12. package/esm2015/public-api.js +2 -1
  13. package/esm2015/seniorsistemas-exclusion-process-component.js +4 -2
  14. package/esm2015/services/filter.service.js +4 -1
  15. package/esm2015/services/index.js +2 -0
  16. package/esm2015/services/logical-delete.service.js +24 -9
  17. package/esm5/exclusion-details/exclusion-details.component.js +15 -5
  18. package/esm5/exclusion-details/exclusion-details.module.js +4 -3
  19. package/esm5/exclusion-details/protocols/show-details-information.js +1 -1
  20. package/esm5/exclusions-list/exclusions-list.component.js +362 -0
  21. package/esm5/exclusions-list/exclusions-list.module.js +50 -0
  22. package/esm5/exclusions-list/exclusions-list.routing.js +127 -0
  23. package/esm5/exclusions-list/index.js +4 -0
  24. package/esm5/public-api.js +2 -1
  25. package/esm5/seniorsistemas-exclusion-process-component.js +4 -2
  26. package/esm5/services/filter.service.js +4 -1
  27. package/esm5/services/index.js +2 -0
  28. package/esm5/services/logical-delete.service.js +24 -9
  29. package/exclusion-details/exclusion-details.component.d.ts +2 -0
  30. package/exclusion-details/protocols/show-details-information.d.ts +2 -1
  31. package/exclusions-list/exclusions-list.component.d.ts +69 -0
  32. package/exclusions-list/exclusions-list.module.d.ts +2 -0
  33. package/exclusions-list/exclusions-list.routing.d.ts +29 -0
  34. package/exclusions-list/index.d.ts +3 -0
  35. package/fesm2015/seniorsistemas-exclusion-process-component.js +517 -18
  36. package/fesm2015/seniorsistemas-exclusion-process-component.js.map +1 -1
  37. package/fesm5/seniorsistemas-exclusion-process-component.js +547 -18
  38. package/fesm5/seniorsistemas-exclusion-process-component.js.map +1 -1
  39. package/package.json +1 -1
  40. package/public-api.d.ts +1 -0
  41. package/seniorsistemas-exclusion-process-component.d.ts +3 -1
  42. package/seniorsistemas-exclusion-process-component.metadata.json +1 -1
  43. package/services/index.d.ts +1 -0
  44. package/services/logical-delete.service.d.ts +5 -3
@@ -1,16 +1,21 @@
1
1
  import { __decorate, __param } from 'tslib';
2
2
  import { CommonModule } from '@angular/common';
3
- import { InjectionToken, Inject, Injectable, Output, Component, ViewEncapsulation, NgModule } from '@angular/core';
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, FieldType } from '@seniorsistemas/angular-components';
6
+ import { EnumColumnFieldType, EnumBadgeColors, 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 } from '@angular/router';
8
+ import { Router, ActivatedRoute, RouterModule } from '@angular/router';
9
9
  import { throwError, Subject } from 'rxjs';
10
10
  import { catchError, map, takeUntil, finalize } from 'rxjs/operators';
11
11
  import { HttpParams, HttpClient } from '@angular/common/http';
12
- import { TranslateService } from '@ngx-translate/core';
12
+ import { TranslateService, TranslateModule } from '@ngx-translate/core';
13
13
  import { MessageService } from 'primeng/api';
14
+ import { Validators, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
15
+ import { DialogModule } from 'primeng/dialog';
16
+ import { ConfirmDialogModule } from 'primeng/confirmdialog';
17
+ import { InputTextModule } from 'primeng/inputtext';
18
+ import { PermissionsService } from '@seniorsistemas/platform-components';
14
19
 
15
20
  var EnumExclusionProcessStatus;
16
21
  (function (EnumExclusionProcessStatus) {
@@ -47,6 +52,8 @@ LogicalDeleteConfigService = __decorate([
47
52
  __param(0, Inject(ProjectConfigsInjectionToken))
48
53
  ], LogicalDeleteConfigService);
49
54
 
55
+ const HTTP_UNAUTHORIZED_CODE = 401;
56
+ const DEFAULT_PAGE_SIZE = 10;
50
57
  let LogicalDeleteService = class LogicalDeleteService {
51
58
  constructor(http, messageService, translate, projectConfigs) {
52
59
  this.http = http;
@@ -60,10 +67,11 @@ let LogicalDeleteService = class LogicalDeleteService {
60
67
  }
61
68
  defaultCatch() {
62
69
  return catchError((err) => {
70
+ var _a;
63
71
  if (err) {
64
72
  let summary = err.status ? String(err.status) : "Error";
65
- let detail = (err.error && err.error.message) || err.statusText || err.message || "Error";
66
- if (err.status === 401) {
73
+ let detail = ((_a = err.error) === null || _a === void 0 ? void 0 : _a.message) || err.statusText || err.message;
74
+ if (err.status === HTTP_UNAUTHORIZED_CODE) {
67
75
  const prefix = this.projectConfigs.getTranslationPrefix();
68
76
  summary = this.translate.instant(`${prefix}.error_unauthorized_title`);
69
77
  detail = this.translate.instant(`${prefix}.error_unauthorized_description`);
@@ -71,14 +79,14 @@ let LogicalDeleteService = class LogicalDeleteService {
71
79
  this.messageService.add({
72
80
  severity: "error",
73
81
  summary,
74
- detail
82
+ detail: detail || "Error"
75
83
  });
76
84
  }
77
85
  return throwError(err);
78
86
  });
79
87
  }
80
88
  getListQueryParams(listParams) {
81
- const { page = 0, size = 10, sort = [], filterQuery = "", displayFields = [] } = listParams;
89
+ const { page = 0, size = DEFAULT_PAGE_SIZE, sort = [], filterQuery = "", displayFields = [] } = listParams;
82
90
  let params = new HttpParams();
83
91
  params = params.append("size", String(size));
84
92
  params = params.append("offset", String(page));
@@ -100,10 +108,22 @@ let LogicalDeleteService = class LogicalDeleteService {
100
108
  }
101
109
  return params;
102
110
  }
103
- getProcessDetails(recordId) {
104
- const filterParams = {
105
- filter: `recordId eq '${recordId}'`
106
- };
111
+ getProcessDetails(id) {
112
+ return this.doGetProcessDetails({
113
+ filter: `id eq '${id}'`,
114
+ size: "1",
115
+ offset: "0",
116
+ });
117
+ }
118
+ getLatestProcessDetails(recordId) {
119
+ return this.doGetProcessDetails({
120
+ filter: `recordId eq '${recordId}'`,
121
+ size: "1",
122
+ offset: "0",
123
+ orderby: "startDate desc"
124
+ });
125
+ }
126
+ doGetProcessDetails(filterParams) {
107
127
  return this.http.get(this.exclusionProcessUrl, { params: filterParams })
108
128
  .pipe(this.defaultCatch())
109
129
  .pipe(map(value => {
@@ -188,8 +208,9 @@ let ExclusionDetailsComponent = class ExclusionDetailsComponent {
188
208
  this.processDetails = null;
189
209
  this._entityName = details.entityName;
190
210
  this._isVisible = true;
211
+ this._processSummaryData = [];
191
212
  this.entityDescription = details.entityDescription;
192
- this.loadProcessDetails(details.recordId);
213
+ this.loadProcessDetails(details);
193
214
  }
194
215
  closeDetails() {
195
216
  this._isVisible = false;
@@ -245,6 +266,12 @@ let ExclusionDetailsComponent = class ExclusionDetailsComponent {
245
266
  getSidebarTitle() {
246
267
  return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_details_title`);
247
268
  }
269
+ getEmptyStateTitle() {
270
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_empty_state_title`);
271
+ }
272
+ getEmptyStateDescription() {
273
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_empty_state_description`);
274
+ }
248
275
  getSummaryColumns() {
249
276
  return [
250
277
  {
@@ -293,9 +320,12 @@ let ExclusionDetailsComponent = class ExclusionDetailsComponent {
293
320
  }
294
321
  return null;
295
322
  }
296
- loadProcessDetails(recordId) {
323
+ loadProcessDetails(details) {
297
324
  this._isLoading = true;
298
- this.logicalDeleteService.getProcessDetails(recordId)
325
+ const processObservable = details.processId
326
+ ? this.logicalDeleteService.getProcessDetails(details.processId)
327
+ : this.logicalDeleteService.getLatestProcessDetails(details.recordId);
328
+ processObservable
299
329
  .pipe(takeUntil(this.ngUnsubscribe))
300
330
  .pipe(finalize(() => this._isLoading = false))
301
331
  .subscribe((process) => {
@@ -344,7 +374,7 @@ __decorate([
344
374
  ExclusionDetailsComponent = __decorate([
345
375
  Component({
346
376
  selector: "s-exclusion-details",
347
- template: "<s-sidebar [visible]=\"isVisible\" (visibleChange)=\"closeDetails()\" [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 <i class=\"far fa-file-alt s-exclusion-details-record-icon\"></i>\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 <p-table\n [value]=\"processSummaryData\"\n [columns]=\"processSummaryColumns\"\n dataKey=\"id\"\n [lazy]=\"false\"\n [scrollable]=\"false\"\n [paginator]=\"false\">\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",
377
+ template: "<s-sidebar [visible]=\"isVisible\" (visibleChange)=\"closeDetails()\" [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",
348
378
  encapsulation: ViewEncapsulation.None,
349
379
  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}"]
350
380
  })
@@ -362,7 +392,8 @@ ExclusionDetailsModule = __decorate([
362
392
  TableModule,
363
393
  TableModule$1,
364
394
  LoadingStateModule,
365
- LocaleModule
395
+ LocaleModule,
396
+ EmptyStateModule
366
397
  ],
367
398
  declarations: [ExclusionDetailsComponent],
368
399
  exports: [ExclusionDetailsComponent],
@@ -439,6 +470,9 @@ let FilterService = class FilterService {
439
470
  ? this.translate.instant(`${this.logicalDeleteConfigService.getTranslationPrefix()}.list_grid_boolean_true`)
440
471
  : this.translate.instant(`${this.logicalDeleteConfigService.getTranslationPrefix()}.list_grid_boolean_false`);
441
472
  break;
473
+ default:
474
+ labelValue = value;
475
+ break;
442
476
  }
443
477
  return { id: name, label: `${label}: ${labelValue}` };
444
478
  }
@@ -467,6 +501,471 @@ FilterService = __decorate([
467
501
  Injectable()
468
502
  ], FilterService);
469
503
 
504
+ var ExclusionsListComponent_1;
505
+ const HTTP_CODE_SERVER_ERROR_START = 500;
506
+ const HTTP_CODE_SERVER_ERROR_END = 600;
507
+ let ExclusionsListComponent = ExclusionsListComponent_1 = class ExclusionsListComponent {
508
+ constructor(route, translate, formBuilder, changeDetectorRef, logicalDeleteService, filterService, projectConfigs) {
509
+ this.route = route;
510
+ this.translate = translate;
511
+ this.formBuilder = formBuilder;
512
+ this.changeDetectorRef = changeDetectorRef;
513
+ this.logicalDeleteService = logicalDeleteService;
514
+ this.filterService = filterService;
515
+ this.projectConfigs = projectConfigs;
516
+ this.currentListParams = { page: 0, size: 10, sort: [], filterData: {} };
517
+ this.showLoader = false;
518
+ this.totalRecords = 0;
519
+ this.filtersPanelCollapsed = true;
520
+ this.searchTokens = [];
521
+ this.serverError = false;
522
+ this.ngUnsubscribe = new Subject();
523
+ }
524
+ ngOnInit() {
525
+ this.filterFormGroup = this.getFormBuilder();
526
+ this.filterFields = this.getFilterFields();
527
+ this.gridColumns = this.getGridColumns();
528
+ this.route.data
529
+ .pipe(takeUntil(this.ngUnsubscribe))
530
+ .subscribe((data) => {
531
+ this.locale = data.localeConfig;
532
+ });
533
+ this.route.params
534
+ .pipe(takeUntil(this.ngUnsubscribe))
535
+ .subscribe((params) => {
536
+ this.entityName = params.entityName;
537
+ this.showBasedOnRoute();
538
+ });
539
+ this.route.queryParams
540
+ .pipe(takeUntil(this.ngUnsubscribe))
541
+ .subscribe((queryParams) => {
542
+ this.entityDescription = queryParams.entityDescription;
543
+ this.processId = queryParams.processId;
544
+ this.showBasedOnRoute();
545
+ });
546
+ }
547
+ showBasedOnRoute() {
548
+ if (this.entityName && this.entityDescription && this.processId) {
549
+ this.exclusionDetailsComponent.showDetails({
550
+ processId: this.processId,
551
+ entityDescription: this.entityDescription,
552
+ entityName: this.entityName
553
+ });
554
+ }
555
+ }
556
+ ngOnDestroy() {
557
+ this.ngUnsubscribe.next();
558
+ this.ngUnsubscribe.complete();
559
+ }
560
+ getFormBuilder() {
561
+ return this.formBuilder.group({
562
+ description: [undefined, Validators.compose([])],
563
+ status: [undefined, Validators.compose([])],
564
+ startDate: [{ value: undefined, disabled: false }, Validators.compose([])],
565
+ endDate: [{ value: undefined, disabled: false }, Validators.compose([])]
566
+ });
567
+ }
568
+ getGridColumns() {
569
+ return [
570
+ {
571
+ field: "description",
572
+ attributes: ["description"],
573
+ header: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_description`),
574
+ type: EnumColumnFieldType.STRING,
575
+ style: {
576
+ width: "300px"
577
+ }
578
+ },
579
+ {
580
+ field: "status",
581
+ attributes: ["status"],
582
+ header: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_status`),
583
+ type: EnumColumnFieldType.ENUM,
584
+ enumPrefix: `${this.projectConfigs.getTranslationPrefix()}.logical_delete_enum_exclusion_process_status_`,
585
+ style: {
586
+ width: "100px"
587
+ },
588
+ badgeConfigs: [
589
+ {
590
+ enumValue: EnumExclusionProcessStatus.ERROR,
591
+ color: EnumBadgeColors.RED
592
+ },
593
+ {
594
+ enumValue: EnumExclusionProcessStatus.PENDING,
595
+ color: EnumBadgeColors.YELLOW
596
+ },
597
+ {
598
+ enumValue: EnumExclusionProcessStatus.PROCESSING,
599
+ color: EnumBadgeColors.BLUE
600
+ },
601
+ {
602
+ enumValue: EnumExclusionProcessStatus.SUCCESS,
603
+ color: EnumBadgeColors.GREEN
604
+ }
605
+ ]
606
+ },
607
+ {
608
+ field: "startDate",
609
+ attributes: ["startDate"],
610
+ header: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_start`),
611
+ type: EnumColumnFieldType.DATE,
612
+ dateFormat: "DD/MM/YYYY HH:mm",
613
+ style: {
614
+ width: "100px"
615
+ }
616
+ },
617
+ {
618
+ field: "finishDate",
619
+ attributes: ["finishDate"],
620
+ header: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_finish`),
621
+ type: EnumColumnFieldType.DATE,
622
+ dateFormat: "DD/MM/YYYY HH:mm",
623
+ style: {
624
+ width: "100px"
625
+ }
626
+ }
627
+ ];
628
+ }
629
+ getFilterFields() {
630
+ const translationPrefix = this.projectConfigs.getTranslationPrefix();
631
+ return [
632
+ new FormField({
633
+ type: FieldType.String,
634
+ name: "description",
635
+ label: this.translate.instant(`${translationPrefix}.logical_delete_description`)
636
+ }),
637
+ new FormField({
638
+ type: FieldType.Enum,
639
+ name: "status",
640
+ label: this.translate.instant(`${translationPrefix}.logical_delete_status`),
641
+ placeholder: this.translate.instant(`${translationPrefix}.logical_delete_status`),
642
+ multiple: true,
643
+ options: [
644
+ {
645
+ label: this.translate.instant(`${translationPrefix}.logical_delete_enum_exclusion_process_status_error`),
646
+ value: EnumExclusionProcessStatus.ERROR
647
+ },
648
+ {
649
+ label: this.translate.instant(`${translationPrefix}.logical_delete_enum_exclusion_process_status_pending`),
650
+ value: EnumExclusionProcessStatus.PENDING
651
+ },
652
+ {
653
+ label: this.translate.instant(`${translationPrefix}.logical_delete_enum_exclusion_process_status_processing`),
654
+ value: EnumExclusionProcessStatus.PROCESSING
655
+ },
656
+ {
657
+ label: this.translate.instant(`${translationPrefix}.logical_delete_enum_exclusion_process_status_success`),
658
+ value: EnumExclusionProcessStatus.SUCCESS
659
+ }
660
+ ]
661
+ }),
662
+ new FormField({
663
+ type: FieldType.Date,
664
+ name: "startDate",
665
+ label: this.translate.instant(`${translationPrefix}.logical_delete_start`)
666
+ }),
667
+ new FormField({
668
+ type: FieldType.Date,
669
+ name: "endDate",
670
+ label: this.translate.instant(`${translationPrefix}.logical_delete_finish`)
671
+ })
672
+ ];
673
+ }
674
+ getEmptyStateTitle() {
675
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_empty_state_title`);
676
+ }
677
+ getEmptyStateDescription() {
678
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_empty_state_description`);
679
+ }
680
+ getTitle() {
681
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_list_title`);
682
+ }
683
+ getDetailsButtonTitle() {
684
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_details`);
685
+ }
686
+ getFiltersTitle() {
687
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.filters`);
688
+ }
689
+ getFilterButtonTitle() {
690
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.filter`);
691
+ }
692
+ getClearButtonTitle() {
693
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.clear`);
694
+ }
695
+ getErrorInvalid() {
696
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.error_invalid`);
697
+ }
698
+ getErrorServerTitle() {
699
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.error_server_title`);
700
+ }
701
+ getErrorServerDescription() {
702
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.error_server_description`);
703
+ }
704
+ getActionsColumnLabel() {
705
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.actions`);
706
+ }
707
+ onSearch() {
708
+ const filterData = this.filterFormGroup.getRawValue();
709
+ this.filtersPanelCollapsed = true;
710
+ this.resetGrid({ filterData });
711
+ }
712
+ onClear() {
713
+ this.filterFormGroup.reset();
714
+ const filterData = this.filterFormGroup.getRawValue();
715
+ this.resetGrid({ filterData });
716
+ }
717
+ onRemoveToken(token) {
718
+ this.filterFormGroup.get(token.id).setValue(undefined);
719
+ const filterData = this.filterFormGroup.getRawValue();
720
+ this.resetGrid({ filterData });
721
+ }
722
+ onGridChange(event) {
723
+ const size = event.rows;
724
+ const page = event.first / size;
725
+ const sort = event.multiSortMeta ? event.multiSortMeta : [];
726
+ return this.updateGrid({ page, size, sort });
727
+ }
728
+ getFilterTokens() {
729
+ const filterData = this.filterFormGroup.value;
730
+ return this.filterFields
731
+ .filter(({ name }) => filterData[name] !== undefined && filterData[name] !== "" && filterData[name] !== null)
732
+ .map(formField => this.filterService.createFilterTokens(formField, filterData[formField.name]));
733
+ }
734
+ getFilterQuery() {
735
+ const { filterData } = this.currentListParams;
736
+ const dateFields = ["startDate", "endDate"];
737
+ let filterQuery = this.filterFields
738
+ .filter(({ name }) => !dateFields.includes(name))
739
+ .filter(({ name }) => filterData[name] !== undefined && filterData[name] !== "" && filterData[name] !== null)
740
+ .map(formField => this.filterService.createFilterString(formField, filterData[formField.name]))
741
+ .join(" and ");
742
+ let dateQuery;
743
+ if (filterData.startDate && filterData.endDate) {
744
+ const startDate = moment(filterData.startDate).format(ExclusionsListComponent_1.DATE_FORMAT);
745
+ const endDate = moment(filterData.endDate).format(ExclusionsListComponent_1.DATE_FORMAT);
746
+ dateQuery = `startDate between '${startDate}T00:00:00Z' and '${endDate}T23:59:59Z'`;
747
+ }
748
+ else if (filterData.startDate) {
749
+ const startDate = moment(filterData.startDate).format(ExclusionsListComponent_1.DATE_FORMAT);
750
+ dateQuery = `startDate >= '${startDate}T00:00:00Z'`;
751
+ }
752
+ else if (filterData.endDate) {
753
+ const endDate = moment(filterData.endDate).format(ExclusionsListComponent_1.DATE_FORMAT);
754
+ dateQuery = `finishDate <= '${endDate}T23:59:59Z'`;
755
+ }
756
+ else {
757
+ // Não é necessário nenhuma condição a mais no filtro.
758
+ }
759
+ if (dateQuery) {
760
+ filterQuery += filterQuery ? ` and ${dateQuery}` : dateQuery;
761
+ }
762
+ return filterQuery;
763
+ }
764
+ updateGrid(listParams = {}) {
765
+ this.currentListParams = Object.assign(Object.assign({}, this.currentListParams), listParams);
766
+ const { page, size, sort } = this.currentListParams;
767
+ this.searchTokens = this.getFilterTokens();
768
+ const filterQuery = this.getFilterQuery();
769
+ const displayFields = [
770
+ "recordId",
771
+ ...this.gridColumns.map(column => column.field)
772
+ ];
773
+ this.listExclusions({ page, size, sort, filterQuery, displayFields });
774
+ }
775
+ listExclusions(params) {
776
+ this.showLoader = true;
777
+ this.serverError = false;
778
+ this.changeDetectorRef.detectChanges();
779
+ this.logicalDeleteService
780
+ .listExclusions(this.entityName, params)
781
+ .pipe(takeUntil(this.ngUnsubscribe), catchError((err) => {
782
+ if (err.status >= HTTP_CODE_SERVER_ERROR_START && err.status < HTTP_CODE_SERVER_ERROR_END) {
783
+ this.serverError = true;
784
+ }
785
+ throw err;
786
+ }), finalize(() => this.showLoader = false))
787
+ .subscribe((list) => {
788
+ this.gridData = list.contents;
789
+ this.totalRecords = list.totalElements;
790
+ });
791
+ }
792
+ focusInput(elementId) {
793
+ const element = document.getElementById(`${elementId}`);
794
+ if (element) {
795
+ element.focus();
796
+ }
797
+ }
798
+ resetGrid(listParams) {
799
+ if (listParams) {
800
+ this.currentListParams = Object.assign(Object.assign({}, this.currentListParams), listParams);
801
+ }
802
+ this.currentListParams = Object.assign(Object.assign({}, this.currentListParams), { page: 0, sort: [] });
803
+ this.table.reset();
804
+ }
805
+ onClickDetails(rowData) {
806
+ this.exclusionDetailsComponent.showDetails({
807
+ processId: rowData.id,
808
+ entityDescription: this.entityDescription,
809
+ entityName: this.entityName
810
+ });
811
+ }
812
+ };
813
+ ExclusionsListComponent.DATE_FORMAT = "YYYY-MM-DD";
814
+ ExclusionsListComponent.ctorParameters = () => [
815
+ { type: ActivatedRoute },
816
+ { type: TranslateService },
817
+ { type: FormBuilder },
818
+ { type: ChangeDetectorRef },
819
+ { type: LogicalDeleteService },
820
+ { type: FilterService },
821
+ { type: LogicalDeleteConfigService }
822
+ ];
823
+ __decorate([
824
+ ViewChild("exclusionsTable")
825
+ ], ExclusionsListComponent.prototype, "table", void 0);
826
+ __decorate([
827
+ ViewChild(ExclusionDetailsComponent)
828
+ ], ExclusionsListComponent.prototype, "exclusionDetailsComponent", void 0);
829
+ ExclusionsListComponent = ExclusionsListComponent_1 = __decorate([
830
+ Component({
831
+ template: "<div>\n <form [formGroup]=\"filterFormGroup\" autocomplete=\"off\">\n <p-panel\n *sLoadingState=\"showLoader\"\n styleClass=\"form-group\"\n [toggleable]=\"true\"\n [(collapsed)]=\"filtersPanelCollapsed\"\n (onAfterToggle)=\"focusInput('description')\"\n >\n <p-header>\n {{ getFiltersTitle() }}\n <s-token-list\n [tokens]=\"searchTokens\"\n (tokenRemoved)=\"onRemoveToken($event)\"\n [removableTokens]=\"true\"\n ></s-token-list>\n </p-header>\n <div>\n <s-dynamic-form\n [fields]=\"filterFields\"\n [form]=\"filterFormGroup\"\n [errorMessages]=\"{ pattern: getErrorInvalid() }\"\n ></s-dynamic-form>\n </div>\n <p-footer>\n <div class=\"ui-g\">\n <div class=\"ui-g-12\">\n <button\n id=\"filter-button\"\n class=\"ui-button\"\n type=\"submit\"\n pButton\n [label]=\"getFilterButtonTitle()\"\n (click)=\"onSearch()\"\n ></button>\n <button\n id=\"clear-button\"\n class=\"ui-button ui-button-link\"\n type=\"button\"\n pButton\n [label]=\"getClearButtonTitle()\"\n (click)=\"onClear()\"\n ></button>\n </div>\n </div>\n </p-footer>\n </p-panel>\n </form>\n <p-panel *sLoadingState=\"showLoader\">\n <p-header>\n {{ getTitle() }}\n </p-header>\n <ng-container>\n <s-empty-state\n *ngIf=\"serverError && !showLoader\"\n iconClass=\"fa fa-exclamation-triangle\"\n title=\"{{ getErrorServerTitle() | translate }}\"\n primaryActionLabel=\"{{ 'error_server_try_again' | translate }}\"\n (primaryAction)=\"resetGrid()\"\n description=\"{{ getErrorServerDescription() | translate }}\"\n ></s-empty-state>\n\n <s-empty-state\n *ngIf=\"!showLoader && !serverError && totalRecords === 0\"\n [title]=\"getEmptyStateTitle()\"\n [showPrimaryAction]=\"false\"\n [description]=\"getEmptyStateDescription()\"\n ></s-empty-state>\n\n <div class=\"ui-g\">\n <div class=\"ui-g-12\">\n <p-table\n #exclusionsTable\n id=\"exclusionsTable\"\n [hidden]=\"totalRecords === 0 || serverError\"\n [value]=\"gridData\"\n [columns]=\"gridColumns\"\n dataKey=\"id\"\n [lazy]=\"true\"\n [scrollable]=\"true\"\n [resizableColumns]=\"true\"\n sortMode=\"multiple\"\n [paginator]=\"true\"\n [totalRecords]=\"totalRecords\"\n [rows]=\"10\"\n rows=\"10\"\n [rowsPerPageOptions]=\"[10, 20, 50, 100]\"\n (onLazyLoad)=\"onGridChange($event)\"\n >\n <ng-template pTemplate=\"colgroup\" let-columns>\n <colgroup>\n <col\n *ngFor=\"let col of columns\"\n [style.width]=\"col.width\"\n />\n </colgroup>\n </ng-template>\n\n <ng-template\n pTemplate=\"header\"\n let-columns\n >\n <tr>\n <th *ngFor=\"let col of columns\"\n [id]=\"col.field\"\n [pSortableColumn]=\"col.field\"\n [ngStyle]=\"col.style\"\n pResizableColumn\n >\n <div class=\"senior-header\">\n <span class=\"senior-header-title\">\n {{ col.header }}\n </span>\n <p-sortIcon [field]=\"col.field\"></p-sortIcon>\n </div>\n </th>\n <th id=\"action-column\" style=\"width: 100px\">\n <div class=\"senior-header\">\n <span class=\"senior-header-title\">{{ getActionsColumnLabel() }}</span>\n </div>\n </th>\n </tr>\n </ng-template>\n\n <ng-template pTemplate=\"body\" let-rowData let-columns=\"columns\">\n <tr [pSelectableRow]=\"rowData\">\n <s-table-columns\n [columns]=\"columns\"\n [rowValue]=\"rowData\"\n [locale]=\"locale\">\n </s-table-columns>\n <td style=\"width: 100px\">\n <s-button\n id=\"details-button\"\n priority=\"default\"\n [label]=\"getDetailsButtonTitle()\"\n [auxiliary]=\"true\"\n (onClick)=\"onClickDetails(rowData)\">\n </s-button>\n </td>\n </tr>\n </ng-template>\n\n <ng-template pTemplate=\"paginatorright\">\n <s-table-paging\n [table]=\"exclusionsTable\"\n [totalRecords]=\"totalRecords\"\n ></s-table-paging>\n </ng-template>\n </p-table>\n </div>\n </div>\n </ng-container>\n </p-panel>\n</div>\n\n<s-exclusion-details></s-exclusion-details>\n",
832
+ providers: []
833
+ })
834
+ ], ExclusionsListComponent);
835
+
836
+ let ExclusionsListFeatureRoutingGuard = class ExclusionsListFeatureRoutingGuard {
837
+ canActivate() {
838
+ return true;
839
+ }
840
+ };
841
+ ExclusionsListFeatureRoutingGuard = __decorate([
842
+ Injectable()
843
+ ], ExclusionsListFeatureRoutingGuard);
844
+ let ExclusionsListFeatureRoutingListTitleResolver = class ExclusionsListFeatureRoutingListTitleResolver {
845
+ constructor(translate, projectConfigs) {
846
+ this.translate = translate;
847
+ this.projectConfigs = projectConfigs;
848
+ }
849
+ resolve() {
850
+ return this.translate.get(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_list_title`);
851
+ }
852
+ };
853
+ ExclusionsListFeatureRoutingListTitleResolver.ctorParameters = () => [
854
+ { type: TranslateService },
855
+ { type: LogicalDeleteConfigService }
856
+ ];
857
+ ExclusionsListFeatureRoutingListTitleResolver = __decorate([
858
+ Injectable()
859
+ ], ExclusionsListFeatureRoutingListTitleResolver);
860
+ let ExclusionsListFeatureRoutingPermissionResolver = class ExclusionsListFeatureRoutingPermissionResolver {
861
+ constructor(permissionsService) {
862
+ this.permissionsService = permissionsService;
863
+ }
864
+ resolve() {
865
+ return this.permissionsService.get();
866
+ }
867
+ };
868
+ ExclusionsListFeatureRoutingPermissionResolver.ctorParameters = () => [
869
+ { type: PermissionsService }
870
+ ];
871
+ ExclusionsListFeatureRoutingPermissionResolver = __decorate([
872
+ Injectable()
873
+ ], ExclusionsListFeatureRoutingPermissionResolver);
874
+ let ExclusionsListFeatureRoutingLocaleResolver = class ExclusionsListFeatureRoutingLocaleResolver {
875
+ constructor(localeService) {
876
+ this.localeService = localeService;
877
+ }
878
+ resolve() {
879
+ return this.localeService.get();
880
+ }
881
+ };
882
+ ExclusionsListFeatureRoutingLocaleResolver.ctorParameters = () => [
883
+ { type: LocaleService }
884
+ ];
885
+ ExclusionsListFeatureRoutingLocaleResolver = __decorate([
886
+ Injectable()
887
+ ], ExclusionsListFeatureRoutingLocaleResolver);
888
+ let EmptyComponent = class EmptyComponent {
889
+ };
890
+ EmptyComponent = __decorate([
891
+ Component({
892
+ template: `<router-outlet></router-outlet>`
893
+ })
894
+ ], EmptyComponent);
895
+ const routes = [
896
+ {
897
+ path: "exclusions-list",
898
+ component: EmptyComponent,
899
+ canActivate: [
900
+ ExclusionsListFeatureRoutingGuard
901
+ ],
902
+ resolve: {
903
+ allPermissions: ExclusionsListFeatureRoutingPermissionResolver,
904
+ localeConfig: ExclusionsListFeatureRoutingLocaleResolver,
905
+ routeTitle: ExclusionsListFeatureRoutingListTitleResolver
906
+ },
907
+ children: [
908
+ {
909
+ path: ":entityName",
910
+ component: ExclusionsListComponent
911
+ }
912
+ ]
913
+ }
914
+ ];
915
+ let ExclusionsListFeatureRouting = class ExclusionsListFeatureRouting {
916
+ };
917
+ ExclusionsListFeatureRouting = __decorate([
918
+ NgModule({
919
+ imports: [
920
+ RouterModule.forChild(routes)
921
+ ],
922
+ exports: [
923
+ RouterModule
924
+ ],
925
+ providers: [
926
+ ExclusionsListFeatureRoutingGuard,
927
+ ExclusionsListFeatureRoutingPermissionResolver,
928
+ ExclusionsListFeatureRoutingLocaleResolver,
929
+ ExclusionsListFeatureRoutingListTitleResolver
930
+ ],
931
+ declarations: [
932
+ EmptyComponent
933
+ ]
934
+ })
935
+ ], ExclusionsListFeatureRouting);
936
+
937
+ let ExclusionsListModule = class ExclusionsListModule {
938
+ };
939
+ ExclusionsListModule = __decorate([
940
+ NgModule({
941
+ imports: [
942
+ FormsModule,
943
+ ReactiveFormsModule,
944
+ TranslateModule,
945
+ CommonModule,
946
+ ControlErrorsModule,
947
+ ButtonModule,
948
+ PanelModule,
949
+ InputTextModule,
950
+ InfoSignModule,
951
+ ConfirmDialogModule,
952
+ DialogModule,
953
+ TableModule,
954
+ TableModule$1,
955
+ LoadingStateModule,
956
+ EmptyStateModule,
957
+ DynamicFormModule,
958
+ TokenListModule,
959
+ LocaleModule.forChild(),
960
+ ExclusionDetailsModule,
961
+ ExclusionsListFeatureRouting
962
+ ],
963
+ declarations: [ExclusionsListComponent],
964
+ exports: [ExclusionsListComponent],
965
+ entryComponents: [ExclusionsListComponent]
966
+ })
967
+ ], ExclusionsListModule);
968
+
470
969
  var LogicalDeleteModule_1;
471
970
  let LogicalDeleteModule = LogicalDeleteModule_1 = class LogicalDeleteModule {
472
971
  static forRoot(config) {
@@ -491,5 +990,5 @@ LogicalDeleteModule = LogicalDeleteModule_1 = __decorate([
491
990
  * Generated bundle index. Do not edit.
492
991
  */
493
992
 
494
- export { ExclusionDetailsComponent, ExclusionDetailsModule, LogicalDeleteModule, LogicalDeleteService as ɵa, LogicalDeleteConfigService as ɵb, ProjectConfigsInjectionToken as ɵc, FilterService as ɵe };
993
+ export { EmptyComponent, ExclusionDetailsComponent, ExclusionDetailsModule, ExclusionsListComponent, ExclusionsListFeatureRouting, ExclusionsListFeatureRoutingGuard, ExclusionsListFeatureRoutingListTitleResolver, ExclusionsListFeatureRoutingLocaleResolver, ExclusionsListFeatureRoutingPermissionResolver, ExclusionsListModule, LogicalDeleteModule, routes, LogicalDeleteService as ɵa, LogicalDeleteConfigService as ɵb, ProjectConfigsInjectionToken as ɵc, ExclusionDetailsModule as ɵe, ExclusionDetailsComponent as ɵf, LogicalDeleteService as ɵg, FilterService as ɵh };
495
994
  //# sourceMappingURL=seniorsistemas-exclusion-process-component.js.map