@seniorsistemas/platform-components 5.3.2 → 5.3.3-develop-73308358
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.
- package/esm2022/modules/advanced-filter/advanced-filter.module.mjs +75 -0
- package/esm2022/modules/advanced-filter/components/advanced-filter/advanced-filter.component.mjs +128 -0
- package/esm2022/modules/advanced-filter/components/form-filter/form-filter.component.mjs +651 -0
- package/esm2022/modules/advanced-filter/index.mjs +6 -0
- package/esm2022/modules/advanced-filter/locale/fallback.mjs +73 -0
- package/esm2022/modules/advanced-filter/models/context.mjs +2 -0
- package/esm2022/modules/advanced-filter/models/depends-on.mjs +2 -0
- package/esm2022/modules/advanced-filter/models/enum-item.mjs +2 -0
- package/esm2022/modules/advanced-filter/models/filter-type.mjs +14 -0
- package/esm2022/modules/advanced-filter/models/filter-value.mjs +2 -0
- package/esm2022/modules/advanced-filter/models/filter.mjs +41 -0
- package/esm2022/modules/advanced-filter/models/form-filter.mjs +28 -0
- package/esm2022/modules/advanced-filter/models/index.mjs +11 -0
- package/esm2022/modules/advanced-filter/models/scope.mjs +6 -0
- package/esm2022/modules/advanced-filter/models/search.mjs +2 -0
- package/esm2022/modules/advanced-filter/models/tab-view.mjs +18 -0
- package/esm2022/modules/advanced-filter/models/ticked-filter.mjs +2 -0
- package/esm2022/modules/advanced-filter/pipes/map-values.pipe.mjs +14 -0
- package/esm2022/modules/advanced-filter/pipes/translate.pipe.mjs +19 -0
- package/esm2022/modules/advanced-filter/services/advanced-filter.service.mjs +146 -0
- package/esm2022/modules/advanced-filter/services/calendar-options.service.mjs +77 -0
- package/esm2022/modules/advanced-filter/services/constants.mjs +6 -0
- package/esm2022/modules/advanced-filter/shared/constants.mjs +3 -0
- package/esm2022/modules/advanced-filter/utils/comparator.mjs +53 -0
- package/esm2022/modules/advanced-filter/utils/filter-id/index.mjs +8 -0
- package/esm2022/modules/advanced-filter/utils/filter-value/index.mjs +26 -0
- package/esm2022/modules/advanced-filter/utils/filterOperators.mjs +9 -0
- package/esm2022/modules/advanced-filter/utils/form-field/index.mjs +52 -0
- package/esm2022/modules/advanced-filter/utils/index.mjs +57 -0
- package/esm2022/modules/advanced-filter/utils/json-path.mjs +13 -0
- package/esm2022/modules/cyclic-json-interceptor/cyclic-json-interceptor.module.mjs +14 -0
- package/esm2022/modules/cyclic-json-interceptor/cyclic-json-interceptor.service.mjs +29 -0
- package/esm2022/modules/cyclic-json-interceptor/index.mjs +2 -0
- package/esm2022/modules/feature-toggle/constants/endpoint.constant.mjs +26 -0
- package/esm2022/modules/feature-toggle/feature-toggle.module.mjs +15 -0
- package/esm2022/modules/feature-toggle/feature-toggle.service.mjs +42 -0
- package/esm2022/modules/feature-toggle/index.mjs +4 -0
- package/esm2022/modules/feature-toggle/models/feature.mjs +2 -0
- package/esm2022/modules/http-interceptor/http-interceptor.module.mjs +16 -0
- package/esm2022/modules/http-interceptor/http-interceptor.service.mjs +42 -0
- package/esm2022/modules/http-interceptor/index.mjs +4 -0
- package/esm2022/modules/http-interceptor/rest-url.service.mjs +15 -0
- package/esm2022/modules/http-interceptor/x-services-url.service.mjs +18 -0
- package/esm2022/modules/permissions/permissions.config.mjs +17 -0
- package/esm2022/modules/permissions/permissions.module.mjs +43 -0
- package/esm2022/modules/permissions/permissions.service.mjs +169 -0
- package/esm2022/modules/spotlight/component/spotlight.component.mjs +274 -0
- package/esm2022/modules/spotlight/index.mjs +3 -0
- package/esm2022/modules/spotlight/locale/fallback.mjs +5 -0
- package/esm2022/modules/spotlight/models/display-type.enum.mjs +6 -0
- package/esm2022/modules/spotlight/models/index.mjs +10 -0
- package/esm2022/modules/spotlight/models/spotlight-control-list.interface.mjs +2 -0
- package/esm2022/modules/spotlight/models/spotlight-control.interface.mjs +11 -0
- package/esm2022/modules/spotlight/models/spotlight-notification.interface.mjs +2 -0
- package/esm2022/modules/spotlight/models/spotlight-screen-list.interface.mjs +2 -0
- package/esm2022/modules/spotlight/models/spotlight-screen.interface.mjs +2 -0
- package/esm2022/modules/spotlight/models/spotlight-status.enum.mjs +8 -0
- package/esm2022/modules/spotlight/models/spotlight-user.interface.mjs +2 -0
- package/esm2022/modules/spotlight/models/spotlight-users-list.interface.mjs +2 -0
- package/esm2022/modules/spotlight/models/spotlight.interface.mjs +2 -0
- package/esm2022/modules/spotlight/models/user-action.enum.mjs +7 -0
- package/esm2022/modules/spotlight/pipes/translate.pipe.mjs +19 -0
- package/esm2022/modules/spotlight/service/spotlight.service.mjs +34 -0
- package/esm2022/modules/spotlight/spotlight.module.mjs +53 -0
- package/esm2022/modules/translations/translations.module.mjs +192 -0
- package/esm2022/public-api.mjs +10 -0
- package/esm2022/seniorsistemas-platform-components.mjs +5 -0
- package/fesm2022/seniorsistemas-platform-components.mjs +2432 -0
- package/fesm2022/seniorsistemas-platform-components.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/modules/advanced-filter/advanced-filter.module.d.ts +19 -0
- package/modules/advanced-filter/components/advanced-filter/advanced-filter.component.d.ts +4 -3
- package/modules/advanced-filter/components/form-filter/form-filter.component.d.ts +15 -12
- package/modules/advanced-filter/index.d.ts +1 -0
- package/modules/advanced-filter/models/tab-view.d.ts +1 -1
- package/modules/advanced-filter/pipes/map-values.pipe.d.ts +3 -0
- package/modules/advanced-filter/pipes/translate.pipe.d.ts +4 -3
- package/modules/advanced-filter/services/advanced-filter.service.d.ts +7 -3
- package/modules/advanced-filter/services/calendar-options.service.d.ts +4 -3
- package/modules/advanced-filter/services/constants.d.ts +4 -4
- package/modules/advanced-filter/utils/comparator.d.ts +1 -1
- package/modules/advanced-filter/utils/form-field/index.d.ts +1 -1
- package/modules/advanced-filter/utils/json-path.d.ts +1 -1
- package/modules/cyclic-json-interceptor/cyclic-json-interceptor.module.d.ts +4 -0
- package/modules/cyclic-json-interceptor/cyclic-json-interceptor.service.d.ts +3 -0
- package/modules/feature-toggle/feature-toggle.module.d.ts +5 -0
- package/modules/feature-toggle/feature-toggle.service.d.ts +4 -3
- package/modules/http-interceptor/http-interceptor.module.d.ts +4 -0
- package/modules/http-interceptor/http-interceptor.service.d.ts +3 -3
- package/modules/http-interceptor/rest-url.service.d.ts +3 -0
- package/modules/http-interceptor/x-services-url.service.d.ts +3 -0
- package/modules/permissions/permissions.config.d.ts +7 -1
- package/modules/permissions/permissions.module.d.ts +4 -0
- package/modules/permissions/permissions.service.d.ts +6 -12
- package/modules/spotlight/component/spotlight.component.d.ts +6 -7
- package/modules/spotlight/pipes/translate.pipe.d.ts +4 -3
- package/modules/spotlight/service/spotlight.service.d.ts +4 -3
- package/modules/spotlight/spotlight.module.d.ts +11 -0
- package/modules/translations/translations.module.d.ts +9 -5
- package/package.json +20 -54
- package/public-api.d.ts +1 -0
- package/bundles/seniorsistemas-platform-components.umd.js +0 -2745
- package/bundles/seniorsistemas-platform-components.umd.js.map +0 -1
- package/bundles/seniorsistemas-platform-components.umd.min.js +0 -17
- package/bundles/seniorsistemas-platform-components.umd.min.js.map +0 -1
- package/esm2015/modules/advanced-filter/advanced-filter.module.js +0 -47
- package/esm2015/modules/advanced-filter/components/advanced-filter/advanced-filter.component.js +0 -136
- package/esm2015/modules/advanced-filter/components/form-filter/form-filter.component.js +0 -578
- package/esm2015/modules/advanced-filter/index.js +0 -5
- package/esm2015/modules/advanced-filter/locale/fallback.js +0 -73
- package/esm2015/modules/advanced-filter/models/context.js +0 -1
- package/esm2015/modules/advanced-filter/models/depends-on.js +0 -1
- package/esm2015/modules/advanced-filter/models/enum-item.js +0 -1
- package/esm2015/modules/advanced-filter/models/filter-type.js +0 -14
- package/esm2015/modules/advanced-filter/models/filter-value.js +0 -1
- package/esm2015/modules/advanced-filter/models/filter.js +0 -23
- package/esm2015/modules/advanced-filter/models/form-filter.js +0 -19
- package/esm2015/modules/advanced-filter/models/index.js +0 -5
- package/esm2015/modules/advanced-filter/models/scope.js +0 -6
- package/esm2015/modules/advanced-filter/models/search.js +0 -1
- package/esm2015/modules/advanced-filter/models/tab-view.js +0 -18
- package/esm2015/modules/advanced-filter/models/ticked-filter.js +0 -1
- package/esm2015/modules/advanced-filter/pipes/map-values.pipe.js +0 -12
- package/esm2015/modules/advanced-filter/pipes/translate.pipe.js +0 -22
- package/esm2015/modules/advanced-filter/services/advanced-filter.service.js +0 -141
- package/esm2015/modules/advanced-filter/services/calendar-options.service.js +0 -81
- package/esm2015/modules/advanced-filter/services/constants.js +0 -6
- package/esm2015/modules/advanced-filter/shared/constants.js +0 -3
- package/esm2015/modules/advanced-filter/utils/comparator.js +0 -55
- package/esm2015/modules/advanced-filter/utils/filter-id/index.js +0 -8
- package/esm2015/modules/advanced-filter/utils/filter-value/index.js +0 -24
- package/esm2015/modules/advanced-filter/utils/filterOperators.js +0 -11
- package/esm2015/modules/advanced-filter/utils/form-field/index.js +0 -50
- package/esm2015/modules/advanced-filter/utils/index.js +0 -57
- package/esm2015/modules/advanced-filter/utils/json-path.js +0 -12
- package/esm2015/modules/cyclic-json-interceptor/cyclic-json-interceptor.module.js +0 -14
- package/esm2015/modules/cyclic-json-interceptor/cyclic-json-interceptor.service.js +0 -27
- package/esm2015/modules/cyclic-json-interceptor/index.js +0 -2
- package/esm2015/modules/feature-toggle/constants/endpoint.constant.js +0 -26
- package/esm2015/modules/feature-toggle/feature-toggle.module.js +0 -15
- package/esm2015/modules/feature-toggle/feature-toggle.service.js +0 -48
- package/esm2015/modules/feature-toggle/index.js +0 -3
- package/esm2015/modules/feature-toggle/models/feature.js +0 -1
- package/esm2015/modules/http-interceptor/http-interceptor.module.js +0 -16
- package/esm2015/modules/http-interceptor/http-interceptor.service.js +0 -47
- package/esm2015/modules/http-interceptor/index.js +0 -4
- package/esm2015/modules/http-interceptor/rest-url.service.js +0 -14
- package/esm2015/modules/http-interceptor/x-services-url.service.js +0 -17
- package/esm2015/modules/permissions/permissions.config.js +0 -11
- package/esm2015/modules/permissions/permissions.module.js +0 -42
- package/esm2015/modules/permissions/permissions.service.js +0 -196
- package/esm2015/modules/spotlight/component/spotlight.component.js +0 -274
- package/esm2015/modules/spotlight/index.js +0 -3
- package/esm2015/modules/spotlight/locale/fallback.js +0 -5
- package/esm2015/modules/spotlight/models/display-type.enum.js +0 -6
- package/esm2015/modules/spotlight/models/index.js +0 -4
- package/esm2015/modules/spotlight/models/spotlight-control-list.interface.js +0 -1
- package/esm2015/modules/spotlight/models/spotlight-control.interface.js +0 -3
- package/esm2015/modules/spotlight/models/spotlight-notification.interface.js +0 -1
- package/esm2015/modules/spotlight/models/spotlight-screen-list.interface.js +0 -1
- package/esm2015/modules/spotlight/models/spotlight-screen.interface.js +0 -1
- package/esm2015/modules/spotlight/models/spotlight-status.enum.js +0 -8
- package/esm2015/modules/spotlight/models/spotlight-user.interface.js +0 -1
- package/esm2015/modules/spotlight/models/spotlight-users-list.interface.js +0 -1
- package/esm2015/modules/spotlight/models/spotlight.interface.js +0 -1
- package/esm2015/modules/spotlight/models/user-action.enum.js +0 -7
- package/esm2015/modules/spotlight/pipes/translate.pipe.js +0 -22
- package/esm2015/modules/spotlight/service/spotlight.service.js +0 -38
- package/esm2015/modules/spotlight/spotlight.module.js +0 -37
- package/esm2015/modules/translations/translations.module.js +0 -182
- package/esm2015/public-api.js +0 -9
- package/esm2015/seniorsistemas-platform-components.js +0 -16
- package/esm5/modules/advanced-filter/advanced-filter.module.js +0 -54
- package/esm5/modules/advanced-filter/components/advanced-filter/advanced-filter.component.js +0 -144
- package/esm5/modules/advanced-filter/components/form-filter/form-filter.component.js +0 -626
- package/esm5/modules/advanced-filter/index.js +0 -5
- package/esm5/modules/advanced-filter/locale/fallback.js +0 -73
- package/esm5/modules/advanced-filter/models/context.js +0 -1
- package/esm5/modules/advanced-filter/models/depends-on.js +0 -1
- package/esm5/modules/advanced-filter/models/enum-item.js +0 -1
- package/esm5/modules/advanced-filter/models/filter-type.js +0 -14
- package/esm5/modules/advanced-filter/models/filter-value.js +0 -1
- package/esm5/modules/advanced-filter/models/filter.js +0 -25
- package/esm5/modules/advanced-filter/models/form-filter.js +0 -25
- package/esm5/modules/advanced-filter/models/index.js +0 -5
- package/esm5/modules/advanced-filter/models/scope.js +0 -6
- package/esm5/modules/advanced-filter/models/search.js +0 -1
- package/esm5/modules/advanced-filter/models/tab-view.js +0 -29
- package/esm5/modules/advanced-filter/models/ticked-filter.js +0 -1
- package/esm5/modules/advanced-filter/pipes/map-values.pipe.js +0 -16
- package/esm5/modules/advanced-filter/pipes/translate.pipe.js +0 -23
- package/esm5/modules/advanced-filter/services/advanced-filter.service.js +0 -152
- package/esm5/modules/advanced-filter/services/calendar-options.service.js +0 -82
- package/esm5/modules/advanced-filter/services/constants.js +0 -6
- package/esm5/modules/advanced-filter/shared/constants.js +0 -3
- package/esm5/modules/advanced-filter/utils/comparator.js +0 -55
- package/esm5/modules/advanced-filter/utils/filter-id/index.js +0 -8
- package/esm5/modules/advanced-filter/utils/filter-value/index.js +0 -25
- package/esm5/modules/advanced-filter/utils/filterOperators.js +0 -11
- package/esm5/modules/advanced-filter/utils/form-field/index.js +0 -52
- package/esm5/modules/advanced-filter/utils/index.js +0 -57
- package/esm5/modules/advanced-filter/utils/json-path.js +0 -12
- package/esm5/modules/cyclic-json-interceptor/cyclic-json-interceptor.module.js +0 -17
- package/esm5/modules/cyclic-json-interceptor/cyclic-json-interceptor.service.js +0 -30
- package/esm5/modules/cyclic-json-interceptor/index.js +0 -2
- package/esm5/modules/feature-toggle/constants/endpoint.constant.js +0 -27
- package/esm5/modules/feature-toggle/feature-toggle.module.js +0 -18
- package/esm5/modules/feature-toggle/feature-toggle.service.js +0 -51
- package/esm5/modules/feature-toggle/index.js +0 -3
- package/esm5/modules/feature-toggle/models/feature.js +0 -1
- package/esm5/modules/http-interceptor/http-interceptor.module.js +0 -19
- package/esm5/modules/http-interceptor/http-interceptor.service.js +0 -49
- package/esm5/modules/http-interceptor/index.js +0 -4
- package/esm5/modules/http-interceptor/rest-url.service.js +0 -17
- package/esm5/modules/http-interceptor/x-services-url.service.js +0 -20
- package/esm5/modules/permissions/permissions.config.js +0 -17
- package/esm5/modules/permissions/permissions.module.js +0 -46
- package/esm5/modules/permissions/permissions.service.js +0 -212
- package/esm5/modules/spotlight/component/spotlight.component.js +0 -300
- package/esm5/modules/spotlight/index.js +0 -3
- package/esm5/modules/spotlight/locale/fallback.js +0 -5
- package/esm5/modules/spotlight/models/display-type.enum.js +0 -6
- package/esm5/modules/spotlight/models/index.js +0 -4
- package/esm5/modules/spotlight/models/spotlight-control-list.interface.js +0 -1
- package/esm5/modules/spotlight/models/spotlight-control.interface.js +0 -7
- package/esm5/modules/spotlight/models/spotlight-notification.interface.js +0 -1
- package/esm5/modules/spotlight/models/spotlight-screen-list.interface.js +0 -1
- package/esm5/modules/spotlight/models/spotlight-screen.interface.js +0 -1
- package/esm5/modules/spotlight/models/spotlight-status.enum.js +0 -8
- package/esm5/modules/spotlight/models/spotlight-user.interface.js +0 -1
- package/esm5/modules/spotlight/models/spotlight-users-list.interface.js +0 -1
- package/esm5/modules/spotlight/models/spotlight.interface.js +0 -1
- package/esm5/modules/spotlight/models/user-action.enum.js +0 -7
- package/esm5/modules/spotlight/pipes/translate.pipe.js +0 -23
- package/esm5/modules/spotlight/service/spotlight.service.js +0 -39
- package/esm5/modules/spotlight/spotlight.module.js +0 -40
- package/esm5/modules/translations/translations.module.js +0 -226
- package/esm5/public-api.js +0 -9
- package/esm5/seniorsistemas-platform-components.js +0 -16
- package/fesm2015/seniorsistemas-platform-components.js +0 -2284
- package/fesm2015/seniorsistemas-platform-components.js.map +0 -1
- package/fesm5/seniorsistemas-platform-components.js +0 -2507
- package/fesm5/seniorsistemas-platform-components.js.map +0 -1
- package/seniorsistemas-platform-components.d.ts +0 -15
- package/seniorsistemas-platform-components.metadata.json +0 -1
|
@@ -1,2284 +0,0 @@
|
|
|
1
|
-
import { __decorate, __awaiter, __rest, __param } from 'tslib';
|
|
2
|
-
import { Pipe, InjectionToken, APP_INITIALIZER, Injector, NgModule, Injectable, EventEmitter, ChangeDetectorRef, Input, Output, HostListener, Component, ViewChild, ViewEncapsulation, ɵɵdefineInjectable, Inject, ɵɵinject } from '@angular/core';
|
|
3
|
-
import { LOCATION_INITIALIZED, CommonModule, DatePipe } from '@angular/common';
|
|
4
|
-
import { FormGroup, FormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
5
|
-
import { ButtonModule as ButtonModule$1 } from 'primeng/button';
|
|
6
|
-
import { DialogModule } from 'primeng/dialog';
|
|
7
|
-
import { TabViewModule } from 'primeng/tabview';
|
|
8
|
-
import { ToastModule } from 'primeng/toast';
|
|
9
|
-
import { TooltipModule } from 'primeng/tooltip';
|
|
10
|
-
import { MessageService } from 'primeng/api';
|
|
11
|
-
import { TextField, FieldType, CurrencyField, SelectField, NumberField, RadioButtonField, CalendarField, AutocompleteField, ButtonModule, DynamicFormModule, EmptyStateModule, LocaleService } from '@seniorsistemas/angular-components';
|
|
12
|
-
import { TranslateService, TranslateModule } from '@ngx-translate/core';
|
|
13
|
-
import { HttpClient, HttpClientModule, HttpParams, HttpHeaders, HttpResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
14
|
-
import { user, service } from '@seniorsistemas/senior-platform-data';
|
|
15
|
-
import { CookieService } from 'ngx-cookie-service';
|
|
16
|
-
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
|
17
|
-
import { Subject, Observable, from, BehaviorSubject as BehaviorSubject$1, defer, forkJoin, throwError, of } from 'rxjs';
|
|
18
|
-
import { map, takeUntil, filter, tap, mergeMap, catchError, shareReplay } from 'rxjs/operators';
|
|
19
|
-
import { NavigationEnd, Router } from '@angular/router';
|
|
20
|
-
import moment from 'moment';
|
|
21
|
-
import { contains, equals, clone } from 'ramda';
|
|
22
|
-
import jsonCycle from 'json-cycle';
|
|
23
|
-
|
|
24
|
-
let MapValuesPipe = class MapValuesPipe {
|
|
25
|
-
transform(map, args = null) {
|
|
26
|
-
return Array.from(map.values());
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
MapValuesPipe = __decorate([
|
|
30
|
-
Pipe({ name: 'mapValues', pure: false })
|
|
31
|
-
], MapValuesPipe);
|
|
32
|
-
|
|
33
|
-
let TranslatePipe = class TranslatePipe {
|
|
34
|
-
constructor(translationService) {
|
|
35
|
-
this.translationService = translationService;
|
|
36
|
-
}
|
|
37
|
-
transform(value, args) {
|
|
38
|
-
return this.translationService.instant(value);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
TranslatePipe.ctorParameters = () => [
|
|
42
|
-
{ type: TranslateService }
|
|
43
|
-
];
|
|
44
|
-
TranslatePipe = __decorate([
|
|
45
|
-
Pipe({
|
|
46
|
-
name: 'translate',
|
|
47
|
-
pure: false,
|
|
48
|
-
})
|
|
49
|
-
], TranslatePipe);
|
|
50
|
-
|
|
51
|
-
var TranslationsModule_1;
|
|
52
|
-
const TranslationsConfig = new InjectionToken('translationConfig');
|
|
53
|
-
const USER_INFO = 'com.senior.token';
|
|
54
|
-
const LENGTH_DEFAULT = 2;
|
|
55
|
-
let TranslationsModule = TranslationsModule_1 = class TranslationsModule {
|
|
56
|
-
static forRoot(translationsConfigs) {
|
|
57
|
-
return {
|
|
58
|
-
ngModule: TranslationsModule_1,
|
|
59
|
-
providers: [
|
|
60
|
-
{
|
|
61
|
-
provide: APP_INITIALIZER,
|
|
62
|
-
useFactory: factory,
|
|
63
|
-
deps: [TranslateService, Injector, HttpClient, CookieService],
|
|
64
|
-
multi: true
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
provide: TranslationsConfig,
|
|
68
|
-
useValue: translationsConfigs,
|
|
69
|
-
multi: true
|
|
70
|
-
}
|
|
71
|
-
]
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
static forChild(translationsConfigs) {
|
|
75
|
-
return {
|
|
76
|
-
ngModule: TranslationsModule_1,
|
|
77
|
-
providers: [
|
|
78
|
-
{
|
|
79
|
-
provide: TranslationsConfig,
|
|
80
|
-
useValue: translationsConfigs,
|
|
81
|
-
multi: true
|
|
82
|
-
}
|
|
83
|
-
]
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
TranslationsModule = TranslationsModule_1 = __decorate([
|
|
88
|
-
NgModule({
|
|
89
|
-
imports: [HttpClientModule, TranslateModule.forChild()],
|
|
90
|
-
providers: [CookieService]
|
|
91
|
-
})
|
|
92
|
-
], TranslationsModule);
|
|
93
|
-
function factory(translate, injector, http, cookieService) {
|
|
94
|
-
return () => new Promise((resolve) => {
|
|
95
|
-
const locationInitialized = injector.get(LOCATION_INITIALIZED, Promise.resolve(null));
|
|
96
|
-
locationInitialized.then(() => __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
let locale = 'pt-BR';
|
|
98
|
-
try {
|
|
99
|
-
const configs = getFlatArray(injector.get(TranslationsConfig, Promise.resolve(null)));
|
|
100
|
-
try {
|
|
101
|
-
let userData = JSON.parse(cookieService.get(USER_INFO));
|
|
102
|
-
if (userDataIsNull(userData)) {
|
|
103
|
-
userData = yield user.getUserData();
|
|
104
|
-
}
|
|
105
|
-
locale = getLocale(userData);
|
|
106
|
-
}
|
|
107
|
-
catch (ex) {
|
|
108
|
-
console.warn('Unable to obtain user locale');
|
|
109
|
-
}
|
|
110
|
-
const fallback = configs.reduce((result, configs) => (Object.assign(Object.assign({}, result), configs.fallback)), {});
|
|
111
|
-
const defaultsLanguages = configs.reduce((result, configs) => (Object.assign(Object.assign({}, result), configs.defaultsLanguages)), {});
|
|
112
|
-
translate.setTranslation(locale, fallback);
|
|
113
|
-
translate.setDefaultLang(locale);
|
|
114
|
-
let configTranslate = {};
|
|
115
|
-
if (defaultsLanguages) {
|
|
116
|
-
configTranslate = getConfigTranslate(defaultsLanguages, locale);
|
|
117
|
-
}
|
|
118
|
-
const translationsPromises = configs.map((config) => getTranslationsRequest(config, locale));
|
|
119
|
-
yield Promise.all(translationsPromises).then((results) => {
|
|
120
|
-
const usedFallback = translate['overriden'];
|
|
121
|
-
results.forEach((file, index) => {
|
|
122
|
-
setTranslations(file['content'], usedFallback, locale, index, configTranslate.fallbackByLocale);
|
|
123
|
-
});
|
|
124
|
-
return translate.use(locale).toPromise();
|
|
125
|
-
});
|
|
126
|
-
resolve();
|
|
127
|
-
}
|
|
128
|
-
catch (err) {
|
|
129
|
-
console.warn('Error setting translations. Using local fallback.', err);
|
|
130
|
-
translate
|
|
131
|
-
.use(locale)
|
|
132
|
-
.toPromise()
|
|
133
|
-
.then(() => {
|
|
134
|
-
resolve();
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}));
|
|
138
|
-
});
|
|
139
|
-
function setTranslations(content, usedFallback, locale, index, fallbackByLocale) {
|
|
140
|
-
if (usedFallback) {
|
|
141
|
-
content && translate.setTranslation(locale, content, true);
|
|
142
|
-
translate.setTranslation(locale, fallbackByLocale, true);
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
if (index === 0) {
|
|
146
|
-
translate.setTranslation(locale, fallbackByLocale, true);
|
|
147
|
-
}
|
|
148
|
-
content && translate.setTranslation(locale, content, true);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
function getTranslationsRequest({ domain, service }, language) {
|
|
152
|
-
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
try {
|
|
154
|
-
if (!domain && !service) {
|
|
155
|
-
throw new Error(`domain and service not found`);
|
|
156
|
-
}
|
|
157
|
-
const params = new HttpParams().set('domainName', domain).set('serviceName', service).set('format', 'FLAT_JSON');
|
|
158
|
-
const headers = new HttpHeaders().set('Authorization', yield user.getAuthHeader());
|
|
159
|
-
const url = 'platform/translation_hub/queries/getTranslationBundle';
|
|
160
|
-
const bundleFiles = yield http
|
|
161
|
-
.get(url, { headers, params })
|
|
162
|
-
.toPromise()
|
|
163
|
-
.then((res) => res.bundleFiles);
|
|
164
|
-
let languageBundle = language && bundleFiles.find((bundle) => bundle.language === language);
|
|
165
|
-
let overriden = false;
|
|
166
|
-
if (!languageBundle) {
|
|
167
|
-
languageBundle = bundleFiles.find((bundle) => bundle.language === 'pt-BR');
|
|
168
|
-
overriden = true;
|
|
169
|
-
}
|
|
170
|
-
if (!languageBundle) {
|
|
171
|
-
return resolve({});
|
|
172
|
-
}
|
|
173
|
-
yield http
|
|
174
|
-
.get(languageBundle.url)
|
|
175
|
-
.toPromise()
|
|
176
|
-
.then((result) => {
|
|
177
|
-
const translations = {
|
|
178
|
-
overriden: overriden,
|
|
179
|
-
content: result
|
|
180
|
-
};
|
|
181
|
-
resolve(translations);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
catch (err) {
|
|
185
|
-
console.warn(`Error getting translation bundle for ${domain}/${service}. Using local fallback.`, err);
|
|
186
|
-
resolve({});
|
|
187
|
-
}
|
|
188
|
-
}));
|
|
189
|
-
}
|
|
190
|
-
function getFlatArray(array) {
|
|
191
|
-
return array.reduce((result, item) => {
|
|
192
|
-
if (Array.isArray(item)) {
|
|
193
|
-
return [...result, ...item];
|
|
194
|
-
}
|
|
195
|
-
return [...result, item];
|
|
196
|
-
}, []);
|
|
197
|
-
}
|
|
198
|
-
function userDataIsNull(data) {
|
|
199
|
-
return !data || Object.keys(data).length === 0;
|
|
200
|
-
}
|
|
201
|
-
function getConfigTranslate(defaultsLanguages, locale) {
|
|
202
|
-
const languages = Object.keys(defaultsLanguages).map((key) => {
|
|
203
|
-
const language = {};
|
|
204
|
-
language['locale'] = key.replace('_', '-');
|
|
205
|
-
language['translation'] = defaultsLanguages[key];
|
|
206
|
-
return language;
|
|
207
|
-
}, []);
|
|
208
|
-
const result = { languages };
|
|
209
|
-
result['foundLocaleUser'] = languages.find((results) => results.locale === locale);
|
|
210
|
-
if (!result['foundLocaleUser']) {
|
|
211
|
-
result['foundLocaleUser'] = languages.find((results) => {
|
|
212
|
-
return results.locale.length === LENGTH_DEFAULT && results.locale === locale.split('-')[0];
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
if (result['foundLocaleUser']) {
|
|
216
|
-
result['fallbackByLocale'] = result['foundLocaleUser']['translation'];
|
|
217
|
-
}
|
|
218
|
-
return result;
|
|
219
|
-
}
|
|
220
|
-
function getLocale(userData) {
|
|
221
|
-
return userData.locale || 'pt-BR';
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const fallback = {
|
|
226
|
-
'platform.filter_service.cancel': 'Cancelar',
|
|
227
|
-
'platform.filter_service.try': 'Tentar Novamente',
|
|
228
|
-
'platform.filter_service.actions': 'Ações',
|
|
229
|
-
'platform.filter_service.save': 'Salvar',
|
|
230
|
-
'platform.filter_service.filter': 'Filtrar',
|
|
231
|
-
'platform.filter_service.error_state': 'O serviço de filtro está indisponível no momento e as informações apresentadas não são as mais recentes. Tente novamente mais tarde.',
|
|
232
|
-
'platform.filter_service.saved_filters_success': 'Filtros salvos com sucesso! Clique em "Filtrar" para visualizar o resultado.',
|
|
233
|
-
'platform.filter_service.saved_filters_error': 'Ocorreu um erro ao tentar salvar os filtros. Verifique os valores e tente novamente.',
|
|
234
|
-
'platform.filter_service.applied_filter_nochange': 'Não houve alterações no filtro.',
|
|
235
|
-
'platform.filter_service.applied_filter_change': 'Filtros aplicados com sucesso!',
|
|
236
|
-
'platform.filter_service.invalid_pattern': 'O valor não atende ao padrão especificado.',
|
|
237
|
-
'platform.filter_service.error_max_value': 'O valor excede o tamanho máximo especificado.',
|
|
238
|
-
'platform.filter_service.error_min_value': 'O valor é menor que o minímo especificado.',
|
|
239
|
-
'platform.filter_service.applied_filters_message': '{{totalActiveFilters}} filtros aplicados',
|
|
240
|
-
'platform.filter_service.applied_filter_message': '{{totalActiveFilters}} filtro aplicado',
|
|
241
|
-
'platform.filter_service.find_suggestions_error': 'Erro ao encontrar sugestões!',
|
|
242
|
-
'platform.filter_service.select': 'Selecionar',
|
|
243
|
-
'platform.filter_service.filters': 'Filtros',
|
|
244
|
-
'platform.filter_service.date_format': 'dd/mm/yy',
|
|
245
|
-
'platform.filter_service.hour_format': '24',
|
|
246
|
-
'platform.filter_service.clear': 'Limpar',
|
|
247
|
-
'platform.filter_service.today': 'Hoje',
|
|
248
|
-
'platform.filter_service.name_january': 'Janeiro',
|
|
249
|
-
'platform.filter_service.name_february': 'Fevereiro',
|
|
250
|
-
'platform.filter_service.name_march': 'Março',
|
|
251
|
-
'platform.filter_service.name_april': 'Abril',
|
|
252
|
-
'platform.filter_service.name_may': 'Maio',
|
|
253
|
-
'platform.filter_service.name_june': 'Junho',
|
|
254
|
-
'platform.filter_service.name_july': 'Julho',
|
|
255
|
-
'platform.filter_service.name_august': 'Agosto',
|
|
256
|
-
'platform.filter_service.name_september': 'Setembro',
|
|
257
|
-
'platform.filter_service.name_october': 'Outubro',
|
|
258
|
-
'platform.filter_service.name_november': 'Novembro',
|
|
259
|
-
'platform.filter_service.name_december': 'Dezembro',
|
|
260
|
-
'platform.filter_service.short_january': 'Jan',
|
|
261
|
-
'platform.filter_service.short_february': 'Fev',
|
|
262
|
-
'platform.filter_service.short_march': 'Mar',
|
|
263
|
-
'platform.filter_service.short_april': 'Abr',
|
|
264
|
-
'platform.filter_service.short_may': 'Mai',
|
|
265
|
-
'platform.filter_service.short_june': 'Jun',
|
|
266
|
-
'platform.filter_service.short_july': 'Jul',
|
|
267
|
-
'platform.filter_service.short_august': 'Ago',
|
|
268
|
-
'platform.filter_service.short_september': 'Set',
|
|
269
|
-
'platform.filter_service.short_october': 'Out',
|
|
270
|
-
'platform.filter_service.short_november': 'Nov',
|
|
271
|
-
'platform.filter_service.short_december': 'Dez',
|
|
272
|
-
'platform.filter_service.name_sunday': 'Domingo',
|
|
273
|
-
'platform.filter_service.name_monday': 'Segunda',
|
|
274
|
-
'platform.filter_service.name_tuesday': 'Terça',
|
|
275
|
-
'platform.filter_service.name_wednesday': 'Quarta',
|
|
276
|
-
'platform.filter_service.name_thursday': 'Quinta',
|
|
277
|
-
'platform.filter_service.name_friday': 'Sexta',
|
|
278
|
-
'platform.filter_service.name_saturday': 'Sábado',
|
|
279
|
-
'platform.filter_service.min_sunday': 'D',
|
|
280
|
-
'platform.filter_service.min_monday': 'S',
|
|
281
|
-
'platform.filter_service.min_tuesday': 'T',
|
|
282
|
-
'platform.filter_service.min_wednesday': 'Q',
|
|
283
|
-
'platform.filter_service.min_thursday': 'Q',
|
|
284
|
-
'platform.filter_service.min_friday': 'S',
|
|
285
|
-
'platform.filter_service.min_saturday': 'S',
|
|
286
|
-
'platform.filter_service.short_sunday': 'Dom',
|
|
287
|
-
'platform.filter_service.short_monday': 'Seg',
|
|
288
|
-
'platform.filter_service.short_tuesday': 'Ter',
|
|
289
|
-
'platform.filter_service.short_wednesday': 'Qua',
|
|
290
|
-
'platform.filter_service.short_thursday': 'Qui',
|
|
291
|
-
'platform.filter_service.short_friday': 'Sex',
|
|
292
|
-
'platform.filter_service.short_saturday': 'Sab',
|
|
293
|
-
'platform.filter_service.yes': 'Sim',
|
|
294
|
-
'platform.filter_service.no': 'Não',
|
|
295
|
-
'platform.filter_service.search_empty_message': 'Nenhum resultado encontrado'
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
const URL_PREFIX = 'platform/filter_service';
|
|
299
|
-
const GET_FILTERS_URL = `${URL_PREFIX}/queries/getFilters`;
|
|
300
|
-
const SAVE_FILTERS_URL = `${URL_PREFIX}/actions/saveUserFilters`;
|
|
301
|
-
const SAVE_TICKED_FILTER_URL = `${URL_PREFIX}/actions/setTicketFilters`;
|
|
302
|
-
const GET_FILTERS_BY_TICKET = `${URL_PREFIX}/queries/getFiltersByTicket`;
|
|
303
|
-
|
|
304
|
-
const searchDisplayName = '$$__displayValue__';
|
|
305
|
-
const searchKeyName = '$$__keyValue__';
|
|
306
|
-
|
|
307
|
-
let AdvancedFilterService = class AdvancedFilterService {
|
|
308
|
-
constructor(http) {
|
|
309
|
-
this.http = http;
|
|
310
|
-
this.filtersObservable = new Subject();
|
|
311
|
-
this.contextsObservable = new BehaviorSubject([]);
|
|
312
|
-
this.ticketFilterObservable = new Subject();
|
|
313
|
-
this.destroy$ = new Subject();
|
|
314
|
-
this.contextsObserver = this.contextsObservable.asObservable();
|
|
315
|
-
this.filtersObserver = this.filtersObservable.asObservable();
|
|
316
|
-
this.ticketFilterObserver = this.ticketFilterObservable.asObservable();
|
|
317
|
-
this.contextsObservable.subscribe(contexts => contexts.length && this.getAndApplyFilters(contexts));
|
|
318
|
-
}
|
|
319
|
-
saveTickedFilters(filters) {
|
|
320
|
-
const requestBody = this.ticketFilter ? { filters, ticketFilter: this.ticketFilter } : { filters };
|
|
321
|
-
this.http
|
|
322
|
-
.post(SAVE_TICKED_FILTER_URL, requestBody)
|
|
323
|
-
.pipe(map(response => response.ticket))
|
|
324
|
-
.subscribe(ticketFilter => {
|
|
325
|
-
this.ticketFilter = ticketFilter;
|
|
326
|
-
this.ticketFilterObservable.next({ ticketFilter });
|
|
327
|
-
window.parent.postMessage({ message: 'advanced-filter:success', payload: ticketFilter }, '*');
|
|
328
|
-
}, err => {
|
|
329
|
-
this.ticketFilterObservable.next({ error: true, message: err });
|
|
330
|
-
window.parent.postMessage({ message: 'advanced-filter:error', payload: err }, '*');
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
addContexts(...contexts) {
|
|
334
|
-
const currentContexts = this.contextsObservable.getValue();
|
|
335
|
-
this.contextsObservable.next([...currentContexts, ...contexts]);
|
|
336
|
-
return Observable.create(() => () => this.removeContexts(contexts));
|
|
337
|
-
}
|
|
338
|
-
removeContexts(contexts) {
|
|
339
|
-
const allContexts = this.contextsObservable.getValue();
|
|
340
|
-
const filteredContexts = allContexts.filter(context => contexts.indexOf(context) === -1);
|
|
341
|
-
this.contextsObservable.next(filteredContexts);
|
|
342
|
-
}
|
|
343
|
-
saveFilters(filters) {
|
|
344
|
-
return this.http.post(SAVE_FILTERS_URL, { filters });
|
|
345
|
-
}
|
|
346
|
-
searchFieldSuggestions(url, params, type) {
|
|
347
|
-
const headers = new HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8' });
|
|
348
|
-
if (type === 'ENTITY') {
|
|
349
|
-
return this.http.get(url, { headers });
|
|
350
|
-
}
|
|
351
|
-
return this.http.post(url, params, { headers });
|
|
352
|
-
}
|
|
353
|
-
tryAgain(serviceContexts) {
|
|
354
|
-
this.getFilters(serviceContexts);
|
|
355
|
-
}
|
|
356
|
-
getAndApplyFilters(serviceContexts) {
|
|
357
|
-
this.getFilters(serviceContexts, true);
|
|
358
|
-
}
|
|
359
|
-
getFilters(serviceContexts, applyFilter) {
|
|
360
|
-
this.http
|
|
361
|
-
.post(GET_FILTERS_URL, { serviceContexts })
|
|
362
|
-
.pipe(map(response => this.mapFilters(response.filters)))
|
|
363
|
-
.subscribe(filters => this.filtersObservable.next({ filters, applyFilter }), //
|
|
364
|
-
//
|
|
365
|
-
err => this.filtersObservable.next({ error: true, message: err }));
|
|
366
|
-
}
|
|
367
|
-
mapFilters(filters) {
|
|
368
|
-
return filters.map(filter => {
|
|
369
|
-
try {
|
|
370
|
-
const value = filter.value && JSON.parse(filter.value);
|
|
371
|
-
if (value && filter.search && filter.search.basicSearch && filter.search.basicSearch.output) {
|
|
372
|
-
this.mapValues(value, filter.search.basicSearch.output.keyFields, filter.search.basicSearch.output.displayFields);
|
|
373
|
-
}
|
|
374
|
-
else if (value && filter.search && filter.search.entitySearch && filter.search.entitySearch.output) {
|
|
375
|
-
this.mapValues(value, filter.search.entitySearch.output.keyFields, filter.search.entitySearch.output.displayFields);
|
|
376
|
-
}
|
|
377
|
-
if (value) {
|
|
378
|
-
if (this.isMultiple(filter)) {
|
|
379
|
-
const valueInText = JSON.stringify(value);
|
|
380
|
-
if ((valueInText.startsWith('[{') && valueInText.endsWith('}]')) || valueInText.length <= 4) {
|
|
381
|
-
filter.value = valueInText;
|
|
382
|
-
}
|
|
383
|
-
else {
|
|
384
|
-
filter.value = JSON.stringify('');
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
filter.value = JSON.stringify(value);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
catch (ex) {
|
|
393
|
-
console.error(`Global: filter ${filter.name} has value error. `, ex);
|
|
394
|
-
filter.value = JSON.stringify('');
|
|
395
|
-
}
|
|
396
|
-
return filter;
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
isMultiple(filter) {
|
|
400
|
-
return (filter.type === 'SEARCH' &&
|
|
401
|
-
filter.search &&
|
|
402
|
-
((filter.search.basicSearch && filter.search.basicSearch.output && filter.search.basicSearch.output.maxSelectedItems > 1) ||
|
|
403
|
-
(filter.search.entitySearch && filter.search.entitySearch.output && filter.search.entitySearch.output.maxSelectedItems > 1)));
|
|
404
|
-
}
|
|
405
|
-
mapValues(value, keyFields, displayFields) {
|
|
406
|
-
if (Array.isArray(value)) {
|
|
407
|
-
value.forEach(e => {
|
|
408
|
-
this.mapValue(e, keyFields, displayFields);
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
this.mapValue(value, keyFields, displayFields);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
mapValue(value, keyFields, displayFields) {
|
|
416
|
-
if (!value) {
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
const ids = [];
|
|
420
|
-
const displays = [];
|
|
421
|
-
keyFields.filter(e => value[e] !== undefined).forEach(e => ids.push(value[e]));
|
|
422
|
-
displayFields.filter(e => value[e] !== undefined).forEach(e => displays.push(value[e]));
|
|
423
|
-
if (ids.length > 0 && displays.length > 0) {
|
|
424
|
-
value[searchKeyName] = ids.join(', ');
|
|
425
|
-
value[searchDisplayName] = displays.join(', ');
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
value = [''];
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
AdvancedFilterService.ctorParameters = () => [
|
|
433
|
-
{ type: HttpClient }
|
|
434
|
-
];
|
|
435
|
-
AdvancedFilterService = __decorate([
|
|
436
|
-
Injectable()
|
|
437
|
-
], AdvancedFilterService);
|
|
438
|
-
|
|
439
|
-
class Filter {
|
|
440
|
-
constructor(type, required, label, domain, scope, name, contexts, services, value, enumItems, defaultValue, search, tabIndex, minValue, maxValue, dependsOn, mask, regExp) {
|
|
441
|
-
this.type = type;
|
|
442
|
-
this.required = required;
|
|
443
|
-
this.label = label;
|
|
444
|
-
this.domain = domain;
|
|
445
|
-
this.scope = scope;
|
|
446
|
-
this.name = name;
|
|
447
|
-
this.contexts = contexts;
|
|
448
|
-
this.services = services;
|
|
449
|
-
this.value = value;
|
|
450
|
-
this.enumItems = enumItems;
|
|
451
|
-
this.defaultValue = defaultValue;
|
|
452
|
-
this.search = search;
|
|
453
|
-
this.tabIndex = tabIndex;
|
|
454
|
-
this.minValue = minValue;
|
|
455
|
-
this.maxValue = maxValue;
|
|
456
|
-
this.dependsOn = dependsOn;
|
|
457
|
-
this.mask = mask;
|
|
458
|
-
this.regExp = regExp;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
var FilterType;
|
|
463
|
-
(function (FilterType) {
|
|
464
|
-
FilterType["STRING"] = "STRING";
|
|
465
|
-
FilterType["BOOLEAN"] = "BOOLEAN";
|
|
466
|
-
FilterType["INTEGER"] = "INTEGER";
|
|
467
|
-
FilterType["DOUBLE"] = "DOUBLE";
|
|
468
|
-
FilterType["DATE"] = "DATE";
|
|
469
|
-
FilterType["DATETIME"] = "DATETIME";
|
|
470
|
-
FilterType["TIME"] = "TIME";
|
|
471
|
-
FilterType["MONEY"] = "MONEY";
|
|
472
|
-
FilterType["ENUMERATION"] = "ENUMERATION";
|
|
473
|
-
FilterType["SEARCH"] = "SEARCH";
|
|
474
|
-
})(FilterType || (FilterType = {}));
|
|
475
|
-
|
|
476
|
-
var Scope;
|
|
477
|
-
(function (Scope) {
|
|
478
|
-
Scope["DOMAIN"] = "DOMAIN";
|
|
479
|
-
Scope["SERVICE"] = "SERVICE";
|
|
480
|
-
})(Scope || (Scope = {}));
|
|
481
|
-
|
|
482
|
-
class FormFilter {
|
|
483
|
-
constructor(_a) {
|
|
484
|
-
var { value } = _a, config = __rest(_a, ["value"]);
|
|
485
|
-
this._valueObserver = new Subject();
|
|
486
|
-
this.valueChanges = this._valueObserver.asObservable();
|
|
487
|
-
this._value = value;
|
|
488
|
-
Object.assign(this, config);
|
|
489
|
-
}
|
|
490
|
-
set value(value) {
|
|
491
|
-
this._value = value;
|
|
492
|
-
this._valueObserver.next(value);
|
|
493
|
-
}
|
|
494
|
-
get value() {
|
|
495
|
-
return this._value;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
class TabView {
|
|
500
|
-
constructor(config) {
|
|
501
|
-
this.fields = [];
|
|
502
|
-
this.form = new FormGroup({});
|
|
503
|
-
Object.assign(this, config);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
class ContextTab extends TabView {
|
|
507
|
-
constructor() {
|
|
508
|
-
super(...arguments);
|
|
509
|
-
this.activeFilters = 0;
|
|
510
|
-
}
|
|
511
|
-
get label() {
|
|
512
|
-
return `${this.name} (${this.activeFilters})`;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
const FILTER_ID_SEPARATOR = ':';
|
|
517
|
-
function getFilterId(domain, filterName) {
|
|
518
|
-
return `${domain}${FILTER_ID_SEPARATOR}${filterName}`;
|
|
519
|
-
}
|
|
520
|
-
function getTabId(domain, contextId) {
|
|
521
|
-
return `${domain}${FILTER_ID_SEPARATOR}${contextId}`;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
*@description Necessary because of https://github.com/rollup/rollup/issues/670
|
|
526
|
-
*
|
|
527
|
-
* */
|
|
528
|
-
const { DATETIME, TIME, DATE } = FilterType;
|
|
529
|
-
const parsers = {
|
|
530
|
-
[DATE]: (value) => dateParser(value, 'YYYY-MM-DD'),
|
|
531
|
-
[TIME]: (value) => dateParser(value, 'HH:mm:ss'),
|
|
532
|
-
[DATETIME]: (value) => dateParser(value)
|
|
533
|
-
};
|
|
534
|
-
function parseFilterValue(value, type) {
|
|
535
|
-
const parser = parsers[type];
|
|
536
|
-
if (value !== undefined && value !== null && value !== '') {
|
|
537
|
-
return parser ? parser(value) : value;
|
|
538
|
-
}
|
|
539
|
-
return value;
|
|
540
|
-
}
|
|
541
|
-
function dateParser(value, format) {
|
|
542
|
-
const date = moment(value);
|
|
543
|
-
return format ? date.format(format) : date.format();
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
function jsonPath(object, path) {
|
|
547
|
-
path = path.replace('$.', '');
|
|
548
|
-
const allPaths = path.split('.');
|
|
549
|
-
const currentPath = allPaths[0];
|
|
550
|
-
const value = object[currentPath];
|
|
551
|
-
allPaths.shift();
|
|
552
|
-
if (allPaths.length) {
|
|
553
|
-
return jsonPath(value, allPaths.join('.'));
|
|
554
|
-
}
|
|
555
|
-
return value;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
const ɵ0 = (attr, value) => `containing(${attr}, '${value}')`, ɵ1 = (attr, value) => `${attr} eq ${value}`, ɵ2 = (attr, value) => `${attr} ne ${value}`, ɵ3 = (attr, value) => `${attr} gt ${value}`, ɵ4 = (attr, value) => `${attr} lt ${value}`, ɵ5 = (attr, value) => `${attr} ge ${value}`;
|
|
559
|
-
const filterOperators = {
|
|
560
|
-
'contains': ɵ0,
|
|
561
|
-
'=': ɵ1,
|
|
562
|
-
'!=': ɵ2,
|
|
563
|
-
'>': ɵ3,
|
|
564
|
-
'<': ɵ4,
|
|
565
|
-
'>=': ɵ5
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
function toUserFormat(value, type) {
|
|
569
|
-
let parsedValue;
|
|
570
|
-
if (type !== FilterType.SEARCH || !Array.isArray(value)) {
|
|
571
|
-
parsedValue = [(value === null || value === undefined) ? '' : value];
|
|
572
|
-
}
|
|
573
|
-
else if (Array.isArray(value)) {
|
|
574
|
-
if (value.length) {
|
|
575
|
-
parsedValue = value[0] === null ? [''] : value;
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
578
|
-
parsedValue = [''];
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
else {
|
|
582
|
-
parsedValue = value ? value : [''];
|
|
583
|
-
}
|
|
584
|
-
return JSON.stringify(parsedValue);
|
|
585
|
-
}
|
|
586
|
-
function toFilterFormat(value, type) {
|
|
587
|
-
let parsedValue;
|
|
588
|
-
if (type !== FilterType.SEARCH) {
|
|
589
|
-
parsedValue = [(value === null || value === undefined) ? '' : value];
|
|
590
|
-
}
|
|
591
|
-
else if (Array.isArray(value)) {
|
|
592
|
-
/*
|
|
593
|
-
Deve enviar para o backend o valor contido no keyValue em array.
|
|
594
|
-
|
|
595
|
-
Exemplo:
|
|
596
|
-
Quando tenho dois objetos selecionados [{1,'Base'},{2,'Other'}] deve enviar no padrão: [1,'Base'], [2,'Other']
|
|
597
|
-
*/
|
|
598
|
-
parsedValue = [''];
|
|
599
|
-
if (value !== null && value.length > 0 && value[0] !== '') {
|
|
600
|
-
parsedValue = value.map(v => v[searchKeyName]);
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
else {
|
|
604
|
-
parsedValue = [value === null ? '' : value[searchKeyName]];
|
|
605
|
-
}
|
|
606
|
-
return JSON.stringify(parsedValue);
|
|
607
|
-
}
|
|
608
|
-
function fromJson(value, type, isNotMultiple) {
|
|
609
|
-
const parsedValue = JSON.parse(value);
|
|
610
|
-
if (type !== FilterType.SEARCH || isNotMultiple) {
|
|
611
|
-
return parsedValue[0];
|
|
612
|
-
}
|
|
613
|
-
return parsedValue;
|
|
614
|
-
}
|
|
615
|
-
function getSearchType(search) {
|
|
616
|
-
return search.basicSearch ? search.basicSearch : search.entitySearch;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
/**
|
|
620
|
-
*@description Necessary because of https://github.com/rollup/rollup/issues/670
|
|
621
|
-
*
|
|
622
|
-
* */
|
|
623
|
-
const { DATE: DATE$1, DATETIME: DATETIME$1, TIME: TIME$1 } = FilterType;
|
|
624
|
-
const parsers$1 = {
|
|
625
|
-
[DATE$1]: (v) => dateParser$1(v),
|
|
626
|
-
[DATETIME$1]: (v) => dateParser$1(v),
|
|
627
|
-
[TIME$1]: (v) => dateParser$1(v, 'HH:mm:ss')
|
|
628
|
-
};
|
|
629
|
-
function parseFormValue(value, type, search) {
|
|
630
|
-
const parser = parsers$1[type];
|
|
631
|
-
const parsedValue = JSON.parse(value);
|
|
632
|
-
const isNotMultiple = search && getSearchType(search).output.maxSelectedItems === 1;
|
|
633
|
-
let formValue;
|
|
634
|
-
if ((type === FilterType.INTEGER || type === FilterType.DOUBLE || type === FilterType.MONEY) && parsedValue[0] === '') {
|
|
635
|
-
formValue = null;
|
|
636
|
-
}
|
|
637
|
-
else if (type !== FilterType.SEARCH || isNotMultiple) {
|
|
638
|
-
formValue = parsedValue[0];
|
|
639
|
-
}
|
|
640
|
-
else {
|
|
641
|
-
formValue = parsedValue[0] ? parsedValue : [];
|
|
642
|
-
}
|
|
643
|
-
if (parser) {
|
|
644
|
-
return parser(formValue);
|
|
645
|
-
}
|
|
646
|
-
return formValue;
|
|
647
|
-
}
|
|
648
|
-
function createFormControl({ minValue, maxValue, regExp, value, type, search }) {
|
|
649
|
-
const validators = createValidators(minValue, maxValue, regExp);
|
|
650
|
-
const formValue = parseFormValue(value, type, search);
|
|
651
|
-
return new FormControl(formValue, { validators });
|
|
652
|
-
}
|
|
653
|
-
function createValidators(minValue, maxValue, regExp) {
|
|
654
|
-
const { pattern, min, max } = Validators;
|
|
655
|
-
const validators = [];
|
|
656
|
-
regExp && validators.push(pattern(regExp));
|
|
657
|
-
minValue !== undefined && validators.push(min(minValue));
|
|
658
|
-
maxValue !== undefined && validators.push(max(maxValue));
|
|
659
|
-
return validators;
|
|
660
|
-
}
|
|
661
|
-
function dateParser$1(value, format) {
|
|
662
|
-
return value !== null && value !== '' ? moment(value, format).toDate() : '';
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
const supportedTypes = [
|
|
666
|
-
FilterType.STRING,
|
|
667
|
-
FilterType.BOOLEAN,
|
|
668
|
-
FilterType.INTEGER,
|
|
669
|
-
FilterType.ENUMERATION,
|
|
670
|
-
FilterType.TIME,
|
|
671
|
-
FilterType.MONEY,
|
|
672
|
-
FilterType.DATETIME,
|
|
673
|
-
FilterType.DATE,
|
|
674
|
-
FilterType.DOUBLE
|
|
675
|
-
];
|
|
676
|
-
const ɵ0$1 = (value, otherValue) => {
|
|
677
|
-
return value > otherValue;
|
|
678
|
-
}, ɵ1$1 = (value, otherValue) => {
|
|
679
|
-
return value < otherValue;
|
|
680
|
-
}, ɵ2$1 = (value, otherValue) => {
|
|
681
|
-
return value >= otherValue;
|
|
682
|
-
}, ɵ3$1 = (value, otherValue) => {
|
|
683
|
-
return value <= otherValue;
|
|
684
|
-
}, ɵ4$1 = (value, otherValue) => {
|
|
685
|
-
return contains(value, otherValue);
|
|
686
|
-
}, ɵ5$1 = (value, otherValue) => {
|
|
687
|
-
if (typeof otherValue === 'number') {
|
|
688
|
-
return equals(Number(value), otherValue);
|
|
689
|
-
}
|
|
690
|
-
return equals(value, otherValue);
|
|
691
|
-
}, ɵ6 = (value, otherValue) => {
|
|
692
|
-
if (typeof otherValue === 'number') {
|
|
693
|
-
return !equals(Number(value), otherValue);
|
|
694
|
-
}
|
|
695
|
-
return !equals(value, otherValue);
|
|
696
|
-
};
|
|
697
|
-
const operation = {
|
|
698
|
-
'>': ɵ0$1,
|
|
699
|
-
'<': ɵ1$1,
|
|
700
|
-
'>=': ɵ2$1,
|
|
701
|
-
'<=': ɵ3$1,
|
|
702
|
-
'contains': ɵ4$1,
|
|
703
|
-
'=': ɵ5$1,
|
|
704
|
-
'!=': ɵ6
|
|
705
|
-
};
|
|
706
|
-
function compare(operator, value, otherValue) {
|
|
707
|
-
const comparator = operation[operator];
|
|
708
|
-
return comparator(value, otherValue);
|
|
709
|
-
}
|
|
710
|
-
function isValidOperator(operator) {
|
|
711
|
-
return !!operation[operator];
|
|
712
|
-
}
|
|
713
|
-
function isSupportedType(type) {
|
|
714
|
-
return contains(type, supportedTypes);
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
const TRANSLATE_PREFIX = 'platform.filter_service';
|
|
718
|
-
let CalendarOptionsService = class CalendarOptionsService {
|
|
719
|
-
constructor(translate) {
|
|
720
|
-
this.translate = translate;
|
|
721
|
-
}
|
|
722
|
-
getOptions() {
|
|
723
|
-
return {
|
|
724
|
-
clear: this.translate.instant(`${TRANSLATE_PREFIX}.clear`),
|
|
725
|
-
dateFormat: this.translate.instant(`${TRANSLATE_PREFIX}.date_format`),
|
|
726
|
-
dayNames: [
|
|
727
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_sunday`),
|
|
728
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_monday`),
|
|
729
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_tuesday`),
|
|
730
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_wednesday`),
|
|
731
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_thursday`),
|
|
732
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_friday`),
|
|
733
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_saturday`)
|
|
734
|
-
],
|
|
735
|
-
dayNamesMin: [
|
|
736
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.min_sunday`),
|
|
737
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.min_monday`),
|
|
738
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.min_tuesday`),
|
|
739
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.min_wednesday`),
|
|
740
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.min_thursday`),
|
|
741
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.min_friday`),
|
|
742
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.min_saturday`)
|
|
743
|
-
],
|
|
744
|
-
dayNamesShort: [
|
|
745
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_sunday`),
|
|
746
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_monday`),
|
|
747
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_tuesday`),
|
|
748
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_wednesday`),
|
|
749
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_thursday`),
|
|
750
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_friday`),
|
|
751
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_saturday`)
|
|
752
|
-
],
|
|
753
|
-
firstDayOfWeek: 0,
|
|
754
|
-
hourFormat: this.translate.instant(`${TRANSLATE_PREFIX}.hour_format`),
|
|
755
|
-
monthNames: [
|
|
756
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_january`),
|
|
757
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_february`),
|
|
758
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_march`),
|
|
759
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_april`),
|
|
760
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_may`),
|
|
761
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_june`),
|
|
762
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_july`),
|
|
763
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_august`),
|
|
764
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_september`),
|
|
765
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_october`),
|
|
766
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_november`),
|
|
767
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.name_december`),
|
|
768
|
-
],
|
|
769
|
-
monthNamesShort: [
|
|
770
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_january`),
|
|
771
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_february`),
|
|
772
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_march`),
|
|
773
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_april`),
|
|
774
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_may`),
|
|
775
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_june`),
|
|
776
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_july`),
|
|
777
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_august`),
|
|
778
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_september`),
|
|
779
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_october`),
|
|
780
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_november`),
|
|
781
|
-
this.translate.instant(`${TRANSLATE_PREFIX}.short_december`),
|
|
782
|
-
],
|
|
783
|
-
today: this.translate.instant(`${TRANSLATE_PREFIX}.today`)
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
};
|
|
787
|
-
CalendarOptionsService.ctorParameters = () => [
|
|
788
|
-
{ type: TranslateService }
|
|
789
|
-
];
|
|
790
|
-
CalendarOptionsService = __decorate([
|
|
791
|
-
Injectable()
|
|
792
|
-
], CalendarOptionsService);
|
|
793
|
-
|
|
794
|
-
const TRANSLATE_PREFIX$1 = 'platform.filter_service';
|
|
795
|
-
const TOAST_LIFE = 5000;
|
|
796
|
-
let FormFilterComponent = class FormFilterComponent {
|
|
797
|
-
constructor(filterService, translate, messageService, calendarOptionsService, changeDetectorRef) {
|
|
798
|
-
this.filterService = filterService;
|
|
799
|
-
this.translate = translate;
|
|
800
|
-
this.messageService = messageService;
|
|
801
|
-
this.calendarOptionsService = calendarOptionsService;
|
|
802
|
-
this.changeDetectorRef = changeDetectorRef;
|
|
803
|
-
this.destroy$ = new Subject();
|
|
804
|
-
this.contexts = [];
|
|
805
|
-
this.formFilters = [];
|
|
806
|
-
this.oldFormFilters = [];
|
|
807
|
-
this.actualFormFilters = [];
|
|
808
|
-
this.general = new TabView({ name: 'Geral' });
|
|
809
|
-
this.totalFiltersActive = 0;
|
|
810
|
-
this.isMobile = false;
|
|
811
|
-
this.tabViewOrientation = 'left';
|
|
812
|
-
this.error = false;
|
|
813
|
-
this.errorMessages = {
|
|
814
|
-
min: this.translate.instant(`${TRANSLATE_PREFIX$1}.error_min_value`),
|
|
815
|
-
max: this.translate.instant(`${TRANSLATE_PREFIX$1}.error_max_value`),
|
|
816
|
-
pattern: this.translate.instant(`${TRANSLATE_PREFIX$1}.invalid_pattern`)
|
|
817
|
-
};
|
|
818
|
-
this.showMessages = true;
|
|
819
|
-
this.isModal = false;
|
|
820
|
-
this.contextId = '';
|
|
821
|
-
this.totalFiltersActiveOutput = new EventEmitter();
|
|
822
|
-
this.errorOutput = new EventEmitter();
|
|
823
|
-
this.showDialogOutput = new EventEmitter();
|
|
824
|
-
this.closeModalOutput = new EventEmitter();
|
|
825
|
-
}
|
|
826
|
-
onResizeWindow(event) {
|
|
827
|
-
const { innerWidth } = event.target;
|
|
828
|
-
this.isMobile = innerWidth <= 640;
|
|
829
|
-
this.tabViewOrientation = this.isMobile ? 'top' : 'left';
|
|
830
|
-
}
|
|
831
|
-
ngOnInit() {
|
|
832
|
-
this.isMobile = innerWidth <= 640;
|
|
833
|
-
this.tabViewOrientation = this.isMobile ? 'top' : 'left';
|
|
834
|
-
this.subscribeContextsObservable();
|
|
835
|
-
this.subscribeFiltersObservable();
|
|
836
|
-
window.addEventListener('message', event => {
|
|
837
|
-
const data = event.data;
|
|
838
|
-
const message = data.message && data.message.split(':')[1];
|
|
839
|
-
if (message === 'addContext') {
|
|
840
|
-
this.filterService.addContexts(...data.payload);
|
|
841
|
-
}
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
ngOnDestroy() {
|
|
845
|
-
this.destroy$.next(true);
|
|
846
|
-
}
|
|
847
|
-
hasChanges() {
|
|
848
|
-
const keys = Object.keys(this.formFilters);
|
|
849
|
-
const oldKeys = Object.keys(this.oldFormFilters);
|
|
850
|
-
if (!oldKeys.length) {
|
|
851
|
-
return true;
|
|
852
|
-
}
|
|
853
|
-
const filtered = keys.filter(key => {
|
|
854
|
-
const currentValue = this.formFilters[key].value;
|
|
855
|
-
const oldValue = this.oldFormFilters[key] && this.oldFormFilters[key].value;
|
|
856
|
-
return !equals(currentValue, oldValue);
|
|
857
|
-
});
|
|
858
|
-
return filtered.length > 0;
|
|
859
|
-
}
|
|
860
|
-
onApplyFilters() {
|
|
861
|
-
this.hasChanges() && this.closeModalOutput.emit();
|
|
862
|
-
}
|
|
863
|
-
getFilters() {
|
|
864
|
-
this.hasChanges() && this.filterService.tryAgain(this.contexts);
|
|
865
|
-
}
|
|
866
|
-
applyFilters(showToast = false) {
|
|
867
|
-
if (this.hasChanges()) {
|
|
868
|
-
this.showDialogOutput.emit(false);
|
|
869
|
-
this.counterUpdate();
|
|
870
|
-
const filters = this.getFiltersValues(this.formFilters);
|
|
871
|
-
this.filterService.saveTickedFilters(filters);
|
|
872
|
-
}
|
|
873
|
-
else if (showToast) {
|
|
874
|
-
const message = {
|
|
875
|
-
key: 'filterServiceToastKey',
|
|
876
|
-
severity: 'info',
|
|
877
|
-
life: TOAST_LIFE,
|
|
878
|
-
detail: this.translate.instant(`${TRANSLATE_PREFIX$1}.applied_filter_nochange`, { activeFilters: this.totalFiltersActive })
|
|
879
|
-
};
|
|
880
|
-
this.sendMessage(message);
|
|
881
|
-
}
|
|
882
|
-
this.oldFormFilters = clone(this.formFilters);
|
|
883
|
-
}
|
|
884
|
-
getDefaultValue(defaultValue, isMultiple) {
|
|
885
|
-
if (defaultValue === undefined || (isMultiple && defaultValue[0] === '')) {
|
|
886
|
-
return [];
|
|
887
|
-
}
|
|
888
|
-
return defaultValue;
|
|
889
|
-
}
|
|
890
|
-
clearFilters() {
|
|
891
|
-
const keys = Object.keys(this.formFilters);
|
|
892
|
-
keys.forEach(key => this.cleanFieldAndSetDefaultValue(key));
|
|
893
|
-
}
|
|
894
|
-
sendCloseMessage() {
|
|
895
|
-
window.parent.postMessage({
|
|
896
|
-
message: 'dashboard:close-modal',
|
|
897
|
-
payload: {
|
|
898
|
-
modalName: 'advanced-filter-1'
|
|
899
|
-
}
|
|
900
|
-
}, '*');
|
|
901
|
-
}
|
|
902
|
-
sendMessage(message) {
|
|
903
|
-
if (this.showMessages) {
|
|
904
|
-
this.messageService.add(message);
|
|
905
|
-
}
|
|
906
|
-
else {
|
|
907
|
-
window.parent.postMessage({
|
|
908
|
-
message: 'dashboard:toastr',
|
|
909
|
-
payload: {
|
|
910
|
-
type: 'success',
|
|
911
|
-
message: message.detail
|
|
912
|
-
}
|
|
913
|
-
}, '*');
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
saveFilters(forceSave = false) {
|
|
917
|
-
const filters = this.parseToUserFilters(this.formFilters);
|
|
918
|
-
const savedFilterSuccess = () => {
|
|
919
|
-
if (!forceSave) {
|
|
920
|
-
const message = {
|
|
921
|
-
key: 'filterServiceToastKey',
|
|
922
|
-
severity: 'info',
|
|
923
|
-
life: TOAST_LIFE,
|
|
924
|
-
detail: this.translate.instant(`${TRANSLATE_PREFIX$1}.saved_filters_success`, { activeFilters: this.totalFiltersActive })
|
|
925
|
-
};
|
|
926
|
-
this.sendMessage(message);
|
|
927
|
-
}
|
|
928
|
-
this.counterUpdate();
|
|
929
|
-
};
|
|
930
|
-
const savedFiltersError = () => {
|
|
931
|
-
const message = {
|
|
932
|
-
key: 'filterServiceToastKey',
|
|
933
|
-
severity: 'error',
|
|
934
|
-
life: TOAST_LIFE,
|
|
935
|
-
detail: this.translate.instant(`${TRANSLATE_PREFIX$1}.saved_filters_error`, { activeFilters: this.totalFiltersActive })
|
|
936
|
-
};
|
|
937
|
-
this.sendMessage(message);
|
|
938
|
-
};
|
|
939
|
-
this.filterService
|
|
940
|
-
.saveFilters(filters)
|
|
941
|
-
.subscribe(savedFilterSuccess, savedFiltersError);
|
|
942
|
-
}
|
|
943
|
-
saveFiltersWithCallbackFunction(callbackFunction) {
|
|
944
|
-
const filters = this.parseToUserFilters(this.formFilters);
|
|
945
|
-
this.filterService
|
|
946
|
-
.saveFilters(filters)
|
|
947
|
-
.subscribe(callbackFunction);
|
|
948
|
-
}
|
|
949
|
-
counterUpdate() {
|
|
950
|
-
this.totalFiltersActive = this.countActiveFilters(this.tabs);
|
|
951
|
-
this.totalFiltersActiveOutput.emit(this.totalFiltersActive);
|
|
952
|
-
}
|
|
953
|
-
countActiveFilters(tabs) {
|
|
954
|
-
let totalFiltersActive = 0;
|
|
955
|
-
tabs.forEach(tabView => {
|
|
956
|
-
const { value } = tabView.form;
|
|
957
|
-
tabView.activeFilters = Object.keys(value).reduce((appliedFilters, key) => {
|
|
958
|
-
const filterValue = value[key];
|
|
959
|
-
const isArray = Array.isArray(filterValue);
|
|
960
|
-
const isValidArray = isArray && filterValue.length > 0;
|
|
961
|
-
if (isValidArray || (!isArray && filterValue)) {
|
|
962
|
-
appliedFilters++;
|
|
963
|
-
}
|
|
964
|
-
return appliedFilters;
|
|
965
|
-
}, 0);
|
|
966
|
-
totalFiltersActive += tabView.activeFilters;
|
|
967
|
-
});
|
|
968
|
-
return totalFiltersActive;
|
|
969
|
-
}
|
|
970
|
-
parseToUserFilters(filters) {
|
|
971
|
-
const ids = Object.keys(filters);
|
|
972
|
-
return ids.reduce((all, filterId) => {
|
|
973
|
-
const { type, services, name, value, domain, contexts } = filters[filterId];
|
|
974
|
-
const filterValue = toUserFormat(value, type);
|
|
975
|
-
const values = services.map(service => ({ name, service, value: filterValue, domain, contexts }));
|
|
976
|
-
return [...all, ...values];
|
|
977
|
-
}, []);
|
|
978
|
-
}
|
|
979
|
-
getFiltersValues(filters) {
|
|
980
|
-
const ids = Object.keys(filters);
|
|
981
|
-
return ids.reduce((all, filterId) => {
|
|
982
|
-
const { type, services, name, value, domain } = filters[filterId];
|
|
983
|
-
const filterValue = toFilterFormat(value, type);
|
|
984
|
-
const values = services.map(service => ({ name, service, value: filterValue, domain }));
|
|
985
|
-
return [...all, ...values];
|
|
986
|
-
}, []);
|
|
987
|
-
}
|
|
988
|
-
subscribeContextsObservable() {
|
|
989
|
-
const { contextsObserver } = this.filterService;
|
|
990
|
-
contextsObserver.pipe(takeUntil(this.destroy$)).subscribe((contexts) => (this.contexts = contexts));
|
|
991
|
-
}
|
|
992
|
-
errorStateAction() {
|
|
993
|
-
this.filterService.tryAgain(this.contexts);
|
|
994
|
-
}
|
|
995
|
-
subscribeFiltersObservable() {
|
|
996
|
-
const { filtersObserver } = this.filterService;
|
|
997
|
-
filtersObserver
|
|
998
|
-
.pipe(takeUntil(this.destroy$))
|
|
999
|
-
.subscribe(({ filters, applyFilter, error, message }) => {
|
|
1000
|
-
this.errorOutput.emit(error);
|
|
1001
|
-
this.error = error;
|
|
1002
|
-
this.errorState = message;
|
|
1003
|
-
if (!error) {
|
|
1004
|
-
this.createForm(filters, applyFilter);
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
createForm(filters, applyFilter) {
|
|
1009
|
-
this.tabs = this.createTabs(filters);
|
|
1010
|
-
this.counterUpdate();
|
|
1011
|
-
this.setDependencies(this.formFilters);
|
|
1012
|
-
this.createChildArray();
|
|
1013
|
-
if (filters.length > 0 && applyFilter) {
|
|
1014
|
-
this.applyFilters();
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
setDependencies(filters) {
|
|
1018
|
-
const names = Object.keys(filters);
|
|
1019
|
-
const dependencies = from(names).pipe(map(key => filters[key]), filter(({ dependsOn }) => dependsOn && dependsOn.length > 0), tap(({ dependsOn, domain, filterControl }) => {
|
|
1020
|
-
const invalidFilters = dependsOn
|
|
1021
|
-
.filter(dep => dep.required)
|
|
1022
|
-
.filter(dep => {
|
|
1023
|
-
const id = getFilterId(domain, dep.filterName);
|
|
1024
|
-
const formFilter = filters[id];
|
|
1025
|
-
const { value, type } = formFilter;
|
|
1026
|
-
const { comparator } = dep;
|
|
1027
|
-
if (comparator && isValidOperator(comparator.operator) && isSupportedType(type)) {
|
|
1028
|
-
const fieldValue = parseFilterValue(value, type);
|
|
1029
|
-
return !compare(comparator.operator, comparator.value, fieldValue);
|
|
1030
|
-
}
|
|
1031
|
-
return dep.required ? !formFilter.value : formFilter.value;
|
|
1032
|
-
});
|
|
1033
|
-
if (invalidFilters.length > 0) {
|
|
1034
|
-
filterControl.disable();
|
|
1035
|
-
}
|
|
1036
|
-
}), map(({ domain, dependsOn, filterControl }) => ({ domain, dependsOn, filterControl })));
|
|
1037
|
-
dependencies.subscribe(({ dependsOn, domain, filterControl }) => from(dependsOn)
|
|
1038
|
-
.pipe(filter(dep => dep.required), map(({ filterName }) => getFilterId(domain, filterName)), map(filterId => filters[filterId]), mergeMap(formFilter => from(formFilter.valueChanges)), map(val => {
|
|
1039
|
-
const comparation = dependsOn.every(dep => {
|
|
1040
|
-
const filterId = getFilterId(domain, dep.filterName);
|
|
1041
|
-
if (this.formFilters[filterId]) {
|
|
1042
|
-
const type = this.formFilters[filterId].type;
|
|
1043
|
-
const { comparator } = dep;
|
|
1044
|
-
if (comparator && isValidOperator(comparator.operator) && isSupportedType(type)) {
|
|
1045
|
-
const value = parseFilterValue(val, type);
|
|
1046
|
-
return compare(comparator.operator, comparator.value, value);
|
|
1047
|
-
}
|
|
1048
|
-
return true;
|
|
1049
|
-
}
|
|
1050
|
-
});
|
|
1051
|
-
return !this.IsEmpty(val) && comparation ? 'enable' : 'disable';
|
|
1052
|
-
}))
|
|
1053
|
-
.subscribe(status => filterControl[status]()));
|
|
1054
|
-
}
|
|
1055
|
-
addGeneralField(filter) {
|
|
1056
|
-
const { name, domain, type } = filter;
|
|
1057
|
-
const controlName = getFilterId(domain, name);
|
|
1058
|
-
const fieldControl = createFormControl(filter);
|
|
1059
|
-
fieldControl.valueChanges
|
|
1060
|
-
.pipe(takeUntil(this.destroy$), map(v => parseFilterValue(v, type)), tap(value => (this.formFilters[controlName].value = value)))
|
|
1061
|
-
.subscribe(val => this.tabs.forEach(tab => {
|
|
1062
|
-
const control = tab.form.controls[name];
|
|
1063
|
-
if (control && tab.domain === domain) {
|
|
1064
|
-
control.setValue(val, { emitEvent: false });
|
|
1065
|
-
}
|
|
1066
|
-
}));
|
|
1067
|
-
const newFilter = Object.assign(Object.assign({}, filter), { name: controlName });
|
|
1068
|
-
const newField = this.createField(newFilter);
|
|
1069
|
-
this.general.form.addControl(controlName, fieldControl);
|
|
1070
|
-
this.general.fields.push(newField);
|
|
1071
|
-
}
|
|
1072
|
-
/*
|
|
1073
|
-
* Verifica os contextos de cada filtro, caso todos os contextos foram informados:
|
|
1074
|
-
* @return true
|
|
1075
|
-
* Caso não tenha nenhum contexto, considera-se por padrão que é todos:
|
|
1076
|
-
* @return true
|
|
1077
|
-
*/
|
|
1078
|
-
containsAllContexts(myContexts) {
|
|
1079
|
-
if (!myContexts.length) {
|
|
1080
|
-
return true;
|
|
1081
|
-
}
|
|
1082
|
-
const allContexts = this.contexts.map(data => data.contextId);
|
|
1083
|
-
return equals(myContexts.sort(), allContexts.sort());
|
|
1084
|
-
}
|
|
1085
|
-
/**
|
|
1086
|
-
*
|
|
1087
|
-
* @todo Refatorar. O método possui muitas responsabilidades
|
|
1088
|
-
*
|
|
1089
|
-
*/
|
|
1090
|
-
createTabs(filters) {
|
|
1091
|
-
return filters.reduce((tabs, filter) => {
|
|
1092
|
-
const { domain, services, name, type, scope, contexts, dependsOn, value, search, defaultValue } = filter;
|
|
1093
|
-
const isNotMultiple = search && getSearchType(search).output.maxSelectedItems === 1;
|
|
1094
|
-
const field = this.createField(filter);
|
|
1095
|
-
const filterId = getFilterId(domain, name);
|
|
1096
|
-
const filterConfig = {
|
|
1097
|
-
domain,
|
|
1098
|
-
contexts,
|
|
1099
|
-
services,
|
|
1100
|
-
name,
|
|
1101
|
-
dependsOn,
|
|
1102
|
-
value: fromJson(value, type, isNotMultiple),
|
|
1103
|
-
type,
|
|
1104
|
-
isMultiple: !isNotMultiple,
|
|
1105
|
-
defaultValue: fromJson(defaultValue, type, isNotMultiple)
|
|
1106
|
-
};
|
|
1107
|
-
this.formFilters[filterId] = new FormFilter(filterConfig);
|
|
1108
|
-
const formFilter = this.formFilters[filterId];
|
|
1109
|
-
if (scope === Scope.DOMAIN && this.containsAllContexts(contexts)) {
|
|
1110
|
-
this.addGeneralField(filter);
|
|
1111
|
-
}
|
|
1112
|
-
contexts.forEach(contextId => {
|
|
1113
|
-
if ((contextId === this.contextId) || (this.contextId === '')) {
|
|
1114
|
-
const tabId = getTabId(domain, contextId);
|
|
1115
|
-
const fieldControl = createFormControl(filter);
|
|
1116
|
-
if (!tabs.has(tabId)) {
|
|
1117
|
-
const { contextLabel } = this.contexts.find(context => context.contextId === contextId);
|
|
1118
|
-
const tab = new ContextTab({ domain, name: contextLabel });
|
|
1119
|
-
tabs.set(tabId, tab);
|
|
1120
|
-
}
|
|
1121
|
-
fieldControl.valueChanges
|
|
1122
|
-
.pipe(takeUntil(this.destroy$))
|
|
1123
|
-
.subscribe((val) => this.updateFilterValue(tabId, name, val, domain, type));
|
|
1124
|
-
const contextTab = tabs.get(tabId);
|
|
1125
|
-
contextTab.fields.push(field);
|
|
1126
|
-
contextTab.form.addControl(filter.name, fieldControl);
|
|
1127
|
-
if (!formFilter.filterControl) {
|
|
1128
|
-
formFilter.filterControl = fieldControl;
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
});
|
|
1132
|
-
return tabs;
|
|
1133
|
-
}, new Map());
|
|
1134
|
-
}
|
|
1135
|
-
updateFilterValue(tabId, filterName, value, domain, type) {
|
|
1136
|
-
const controlOpts = { emitEvent: false };
|
|
1137
|
-
const fieldValue = parseFilterValue(value, type);
|
|
1138
|
-
const filterId = getFilterId(domain, filterName);
|
|
1139
|
-
const generalFieldControl = this.general.form.controls[filterId];
|
|
1140
|
-
this.tabs.forEach(({ form }, key) => {
|
|
1141
|
-
const control = form.controls[filterName];
|
|
1142
|
-
if (tabId !== key && control) {
|
|
1143
|
-
control.setValue(value, controlOpts);
|
|
1144
|
-
}
|
|
1145
|
-
});
|
|
1146
|
-
const { childs } = this.formFilters[filterId];
|
|
1147
|
-
childs && childs.forEach((child) => this.cleanFieldAndSetDefaultValue(child.filter.key));
|
|
1148
|
-
generalFieldControl && generalFieldControl.setValue(value, controlOpts);
|
|
1149
|
-
this.formFilters[filterId].value = fieldValue;
|
|
1150
|
-
}
|
|
1151
|
-
cleanFieldAndSetDefaultValue(key) {
|
|
1152
|
-
const { isMultiple, defaultValue, filterControl, type } = this.formFilters[key];
|
|
1153
|
-
const finalValue = this.getDefaultValue(defaultValue, isMultiple);
|
|
1154
|
-
if (filterControl) {
|
|
1155
|
-
if (type === 'DATE' || (type === 'SEARCH' && isMultiple)) {
|
|
1156
|
-
filterControl.setValue(finalValue);
|
|
1157
|
-
}
|
|
1158
|
-
if (type === 'INTEGER' || type === 'DOUBLE' || type === 'MONEY') {
|
|
1159
|
-
finalValue === '' ? filterControl.setValue(null) : filterControl.setValue(finalValue);
|
|
1160
|
-
}
|
|
1161
|
-
else {
|
|
1162
|
-
filterControl.setValue(finalValue, { onlySelf: true });
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
createChildArray() {
|
|
1167
|
-
const keys = Object.keys(this.formFilters);
|
|
1168
|
-
keys.forEach(key => {
|
|
1169
|
-
const { dependsOn, domain } = this.formFilters[key];
|
|
1170
|
-
dependsOn.forEach((field) => {
|
|
1171
|
-
const filterId = getFilterId(domain, field.filterName);
|
|
1172
|
-
if (this.formFilters[filterId]) {
|
|
1173
|
-
if (!this.formFilters[filterId].childs) {
|
|
1174
|
-
this.formFilters[filterId].childs = [];
|
|
1175
|
-
}
|
|
1176
|
-
this.formFilters[filterId].childs.push({ filter: { key, required: field.required } });
|
|
1177
|
-
}
|
|
1178
|
-
});
|
|
1179
|
-
});
|
|
1180
|
-
}
|
|
1181
|
-
createField(filter) {
|
|
1182
|
-
const { name, label, enumItems, type, mask } = filter;
|
|
1183
|
-
const translatedEnumItems = enumItems && enumItems.map((item) => ({ label: this.translate.instant(item.label), value: item.value }));
|
|
1184
|
-
const field = { name, label: this.translate.instant(label), placeholder: '' };
|
|
1185
|
-
const creators = {
|
|
1186
|
-
[FilterType.STRING]: () => new TextField(Object.assign(Object.assign({}, field), { mask: mask ? () => mask : null, type: FieldType.String })),
|
|
1187
|
-
[FilterType.MONEY]: () => new CurrencyField(Object.assign(Object.assign({}, field), { type: FieldType.Money })),
|
|
1188
|
-
[FilterType.BOOLEAN]: () => this.createRadioButton(Object.assign({}, field)),
|
|
1189
|
-
[FilterType.DATE]: () => this.createCalendar(Object.assign(Object.assign({}, field), { type: FieldType.Date })),
|
|
1190
|
-
[FilterType.DATETIME]: () => this.createCalendar(Object.assign(Object.assign({}, field), { type: FieldType.DateTime })),
|
|
1191
|
-
[FilterType.TIME]: () => this.createCalendar(Object.assign(Object.assign({}, field), { type: FieldType.Time })),
|
|
1192
|
-
[FilterType.ENUMERATION]: () => new SelectField(Object.assign(Object.assign({}, field), { placeholder: this.translate.instant('platform.filter_service.select'), options: [...translatedEnumItems], type: FieldType.Enum })),
|
|
1193
|
-
[FilterType.INTEGER]: () => new NumberField(Object.assign(Object.assign({}, field), { numberLocaleOptions: this.optionsInteger(), mask: mask ? () => mask : null, type: FieldType.Integer })),
|
|
1194
|
-
[FilterType.DOUBLE]: () => new CurrencyField(Object.assign(Object.assign({}, field), { type: FieldType.Double })),
|
|
1195
|
-
[FilterType.SEARCH]: () => this.createAutocompleteField(field, filter)
|
|
1196
|
-
};
|
|
1197
|
-
return creators[type]();
|
|
1198
|
-
}
|
|
1199
|
-
createRadioButton(field) {
|
|
1200
|
-
const options = [
|
|
1201
|
-
{ label: this.translate.instant(`${TRANSLATE_PREFIX$1}.yes`), value: true },
|
|
1202
|
-
{ label: this.translate.instant(`${TRANSLATE_PREFIX$1}.no`), value: false }
|
|
1203
|
-
];
|
|
1204
|
-
return new RadioButtonField(Object.assign(Object.assign({}, field), { type: FieldType.Radio, options }));
|
|
1205
|
-
}
|
|
1206
|
-
createCalendar(config) {
|
|
1207
|
-
const calendar = new CalendarField(config);
|
|
1208
|
-
calendar.calendarLocaleOptions = this.calendarOptionsService.getOptions();
|
|
1209
|
-
if (!this.isModal)
|
|
1210
|
-
calendar.appendTo = 'body';
|
|
1211
|
-
return calendar;
|
|
1212
|
-
}
|
|
1213
|
-
createAutocompleteField(field, { dependsOn, search, domain, name }) {
|
|
1214
|
-
const suggestionsObservable = new BehaviorSubject$1([]);
|
|
1215
|
-
const { queryParam } = getSearchType(search).input;
|
|
1216
|
-
const { displayFields, keyFields, resultDataJsonPath, displayFieldConcatToken, maxSelectedItems } = getSearchType(search).output;
|
|
1217
|
-
const filterId = getFilterId(domain, name);
|
|
1218
|
-
const suggestionsError = (messageError) => {
|
|
1219
|
-
const messageDetail = messageError ? messageError : this.translate.instant(`${TRANSLATE_PREFIX$1}.find_suggestions_error`, { activeFilters: this.totalFiltersActive });
|
|
1220
|
-
const message = {
|
|
1221
|
-
key: 'filterServiceToastKey',
|
|
1222
|
-
severity: 'error',
|
|
1223
|
-
life: TOAST_LIFE,
|
|
1224
|
-
detail: messageDetail
|
|
1225
|
-
};
|
|
1226
|
-
this.sendMessage(message);
|
|
1227
|
-
};
|
|
1228
|
-
const onSearch = (val) => {
|
|
1229
|
-
const params = { [queryParam]: val };
|
|
1230
|
-
dependsOn && Object.assign(params, this.getDependenciesValues(dependsOn, domain));
|
|
1231
|
-
const searchUrl = search && search.type === 'ENTITY'
|
|
1232
|
-
? this.getEntitySearchUrl(search.entitySearch.input, val, dependsOn)
|
|
1233
|
-
: getSearchType(search).input.url;
|
|
1234
|
-
this.filterService
|
|
1235
|
-
.searchFieldSuggestions(searchUrl, params, search.type)
|
|
1236
|
-
.pipe(map(response => jsonPath(response, resultDataJsonPath)), map((suggestions) => this.addSuggestionFields(suggestions, displayFields, keyFields, displayFieldConcatToken, filterId)))
|
|
1237
|
-
.subscribe(result => {
|
|
1238
|
-
suggestionsObservable.next(result);
|
|
1239
|
-
this.changeDetectorRef.detectChanges();
|
|
1240
|
-
}, (error) => {
|
|
1241
|
-
let messageError = undefined;
|
|
1242
|
-
if (error && error.error.message)
|
|
1243
|
-
messageError = error.error.message;
|
|
1244
|
-
suggestionsError(messageError);
|
|
1245
|
-
});
|
|
1246
|
-
};
|
|
1247
|
-
return new AutocompleteField(Object.assign(Object.assign({}, field), { onSearch, appendTo: 'body', suggestionsObservable, displayField: searchDisplayName, dataKey: searchKeyName, multiple: maxSelectedItems > 1, size: { lg: 12, md: 12, xl: 12 }, emptyMessage: this.translate.instant(`${TRANSLATE_PREFIX$1}.search_empty_message`) }));
|
|
1248
|
-
}
|
|
1249
|
-
getEntitySearchUrl(search, value, dependsOn) {
|
|
1250
|
-
const { attributes, domainName, entityName, serviceName } = search;
|
|
1251
|
-
const url = `${domainName}/${serviceName}/entities/${entityName}/?filter=`;
|
|
1252
|
-
const filters = attributes.map(attr => filterOperators[attr.comparator](attr.name, value));
|
|
1253
|
-
dependsOn &&
|
|
1254
|
-
dependsOn.forEach(obj => {
|
|
1255
|
-
const filterId = getFilterId(domainName, obj.filterName);
|
|
1256
|
-
const fieldValue = this.formFilters[filterId].value[searchKeyName];
|
|
1257
|
-
filters.push(`${obj.entityAttribute} eq '${fieldValue}'`);
|
|
1258
|
-
});
|
|
1259
|
-
// O regex apenas seleciona as virgulas ignorando as que estiverem dentro do ()
|
|
1260
|
-
return url.concat(filters).replace(/[,]+(?![^(]*[)])/g, ` ${search.operator} `);
|
|
1261
|
-
}
|
|
1262
|
-
addSuggestionFields(suggestions, displayFields, keyFields, separator, filterId) {
|
|
1263
|
-
const addValue = (acc, value, token) => (acc ? `${acc}${token}${value}` : value);
|
|
1264
|
-
const result = suggestions.map(suggestion => (Object.assign(Object.assign({}, suggestion), { [searchDisplayName]: displayFields.reduce((value, display) => {
|
|
1265
|
-
return addValue(value, this.translate.instant(suggestion[display]), separator);
|
|
1266
|
-
}, ''), [searchKeyName]: keyFields.reduce((value, key) => addValue(value, suggestion[key], ', '), '') })));
|
|
1267
|
-
this.formFilters[filterId].invalidValue = result.length === 0;
|
|
1268
|
-
return result.filter(item => {
|
|
1269
|
-
const { value } = this.formFilters[filterId];
|
|
1270
|
-
if (Array.isArray(value)) {
|
|
1271
|
-
const index = value.findIndex((i) => i.$$__keyValue__ === item.$$__keyValue__);
|
|
1272
|
-
if (index === -1) {
|
|
1273
|
-
return item;
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
else {
|
|
1277
|
-
return item;
|
|
1278
|
-
}
|
|
1279
|
-
});
|
|
1280
|
-
}
|
|
1281
|
-
getDependenciesValues(dependencies, domain) {
|
|
1282
|
-
return dependencies.reduce((params, { filterName }) => {
|
|
1283
|
-
const filterId = getFilterId(domain, filterName);
|
|
1284
|
-
if (this.formFilters[filterId]) {
|
|
1285
|
-
const { value, type } = this.formFilters[filterId];
|
|
1286
|
-
if (type === 'ENUMERATION') {
|
|
1287
|
-
params[filterName] = value;
|
|
1288
|
-
}
|
|
1289
|
-
else {
|
|
1290
|
-
if (Array.isArray(value)) {
|
|
1291
|
-
params[filterName] = value.map(arr => arr[searchKeyName]);
|
|
1292
|
-
}
|
|
1293
|
-
else {
|
|
1294
|
-
params[filterName] = value ? value[searchKeyName] : [''];
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
this.IsEmpty(params[filterName]) && delete params[filterName];
|
|
1298
|
-
return params;
|
|
1299
|
-
}
|
|
1300
|
-
}, {});
|
|
1301
|
-
}
|
|
1302
|
-
/*
|
|
1303
|
-
* Verifica se o valor informado é falso, em arrays, é verificado cada item
|
|
1304
|
-
*/
|
|
1305
|
-
IsEmpty(value) {
|
|
1306
|
-
return Array.isArray(value) ? value.every(data => !data) : !value;
|
|
1307
|
-
}
|
|
1308
|
-
/**
|
|
1309
|
-
* Return format to specify for integer type field
|
|
1310
|
-
*/
|
|
1311
|
-
optionsInteger() {
|
|
1312
|
-
return { currencySymbol: '', decimalSeparator: '', thousandsSeparator: '' };
|
|
1313
|
-
}
|
|
1314
|
-
};
|
|
1315
|
-
FormFilterComponent.ctorParameters = () => [
|
|
1316
|
-
{ type: AdvancedFilterService },
|
|
1317
|
-
{ type: TranslateService },
|
|
1318
|
-
{ type: MessageService },
|
|
1319
|
-
{ type: CalendarOptionsService },
|
|
1320
|
-
{ type: ChangeDetectorRef }
|
|
1321
|
-
];
|
|
1322
|
-
__decorate([
|
|
1323
|
-
Input()
|
|
1324
|
-
], FormFilterComponent.prototype, "showMessages", void 0);
|
|
1325
|
-
__decorate([
|
|
1326
|
-
Input()
|
|
1327
|
-
], FormFilterComponent.prototype, "isModal", void 0);
|
|
1328
|
-
__decorate([
|
|
1329
|
-
Input()
|
|
1330
|
-
], FormFilterComponent.prototype, "contextId", void 0);
|
|
1331
|
-
__decorate([
|
|
1332
|
-
Output()
|
|
1333
|
-
], FormFilterComponent.prototype, "totalFiltersActiveOutput", void 0);
|
|
1334
|
-
__decorate([
|
|
1335
|
-
Output()
|
|
1336
|
-
], FormFilterComponent.prototype, "errorOutput", void 0);
|
|
1337
|
-
__decorate([
|
|
1338
|
-
Output()
|
|
1339
|
-
], FormFilterComponent.prototype, "showDialogOutput", void 0);
|
|
1340
|
-
__decorate([
|
|
1341
|
-
Output()
|
|
1342
|
-
], FormFilterComponent.prototype, "closeModalOutput", void 0);
|
|
1343
|
-
__decorate([
|
|
1344
|
-
HostListener('window:resize', ['$event'])
|
|
1345
|
-
], FormFilterComponent.prototype, "onResizeWindow", null);
|
|
1346
|
-
FormFilterComponent = __decorate([
|
|
1347
|
-
Component({
|
|
1348
|
-
selector: 's-app-form-filter',
|
|
1349
|
-
template: "<s-empty-state\n *ngIf=\"error\"\n iconClass=\"fa fa-exclamation-triangle\"\n title=\"{{ errorState?.status }} - {{ errorState?.statusText }}\"\n (primaryAction)=\"errorStateAction()\"\n [primaryActionLabel]=\"translate.instant('platform.filter_service.try')\"\n [description]=\"translate.instant('platform.filter_service.error_state')\"\n></s-empty-state>\n\n<div *ngIf=\"!error\">\n <p-tabView *ngIf=\"tabs && tabs.size > 1\" [orientation]=\"tabViewOrientation\" selected=\"false\">\n <p-tabPanel *ngIf=\"general.fields.length\" [selected]=\"false\" [header]=\"general.name\">\n <s-dynamic-form [errorMessages]=\"errorMessages\" [fields]=\"general.fields\" [form]=\"general.form\"></s-dynamic-form>\n </p-tabPanel>\n\n <p-tabPanel *ngFor=\"let tab of (tabs | mapValues); let i = index\" [selected]=\"i === 0\" [header]=\"tab.label\">\n <s-dynamic-form [errorMessages]=\"errorMessages\" [fields]=\"tab.fields\" [form]=\"tab.form\"></s-dynamic-form>\n </p-tabPanel>\n </p-tabView>\n\n <div *ngIf=\"tabs && tabs.size === 1\">\n <s-dynamic-form\n *ngFor=\"let tab of (tabs | mapValues)\"\n [errorMessages]=\"errorMessages\"\n [fields]=\"tab.fields\"\n [form]=\"tab.form\"\n ></s-dynamic-form>\n </div>\n</div>\n",
|
|
1350
|
-
styles: [".filter-dialog{width:800px;top:100px}.filter-dialog>.ui-dialog-content{height:300px;padding:10px!important}@media (min-width:641px) and (max-width:1024px){.filter-dialog{width:75%}.filter-dialog>.ui-dialog-content{height:300px}}@media only screen and (min-device-width:481px) and (max-device-width:1024px) and (orientation:portrait){.filter-dialog{width:75%}.filter-dialog>.ui-dialog-content{height:90%}}@media (min-width:320px) and (max-width:640px){.filter-dialog{width:95%;left:0;top:0;opacity:1;margin:auto;height:93%}.filter-dialog>.ui-dialog-content{height:85%}}@media (min-width:320px) and (max-width:640px) and (max-width:360px){.filter-dialog button{padding:0!important}.filter-dialog>.ui-dialog-content{height:81%}}"]
|
|
1351
|
-
})
|
|
1352
|
-
], FormFilterComponent);
|
|
1353
|
-
|
|
1354
|
-
const TRANSLATE_PREFIX$2 = 'platform.filter_service';
|
|
1355
|
-
let AdvancedFilterComponent = class AdvancedFilterComponent {
|
|
1356
|
-
constructor(translate, router) {
|
|
1357
|
-
this.translate = translate;
|
|
1358
|
-
this.router = router;
|
|
1359
|
-
this.labelButton = 'Filters';
|
|
1360
|
-
this.onlyContent = false;
|
|
1361
|
-
this.hideButtons = false;
|
|
1362
|
-
this.canOpenFilter = true;
|
|
1363
|
-
this.showActiveFiltersCountBadge = true;
|
|
1364
|
-
this.filterAndSave = false;
|
|
1365
|
-
this.contextId = '';
|
|
1366
|
-
this.subscriptions = [];
|
|
1367
|
-
this.isMobile = false;
|
|
1368
|
-
this.tabViewOrientation = 'left';
|
|
1369
|
-
this.totalFiltersActive = 0;
|
|
1370
|
-
this.showDialog = false;
|
|
1371
|
-
this.error = false;
|
|
1372
|
-
this.currentTicket = '';
|
|
1373
|
-
this.mobileButtonActions = [
|
|
1374
|
-
{ id: 'save', label: this.translate.instant('save'), command: () => this.modalComponent.saveFilters() },
|
|
1375
|
-
{ id: 'clear', label: this.translate.instant('clear'), command: () => this.modalComponent.clearFilters() }
|
|
1376
|
-
];
|
|
1377
|
-
}
|
|
1378
|
-
ngOnInit() {
|
|
1379
|
-
this.isMobile = innerWidth <= 640;
|
|
1380
|
-
this.tabViewOrientation = this.isMobile ? 'top' : 'left';
|
|
1381
|
-
const sub = this.router.events.subscribe(e => {
|
|
1382
|
-
if (e instanceof NavigationEnd) {
|
|
1383
|
-
this.modalComponent.getFilters();
|
|
1384
|
-
}
|
|
1385
|
-
});
|
|
1386
|
-
this.subscriptions.push(sub);
|
|
1387
|
-
}
|
|
1388
|
-
ngOnDestroy() {
|
|
1389
|
-
this.subscriptions.forEach(v => v.unsubscribe());
|
|
1390
|
-
}
|
|
1391
|
-
onResizeWindow(event) {
|
|
1392
|
-
const { innerWidth } = event.target;
|
|
1393
|
-
this.isMobile = innerWidth <= 640;
|
|
1394
|
-
this.tabViewOrientation = this.isMobile ? 'top' : 'left';
|
|
1395
|
-
}
|
|
1396
|
-
get appliedFiltersTooltip() {
|
|
1397
|
-
return this.totalFiltersActive > 1
|
|
1398
|
-
? this.translate.instant(`${TRANSLATE_PREFIX$2}.applied_filters_message`, { totalActiveFilters: this.totalFiltersActive })
|
|
1399
|
-
: this.translate.instant(`${TRANSLATE_PREFIX$2}.applied_filter_message`, { totalActiveFilters: this.totalFiltersActive });
|
|
1400
|
-
}
|
|
1401
|
-
onError(event) {
|
|
1402
|
-
this.error = event;
|
|
1403
|
-
}
|
|
1404
|
-
saveFilters(forceSave = false) {
|
|
1405
|
-
this.modalComponent.saveFilters(forceSave);
|
|
1406
|
-
}
|
|
1407
|
-
saveFiltersWithCallbackFunction(callbackFunction) {
|
|
1408
|
-
this.modalComponent.saveFiltersWithCallbackFunction(callbackFunction);
|
|
1409
|
-
}
|
|
1410
|
-
clearFilters() {
|
|
1411
|
-
this.modalComponent.clearFilters();
|
|
1412
|
-
}
|
|
1413
|
-
close() {
|
|
1414
|
-
this.modalComponent.getFilters();
|
|
1415
|
-
window.parent.postMessage({
|
|
1416
|
-
message: 'dashboard:close-modal',
|
|
1417
|
-
payload: {
|
|
1418
|
-
modalName: 'advanced-filter-1'
|
|
1419
|
-
}
|
|
1420
|
-
}, '*');
|
|
1421
|
-
}
|
|
1422
|
-
applyFilters() {
|
|
1423
|
-
if (this.modalComponent.hasChanges()) {
|
|
1424
|
-
this.showDialog = false;
|
|
1425
|
-
}
|
|
1426
|
-
if (this.filterAndSave) {
|
|
1427
|
-
this.modalComponent.saveFilters();
|
|
1428
|
-
}
|
|
1429
|
-
this.modalComponent.applyFilters(true);
|
|
1430
|
-
}
|
|
1431
|
-
onApplyFilters() {
|
|
1432
|
-
if (this.filterAndSave) {
|
|
1433
|
-
this.modalComponent.saveFilters();
|
|
1434
|
-
}
|
|
1435
|
-
this.modalComponent.onApplyFilters();
|
|
1436
|
-
}
|
|
1437
|
-
toggleDialog() {
|
|
1438
|
-
this.showDialog = !this.showDialog;
|
|
1439
|
-
}
|
|
1440
|
-
updateTotalFiltersActive(event) {
|
|
1441
|
-
this.totalFiltersActive = event;
|
|
1442
|
-
}
|
|
1443
|
-
};
|
|
1444
|
-
AdvancedFilterComponent.ctorParameters = () => [
|
|
1445
|
-
{ type: TranslateService },
|
|
1446
|
-
{ type: Router }
|
|
1447
|
-
];
|
|
1448
|
-
__decorate([
|
|
1449
|
-
Input()
|
|
1450
|
-
], AdvancedFilterComponent.prototype, "labelButton", void 0);
|
|
1451
|
-
__decorate([
|
|
1452
|
-
Input()
|
|
1453
|
-
], AdvancedFilterComponent.prototype, "onlyContent", void 0);
|
|
1454
|
-
__decorate([
|
|
1455
|
-
Input()
|
|
1456
|
-
], AdvancedFilterComponent.prototype, "hideButtons", void 0);
|
|
1457
|
-
__decorate([
|
|
1458
|
-
Input()
|
|
1459
|
-
], AdvancedFilterComponent.prototype, "canOpenFilter", void 0);
|
|
1460
|
-
__decorate([
|
|
1461
|
-
Input()
|
|
1462
|
-
], AdvancedFilterComponent.prototype, "showActiveFiltersCountBadge", void 0);
|
|
1463
|
-
__decorate([
|
|
1464
|
-
Input()
|
|
1465
|
-
], AdvancedFilterComponent.prototype, "filterAndSave", void 0);
|
|
1466
|
-
__decorate([
|
|
1467
|
-
Input()
|
|
1468
|
-
], AdvancedFilterComponent.prototype, "contextId", void 0);
|
|
1469
|
-
__decorate([
|
|
1470
|
-
ViewChild(FormFilterComponent)
|
|
1471
|
-
], AdvancedFilterComponent.prototype, "modalComponent", void 0);
|
|
1472
|
-
__decorate([
|
|
1473
|
-
HostListener('window:resize', ['$event'])
|
|
1474
|
-
], AdvancedFilterComponent.prototype, "onResizeWindow", null);
|
|
1475
|
-
AdvancedFilterComponent = __decorate([
|
|
1476
|
-
Component({
|
|
1477
|
-
selector: 's-advanced-filter',
|
|
1478
|
-
template: "<s-button\n *ngIf=\"!onlyContent\"\n [id]=\"'filterButton'\"\n [disabled]=\"!canOpenFilter\"\n (click)=\"canOpenFilter ? toggleDialog() : ''\"\n iconClass=\"fa fa-filter\"\n priority=\"default\"\n [label]=\"labelButton\"\n [auxiliary]=\"true\"\n [tooltip]=\"appliedFiltersTooltip\"\n>\n <span\n *ngIf=\"totalFiltersActive && showActiveFiltersCountBadge\"\n class=\"sds-badge-number sds-color-primary custom-badge\"\n >{{ totalFiltersActive }}</span\n >\n</s-button>\n\n<section *ngIf=\"onlyContent\">\n <div class=\"only-content-wrapper\">\n <div class=\"header\">\n <h3>{{ 'platform.filter_service.filters' | translate }}</h3>\n <span (click)=\"close()\" class=\"close_btn pi pi-times\"></span>\n </div>\n <div class=\"app-form-filter\">\n <s-app-form-filter\n [showMessages]=\"false\"\n (totalFiltersActiveOutput)=\"updateTotalFiltersActive($event)\"\n (closeModalOutput)=\"close()\"\n [isModal]=\"false\"\n [contextId]=\"contextId\"\n ></s-app-form-filter>\n </div>\n <div class=\"filter-footer\" *ngIf=\"!error\">\n <s-button\n priority=\"link\"\n [label]=\"translate.instant('platform.filter_service.cancel')\"\n (click)=\"close()\"\n ></s-button>\n <s-button\n *ngIf=\"isMobile\"\n priority=\"default\"\n [label]=\"translate.instant('platform.filter_service.actions')\"\n [auxiliary]=\"true\"\n [model]=\"mobileButtonActions\"\n ></s-button>\n <ng-container *ngIf=\"!isMobile\">\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.clear')\"\n (click)=\"clearFilters()\"\n ></s-button>\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.save')\"\n (click)=\"saveFilters()\"\n ></s-button>\n </ng-container>\n <s-button\n type=\"submit\"\n priority=\"primary\"\n [label]=\"translate.instant('platform.filter_service.filter')\"\n (click)=\"onApplyFilters()\"\n ></s-button>\n </div>\n </div>\n</section>\n\n<p-dialog\n *ngIf=\"!onlyContent\"\n appendTo=\"body\"\n styleClass=\"filter-dialog\"\n [draggable]=\"false\"\n [modal]=\"true\"\n [responsive]=\"true\"\n [(visible)]=\"showDialog\"\n blockScroll=\"true\"\n [closable]=\"false\"\n>\n <p-header>\n <div style=\"display: flex\">\n {{ 'platform.filter_service.filters' | translate }}\n <span (click)=\"toggleDialog(); close()\" class=\"close_btn pi pi-times\"></span>\n </div>\n </p-header>\n\n <s-app-form-filter\n [showMessages]=\"true\"\n (errorOutput)=\"onError($event)\"\n (totalFiltersActiveOutput)=\"updateTotalFiltersActive($event)\"\n [isModal]=\"true\"\n [contextId]=\"contextId\"\n ></s-app-form-filter>\n <p-footer *ngIf=\"!error && !hideButtons\">\n <s-button\n type=\"submit\"\n priority=\"primary\"\n [label]=\"translate.instant('platform.filter_service.filter')\"\n (click)=\"applyFilters()\"\n ></s-button>\n <ng-container *ngIf=\"!isMobile\">\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.save')\"\n (click)=\"saveFilters()\"\n ></s-button>\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.clear')\"\n (click)=\"clearFilters()\"\n ></s-button>\n </ng-container>\n <s-button\n *ngIf=\"isMobile\"\n priority=\"default\"\n [label]=\"translate.instant('platform.filter_service.actions')\"\n [auxiliary]=\"true\"\n [model]=\"mobileButtonActions\"\n ></s-button>\n <s-button\n priority=\"link\"\n [label]=\"translate.instant('platform.filter_service.cancel')\"\n (click)=\"toggleDialog(); close()\"\n ></s-button>\n </p-footer>\n</p-dialog>\n\n<p-toast key=\"filterServiceToastKey\" [baseZIndex]=\"5000\"></p-toast>\n",
|
|
1479
|
-
encapsulation: ViewEncapsulation.None,
|
|
1480
|
-
styles: [".custom-badge{position:absolute!important;right:-4px;top:-10px;height:20px;vertical-align:middle;display:table;min-width:22px}.filter-button{position:relative;border:1px solid #000;border-radius:1.5rem;background:0 0;padding:.5rem 1rem;cursor:pointer}.filter-dialog .ui-dialog-title{display:block!important;padding-right:0!important}.filter-footer{text-align:end;border-top:1px solid #e5eaea;padding:13px}.filter-dialog>.ui-dialog-content{height:300px;padding:10px!important}.app-form-filter{height:335px;max-height:335px;overflow:auto}.only-content-wrapper{background-color:#fff}.close_btn{-ms-flex-line-pack:center;align-content:center;-ms-grid-column-align:right;justify-self:right;margin-left:auto}.close_btn:hover{cursor:pointer}.header{text-transform:uppercase;display:-ms-flexbox;display:flex;width:100%;border-bottom:1px solid #e5eaea;padding:15px;margin-left:0}@media (min-width:641px) and (max-width:1024px){.filter-dialog{width:75%}.filter-dialog>.ui-dialog-content{height:300px}}@media only screen and (min-device-width:481px) and (max-device-width:1024px) and (orientation:portrait){.filter-dialog{width:75%}.filter-dialog>.ui-dialog-content{height:90%}}@media (min-width:320px) and (max-width:640px){.filter-dialog{width:95%;left:0;top:0;opacity:1;margin:auto;height:93%}.filter-dialog>.ui-dialog-content{height:85%}}@media (min-width:320px) and (max-width:640px) and (max-width:360px){.filter-dialog button{padding:0!important}.filter-dialog>.ui-dialog-content{height:81%}}"]
|
|
1481
|
-
})
|
|
1482
|
-
], AdvancedFilterComponent);
|
|
1483
|
-
|
|
1484
|
-
class AppRoutingModule {
|
|
1485
|
-
}
|
|
1486
|
-
let AdvancedFilterModule = class AdvancedFilterModule {
|
|
1487
|
-
};
|
|
1488
|
-
AdvancedFilterModule = __decorate([
|
|
1489
|
-
NgModule({
|
|
1490
|
-
imports: [
|
|
1491
|
-
DialogModule,
|
|
1492
|
-
ButtonModule,
|
|
1493
|
-
ButtonModule$1,
|
|
1494
|
-
TabViewModule,
|
|
1495
|
-
CommonModule,
|
|
1496
|
-
FormsModule,
|
|
1497
|
-
ReactiveFormsModule,
|
|
1498
|
-
DynamicFormModule,
|
|
1499
|
-
ToastModule,
|
|
1500
|
-
EmptyStateModule,
|
|
1501
|
-
TooltipModule,
|
|
1502
|
-
TranslationsModule.forChild([{ domain: 'platform', service: 'filter_service', fallback }]),
|
|
1503
|
-
],
|
|
1504
|
-
providers: [AdvancedFilterService, LocaleService, MessageService, TranslateService, CalendarOptionsService],
|
|
1505
|
-
declarations: [AdvancedFilterComponent, FormFilterComponent, MapValuesPipe, TranslatePipe],
|
|
1506
|
-
exports: [AdvancedFilterComponent, FormFilterComponent]
|
|
1507
|
-
})
|
|
1508
|
-
], AdvancedFilterModule);
|
|
1509
|
-
|
|
1510
|
-
let CyclicJsonInterceptor = class CyclicJsonInterceptor {
|
|
1511
|
-
intercept(req, next) {
|
|
1512
|
-
if (req.body instanceof Blob === false && req.body instanceof FormData === false) {
|
|
1513
|
-
req = req.clone({ body: jsonCycle.decycle(req.body) });
|
|
1514
|
-
}
|
|
1515
|
-
return next.handle(req).pipe(map((event) => {
|
|
1516
|
-
if (event instanceof HttpResponse) {
|
|
1517
|
-
event = event.clone({ body: jsonCycle.retrocycle(event.body) });
|
|
1518
|
-
}
|
|
1519
|
-
return event;
|
|
1520
|
-
}));
|
|
1521
|
-
}
|
|
1522
|
-
};
|
|
1523
|
-
CyclicJsonInterceptor.ɵprov = ɵɵdefineInjectable({ factory: function CyclicJsonInterceptor_Factory() { return new CyclicJsonInterceptor(); }, token: CyclicJsonInterceptor, providedIn: "root" });
|
|
1524
|
-
CyclicJsonInterceptor = __decorate([
|
|
1525
|
-
Injectable({
|
|
1526
|
-
providedIn: 'root',
|
|
1527
|
-
})
|
|
1528
|
-
], CyclicJsonInterceptor);
|
|
1529
|
-
|
|
1530
|
-
let CyclicJsonInterceptorModule = class CyclicJsonInterceptorModule {
|
|
1531
|
-
};
|
|
1532
|
-
CyclicJsonInterceptorModule = __decorate([
|
|
1533
|
-
NgModule({
|
|
1534
|
-
imports: [HttpClientModule],
|
|
1535
|
-
providers: [{ provide: HTTP_INTERCEPTORS, useClass: CyclicJsonInterceptor, multi: true }]
|
|
1536
|
-
})
|
|
1537
|
-
], CyclicJsonInterceptorModule);
|
|
1538
|
-
|
|
1539
|
-
let RestUrl = class RestUrl {
|
|
1540
|
-
get() {
|
|
1541
|
-
return defer(() => from(service.getRestUrl()));
|
|
1542
|
-
}
|
|
1543
|
-
};
|
|
1544
|
-
RestUrl = __decorate([
|
|
1545
|
-
Injectable()
|
|
1546
|
-
], RestUrl);
|
|
1547
|
-
|
|
1548
|
-
let XServicesUrl = class XServicesUrl {
|
|
1549
|
-
get() {
|
|
1550
|
-
return defer(() => {
|
|
1551
|
-
const url = service.getXServicesUrl();
|
|
1552
|
-
return from(url);
|
|
1553
|
-
});
|
|
1554
|
-
}
|
|
1555
|
-
};
|
|
1556
|
-
XServicesUrl = __decorate([
|
|
1557
|
-
Injectable()
|
|
1558
|
-
], XServicesUrl);
|
|
1559
|
-
|
|
1560
|
-
let HttpInterceptor = class HttpInterceptor {
|
|
1561
|
-
constructor(restUrl, xServicesUrl) {
|
|
1562
|
-
this.restUrl = restUrl;
|
|
1563
|
-
this.xServicesUrl = xServicesUrl;
|
|
1564
|
-
}
|
|
1565
|
-
intercept(originalReq, next) {
|
|
1566
|
-
if (!originalReq.url.includes(`://`)) {
|
|
1567
|
-
const getAuthHeader = defer(() => from(user.getAuthHeader()));
|
|
1568
|
-
if (/^\/?[^\/]+\/[^\/]+\/api\/(?:latest|v\d+)\/.+$/g.test(originalReq.url)) {
|
|
1569
|
-
const getXServicesUrl = this.xServicesUrl.get();
|
|
1570
|
-
return forkJoin([getXServicesUrl, getAuthHeader]).pipe(mergeMap((values) => {
|
|
1571
|
-
const [xUrl, authHeader] = values;
|
|
1572
|
-
return this.injectBaseUrl(originalReq, next, xUrl, authHeader);
|
|
1573
|
-
}));
|
|
1574
|
-
}
|
|
1575
|
-
const getRestUrl = this.restUrl.get();
|
|
1576
|
-
return forkJoin([getRestUrl, getAuthHeader]).pipe(mergeMap((values) => {
|
|
1577
|
-
const [bridgeUrl, authHeader] = values;
|
|
1578
|
-
return this.injectBaseUrl(originalReq, next, bridgeUrl, authHeader);
|
|
1579
|
-
}));
|
|
1580
|
-
}
|
|
1581
|
-
return next.handle(originalReq);
|
|
1582
|
-
}
|
|
1583
|
-
injectBaseUrl(originalReq, next, baseUrl, authorization) {
|
|
1584
|
-
const request = originalReq.clone({
|
|
1585
|
-
url: baseUrl + originalReq.url,
|
|
1586
|
-
headers: originalReq.headers.set(`Authorization`, authorization)
|
|
1587
|
-
});
|
|
1588
|
-
return next.handle(request);
|
|
1589
|
-
}
|
|
1590
|
-
};
|
|
1591
|
-
HttpInterceptor.ctorParameters = () => [
|
|
1592
|
-
{ type: RestUrl },
|
|
1593
|
-
{ type: XServicesUrl }
|
|
1594
|
-
];
|
|
1595
|
-
HttpInterceptor = __decorate([
|
|
1596
|
-
Injectable()
|
|
1597
|
-
], HttpInterceptor);
|
|
1598
|
-
|
|
1599
|
-
let HttpInterceptorModule = class HttpInterceptorModule {
|
|
1600
|
-
};
|
|
1601
|
-
HttpInterceptorModule = __decorate([
|
|
1602
|
-
NgModule({
|
|
1603
|
-
imports: [HttpClientModule],
|
|
1604
|
-
providers: [RestUrl, XServicesUrl, { provide: HTTP_INTERCEPTORS, useClass: HttpInterceptor, multi: true }]
|
|
1605
|
-
})
|
|
1606
|
-
], HttpInterceptorModule);
|
|
1607
|
-
|
|
1608
|
-
const RESOURCES = new InjectionToken('RESOURCES');
|
|
1609
|
-
const ENVIRONMENT = new InjectionToken('ENVIRONMENT');
|
|
1610
|
-
class Resource {
|
|
1611
|
-
constructor() {
|
|
1612
|
-
this.redirectToError = false;
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
class Environment {
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
let promise;
|
|
1619
|
-
let PermissionsService = class PermissionsService {
|
|
1620
|
-
constructor(resources, environment, http, router, messageService, translate) {
|
|
1621
|
-
this.resources = resources;
|
|
1622
|
-
this.environment = environment;
|
|
1623
|
-
this.http = http;
|
|
1624
|
-
this.router = router;
|
|
1625
|
-
this.messageService = messageService;
|
|
1626
|
-
this.translate = translate;
|
|
1627
|
-
this.checkedPermissions = [];
|
|
1628
|
-
this.actionUrl = 'platform/authorization/queries';
|
|
1629
|
-
}
|
|
1630
|
-
// v2
|
|
1631
|
-
checkAccess(resources) {
|
|
1632
|
-
const permissions = [];
|
|
1633
|
-
resources.forEach(rec => {
|
|
1634
|
-
rec.actions.forEach(action => {
|
|
1635
|
-
if (!rec.uri) {
|
|
1636
|
-
const resource = this.getUriByResourceName(rec.name, rec.entity);
|
|
1637
|
-
rec.uri = resource;
|
|
1638
|
-
}
|
|
1639
|
-
permissions.push({ action, resource: rec.uri });
|
|
1640
|
-
});
|
|
1641
|
-
});
|
|
1642
|
-
return this.http.post(`${this.actionUrl}/checkAccess`, { includeFilters: true, permissions }).pipe(map(({ permissions: checkedPermissions }) => {
|
|
1643
|
-
this.checkedPermissions = [...this.checkedPermissions, ...checkedPermissions];
|
|
1644
|
-
const values = {};
|
|
1645
|
-
if (this.shouldRedirectToForbiddenPage(resources, checkedPermissions)) {
|
|
1646
|
-
this.router.navigate(['error', 403]);
|
|
1647
|
-
return throwError('forbidden');
|
|
1648
|
-
}
|
|
1649
|
-
checkedPermissions.forEach(permission => {
|
|
1650
|
-
const resource = resources.find(res => res.uri === permission.resource);
|
|
1651
|
-
const { name } = resource;
|
|
1652
|
-
values[name] = values[name] || {};
|
|
1653
|
-
values[name][permission.action] = permission.authorized;
|
|
1654
|
-
values[name][permission.action.toLowerCase()] = permission.authorized;
|
|
1655
|
-
if (permission.resourceFilters && permission.resourceFilters.length) {
|
|
1656
|
-
if (!values[name]['resourceFilters']) {
|
|
1657
|
-
values[name]['resourceFilters'] = [];
|
|
1658
|
-
}
|
|
1659
|
-
permission.resourceFilters.forEach((resourceFilter) => {
|
|
1660
|
-
values[name]['resourceFilters'].push(resourceFilter);
|
|
1661
|
-
});
|
|
1662
|
-
}
|
|
1663
|
-
});
|
|
1664
|
-
return values;
|
|
1665
|
-
}));
|
|
1666
|
-
}
|
|
1667
|
-
// v1
|
|
1668
|
-
get(resource = '') {
|
|
1669
|
-
if (!promise) {
|
|
1670
|
-
promise = this.getPermissions();
|
|
1671
|
-
}
|
|
1672
|
-
return from(promise).pipe(map((permissions) => {
|
|
1673
|
-
this.checkedPermissions = permissions;
|
|
1674
|
-
if (resource) {
|
|
1675
|
-
const resourceKey = Object.keys(permissions).find(key => key.toLowerCase() === resource.toLowerCase());
|
|
1676
|
-
return permissions[resourceKey];
|
|
1677
|
-
}
|
|
1678
|
-
return permissions;
|
|
1679
|
-
}), catchError((err) => {
|
|
1680
|
-
promise = undefined;
|
|
1681
|
-
this.messageService.add({
|
|
1682
|
-
severity: 'error',
|
|
1683
|
-
summary: this.translate.instant('permission_error_summary'),
|
|
1684
|
-
detail: this.translate.instant('permission_error_detail')
|
|
1685
|
-
});
|
|
1686
|
-
return of(this.getPermissionObject(false));
|
|
1687
|
-
}));
|
|
1688
|
-
}
|
|
1689
|
-
isAuthorized(resourceName, action, isEntity) {
|
|
1690
|
-
if (!this.checkedPermissions.length) {
|
|
1691
|
-
throwError('\'Permissions\' are not defined. You should call \'get\' or \'checkAccess\' method first.');
|
|
1692
|
-
}
|
|
1693
|
-
const resourceUri = this.getUriByResourceName(resourceName, isEntity);
|
|
1694
|
-
const permissionsOfResource = this.checkedPermissions.filter(perm => perm.resource === resourceUri);
|
|
1695
|
-
const permissionOfAction = permissionsOfResource.find(permRec => permRec.action.toLowerCase() === action.toLowerCase());
|
|
1696
|
-
return permissionOfAction && permissionOfAction.authorized;
|
|
1697
|
-
}
|
|
1698
|
-
getUriByResourceName(resourceName, isEntity) {
|
|
1699
|
-
const { domain, service } = this.environment;
|
|
1700
|
-
if (!domain || !service) {
|
|
1701
|
-
throwError('You must inform domain and service name');
|
|
1702
|
-
}
|
|
1703
|
-
const uriBase = `res://senior.com.br/${domain}/${service}`;
|
|
1704
|
-
if (isEntity) {
|
|
1705
|
-
return `${uriBase}/entities/${resourceName}`;
|
|
1706
|
-
}
|
|
1707
|
-
else {
|
|
1708
|
-
return `${uriBase}/${resourceName}`;
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
/**
|
|
1712
|
-
* Valida com base nas propriedade redirectToError e actionsToCheck
|
|
1713
|
-
* se a ação de um recurso deve enviar para a página de erro caso não tenha autorização
|
|
1714
|
-
*/
|
|
1715
|
-
shouldRedirectToForbiddenPage(resources = [], permissions) {
|
|
1716
|
-
const permissionsDenied = permissions.filter(perm => !perm.authorized);
|
|
1717
|
-
if (permissionsDenied && permissionsDenied.length) {
|
|
1718
|
-
const resourcesToCheck = resources.filter(resource => resource.redirectToError);
|
|
1719
|
-
if (resourcesToCheck && resourcesToCheck.length) {
|
|
1720
|
-
return resourcesToCheck.every(resource => {
|
|
1721
|
-
const actionsToCheck = resource.actionsToCheck && resource.actionsToCheck.length ? resource.actionsToCheck : resource.actions;
|
|
1722
|
-
return actionsToCheck.every(action => permissionsDenied.some(permissionDenied => permissionDenied.resource === resource.uri && permissionDenied.action === action));
|
|
1723
|
-
});
|
|
1724
|
-
}
|
|
1725
|
-
return false;
|
|
1726
|
-
}
|
|
1727
|
-
return false;
|
|
1728
|
-
}
|
|
1729
|
-
getFlatEnvironment() {
|
|
1730
|
-
return this.environment.ignorePermissions;
|
|
1731
|
-
}
|
|
1732
|
-
getFlatResources() {
|
|
1733
|
-
return this.resources.reduce((result, item) => {
|
|
1734
|
-
if (!item) {
|
|
1735
|
-
return result;
|
|
1736
|
-
}
|
|
1737
|
-
if (Array.isArray(item)) {
|
|
1738
|
-
return [...result, ...item];
|
|
1739
|
-
}
|
|
1740
|
-
return [...result, item];
|
|
1741
|
-
}, []);
|
|
1742
|
-
}
|
|
1743
|
-
getPermissionObject(defaultValue) {
|
|
1744
|
-
return this.getFlatResources().reduce((resources, resource) => {
|
|
1745
|
-
resources[resource.name] = resource.actions.reduce((actions, action) => {
|
|
1746
|
-
actions[action] = defaultValue;
|
|
1747
|
-
actions[action.toLowerCase()] = defaultValue;
|
|
1748
|
-
return actions;
|
|
1749
|
-
}, {});
|
|
1750
|
-
return resources;
|
|
1751
|
-
}, {});
|
|
1752
|
-
}
|
|
1753
|
-
getPermissions() {
|
|
1754
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1755
|
-
if (this.getFlatEnvironment()) {
|
|
1756
|
-
return this.getPermissionObject(true);
|
|
1757
|
-
}
|
|
1758
|
-
const resources = this.getFlatResources();
|
|
1759
|
-
const perm = resources
|
|
1760
|
-
.map(resource => resource.actions.map((action) => ({ action: action, resource: resource.uri })))
|
|
1761
|
-
.reduce((acc, val) => [...acc, ...val]);
|
|
1762
|
-
const permissions = yield this.http
|
|
1763
|
-
.post(`${this.actionUrl}/checkAccess`, {
|
|
1764
|
-
includeFilters: false,
|
|
1765
|
-
permissions: perm
|
|
1766
|
-
})
|
|
1767
|
-
.toPromise()
|
|
1768
|
-
.then(response => response.permissions);
|
|
1769
|
-
const values = {};
|
|
1770
|
-
permissions.forEach((permission) => {
|
|
1771
|
-
const resource = resources.find((res) => res.uri === permission.resource);
|
|
1772
|
-
const { name } = resource;
|
|
1773
|
-
values[name] = values[name] ? values[name] : {};
|
|
1774
|
-
values[name][permission.action] = permission.authorized;
|
|
1775
|
-
values[name][permission.action.toLowerCase()] = permission.authorized;
|
|
1776
|
-
});
|
|
1777
|
-
return values;
|
|
1778
|
-
});
|
|
1779
|
-
}
|
|
1780
|
-
};
|
|
1781
|
-
PermissionsService.ctorParameters = () => [
|
|
1782
|
-
{ type: undefined, decorators: [{ type: Inject, args: [RESOURCES,] }] },
|
|
1783
|
-
{ type: Environment, decorators: [{ type: Inject, args: [ENVIRONMENT,] }] },
|
|
1784
|
-
{ type: HttpClient },
|
|
1785
|
-
{ type: Router },
|
|
1786
|
-
{ type: MessageService },
|
|
1787
|
-
{ type: TranslateService }
|
|
1788
|
-
];
|
|
1789
|
-
PermissionsService.ɵprov = ɵɵdefineInjectable({ factory: function PermissionsService_Factory() { return new PermissionsService(ɵɵinject(RESOURCES), ɵɵinject(ENVIRONMENT), ɵɵinject(HttpClient), ɵɵinject(Router), ɵɵinject(MessageService), ɵɵinject(TranslateService)); }, token: PermissionsService, providedIn: "root" });
|
|
1790
|
-
PermissionsService = __decorate([
|
|
1791
|
-
Injectable({
|
|
1792
|
-
providedIn: 'root'
|
|
1793
|
-
}),
|
|
1794
|
-
__param(0, Inject(RESOURCES)),
|
|
1795
|
-
__param(1, Inject(ENVIRONMENT))
|
|
1796
|
-
], PermissionsService);
|
|
1797
|
-
|
|
1798
|
-
var PermissionsModule_1;
|
|
1799
|
-
let PermissionsModule = PermissionsModule_1 = class PermissionsModule {
|
|
1800
|
-
static forRoot(resources, environment) {
|
|
1801
|
-
return {
|
|
1802
|
-
ngModule: PermissionsModule_1,
|
|
1803
|
-
providers: [
|
|
1804
|
-
PermissionsService,
|
|
1805
|
-
{
|
|
1806
|
-
provide: RESOURCES,
|
|
1807
|
-
multi: true,
|
|
1808
|
-
useValue: resources
|
|
1809
|
-
},
|
|
1810
|
-
{
|
|
1811
|
-
provide: ENVIRONMENT,
|
|
1812
|
-
multi: false,
|
|
1813
|
-
useValue: environment
|
|
1814
|
-
}
|
|
1815
|
-
]
|
|
1816
|
-
};
|
|
1817
|
-
}
|
|
1818
|
-
static forChild(resources) {
|
|
1819
|
-
return {
|
|
1820
|
-
ngModule: PermissionsModule_1,
|
|
1821
|
-
providers: [
|
|
1822
|
-
{
|
|
1823
|
-
provide: RESOURCES,
|
|
1824
|
-
multi: true,
|
|
1825
|
-
useValue: resources
|
|
1826
|
-
}
|
|
1827
|
-
]
|
|
1828
|
-
};
|
|
1829
|
-
}
|
|
1830
|
-
};
|
|
1831
|
-
PermissionsModule = PermissionsModule_1 = __decorate([
|
|
1832
|
-
NgModule()
|
|
1833
|
-
], PermissionsModule);
|
|
1834
|
-
|
|
1835
|
-
function ResourceFactory({ domain, service, resource }) {
|
|
1836
|
-
return `res://senior.com.br/${domain}/${service}/${resource}`;
|
|
1837
|
-
}
|
|
1838
|
-
function endpointFactoryFunction(domain, service) {
|
|
1839
|
-
// The @seniorsistemas/platform-components http interceptor is handling the base url portion of the final URL
|
|
1840
|
-
const create = (method, endpoint) => `${domain}/${service}/${method}/${endpoint}`;
|
|
1841
|
-
const resource = (resource) => ResourceFactory({ domain, service, resource });
|
|
1842
|
-
return {
|
|
1843
|
-
resource,
|
|
1844
|
-
query: create.bind(null, 'queries'),
|
|
1845
|
-
action: create.bind(null, 'actions'),
|
|
1846
|
-
signal: create.bind(null, 'signals'),
|
|
1847
|
-
entity(entity) {
|
|
1848
|
-
const URL = create('entities', entity);
|
|
1849
|
-
return {
|
|
1850
|
-
create: () => URL,
|
|
1851
|
-
update: (id) => URL + '/' + id,
|
|
1852
|
-
remove: (id) => URL + '/' + id
|
|
1853
|
-
};
|
|
1854
|
-
}
|
|
1855
|
-
};
|
|
1856
|
-
}
|
|
1857
|
-
const endpointFactory = endpointFactoryFunction;
|
|
1858
|
-
// ADD HERE YOUR NEW ENDPOINT
|
|
1859
|
-
const PLATFORM_FEATURE_TOGGLE = endpointFactoryFunction('platform', 'feature_toggle');
|
|
1860
|
-
|
|
1861
|
-
let FeatureToggleService = class FeatureToggleService {
|
|
1862
|
-
constructor(http) {
|
|
1863
|
-
this.http = http;
|
|
1864
|
-
this.cache = {};
|
|
1865
|
-
}
|
|
1866
|
-
isEnabled({ domain, service, name }, tenant) {
|
|
1867
|
-
let tenantObs;
|
|
1868
|
-
if (tenant) {
|
|
1869
|
-
tenantObs = of(tenant);
|
|
1870
|
-
}
|
|
1871
|
-
else {
|
|
1872
|
-
tenantObs = from(user.getUserData()).pipe(map(userData => userData.tenantName));
|
|
1873
|
-
}
|
|
1874
|
-
return tenantObs.pipe(mergeMap(tenant => {
|
|
1875
|
-
const key = JSON.stringify({ tenant, domain, service });
|
|
1876
|
-
if (!this.cache[key]) {
|
|
1877
|
-
this.cache[key] = this.http
|
|
1878
|
-
.post(PLATFORM_FEATURE_TOGGLE.query('getEnabledFeatures'), { tenant, domain, service })
|
|
1879
|
-
.pipe(map(output => output.features), shareReplay(1), catchError(err => {
|
|
1880
|
-
console.error(err);
|
|
1881
|
-
delete this.cache[key];
|
|
1882
|
-
return of([]);
|
|
1883
|
-
}));
|
|
1884
|
-
}
|
|
1885
|
-
return this.cache[key];
|
|
1886
|
-
}), map((features) => {
|
|
1887
|
-
return features.findIndex(f => f.name === name) !== -1;
|
|
1888
|
-
}));
|
|
1889
|
-
}
|
|
1890
|
-
};
|
|
1891
|
-
FeatureToggleService.ctorParameters = () => [
|
|
1892
|
-
{ type: HttpClient }
|
|
1893
|
-
];
|
|
1894
|
-
FeatureToggleService.ɵprov = ɵɵdefineInjectable({ factory: function FeatureToggleService_Factory() { return new FeatureToggleService(ɵɵinject(HttpClient)); }, token: FeatureToggleService, providedIn: "root" });
|
|
1895
|
-
FeatureToggleService = __decorate([
|
|
1896
|
-
Injectable({ providedIn: 'root' })
|
|
1897
|
-
], FeatureToggleService);
|
|
1898
|
-
|
|
1899
|
-
let FeatureToggleModule = class FeatureToggleModule {
|
|
1900
|
-
};
|
|
1901
|
-
FeatureToggleModule = __decorate([
|
|
1902
|
-
NgModule({
|
|
1903
|
-
imports: [HttpClientModule, HttpInterceptorModule],
|
|
1904
|
-
providers: [FeatureToggleService]
|
|
1905
|
-
})
|
|
1906
|
-
], FeatureToggleModule);
|
|
1907
|
-
|
|
1908
|
-
var UserAction;
|
|
1909
|
-
(function (UserAction) {
|
|
1910
|
-
UserAction["CONFIRMED"] = "CONFIRMED";
|
|
1911
|
-
UserAction["POSTPONED"] = "POSTPONED";
|
|
1912
|
-
UserAction["REFUSED"] = "REFUSED";
|
|
1913
|
-
})(UserAction || (UserAction = {}));
|
|
1914
|
-
|
|
1915
|
-
let SpotlightService = class SpotlightService {
|
|
1916
|
-
constructor(http) {
|
|
1917
|
-
this.http = http;
|
|
1918
|
-
this.API_URL = 'platform/spotlight/';
|
|
1919
|
-
}
|
|
1920
|
-
getUser() {
|
|
1921
|
-
return this.http.post('platform/user/queries/getUser', {}).toPromise();
|
|
1922
|
-
}
|
|
1923
|
-
listSpotlightScreen() {
|
|
1924
|
-
return this.http.get(this.API_URL + 'queries/listSpotlightScreen');
|
|
1925
|
-
}
|
|
1926
|
-
listSpotlightUsers() {
|
|
1927
|
-
return this.http.get(this.API_URL + 'queries/listSpotlightUsers').toPromise();
|
|
1928
|
-
}
|
|
1929
|
-
listSpotlightControl() {
|
|
1930
|
-
return this.http.get(this.API_URL + 'queries/listSpotlightControl').toPromise();
|
|
1931
|
-
}
|
|
1932
|
-
saveSpotlightUser(content) {
|
|
1933
|
-
return this.http.post(this.API_URL + 'actions/saveSpotlightUsers', { content });
|
|
1934
|
-
}
|
|
1935
|
-
saveSpotlightControl(content) {
|
|
1936
|
-
return this.http.post(this.API_URL + 'actions/saveSpotlightControl', { content });
|
|
1937
|
-
}
|
|
1938
|
-
notificateSpotlight(content) {
|
|
1939
|
-
return this.http.post(this.API_URL + 'actions/notificateSpotlight', content);
|
|
1940
|
-
}
|
|
1941
|
-
};
|
|
1942
|
-
SpotlightService.ctorParameters = () => [
|
|
1943
|
-
{ type: HttpClient }
|
|
1944
|
-
];
|
|
1945
|
-
SpotlightService = __decorate([
|
|
1946
|
-
Injectable()
|
|
1947
|
-
], SpotlightService);
|
|
1948
|
-
|
|
1949
|
-
var EnumDisplayType;
|
|
1950
|
-
(function (EnumDisplayType) {
|
|
1951
|
-
EnumDisplayType["ADVERSITING"] = "ADVERSITING";
|
|
1952
|
-
EnumDisplayType["INTEGRATION"] = "INTEGRATION";
|
|
1953
|
-
})(EnumDisplayType || (EnumDisplayType = {}));
|
|
1954
|
-
|
|
1955
|
-
class SpotlightControl {
|
|
1956
|
-
}
|
|
1957
|
-
|
|
1958
|
-
var EnumSpotlightStatus;
|
|
1959
|
-
(function (EnumSpotlightStatus) {
|
|
1960
|
-
EnumSpotlightStatus["ACTIVE"] = "ACTIVE";
|
|
1961
|
-
EnumSpotlightStatus["IN_PROGRESS"] = "IN_PROGRESS";
|
|
1962
|
-
EnumSpotlightStatus["NO_STARTED"] = "NO_STARTED";
|
|
1963
|
-
EnumSpotlightStatus["REFUSED"] = "REFUSED";
|
|
1964
|
-
})(EnumSpotlightStatus || (EnumSpotlightStatus = {}));
|
|
1965
|
-
|
|
1966
|
-
let SpotlightComponent = class SpotlightComponent {
|
|
1967
|
-
constructor(spotlightService, cookieService, datePipe) {
|
|
1968
|
-
this.spotlightService = spotlightService;
|
|
1969
|
-
this.cookieService = cookieService;
|
|
1970
|
-
this.datePipe = datePipe;
|
|
1971
|
-
this.canAppear = false;
|
|
1972
|
-
this.visible = false;
|
|
1973
|
-
this.fade = false;
|
|
1974
|
-
this.visibleChange = new EventEmitter();
|
|
1975
|
-
}
|
|
1976
|
-
ngOnInit() {
|
|
1977
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1978
|
-
yield this.setValues();
|
|
1979
|
-
this.fetchSpotlight();
|
|
1980
|
-
});
|
|
1981
|
-
}
|
|
1982
|
-
setValues() {
|
|
1983
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1984
|
-
const userData = JSON.parse(this.cookieService.get('com.senior.token'));
|
|
1985
|
-
this.currentUser = userData.username;
|
|
1986
|
-
this.spotlightUsersList = yield this.spotlightService.listSpotlightUsers();
|
|
1987
|
-
this.spotlightControlsList = yield this.spotlightService.listSpotlightControl();
|
|
1988
|
-
});
|
|
1989
|
-
}
|
|
1990
|
-
setValuesInSpotlight(values) {
|
|
1991
|
-
this.header = values.spotlightTitle;
|
|
1992
|
-
this.imgUrl = values.bannerUrl;
|
|
1993
|
-
this.primaryButtonLabel = values.primaryButtonLabel;
|
|
1994
|
-
this.primaryButtonTooltip = values.primaryButtonHint;
|
|
1995
|
-
}
|
|
1996
|
-
getShowDate(days) {
|
|
1997
|
-
const currentDate = new Date();
|
|
1998
|
-
return this.datePipe.transform(currentDate.setDate(currentDate.getDate() + days).toString(), 'yyyy-MM-dd');
|
|
1999
|
-
}
|
|
2000
|
-
fetchSpotlight() {
|
|
2001
|
-
this.spotlightService.listSpotlightScreen().subscribe(value => {
|
|
2002
|
-
this.spotlightScreen = value.contents.filter(val => val.screenMenuId === this.menuId)[0];
|
|
2003
|
-
if (this.spotlightScreen) {
|
|
2004
|
-
this.showSpotlight(this.spotlightScreen.spotlight);
|
|
2005
|
-
}
|
|
2006
|
-
});
|
|
2007
|
-
}
|
|
2008
|
-
showSpotlight(spotlight) {
|
|
2009
|
-
if (this.validateDate(spotlight.initialDate) && this.validateFinalDate(spotlight.finalDate) && this.validateSpotlight(spotlight)) {
|
|
2010
|
-
this.setValuesInSpotlight(spotlight);
|
|
2011
|
-
this.canAppear = true;
|
|
2012
|
-
const control = this.getSpotlightControlFromList(this.spotlightScreen.spotlight.id);
|
|
2013
|
-
this.canEmitEvent = !control || this.currentUser !== control.firstUser;
|
|
2014
|
-
}
|
|
2015
|
-
}
|
|
2016
|
-
validateDate(date) {
|
|
2017
|
-
if (date) {
|
|
2018
|
-
const currentDate = this.datePipe.transform(new Date().toString(), 'yyyy-MM-dd');
|
|
2019
|
-
const initialDate = this.datePipe.transform(date, 'yyyy-MM-dd');
|
|
2020
|
-
return currentDate >= initialDate;
|
|
2021
|
-
}
|
|
2022
|
-
return false;
|
|
2023
|
-
}
|
|
2024
|
-
validateFinalDate(date) {
|
|
2025
|
-
if (date) {
|
|
2026
|
-
const currentDate = this.datePipe.transform(new Date().toString(), 'yyyy-MM-dd');
|
|
2027
|
-
const finalDate = this.datePipe.transform(date, 'yyyy-MM-dd');
|
|
2028
|
-
return currentDate <= finalDate;
|
|
2029
|
-
}
|
|
2030
|
-
return true;
|
|
2031
|
-
}
|
|
2032
|
-
validateSpotlight(spotlight) {
|
|
2033
|
-
if (!this.validateControlsList(this.spotlightControlsList, spotlight, this.currentUser)) {
|
|
2034
|
-
return false;
|
|
2035
|
-
}
|
|
2036
|
-
if (!this.validateDisplayType(spotlight, this.spotlightUsersList, this.spotlightControlsList, this.currentUser)) {
|
|
2037
|
-
return false;
|
|
2038
|
-
}
|
|
2039
|
-
return true;
|
|
2040
|
-
}
|
|
2041
|
-
validateControlsList(controlsList, spotlight, currentUser) {
|
|
2042
|
-
if (controlsList.totalElements) {
|
|
2043
|
-
const notCompatibleControls = controlsList.contents.filter(control => {
|
|
2044
|
-
if (control.status === EnumSpotlightStatus.ACTIVE) {
|
|
2045
|
-
return control.spotlightId === spotlight.id;
|
|
2046
|
-
}
|
|
2047
|
-
else if (control.status === EnumSpotlightStatus.IN_PROGRESS) {
|
|
2048
|
-
return control.spotlightId === spotlight.id && control.firstUser !== currentUser;
|
|
2049
|
-
}
|
|
2050
|
-
});
|
|
2051
|
-
if (notCompatibleControls.length > 0) {
|
|
2052
|
-
return false;
|
|
2053
|
-
}
|
|
2054
|
-
}
|
|
2055
|
-
return true;
|
|
2056
|
-
}
|
|
2057
|
-
validateDisplayType(spotlight, usersList, controlsList, currentUser) {
|
|
2058
|
-
switch (spotlight.displayType) {
|
|
2059
|
-
case EnumDisplayType.ADVERSITING:
|
|
2060
|
-
return usersList.totalElements ? this.validateUser(usersList.contents, spotlight) : true;
|
|
2061
|
-
case EnumDisplayType.INTEGRATION:
|
|
2062
|
-
if (controlsList.totalElements) {
|
|
2063
|
-
const compatibleControls = controlsList.contents.filter(control => {
|
|
2064
|
-
switch (control.status) {
|
|
2065
|
-
case EnumSpotlightStatus.NO_STARTED:
|
|
2066
|
-
return control.spotlightId === spotlight.id;
|
|
2067
|
-
case EnumSpotlightStatus.REFUSED:
|
|
2068
|
-
return usersList.totalElements ? this.validateUser(usersList.contents, spotlight) : true;
|
|
2069
|
-
case EnumSpotlightStatus.IN_PROGRESS:
|
|
2070
|
-
return control.firstUser === currentUser
|
|
2071
|
-
&& control.spotlightId === spotlight.id;
|
|
2072
|
-
}
|
|
2073
|
-
});
|
|
2074
|
-
if (compatibleControls.length === 0) {
|
|
2075
|
-
return false;
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2078
|
-
return true;
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
validateUser(users, spotlight) {
|
|
2082
|
-
let spotlightUsers = users.filter(user => user.spotlightId === spotlight.id);
|
|
2083
|
-
if (!spotlightUsers.length) {
|
|
2084
|
-
spotlightUsers = users.filter(user => user.userOperation === this.currentUser);
|
|
2085
|
-
return spotlightUsers.length === 0;
|
|
2086
|
-
}
|
|
2087
|
-
const compatibleUserToValidate = spotlightUsers.filter(user => user.userOperation === this.currentUser)[0];
|
|
2088
|
-
return compatibleUserToValidate ? this.validateDate(compatibleUserToValidate.showDate) : true;
|
|
2089
|
-
}
|
|
2090
|
-
saveSpotlightUser(days) {
|
|
2091
|
-
const spotlight = this.spotlightScreen.spotlight;
|
|
2092
|
-
const user = this.spotlightUsersList.contents.filter(val => {
|
|
2093
|
-
return val.spotlightId === spotlight.id
|
|
2094
|
-
&& val.userOperation === this.currentUser;
|
|
2095
|
-
})[0];
|
|
2096
|
-
let spotlightUser = {
|
|
2097
|
-
spotlightId: spotlight.id,
|
|
2098
|
-
showDate: days ? this.getShowDate(days) : null,
|
|
2099
|
-
userOperation: this.currentUser
|
|
2100
|
-
};
|
|
2101
|
-
if (user) {
|
|
2102
|
-
spotlightUser = Object.assign({ id: user.id }, spotlightUser);
|
|
2103
|
-
}
|
|
2104
|
-
this.spotlightService.saveSpotlightUser(spotlightUser).subscribe();
|
|
2105
|
-
}
|
|
2106
|
-
onPrimary() {
|
|
2107
|
-
const spotlight = this.spotlightScreen.spotlight;
|
|
2108
|
-
const notification = this.buildNotification(UserAction.CONFIRMED);
|
|
2109
|
-
this.saveSpotlightControl();
|
|
2110
|
-
this.saveSpotlightUser();
|
|
2111
|
-
if (this.canEmitEvent) {
|
|
2112
|
-
this.spotlightService.notificateSpotlight(notification).subscribe();
|
|
2113
|
-
}
|
|
2114
|
-
if (spotlight.primaryButtonUrl) {
|
|
2115
|
-
window.open(spotlight.primaryButtonUrl);
|
|
2116
|
-
}
|
|
2117
|
-
this.close();
|
|
2118
|
-
}
|
|
2119
|
-
onSecondary() {
|
|
2120
|
-
const notification = this.buildNotification(UserAction.POSTPONED);
|
|
2121
|
-
this.saveSpotlightControl(EnumSpotlightStatus.REFUSED);
|
|
2122
|
-
this.saveSpotlightUser(this.spotlightScreen.spotlight.daysRememberLate);
|
|
2123
|
-
this.spotlightService.notificateSpotlight(notification).subscribe();
|
|
2124
|
-
this.close();
|
|
2125
|
-
}
|
|
2126
|
-
onTertiary() {
|
|
2127
|
-
const notification = this.buildNotification(UserAction.REFUSED);
|
|
2128
|
-
this.saveSpotlightControl(EnumSpotlightStatus.REFUSED);
|
|
2129
|
-
this.saveSpotlightUser(this.spotlightScreen.spotlight.daysNotInterested);
|
|
2130
|
-
this.spotlightService.notificateSpotlight(notification).subscribe();
|
|
2131
|
-
this.close();
|
|
2132
|
-
}
|
|
2133
|
-
/**
|
|
2134
|
-
* Verifica se um registro de usuário pertence ao usuário logado e corresponde ao spotlight atual
|
|
2135
|
-
* @param user SpotlightUser Objeto representando o registro do usuário para uma spotlight
|
|
2136
|
-
* @param spotlight Spotlight Spotlight
|
|
2137
|
-
* @returns boolean true se corresponder ao spotlight atual, false caso contrário
|
|
2138
|
-
*/
|
|
2139
|
-
hasThisRegister(user, spotlight) {
|
|
2140
|
-
return (user.spotlightId === spotlight.id && user.userOperation === this.currentUser);
|
|
2141
|
-
}
|
|
2142
|
-
/**
|
|
2143
|
-
* Verifica se um registro de usuário pertece ao usuário logado, mas não corresponde ao spotlight atual
|
|
2144
|
-
* @param user SpotlightUser Objeto representando o registro do usuário para uma spotlight
|
|
2145
|
-
* @param spotlight Spotlight Spotlight
|
|
2146
|
-
* @returns boolean true se corresponder ao spotlight atual, false caso contrário
|
|
2147
|
-
*/
|
|
2148
|
-
hasAnotherRegister(user, spotlight) {
|
|
2149
|
-
return user.spotlightId !== spotlight.id && user.userOperation === this.currentUser;
|
|
2150
|
-
}
|
|
2151
|
-
/**
|
|
2152
|
-
* Persiste um novo registro de controle para o spotlight atual se
|
|
2153
|
-
* não for encontrado nenhum na lista de controles carregada inicialmente
|
|
2154
|
-
* @param status EnumSpotlightStatus Status do controle do spotlight. Se nenhum for informado, IN_PROGRESS será aplicado
|
|
2155
|
-
* @returns SpotlightControl Controle do spotlight recuperado/pesistido
|
|
2156
|
-
*/
|
|
2157
|
-
saveSpotlightControl(status = EnumSpotlightStatus.IN_PROGRESS) {
|
|
2158
|
-
const spotlight = this.spotlightScreen.spotlight;
|
|
2159
|
-
let control = this.getSpotlightControlFromList(spotlight.id);
|
|
2160
|
-
if (!control) {
|
|
2161
|
-
control = {
|
|
2162
|
-
spotlightId: spotlight.id,
|
|
2163
|
-
status: status,
|
|
2164
|
-
firstUser: this.currentUser
|
|
2165
|
-
};
|
|
2166
|
-
}
|
|
2167
|
-
if (this.isNewControl(control) || control.status !== EnumSpotlightStatus.IN_PROGRESS) {
|
|
2168
|
-
control.status = status;
|
|
2169
|
-
control.firstUser = status === EnumSpotlightStatus.IN_PROGRESS ? this.currentUser : '';
|
|
2170
|
-
this.spotlightService.saveSpotlightControl(control).subscribe();
|
|
2171
|
-
}
|
|
2172
|
-
return control;
|
|
2173
|
-
}
|
|
2174
|
-
/**
|
|
2175
|
-
* Retorna o controle de spotlight correspondente ao identificador
|
|
2176
|
-
* informado na lista de controles carregada na inicialização do componente
|
|
2177
|
-
* @param id string Identificador do controle de spotlight
|
|
2178
|
-
*/
|
|
2179
|
-
getSpotlightControlFromList(id) {
|
|
2180
|
-
return this.spotlightControlsList.contents.filter(val => val.spotlightId === id)[0];
|
|
2181
|
-
}
|
|
2182
|
-
/**
|
|
2183
|
-
* Verifica se o controle de spotlight informado não foi registrado ainda
|
|
2184
|
-
* @param spotlightControl SpotlightControl Controle do spotlight
|
|
2185
|
-
* @returns boolean true se ainda não foi registrado na base, false caso contrário
|
|
2186
|
-
*/
|
|
2187
|
-
isNewControl(spotlightControl) {
|
|
2188
|
-
return !this.spotlightControlsList.contents.includes(spotlightControl);
|
|
2189
|
-
}
|
|
2190
|
-
/**
|
|
2191
|
-
* Retorna um objeto de notificação referente ao botão clicado pelo usuário.
|
|
2192
|
-
* @param userAction UserAction Ação realizada pelo usuário ao clicar nos botões da modal
|
|
2193
|
-
* @returns SpotlightNotification Objeto de notificação
|
|
2194
|
-
*/
|
|
2195
|
-
buildNotification(userAction) {
|
|
2196
|
-
const spotlight = this.spotlightScreen.spotlight;
|
|
2197
|
-
return {
|
|
2198
|
-
clickedButton: userAction,
|
|
2199
|
-
spotlightControlId: spotlight.id,
|
|
2200
|
-
primaryButtonUrl: spotlight.primaryButtonUrl
|
|
2201
|
-
};
|
|
2202
|
-
}
|
|
2203
|
-
close() {
|
|
2204
|
-
this.visibleChange.emit(false);
|
|
2205
|
-
}
|
|
2206
|
-
};
|
|
2207
|
-
SpotlightComponent.ctorParameters = () => [
|
|
2208
|
-
{ type: SpotlightService },
|
|
2209
|
-
{ type: CookieService },
|
|
2210
|
-
{ type: DatePipe }
|
|
2211
|
-
];
|
|
2212
|
-
__decorate([
|
|
2213
|
-
Input()
|
|
2214
|
-
], SpotlightComponent.prototype, "visible", void 0);
|
|
2215
|
-
__decorate([
|
|
2216
|
-
Input()
|
|
2217
|
-
], SpotlightComponent.prototype, "menuId", void 0);
|
|
2218
|
-
__decorate([
|
|
2219
|
-
Input()
|
|
2220
|
-
], SpotlightComponent.prototype, "fade", void 0);
|
|
2221
|
-
__decorate([
|
|
2222
|
-
Output()
|
|
2223
|
-
], SpotlightComponent.prototype, "visibleChange", void 0);
|
|
2224
|
-
SpotlightComponent = __decorate([
|
|
2225
|
-
Component({
|
|
2226
|
-
selector: 's-spotlight',
|
|
2227
|
-
template: "<div class=\"s-spotlight-overlay\" id=\"ol\" *ngIf=\"canAppear && visible\">\n <div class=\"s-spotlight\" id=\"sl\" [ngClass]=\"{'s-effect-fadein': fade}\">\n <div class=\"s-spotlight-header\">\n <span class=\"s-spotlight-title\">{{header.toUpperCase()}}</span>\n <a role=\"button\" class=\"s-spotlight-close\" (click)=\"close()\"><span class=\"fa fa-times\" aria-hidden=\"true\"></span></a>\n </div>\n <div class=\"s-img\">\n <img src=\"{{imgUrl}}\">\n </div>\n <div class=\"s-spotlight-footer\">\n <div class=\"s-spotlight-footer-left\">\n <button\n pButton\n type=\"submit\"\n id=\"decline-button\"\n label=\"{{'platform.spotlight.no_interest' | translate}}\"\n (click)=\"onTertiary()\"\n class=\"ui-button-link\">\n </button>\n </div>\n <div class=\"s-spotlight-footer-right\">\n <button\n pButton\n type=\"submit\"\n id=\"remember-button\"\n label=\"{{'platform.spotlight.remember_late' | translate}}\"\n (click)=\"onSecondary()\"\n class=\"ui-button-raised ui-button-secondary\">\n </button>\n <button\n pButton\n label=\"{{primaryButtonLabel}}\"\n type=\"submit\"\n id=\"submit-button\"\n (click)=\"onPrimary()\"\n [pTooltip]=\"primaryButtonTooltip\"\n tooltipPosition=\"top\"\n showDelay=\"500\"\n class=\"ui-button-raised\">\n </button>\n </div>\n </div>\n</div>\n</div>",
|
|
2228
|
-
styles: [".s-spotlight-overlay{display:-ms-flexbox;display:flex;position:fixed;z-index:10;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:rgba(0,0,0,.4)}.s-spotlight{border-radius:3px;background:#fff;margin:auto;overflow:hidden;animation:.15s forwards move}.s-spotlight-footer,.s-spotlight-header{display:-ms-flexbox;display:flex;padding:15px}.s-spotlight-header{-ms-flex-align:center;align-items:center;-ms-flex-pack:justify;justify-content:space-between}.s-spotlight-footer,.s-spotlight-footer-left,.s-spotlight-footer-right{display:-ms-flexbox;display:flex}.s-spotlight-footer-right{-ms-flex:2;flex:2;-ms-flex-pack:end;justify-content:flex-end}.s-spotlight-footer-left{-ms-flex:1;flex:1;-ms-flex-pack:start;justify-content:flex-start}.s-spotlight-title{font-family:\"Open Sans\",sans-serif;font-size:16px;font-weight:400;color:#333}.s-spotlight-close{display:block;margin-left:15px;color:#000}.s-img{width:100%;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}.s-img img{width:100%}.s-effect-fadein{animation:.15s forwards fade}@keyframes fade{0%{opacity:0}100%{opacity:1}}@media (max-width:595px){.s-spotlight-footer,.s-spotlight-footer-left,.s-spotlight-footer-right{-ms-flex-align:center;align-items:center;-ms-flex-direction:column-reverse;flex-direction:column-reverse}.s-spotlight-footer button{margin:0 0 15px!important;width:100%!important}}@media (min-width:576px){.s-spotlight{width:100%}}@media (min-width:768px){.s-spotlight{width:720px}.s-spotlight-footer,.s-spotlight-footer-left,.s-spotlight-footer-right{-ms-flex-direction:row;flex-direction:row}}@media (min-width:992px){.s-spotlight{width:960px}}@media (min-width:1200px){.s-spotlight{width:50%}}"]
|
|
2229
|
-
})
|
|
2230
|
-
], SpotlightComponent);
|
|
2231
|
-
|
|
2232
|
-
const fallback$1 = {
|
|
2233
|
-
'platform.spotlight.no_interest': 'Não tenho interesse',
|
|
2234
|
-
'platform.spotlight.remember_late': 'Lembrar mais tarde'
|
|
2235
|
-
};
|
|
2236
|
-
|
|
2237
|
-
let TranslatePipe$1 = class TranslatePipe {
|
|
2238
|
-
constructor(translationService) {
|
|
2239
|
-
this.translationService = translationService;
|
|
2240
|
-
}
|
|
2241
|
-
transform(value) {
|
|
2242
|
-
return this.translationService.instant(value);
|
|
2243
|
-
}
|
|
2244
|
-
};
|
|
2245
|
-
TranslatePipe$1.ctorParameters = () => [
|
|
2246
|
-
{ type: TranslateService }
|
|
2247
|
-
];
|
|
2248
|
-
TranslatePipe$1 = __decorate([
|
|
2249
|
-
Pipe({
|
|
2250
|
-
name: 'translate',
|
|
2251
|
-
pure: false,
|
|
2252
|
-
})
|
|
2253
|
-
], TranslatePipe$1);
|
|
2254
|
-
|
|
2255
|
-
let SpotlightModule = class SpotlightModule {
|
|
2256
|
-
};
|
|
2257
|
-
SpotlightModule = __decorate([
|
|
2258
|
-
NgModule({
|
|
2259
|
-
imports: [
|
|
2260
|
-
ButtonModule$1,
|
|
2261
|
-
TooltipModule,
|
|
2262
|
-
CommonModule,
|
|
2263
|
-
HttpInterceptorModule,
|
|
2264
|
-
TranslationsModule.forChild([{ domain: 'platform', service: 'spotlight', fallback: fallback$1 }]),
|
|
2265
|
-
],
|
|
2266
|
-
providers: [
|
|
2267
|
-
SpotlightService,
|
|
2268
|
-
DatePipe,
|
|
2269
|
-
CookieService
|
|
2270
|
-
],
|
|
2271
|
-
declarations: [
|
|
2272
|
-
SpotlightComponent,
|
|
2273
|
-
TranslatePipe$1
|
|
2274
|
-
],
|
|
2275
|
-
exports: [SpotlightComponent]
|
|
2276
|
-
})
|
|
2277
|
-
], SpotlightModule);
|
|
2278
|
-
|
|
2279
|
-
/**
|
|
2280
|
-
* Generated bundle index. Do not edit.
|
|
2281
|
-
*/
|
|
2282
|
-
|
|
2283
|
-
export { AdvancedFilterComponent, AdvancedFilterModule, AdvancedFilterService, AppRoutingModule, CyclicJsonInterceptorModule, FeatureToggleModule, FeatureToggleService, Filter, FilterType, FormFilter, HttpInterceptorModule, LENGTH_DEFAULT, PermissionsModule, PermissionsService, RestUrl, Scope, SpotlightComponent, SpotlightModule, TranslationsConfig, TranslationsModule, USER_INFO, XServicesUrl, factory, promise, fallback as ɵa, CalendarOptionsService as ɵb, FormFilterComponent as ɵc, MapValuesPipe as ɵd, TranslatePipe as ɵe, CyclicJsonInterceptor as ɵf, HttpInterceptor as ɵg, RESOURCES as ɵh, ENVIRONMENT as ɵi, Environment as ɵk, fallback$1 as ɵl, SpotlightService as ɵm, TranslatePipe$1 as ɵn };
|
|
2284
|
-
//# sourceMappingURL=seniorsistemas-platform-components.js.map
|