@seniorsistemas/exclusion-process-component 0.0.1-40efacd8-8a6c-4d38-8102-8c977c14410a → 0.0.1-578162e8-6e18-48ad-b6a2-f63ffb1cd87a

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 (26) hide show
  1. package/bundles/seniorsistemas-exclusion-process-component.umd.js +124 -49
  2. package/bundles/seniorsistemas-exclusion-process-component.umd.js.map +1 -1
  3. package/bundles/seniorsistemas-exclusion-process-component.umd.min.js +1 -1
  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 +96 -50
  9. package/esm2015/services/filter.service.js +4 -1
  10. package/esm2015/services/logical-delete.service.js +24 -9
  11. package/esm5/exclusion-details/exclusion-details.component.js +15 -5
  12. package/esm5/exclusion-details/exclusion-details.module.js +4 -3
  13. package/esm5/exclusion-details/protocols/show-details-information.js +1 -1
  14. package/esm5/exclusions-list/exclusions-list.component.js +96 -50
  15. package/esm5/services/filter.service.js +4 -1
  16. package/esm5/services/logical-delete.service.js +24 -9
  17. package/exclusion-details/exclusion-details.component.d.ts +2 -0
  18. package/exclusion-details/protocols/show-details-information.d.ts +2 -1
  19. package/exclusions-list/exclusions-list.component.d.ts +23 -14
  20. package/fesm2015/seniorsistemas-exclusion-process-component.js +125 -50
  21. package/fesm2015/seniorsistemas-exclusion-process-component.js.map +1 -1
  22. package/fesm5/seniorsistemas-exclusion-process-component.js +125 -50
  23. package/fesm5/seniorsistemas-exclusion-process-component.js.map +1 -1
  24. package/package.json +1 -1
  25. package/seniorsistemas-exclusion-process-component.metadata.json +1 -1
  26. package/services/logical-delete.service.d.ts +5 -3
@@ -3,7 +3,7 @@ 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, FieldType, FormField, LocaleService, ControlErrorsModule, InfoSignModule, EmptyStateModule, DynamicFormModule, TokenListModule } 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
8
  import { Router, ActivatedRoute, RouterModule } from '@angular/router';
9
9
  import { throwError, Subject } from 'rxjs';
@@ -52,6 +52,8 @@ LogicalDeleteConfigService = __decorate([
52
52
  __param(0, Inject(ProjectConfigsInjectionToken))
53
53
  ], LogicalDeleteConfigService);
54
54
 
55
+ const HTTP_UNAUTHORIZED_CODE = 401;
56
+ const DEFAULT_PAGE_SIZE = 10;
55
57
  let LogicalDeleteService = class LogicalDeleteService {
56
58
  constructor(http, messageService, translate, projectConfigs) {
57
59
  this.http = http;
@@ -65,10 +67,11 @@ let LogicalDeleteService = class LogicalDeleteService {
65
67
  }
66
68
  defaultCatch() {
67
69
  return catchError((err) => {
70
+ var _a;
68
71
  if (err) {
69
72
  let summary = err.status ? String(err.status) : "Error";
70
- let detail = (err.error && err.error.message) || err.statusText || err.message || "Error";
71
- 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) {
72
75
  const prefix = this.projectConfigs.getTranslationPrefix();
73
76
  summary = this.translate.instant(`${prefix}.error_unauthorized_title`);
74
77
  detail = this.translate.instant(`${prefix}.error_unauthorized_description`);
@@ -76,14 +79,14 @@ let LogicalDeleteService = class LogicalDeleteService {
76
79
  this.messageService.add({
77
80
  severity: "error",
78
81
  summary,
79
- detail
82
+ detail: detail || "Error"
80
83
  });
81
84
  }
82
85
  return throwError(err);
83
86
  });
84
87
  }
85
88
  getListQueryParams(listParams) {
86
- const { page = 0, size = 10, sort = [], filterQuery = "", displayFields = [] } = listParams;
89
+ const { page = 0, size = DEFAULT_PAGE_SIZE, sort = [], filterQuery = "", displayFields = [] } = listParams;
87
90
  let params = new HttpParams();
88
91
  params = params.append("size", String(size));
89
92
  params = params.append("offset", String(page));
@@ -105,10 +108,22 @@ let LogicalDeleteService = class LogicalDeleteService {
105
108
  }
106
109
  return params;
107
110
  }
108
- getProcessDetails(recordId) {
109
- const filterParams = {
110
- filter: `recordId eq '${recordId}'`
111
- };
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) {
112
127
  return this.http.get(this.exclusionProcessUrl, { params: filterParams })
113
128
  .pipe(this.defaultCatch())
114
129
  .pipe(map(value => {
@@ -193,8 +208,9 @@ let ExclusionDetailsComponent = class ExclusionDetailsComponent {
193
208
  this.processDetails = null;
194
209
  this._entityName = details.entityName;
195
210
  this._isVisible = true;
211
+ this._processSummaryData = [];
196
212
  this.entityDescription = details.entityDescription;
197
- this.loadProcessDetails(details.recordId);
213
+ this.loadProcessDetails(details);
198
214
  }
199
215
  closeDetails() {
200
216
  this._isVisible = false;
@@ -250,6 +266,12 @@ let ExclusionDetailsComponent = class ExclusionDetailsComponent {
250
266
  getSidebarTitle() {
251
267
  return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_details_title`);
252
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
+ }
253
275
  getSummaryColumns() {
254
276
  return [
255
277
  {
@@ -298,9 +320,12 @@ let ExclusionDetailsComponent = class ExclusionDetailsComponent {
298
320
  }
299
321
  return null;
300
322
  }
301
- loadProcessDetails(recordId) {
323
+ loadProcessDetails(details) {
302
324
  this._isLoading = true;
303
- this.logicalDeleteService.getProcessDetails(recordId)
325
+ const processObservable = details.processId
326
+ ? this.logicalDeleteService.getProcessDetails(details.processId)
327
+ : this.logicalDeleteService.getLatestProcessDetails(details.recordId);
328
+ processObservable
304
329
  .pipe(takeUntil(this.ngUnsubscribe))
305
330
  .pipe(finalize(() => this._isLoading = false))
306
331
  .subscribe((process) => {
@@ -349,7 +374,7 @@ __decorate([
349
374
  ExclusionDetailsComponent = __decorate([
350
375
  Component({
351
376
  selector: "s-exclusion-details",
352
- 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 <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\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",
353
378
  encapsulation: ViewEncapsulation.None,
354
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}"]
355
380
  })
@@ -367,7 +392,8 @@ ExclusionDetailsModule = __decorate([
367
392
  TableModule,
368
393
  TableModule$1,
369
394
  LoadingStateModule,
370
- LocaleModule
395
+ LocaleModule,
396
+ EmptyStateModule
371
397
  ],
372
398
  declarations: [ExclusionDetailsComponent],
373
399
  exports: [ExclusionDetailsComponent],
@@ -444,6 +470,9 @@ let FilterService = class FilterService {
444
470
  ? this.translate.instant(`${this.logicalDeleteConfigService.getTranslationPrefix()}.list_grid_boolean_true`)
445
471
  : this.translate.instant(`${this.logicalDeleteConfigService.getTranslationPrefix()}.list_grid_boolean_false`);
446
472
  break;
473
+ default:
474
+ labelValue = value;
475
+ break;
447
476
  }
448
477
  return { id: name, label: `${label}: ${labelValue}` };
449
478
  }
@@ -472,6 +501,8 @@ FilterService = __decorate([
472
501
  Injectable()
473
502
  ], FilterService);
474
503
 
504
+ const HTTP_CODE_SERVER_ERROR_START = 500;
505
+ const HTTP_CODE_SERVER_ERROR_END = 600;
475
506
  let ExclusionsListComponent = class ExclusionsListComponent {
476
507
  constructor(route, translate, formBuilder, changeDetectorRef, logicalDeleteService, filterService, projectConfigs) {
477
508
  this.route = route;
@@ -502,13 +533,25 @@ let ExclusionsListComponent = class ExclusionsListComponent {
502
533
  .pipe(takeUntil(this.ngUnsubscribe))
503
534
  .subscribe((params) => {
504
535
  this.entityName = params.entityName;
536
+ this.showBasedOnRoute();
505
537
  });
506
538
  this.route.queryParams
507
539
  .pipe(takeUntil(this.ngUnsubscribe))
508
540
  .subscribe((queryParams) => {
509
541
  this.entityDescription = queryParams.entityDescription;
542
+ this.processId = queryParams.processId;
543
+ this.showBasedOnRoute();
510
544
  });
511
545
  }
546
+ showBasedOnRoute() {
547
+ if (this.entityName && this.entityDescription && this.processId) {
548
+ this.exclusionDetailsComponent.showDetails({
549
+ processId: this.processId,
550
+ entityDescription: this.entityDescription,
551
+ entityName: this.entityName
552
+ });
553
+ }
554
+ }
512
555
  ngOnDestroy() {
513
556
  this.ngUnsubscribe.next();
514
557
  this.ngUnsubscribe.complete();
@@ -516,7 +559,7 @@ let ExclusionsListComponent = class ExclusionsListComponent {
516
559
  getFormBuilder() {
517
560
  return this.formBuilder.group({
518
561
  description: [undefined, Validators.compose([])],
519
- state: [undefined, Validators.compose([])],
562
+ status: [undefined, Validators.compose([])],
520
563
  startDate: [{ value: undefined, disabled: false }, Validators.compose([])],
521
564
  endDate: [{ value: undefined, disabled: false }, Validators.compose([])]
522
565
  });
@@ -525,21 +568,21 @@ let ExclusionsListComponent = class ExclusionsListComponent {
525
568
  return [
526
569
  {
527
570
  field: "description",
528
- attributes: ['description'],
571
+ attributes: ["description"],
529
572
  header: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_description`),
530
573
  type: EnumColumnFieldType.STRING,
531
574
  style: {
532
- width: '300px'
575
+ width: "300px"
533
576
  }
534
577
  },
535
578
  {
536
579
  field: "status",
537
- attributes: ['status'],
580
+ attributes: ["status"],
538
581
  header: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_status`),
539
582
  type: EnumColumnFieldType.ENUM,
540
583
  enumPrefix: `${this.projectConfigs.getTranslationPrefix()}.logical_delete_enum_exclusion_process_status_`,
541
584
  style: {
542
- width: '100px'
585
+ width: "100px"
543
586
  },
544
587
  badgeConfigs: [
545
588
  {
@@ -562,54 +605,55 @@ let ExclusionsListComponent = class ExclusionsListComponent {
562
605
  },
563
606
  {
564
607
  field: "startDate",
565
- attributes: ['startDate'],
608
+ attributes: ["startDate"],
566
609
  header: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_start`),
567
610
  type: EnumColumnFieldType.DATE,
568
611
  dateFormat: "DD/MM/YYYY HH:mm",
569
612
  style: {
570
- width: '100px'
613
+ width: "100px"
571
614
  }
572
615
  },
573
616
  {
574
617
  field: "finishDate",
575
- attributes: ['finishDate'],
618
+ attributes: ["finishDate"],
576
619
  header: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_finish`),
577
620
  type: EnumColumnFieldType.DATE,
578
621
  dateFormat: "DD/MM/YYYY HH:mm",
579
622
  style: {
580
- width: '100px'
623
+ width: "100px"
581
624
  }
582
625
  }
583
626
  ];
584
627
  }
585
628
  getFilterFields() {
629
+ const translationPrefix = this.projectConfigs.getTranslationPrefix();
586
630
  return [
587
631
  new FormField({
588
632
  type: FieldType.String,
589
633
  name: "description",
590
- label: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_description`)
634
+ label: this.translate.instant(`${translationPrefix}.logical_delete_description`)
591
635
  }),
592
636
  new FormField({
593
637
  type: FieldType.Enum,
594
- name: "state",
595
- label: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_status`),
596
- placeholder: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_status`),
638
+ name: "status",
639
+ label: this.translate.instant(`${translationPrefix}.logical_delete_status`),
640
+ placeholder: this.translate.instant(`${translationPrefix}.logical_delete_status`),
597
641
  multiple: true,
598
642
  options: [
599
643
  {
600
- label: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_enum_exclusion_process_status_error`),
644
+ label: this.translate.instant(`${translationPrefix}.logical_delete_enum_exclusion_process_status_error`),
601
645
  value: EnumExclusionProcessStatus.ERROR
602
646
  },
603
647
  {
604
- label: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_enum_exclusion_process_status_pending`),
648
+ label: this.translate.instant(`${translationPrefix}.logical_delete_enum_exclusion_process_status_pending`),
605
649
  value: EnumExclusionProcessStatus.PENDING
606
650
  },
607
651
  {
608
- label: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_enum_exclusion_process_status_processing`),
652
+ label: this.translate.instant(`${translationPrefix}.logical_delete_enum_exclusion_process_status_processing`),
609
653
  value: EnumExclusionProcessStatus.PROCESSING
610
654
  },
611
655
  {
612
- label: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_enum_exclusion_process_status_success`),
656
+ label: this.translate.instant(`${translationPrefix}.logical_delete_enum_exclusion_process_status_success`),
613
657
  value: EnumExclusionProcessStatus.SUCCESS
614
658
  }
615
659
  ]
@@ -617,12 +661,12 @@ let ExclusionsListComponent = class ExclusionsListComponent {
617
661
  new FormField({
618
662
  type: FieldType.Date,
619
663
  name: "startDate",
620
- label: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_start`)
664
+ label: this.translate.instant(`${translationPrefix}.logical_delete_start`)
621
665
  }),
622
666
  new FormField({
623
667
  type: FieldType.Date,
624
668
  name: "endDate",
625
- label: this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_finish`)
669
+ label: this.translate.instant(`${translationPrefix}.logical_delete_finish`)
626
670
  })
627
671
  ];
628
672
  }
@@ -638,6 +682,27 @@ let ExclusionsListComponent = class ExclusionsListComponent {
638
682
  getDetailsButtonTitle() {
639
683
  return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.logical_delete_details`);
640
684
  }
685
+ getFiltersTitle() {
686
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.filters`);
687
+ }
688
+ getFilterButtonTitle() {
689
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.filter`);
690
+ }
691
+ getClearButtonTitle() {
692
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.clear`);
693
+ }
694
+ getErrorInvalid() {
695
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.error_invalid`);
696
+ }
697
+ getErrorServerTitle() {
698
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.error_server_title`);
699
+ }
700
+ getErrorServerDescription() {
701
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.error_server_description`);
702
+ }
703
+ getActionsColumnLabel() {
704
+ return this.translate.instant(`${this.projectConfigs.getTranslationPrefix()}.actions`);
705
+ }
641
706
  onSearch() {
642
707
  const filterData = this.filterFormGroup.getRawValue();
643
708
  this.filtersPanelCollapsed = true;
@@ -662,27 +727,36 @@ let ExclusionsListComponent = class ExclusionsListComponent {
662
727
  getFilterTokens() {
663
728
  const filterData = this.filterFormGroup.value;
664
729
  return this.filterFields
665
- .filter(({ name }) => filterData[name] != undefined && filterData[name] !== "")
730
+ .filter(({ name }) => filterData[name] !== undefined && filterData[name] !== "" && filterData[name] !== null)
666
731
  .map(formField => this.filterService.createFilterTokens(formField, filterData[formField.name]));
667
732
  }
668
733
  getFilterQuery() {
669
734
  const { filterData } = this.currentListParams;
670
- const dateFields = ['startDate', 'endDate'];
735
+ const dateFields = ["startDate", "endDate"];
671
736
  let filterQuery = this.filterFields
672
737
  .filter(({ name }) => !dateFields.includes(name))
673
- .filter(({ name }) => filterData[name] != undefined)
738
+ .filter(({ name }) => filterData[name] !== undefined && filterData[name] !== "" && filterData[name] !== null)
674
739
  .map(formField => this.filterService.createFilterString(formField, filterData[formField.name]))
675
740
  .join(" and ");
741
+ let dateQuery;
676
742
  if (filterData.startDate && filterData.endDate) {
677
- const startDate = moment(filterData.startDate).format('YYYY-MM-DD');
678
- const endDate = moment(filterData.endDate).format('YYYY-MM-DD');
679
- const dateQuery = `startDate between '${startDate}' and '${endDate}'`;
680
- if (filterQuery) {
681
- filterQuery += ` and ${dateQuery}`;
682
- }
683
- else {
684
- filterQuery = dateQuery;
685
- }
743
+ const startDate = moment(filterData.startDate).format("YYYY-MM-DD");
744
+ const endDate = moment(filterData.endDate).format("YYYY-MM-DD");
745
+ dateQuery = `startDate between '${startDate}T00:00:00Z' and '${endDate}T23:59:59Z'`;
746
+ }
747
+ else if (filterData.startDate) {
748
+ const startDate = moment(filterData.startDate).format("YYYY-MM-DD");
749
+ dateQuery = `startDate >= '${startDate}T00:00:00Z'`;
750
+ }
751
+ else if (filterData.endDate) {
752
+ const endDate = moment(filterData.endDate).format("YYYY-MM-DD");
753
+ dateQuery = `finishDate <= '${endDate}T23:59:59Z'`;
754
+ }
755
+ else {
756
+ // Não é necessário nenhuma condição a mais no filtro.
757
+ }
758
+ if (dateQuery) {
759
+ filterQuery += filterQuery ? ` and ${dateQuery}` : dateQuery;
686
760
  }
687
761
  return filterQuery;
688
762
  }
@@ -692,7 +766,7 @@ let ExclusionsListComponent = class ExclusionsListComponent {
692
766
  this.searchTokens = this.getFilterTokens();
693
767
  const filterQuery = this.getFilterQuery();
694
768
  const displayFields = [
695
- 'recordId',
769
+ "recordId",
696
770
  ...this.gridColumns.map(column => column.field)
697
771
  ];
698
772
  this.listExclusions({ page, size, sort, filterQuery, displayFields });
@@ -704,7 +778,7 @@ let ExclusionsListComponent = class ExclusionsListComponent {
704
778
  this.logicalDeleteService
705
779
  .listExclusions(this.entityName, params)
706
780
  .pipe(takeUntil(this.ngUnsubscribe), catchError((err) => {
707
- if (err.status >= 500 && err.status < 600) {
781
+ if (err.status >= HTTP_CODE_SERVER_ERROR_START && err.status < HTTP_CODE_SERVER_ERROR_END) {
708
782
  this.serverError = true;
709
783
  }
710
784
  throw err;
@@ -721,14 +795,15 @@ let ExclusionsListComponent = class ExclusionsListComponent {
721
795
  }
722
796
  }
723
797
  resetGrid(listParams) {
724
- if (listParams)
798
+ if (listParams) {
725
799
  this.currentListParams = Object.assign(Object.assign({}, this.currentListParams), listParams);
800
+ }
726
801
  this.currentListParams = Object.assign(Object.assign({}, this.currentListParams), { page: 0, sort: [] });
727
802
  this.table.reset();
728
803
  }
729
804
  onClickDetails(rowData) {
730
805
  this.exclusionDetailsComponent.showDetails({
731
- recordId: rowData.recordId,
806
+ processId: rowData.id,
732
807
  entityDescription: this.entityDescription,
733
808
  entityName: this.entityName
734
809
  });
@@ -751,7 +826,7 @@ __decorate([
751
826
  ], ExclusionsListComponent.prototype, "exclusionDetailsComponent", void 0);
752
827
  ExclusionsListComponent = __decorate([
753
828
  Component({
754
- 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 {{ 'filters' | translate }}\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: 'error_invalid' | translate }\"\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]=\"'filter' | translate\"\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]=\"'clear' | translate\"\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=\"{{ 'error_server_title' | translate }}\"\n primaryActionLabel=\"{{ 'error_server_try_again' | translate }}\"\n (primaryAction)=\"resetGrid()\"\n description=\"{{ 'error_server_description' | 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\">{{'A\u00E7\u00F5es'}}</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>",
829
+ 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",
755
830
  providers: []
756
831
  })
757
832
  ], ExclusionsListComponent);