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