@seniorsistemas/platform-components 5.3.2-develop-a39d6d30 → 5.3.3-feature-ptfgap-1001-b8dc76dc
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/bundles/seniorsistemas-platform-components.umd.js +620 -409
- package/bundles/seniorsistemas-platform-components.umd.js.map +1 -1
- package/bundles/seniorsistemas-platform-components.umd.min.js +2 -2
- package/bundles/seniorsistemas-platform-components.umd.min.js.map +1 -1
- package/esm2015/modules/advanced-filter/advanced-filter.module.js +1 -3
- package/esm2015/modules/advanced-filter/components/advanced-filter/advanced-filter.component.js +3 -3
- package/esm2015/modules/advanced-filter/components/form-filter/form-filter.component.js +209 -114
- package/esm2015/modules/advanced-filter/constants/form-filter.constants.js +45 -0
- package/esm2015/modules/advanced-filter/index.js +13 -5
- package/esm2015/modules/advanced-filter/models/form-filter.js +1 -1
- package/esm2015/modules/advanced-filter/services/advanced-filter.service.js +42 -36
- package/esm2015/modules/advanced-filter/utils/comparator.js +1 -1
- package/esm2015/modules/advanced-filter/utils/filter-value/index.js +6 -10
- package/esm2015/modules/advanced-filter/utils/filterOperators.js +1 -1
- package/esm2015/modules/advanced-filter/utils/form-field/index.js +6 -10
- package/esm2015/modules/advanced-filter/utils/json-path.js +1 -1
- package/esm2015/modules/http-interceptor/http-interceptor.service.js +2 -2
- package/esm2015/modules/permissions/permissions.service.js +100 -70
- package/esm2015/modules/spotlight/component/spotlight.component.js +3 -3
- package/esm2015/modules/translations/translations.module.js +131 -120
- package/esm5/modules/advanced-filter/advanced-filter.module.js +1 -7
- package/esm5/modules/advanced-filter/components/advanced-filter/advanced-filter.component.js +3 -3
- package/esm5/modules/advanced-filter/components/form-filter/form-filter.component.js +223 -115
- package/esm5/modules/advanced-filter/constants/form-filter.constants.js +45 -0
- package/esm5/modules/advanced-filter/index.js +13 -5
- package/esm5/modules/advanced-filter/models/form-filter.js +1 -1
- package/esm5/modules/advanced-filter/services/advanced-filter.service.js +42 -35
- package/esm5/modules/advanced-filter/utils/comparator.js +1 -1
- package/esm5/modules/advanced-filter/utils/filter-value/index.js +6 -10
- package/esm5/modules/advanced-filter/utils/filterOperators.js +1 -1
- package/esm5/modules/advanced-filter/utils/form-field/index.js +6 -10
- package/esm5/modules/advanced-filter/utils/json-path.js +1 -1
- package/esm5/modules/http-interceptor/http-interceptor.service.js +2 -2
- package/esm5/modules/permissions/permissions.service.js +108 -72
- package/esm5/modules/spotlight/component/spotlight.component.js +3 -3
- package/esm5/modules/translations/translations.module.js +188 -163
- package/fesm2015/seniorsistemas-platform-components.js +539 -360
- package/fesm2015/seniorsistemas-platform-components.js.map +1 -1
- package/fesm5/seniorsistemas-platform-components.js +618 -409
- package/fesm5/seniorsistemas-platform-components.js.map +1 -1
- package/modules/advanced-filter/advanced-filter.module.d.ts +0 -2
- package/modules/advanced-filter/components/form-filter/form-filter.component.d.ts +42 -14
- package/modules/advanced-filter/constants/form-filter.constants.d.ts +40 -0
- package/modules/advanced-filter/index.d.ts +14 -4
- package/modules/advanced-filter/models/form-filter.d.ts +9 -2
- package/modules/advanced-filter/services/advanced-filter.service.d.ts +7 -4
- package/modules/advanced-filter/utils/comparator.d.ts +1 -1
- package/modules/advanced-filter/utils/filterOperators.d.ts +7 -7
- package/modules/advanced-filter/utils/json-path.d.ts +3 -1
- package/modules/permissions/permissions.service.d.ts +10 -4
- package/modules/translations/translations.module.d.ts +2 -2
- package/package.json +1 -1
- package/seniorsistemas-platform-components.metadata.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('primeng/button'), require('primeng/dialog'), require('primeng/tabview'), require('primeng/toast'), require('primeng/tooltip'), require('primeng/api'), require('@seniorsistemas/angular-components'), require('@ngx-translate/core'), require('@angular/common/http'), require('@seniorsistemas/senior-platform-data'), require('ngx-cookie-service'), require('rxjs'), require('rxjs/operators'), require('@angular/router'), require('moment'), require('ramda'), require('json-cycle')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define('@seniorsistemas/platform-components', ['exports', '@angular/core', '@angular/common', '@angular/forms', 'primeng/button', 'primeng/dialog', 'primeng/tabview', 'primeng/toast', 'primeng/tooltip', 'primeng/api', '@seniorsistemas/angular-components', '@ngx-translate/core', '@angular/common/http', '@seniorsistemas/senior-platform-data', 'ngx-cookie-service', 'rxjs', 'rxjs/operators', '@angular/router', 'moment', 'ramda', 'json-cycle'], factory) :
|
|
4
|
-
(global = global || self, factory((global.seniorsistemas = global.seniorsistemas || {}, global.seniorsistemas['platform-components'] = {}), global.ng.core, global.ng.common, global.ng.forms, global.button, global.dialog, global.tabview, global.toast, global.tooltip, global.api, global.angularComponents, global.core$1, global.ng.common.http, global.seniorPlatformData, global.ngxCookieService, global.rxjs, global.rxjs.operators, global.ng.router, global.
|
|
5
|
-
}(this, (function (exports, core, common, forms, button, dialog, tabview, toast, tooltip, api, angularComponents, core$1, http, seniorPlatformData, ngxCookieService, rxjs, operators, router,
|
|
4
|
+
(global = global || self, factory((global.seniorsistemas = global.seniorsistemas || {}, global.seniorsistemas['platform-components'] = {}), global.ng.core, global.ng.common, global.ng.forms, global.button, global.dialog, global.tabview, global.toast, global.tooltip, global.api, global.angularComponents, global.core$1, global.ng.common.http, global.seniorPlatformData, global.ngxCookieService, global.rxjs, global.rxjs.operators, global.ng.router, global.momentNs__default, global.ramda, global.jsonCycle));
|
|
5
|
+
}(this, (function (exports, core, common, forms, button, dialog, tabview, toast, tooltip, api, angularComponents, core$1, http, seniorPlatformData, ngxCookieService, rxjs, operators, router, momentNs__default, ramda, jsonCycle) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
var momentNs__default__default = 'default' in momentNs__default ? momentNs__default['default'] : momentNs__default;
|
|
8
8
|
jsonCycle = jsonCycle && Object.prototype.hasOwnProperty.call(jsonCycle, 'default') ? jsonCycle['default'] : jsonCycle;
|
|
9
9
|
|
|
10
10
|
/*! *****************************************************************************
|
|
@@ -304,176 +304,201 @@
|
|
|
304
304
|
], TranslationsModule);
|
|
305
305
|
return TranslationsModule;
|
|
306
306
|
}());
|
|
307
|
-
function
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
return __generator(this, function (_a) {
|
|
315
|
-
switch (_a.label) {
|
|
316
|
-
case 0:
|
|
317
|
-
locale = 'pt-BR';
|
|
318
|
-
_a.label = 1;
|
|
319
|
-
case 1:
|
|
320
|
-
_a.trys.push([1, 8, , 9]);
|
|
321
|
-
configs = getFlatArray(injector.get(TranslationsConfig, Promise.resolve(null)));
|
|
322
|
-
_a.label = 2;
|
|
323
|
-
case 2:
|
|
324
|
-
_a.trys.push([2, 5, , 6]);
|
|
325
|
-
userData = JSON.parse(cookieService.get(USER_INFO));
|
|
326
|
-
if (!userDataIsNull(userData)) return [3 /*break*/, 4];
|
|
327
|
-
return [4 /*yield*/, seniorPlatformData.user.getUserData()];
|
|
328
|
-
case 3:
|
|
329
|
-
userData = _a.sent();
|
|
330
|
-
_a.label = 4;
|
|
331
|
-
case 4:
|
|
332
|
-
locale = getLocale(userData);
|
|
333
|
-
return [3 /*break*/, 6];
|
|
334
|
-
case 5:
|
|
335
|
-
ex_1 = _a.sent();
|
|
336
|
-
console.warn('Unable to obtain user locale');
|
|
337
|
-
return [3 /*break*/, 6];
|
|
338
|
-
case 6:
|
|
339
|
-
fallback = configs.reduce(function (result, configs) { return (__assign(__assign({}, result), configs.fallback)); }, {});
|
|
340
|
-
defaultsLanguages = configs.reduce(function (result, configs) { return (__assign(__assign({}, result), configs.defaultsLanguages)); }, {});
|
|
341
|
-
translate.setTranslation(locale, fallback);
|
|
342
|
-
translate.setDefaultLang(locale);
|
|
343
|
-
configTranslate_1 = {};
|
|
344
|
-
if (defaultsLanguages) {
|
|
345
|
-
configTranslate_1 = getConfigTranslate(defaultsLanguages, locale);
|
|
346
|
-
}
|
|
347
|
-
translationsPromises = configs.map(function (config) { return getTranslationsRequest(config, locale); });
|
|
348
|
-
return [4 /*yield*/, Promise.all(translationsPromises).then(function (results) {
|
|
349
|
-
var usedFallback = translate['overriden'];
|
|
350
|
-
results.forEach(function (file, index) {
|
|
351
|
-
setTranslations(file['content'], usedFallback, locale, index, configTranslate_1.fallbackByLocale);
|
|
352
|
-
});
|
|
353
|
-
return translate.use(locale).toPromise();
|
|
354
|
-
})];
|
|
355
|
-
case 7:
|
|
356
|
-
_a.sent();
|
|
357
|
-
resolve();
|
|
358
|
-
return [3 /*break*/, 9];
|
|
359
|
-
case 8:
|
|
360
|
-
err_1 = _a.sent();
|
|
361
|
-
console.warn('Error setting translations. Using local fallback.', err_1);
|
|
362
|
-
translate
|
|
363
|
-
.use(locale)
|
|
364
|
-
.toPromise()
|
|
365
|
-
.then(function () {
|
|
366
|
-
resolve();
|
|
367
|
-
});
|
|
368
|
-
return [3 /*break*/, 9];
|
|
369
|
-
case 9: return [2 /*return*/];
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
}); });
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
function setTranslations(content, usedFallback, locale, index, fallbackByLocale) {
|
|
376
|
-
if (usedFallback) {
|
|
377
|
-
content && translate.setTranslation(locale, content, true);
|
|
307
|
+
function setTranslations(translate, content, usedFallback, locale, index, fallbackByLocale) {
|
|
308
|
+
if (usedFallback) {
|
|
309
|
+
content && translate.setTranslation(locale, content, true);
|
|
310
|
+
translate.setTranslation(locale, fallbackByLocale, true);
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
if (index === 0) {
|
|
378
314
|
translate.setTranslation(locale, fallbackByLocale, true);
|
|
379
315
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
316
|
+
content && translate.setTranslation(locale, content, true);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function getTranslationsRequest(http$1, _a, language) {
|
|
320
|
+
var domain = _a.domain, service = _a.service;
|
|
321
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
+
var params, headers, _b, _c, _d, url, bundleFiles, languageBundle, overriden, result, err_1;
|
|
323
|
+
return __generator(this, function (_e) {
|
|
324
|
+
switch (_e.label) {
|
|
325
|
+
case 0:
|
|
326
|
+
_e.trys.push([0, 4, , 5]);
|
|
327
|
+
if (!domain && !service) {
|
|
328
|
+
throw new Error("domain and service not found");
|
|
329
|
+
}
|
|
330
|
+
params = new http.HttpParams().set('domainName', domain).set('serviceName', service).set('format', 'FLAT_JSON');
|
|
331
|
+
_c = (_b = new http.HttpHeaders()).set;
|
|
332
|
+
_d = ['Authorization'];
|
|
333
|
+
return [4 /*yield*/, seniorPlatformData.user.getAuthHeader()];
|
|
334
|
+
case 1:
|
|
335
|
+
headers = _c.apply(_b, _d.concat([_e.sent()]));
|
|
336
|
+
url = 'platform/translation_hub/queries/getTranslationBundle';
|
|
337
|
+
return [4 /*yield*/, http$1
|
|
338
|
+
.get(url, { headers: headers, params: params })
|
|
339
|
+
.toPromise()
|
|
340
|
+
.then(function (res) { return res.bundleFiles; })];
|
|
341
|
+
case 2:
|
|
342
|
+
bundleFiles = _e.sent();
|
|
343
|
+
languageBundle = language && bundleFiles.find(function (bundle) { return bundle.language === language; });
|
|
344
|
+
overriden = false;
|
|
345
|
+
if (!languageBundle) {
|
|
346
|
+
languageBundle = bundleFiles.find(function (bundle) { return bundle.language === 'pt-BR'; });
|
|
347
|
+
overriden = true;
|
|
348
|
+
}
|
|
349
|
+
if (!languageBundle) {
|
|
350
|
+
return [2 /*return*/, { overriden: false, content: null }];
|
|
351
|
+
}
|
|
352
|
+
return [4 /*yield*/, http$1.get(languageBundle.url).toPromise()];
|
|
353
|
+
case 3:
|
|
354
|
+
result = _e.sent();
|
|
355
|
+
return [2 /*return*/, {
|
|
356
|
+
overriden: overriden,
|
|
357
|
+
content: result
|
|
358
|
+
}];
|
|
359
|
+
case 4:
|
|
360
|
+
err_1 = _e.sent();
|
|
361
|
+
console.info("Error getting translation bundle for " + domain + "/" + service + ". Using local fallback.", err_1);
|
|
362
|
+
return [2 /*return*/, { overriden: false, content: null }];
|
|
363
|
+
case 5: return [2 /*return*/];
|
|
383
364
|
}
|
|
384
|
-
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
function getFlatArray(array) {
|
|
369
|
+
return array.reduce(function (result, item) {
|
|
370
|
+
if (Array.isArray(item)) {
|
|
371
|
+
return __spread(result, item);
|
|
385
372
|
}
|
|
373
|
+
return __spread(result, [item]);
|
|
374
|
+
}, []);
|
|
375
|
+
}
|
|
376
|
+
function userDataIsNull(data) {
|
|
377
|
+
return !data || Object.keys(data).length === 0;
|
|
378
|
+
}
|
|
379
|
+
function getConfigTranslate(defaultsLanguages, locale) {
|
|
380
|
+
var languages = Object.keys(defaultsLanguages).map(function (key) {
|
|
381
|
+
return {
|
|
382
|
+
locale: key.replace('_', '-'),
|
|
383
|
+
translation: defaultsLanguages[key]
|
|
384
|
+
};
|
|
385
|
+
}, []);
|
|
386
|
+
var result = { languages: languages };
|
|
387
|
+
result['foundLocaleUser'] = languages.find(function (results) { return results.locale === locale; });
|
|
388
|
+
if (!result['foundLocaleUser']) {
|
|
389
|
+
result['foundLocaleUser'] = languages.find(function (results) {
|
|
390
|
+
return results.locale.length === LENGTH_DEFAULT && results.locale === locale.split('-')[0];
|
|
391
|
+
});
|
|
386
392
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
var domain = _a.domain, service = _a.service;
|
|
390
|
-
return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
|
391
|
-
var params, headers, _a, _b, _c, url, bundleFiles, languageBundle, overriden_1, err_2;
|
|
392
|
-
return __generator(this, function (_d) {
|
|
393
|
-
switch (_d.label) {
|
|
394
|
-
case 0:
|
|
395
|
-
_d.trys.push([0, 4, , 5]);
|
|
396
|
-
if (!domain && !service) {
|
|
397
|
-
throw new Error("domain and service not found");
|
|
398
|
-
}
|
|
399
|
-
params = new http.HttpParams().set('domainName', domain).set('serviceName', service).set('format', 'FLAT_JSON');
|
|
400
|
-
_b = (_a = new http.HttpHeaders()).set;
|
|
401
|
-
_c = ['Authorization'];
|
|
402
|
-
return [4 /*yield*/, seniorPlatformData.user.getAuthHeader()];
|
|
403
|
-
case 1:
|
|
404
|
-
headers = _b.apply(_a, _c.concat([_d.sent()]));
|
|
405
|
-
url = 'platform/translation_hub/queries/getTranslationBundle';
|
|
406
|
-
return [4 /*yield*/, http$1
|
|
407
|
-
.get(url, { headers: headers, params: params })
|
|
408
|
-
.toPromise()
|
|
409
|
-
.then(function (res) { return res.bundleFiles; })];
|
|
410
|
-
case 2:
|
|
411
|
-
bundleFiles = _d.sent();
|
|
412
|
-
languageBundle = language && bundleFiles.find(function (bundle) { return bundle.language === language; });
|
|
413
|
-
overriden_1 = false;
|
|
414
|
-
if (!languageBundle) {
|
|
415
|
-
languageBundle = bundleFiles.find(function (bundle) { return bundle.language === 'pt-BR'; });
|
|
416
|
-
overriden_1 = true;
|
|
417
|
-
}
|
|
418
|
-
if (!languageBundle) {
|
|
419
|
-
return [2 /*return*/, resolve({})];
|
|
420
|
-
}
|
|
421
|
-
return [4 /*yield*/, http$1
|
|
422
|
-
.get(languageBundle.url)
|
|
423
|
-
.toPromise()
|
|
424
|
-
.then(function (result) {
|
|
425
|
-
var translations = {
|
|
426
|
-
overriden: overriden_1,
|
|
427
|
-
content: result
|
|
428
|
-
};
|
|
429
|
-
resolve(translations);
|
|
430
|
-
})];
|
|
431
|
-
case 3:
|
|
432
|
-
_d.sent();
|
|
433
|
-
return [3 /*break*/, 5];
|
|
434
|
-
case 4:
|
|
435
|
-
err_2 = _d.sent();
|
|
436
|
-
console.warn("Error getting translation bundle for " + domain + "/" + service + ". Using local fallback.", err_2);
|
|
437
|
-
resolve({});
|
|
438
|
-
return [3 /*break*/, 5];
|
|
439
|
-
case 5: return [2 /*return*/];
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
}); });
|
|
393
|
+
if (result['foundLocaleUser']) {
|
|
394
|
+
result['fallbackByLocale'] = result['foundLocaleUser']['translation'];
|
|
443
395
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
396
|
+
return result;
|
|
397
|
+
}
|
|
398
|
+
function getLocale(userData) {
|
|
399
|
+
return userData.locale || 'pt-BR';
|
|
400
|
+
}
|
|
401
|
+
function initializeTranslations(translate, injector, http, cookieService) {
|
|
402
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
403
|
+
var locale, usedFallback, configs, userData, ex_1, fallback, defaultsLanguages, configTranslate, translationsPromises, results;
|
|
404
|
+
return __generator(this, function (_a) {
|
|
405
|
+
switch (_a.label) {
|
|
406
|
+
case 0:
|
|
407
|
+
locale = 'pt-BR';
|
|
408
|
+
usedFallback = false;
|
|
409
|
+
configs = getFlatArray(injector.get(TranslationsConfig, []));
|
|
410
|
+
_a.label = 1;
|
|
411
|
+
case 1:
|
|
412
|
+
_a.trys.push([1, 4, , 5]);
|
|
413
|
+
userData = JSON.parse(cookieService.get(USER_INFO));
|
|
414
|
+
if (!userDataIsNull(userData)) return [3 /*break*/, 3];
|
|
415
|
+
return [4 /*yield*/, seniorPlatformData.user.getUserData()];
|
|
416
|
+
case 2:
|
|
417
|
+
userData = _a.sent();
|
|
418
|
+
_a.label = 3;
|
|
419
|
+
case 3:
|
|
420
|
+
locale = getLocale(userData);
|
|
421
|
+
return [3 /*break*/, 5];
|
|
422
|
+
case 4:
|
|
423
|
+
ex_1 = _a.sent();
|
|
424
|
+
console.info('Unable to obtain user locale, using default locale pt-BR', ex_1);
|
|
425
|
+
locale = 'pt-BR';
|
|
426
|
+
return [3 /*break*/, 5];
|
|
427
|
+
case 5:
|
|
428
|
+
fallback = configs.reduce(function (result, configs) { return (__assign(__assign({}, result), configs.fallback)); }, {});
|
|
429
|
+
defaultsLanguages = configs.reduce(function (result, configs) { return (__assign(__assign({}, result), configs.defaultsLanguages)); }, {});
|
|
430
|
+
translate.setTranslation(locale, fallback);
|
|
431
|
+
translate.setDefaultLang(locale);
|
|
432
|
+
configTranslate = {};
|
|
433
|
+
if (defaultsLanguages) {
|
|
434
|
+
configTranslate = getConfigTranslate(defaultsLanguages, locale);
|
|
435
|
+
}
|
|
436
|
+
translationsPromises = configs.map(function (config) { return getTranslationsRequest(http, config, locale); });
|
|
437
|
+
return [4 /*yield*/, Promise.all(translationsPromises)];
|
|
438
|
+
case 6:
|
|
439
|
+
results = _a.sent();
|
|
440
|
+
results.forEach(function (result, index) {
|
|
441
|
+
if (result.overriden) {
|
|
442
|
+
usedFallback = true;
|
|
443
|
+
}
|
|
444
|
+
setTranslations(translate, result.content, usedFallback, locale, index, configTranslate.fallbackByLocale);
|
|
445
|
+
});
|
|
446
|
+
return [4 /*yield*/, translate.use(locale).toPromise()];
|
|
447
|
+
case 7:
|
|
448
|
+
_a.sent();
|
|
449
|
+
return [2 /*return*/];
|
|
448
450
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
function handleTranslationError(translate, err) {
|
|
455
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
456
|
+
var locale;
|
|
457
|
+
return __generator(this, function (_a) {
|
|
458
|
+
switch (_a.label) {
|
|
459
|
+
case 0:
|
|
460
|
+
console.info('Error setting translations. Using local fallback.', err);
|
|
461
|
+
locale = 'pt-BR';
|
|
462
|
+
return [4 /*yield*/, translate.use(locale).toPromise()];
|
|
463
|
+
case 1:
|
|
464
|
+
_a.sent();
|
|
465
|
+
return [2 /*return*/];
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
function initializeAfterLocationReady(translate, injector, http, cookieService) {
|
|
471
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
472
|
+
var err_2;
|
|
473
|
+
return __generator(this, function (_a) {
|
|
474
|
+
switch (_a.label) {
|
|
475
|
+
case 0:
|
|
476
|
+
_a.trys.push([0, 2, , 4]);
|
|
477
|
+
return [4 /*yield*/, initializeTranslations(translate, injector, http, cookieService)];
|
|
478
|
+
case 1:
|
|
479
|
+
_a.sent();
|
|
480
|
+
return [3 /*break*/, 4];
|
|
481
|
+
case 2:
|
|
482
|
+
err_2 = _a.sent();
|
|
483
|
+
return [4 /*yield*/, handleTranslationError(translate, err_2)];
|
|
484
|
+
case 3:
|
|
485
|
+
_a.sent();
|
|
486
|
+
return [3 /*break*/, 4];
|
|
487
|
+
case 4: return [2 /*return*/];
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
function factory(translate, injector, http, cookieService) {
|
|
493
|
+
function initFactory() {
|
|
494
|
+
return new Promise(function (resolve) {
|
|
495
|
+
var locationInitialized = injector.get(common.LOCATION_INITIALIZED, Promise.resolve(null));
|
|
496
|
+
locationInitialized
|
|
497
|
+
.then(function () { return initializeAfterLocationReady(translate, injector, http, cookieService); })
|
|
498
|
+
.then(function () { return resolve(undefined); });
|
|
499
|
+
});
|
|
476
500
|
}
|
|
501
|
+
return initFactory;
|
|
477
502
|
}
|
|
478
503
|
|
|
479
504
|
var fallback = {
|
|
@@ -580,10 +605,10 @@
|
|
|
580
605
|
.subscribe(function (ticketFilter) {
|
|
581
606
|
_this.ticketFilter = ticketFilter;
|
|
582
607
|
_this.ticketFilterObservable.next({ ticketFilter: ticketFilter });
|
|
583
|
-
window.parent.postMessage({ message: 'advanced-filter:success', payload: ticketFilter },
|
|
608
|
+
window.parent.postMessage({ message: 'advanced-filter:success', payload: ticketFilter }, window.location.origin);
|
|
584
609
|
}, function (err) {
|
|
585
610
|
_this.ticketFilterObservable.next({ error: true, message: err });
|
|
586
|
-
window.parent.postMessage({ message: 'advanced-filter:error', payload: err },
|
|
611
|
+
window.parent.postMessage({ message: 'advanced-filter:error', payload: err }, window.location.origin);
|
|
587
612
|
});
|
|
588
613
|
};
|
|
589
614
|
AdvancedFilterService.prototype.addContexts = function () {
|
|
@@ -594,7 +619,7 @@
|
|
|
594
619
|
}
|
|
595
620
|
var currentContexts = this.contextsObservable.getValue();
|
|
596
621
|
this.contextsObservable.next(__spread(currentContexts, contexts));
|
|
597
|
-
return rxjs.Observable
|
|
622
|
+
return new rxjs.Observable(function () { return function () { return _this.removeContexts(contexts); }; });
|
|
598
623
|
};
|
|
599
624
|
AdvancedFilterService.prototype.removeContexts = function (contexts) {
|
|
600
625
|
var allContexts = this.contextsObservable.getValue();
|
|
@@ -619,6 +644,7 @@
|
|
|
619
644
|
};
|
|
620
645
|
AdvancedFilterService.prototype.getFilters = function (serviceContexts, applyFilter) {
|
|
621
646
|
var _this = this;
|
|
647
|
+
if (applyFilter === void 0) { applyFilter = false; }
|
|
622
648
|
this.http
|
|
623
649
|
.post(GET_FILTERS_URL, { serviceContexts: serviceContexts })
|
|
624
650
|
.pipe(operators.map(function (response) { return _this.mapFilters(response.filters); }))
|
|
@@ -628,42 +654,48 @@
|
|
|
628
654
|
};
|
|
629
655
|
AdvancedFilterService.prototype.mapFilters = function (filters) {
|
|
630
656
|
var _this = this;
|
|
631
|
-
return filters.map(function (filter) {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
}
|
|
640
|
-
if (value) {
|
|
641
|
-
if (_this.isMultiple(filter)) {
|
|
642
|
-
var valueInText = JSON.stringify(value);
|
|
643
|
-
if ((valueInText.startsWith('[{') && valueInText.endsWith('}]')) || valueInText.length <= 4) {
|
|
644
|
-
filter.value = valueInText;
|
|
645
|
-
}
|
|
646
|
-
else {
|
|
647
|
-
filter.value = JSON.stringify('');
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
else {
|
|
651
|
-
filter.value = JSON.stringify(value);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
657
|
+
return filters.map(function (filter) { return _this.processFilter(filter); });
|
|
658
|
+
};
|
|
659
|
+
AdvancedFilterService.prototype.processFilter = function (filter) {
|
|
660
|
+
try {
|
|
661
|
+
var value = filter.value && JSON.parse(filter.value);
|
|
662
|
+
if (value) {
|
|
663
|
+
this.processSearchOutput(filter, value);
|
|
664
|
+
filter.value = this.serializeFilterValue(filter, value);
|
|
654
665
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
666
|
+
}
|
|
667
|
+
catch (ex) {
|
|
668
|
+
console.trace("Global: filter " + filter.name + " has value error. ", ex);
|
|
669
|
+
filter.value = JSON.stringify('');
|
|
670
|
+
}
|
|
671
|
+
return filter;
|
|
672
|
+
};
|
|
673
|
+
AdvancedFilterService.prototype.processSearchOutput = function (filter, value) {
|
|
674
|
+
var _a, _b, _c, _d;
|
|
675
|
+
if ((_b = (_a = filter.search) === null || _a === void 0 ? void 0 : _a.basicSearch) === null || _b === void 0 ? void 0 : _b.output) {
|
|
676
|
+
this.mapValues(value, filter.search.basicSearch.output.keyFields, filter.search.basicSearch.output.displayFields);
|
|
677
|
+
}
|
|
678
|
+
else if ((_d = (_c = filter.search) === null || _c === void 0 ? void 0 : _c.entitySearch) === null || _d === void 0 ? void 0 : _d.output) {
|
|
679
|
+
this.mapValues(value, filter.search.entitySearch.output.keyFields, filter.search.entitySearch.output.displayFields);
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
// No search output configuration available
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
AdvancedFilterService.prototype.serializeFilterValue = function (filter, value) {
|
|
686
|
+
if (!this.isMultiple(filter)) {
|
|
687
|
+
return JSON.stringify(value);
|
|
688
|
+
}
|
|
689
|
+
var valueInText = JSON.stringify(value);
|
|
690
|
+
var isValidMultipleValue = (valueInText.startsWith('[{') && valueInText.endsWith('}]')) || valueInText.length <= 4;
|
|
691
|
+
return isValidMultipleValue ? valueInText : JSON.stringify('');
|
|
661
692
|
};
|
|
662
693
|
AdvancedFilterService.prototype.isMultiple = function (filter) {
|
|
694
|
+
var _a, _b, _c, _d;
|
|
663
695
|
return (filter.type === 'SEARCH' &&
|
|
664
696
|
filter.search &&
|
|
665
|
-
((filter.search.basicSearch
|
|
666
|
-
(filter.search.entitySearch
|
|
697
|
+
((((_b = (_a = filter.search.basicSearch) === null || _a === void 0 ? void 0 : _a.output) === null || _b === void 0 ? void 0 : _b.maxSelectedItems) > 1) ||
|
|
698
|
+
(((_d = (_c = filter.search.entitySearch) === null || _c === void 0 ? void 0 : _c.output) === null || _d === void 0 ? void 0 : _d.maxSelectedItems) > 1)));
|
|
667
699
|
};
|
|
668
700
|
AdvancedFilterService.prototype.mapValues = function (value, keyFields, displayFields) {
|
|
669
701
|
var _this = this;
|
|
@@ -801,16 +833,11 @@
|
|
|
801
833
|
}
|
|
802
834
|
|
|
803
835
|
var _a;
|
|
804
|
-
|
|
805
|
-
/**
|
|
806
|
-
*@description Necessary because of https://github.com/rollup/rollup/issues/670
|
|
807
|
-
*
|
|
808
|
-
* */
|
|
809
|
-
var DATETIME = exports.FilterType.DATETIME, TIME = exports.FilterType.TIME, DATE = exports.FilterType.DATE;
|
|
836
|
+
var moment = momentNs__default__default || momentNs__default;
|
|
810
837
|
var parsers = (_a = {},
|
|
811
|
-
_a[DATE] = function (value) { return dateParser(value, 'YYYY-MM-DD'); },
|
|
812
|
-
_a[TIME] = function (value) { return dateParser(value, 'HH:mm:ss'); },
|
|
813
|
-
_a[DATETIME] = function (value) { return dateParser(value); },
|
|
838
|
+
_a[exports.FilterType.DATE] = function (value) { return dateParser(value, 'YYYY-MM-DD'); },
|
|
839
|
+
_a[exports.FilterType.TIME] = function (value) { return dateParser(value, 'HH:mm:ss'); },
|
|
840
|
+
_a[exports.FilterType.DATETIME] = function (value) { return dateParser(value); },
|
|
814
841
|
_a);
|
|
815
842
|
function parseFilterValue(value, type) {
|
|
816
843
|
var parser = parsers[type];
|
|
@@ -898,15 +925,11 @@
|
|
|
898
925
|
}
|
|
899
926
|
|
|
900
927
|
var _a$1;
|
|
901
|
-
|
|
902
|
-
*@description Necessary because of https://github.com/rollup/rollup/issues/670
|
|
903
|
-
*
|
|
904
|
-
* */
|
|
905
|
-
var DATE$1 = exports.FilterType.DATE, DATETIME$1 = exports.FilterType.DATETIME, TIME$1 = exports.FilterType.TIME;
|
|
928
|
+
var moment$1 = momentNs__default__default || momentNs__default;
|
|
906
929
|
var parsers$1 = (_a$1 = {},
|
|
907
|
-
_a$1[DATE
|
|
908
|
-
_a$1[DATETIME
|
|
909
|
-
_a$1[TIME
|
|
930
|
+
_a$1[exports.FilterType.DATE] = function (v) { return dateParser$1(v); },
|
|
931
|
+
_a$1[exports.FilterType.DATETIME] = function (v) { return dateParser$1(v); },
|
|
932
|
+
_a$1[exports.FilterType.TIME] = function (v) { return dateParser$1(v, 'HH:mm:ss'); },
|
|
910
933
|
_a$1);
|
|
911
934
|
function parseFormValue(value, type, search) {
|
|
912
935
|
var parser = parsers$1[type];
|
|
@@ -942,7 +965,7 @@
|
|
|
942
965
|
return validators;
|
|
943
966
|
}
|
|
944
967
|
function dateParser$1(value, format) {
|
|
945
|
-
return value !== null && value !== '' ? moment(value, format).toDate() : '';
|
|
968
|
+
return value !== null && value !== '' ? moment$1(value, format).toDate() : '';
|
|
946
969
|
}
|
|
947
970
|
|
|
948
971
|
var supportedTypes = [
|
|
@@ -1075,8 +1098,53 @@
|
|
|
1075
1098
|
return CalendarOptionsService;
|
|
1076
1099
|
}());
|
|
1077
1100
|
|
|
1078
|
-
|
|
1079
|
-
|
|
1101
|
+
/**
|
|
1102
|
+
* Constantes para o componente FormFilter
|
|
1103
|
+
* Centraliza todos os valores mágicos para facilitar manutenção e reutilização
|
|
1104
|
+
*/
|
|
1105
|
+
// Configurações de UI e Layout
|
|
1106
|
+
var UI_CONSTANTS = {
|
|
1107
|
+
/** Breakpoint em pixels para considerar dispositivo móvel */
|
|
1108
|
+
MOBILE_BREAKPOINT: 640,
|
|
1109
|
+
/** Tempo de vida padrão das mensagens toast em milissegundos */
|
|
1110
|
+
TOAST_LIFE_TIME: 5000,
|
|
1111
|
+
/** Tamanho padrão de grid para componentes AutocompleteField */
|
|
1112
|
+
DEFAULT_GRID_SIZE: 12,
|
|
1113
|
+
/** Nome padrão do modal de filtro avançado */
|
|
1114
|
+
ADVANCED_FILTER_MODAL_NAME: 'advanced-filter-1'
|
|
1115
|
+
};
|
|
1116
|
+
// Valores de controle e validação
|
|
1117
|
+
var VALIDATION_CONSTANTS = {
|
|
1118
|
+
/** Valor inicial para contadores */
|
|
1119
|
+
INITIAL_COUNT: 0,
|
|
1120
|
+
/** Indica que não há itens/elementos */
|
|
1121
|
+
NO_ITEMS: 0,
|
|
1122
|
+
/** Valor para indicar item único em seleção */
|
|
1123
|
+
SINGLE_ITEM: 1,
|
|
1124
|
+
/** Índice que indica item não encontrado em arrays */
|
|
1125
|
+
NOT_FOUND_INDEX: -1,
|
|
1126
|
+
/** Posição do índice para extrair mensagem de evento */
|
|
1127
|
+
MESSAGE_SPLIT_INDEX: 1,
|
|
1128
|
+
/** Índice do primeiro elemento em array */
|
|
1129
|
+
FIRST_ELEMENT_INDEX: 0
|
|
1130
|
+
};
|
|
1131
|
+
// Configurações de grid responsivo
|
|
1132
|
+
var GRID_CONFIG = {
|
|
1133
|
+
/** Configuração padrão de tamanhos de grid para AutocompleteField */
|
|
1134
|
+
DEFAULT_SIZE: {
|
|
1135
|
+
lg: UI_CONSTANTS.DEFAULT_GRID_SIZE,
|
|
1136
|
+
md: UI_CONSTANTS.DEFAULT_GRID_SIZE,
|
|
1137
|
+
xl: UI_CONSTANTS.DEFAULT_GRID_SIZE
|
|
1138
|
+
}
|
|
1139
|
+
};
|
|
1140
|
+
// Prefixos e identificadores
|
|
1141
|
+
var FILTER_CONSTANTS = {
|
|
1142
|
+
/** Prefixo para chaves de tradução do serviço de filtros */
|
|
1143
|
+
TRANSLATE_PREFIX: 'platform.filter_service'
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
var TRANSLATE_PREFIX$1 = FILTER_CONSTANTS.TRANSLATE_PREFIX;
|
|
1147
|
+
var TOAST_LIFE = UI_CONSTANTS.TOAST_LIFE_TIME;
|
|
1080
1148
|
var FormFilterComponent = /** @class */ (function () {
|
|
1081
1149
|
function FormFilterComponent(filterService, translate, messageService, calendarOptionsService, changeDetectorRef) {
|
|
1082
1150
|
this.filterService = filterService;
|
|
@@ -1086,11 +1154,11 @@
|
|
|
1086
1154
|
this.changeDetectorRef = changeDetectorRef;
|
|
1087
1155
|
this.destroy$ = new rxjs.Subject();
|
|
1088
1156
|
this.contexts = [];
|
|
1089
|
-
this.formFilters =
|
|
1090
|
-
this.oldFormFilters =
|
|
1157
|
+
this.formFilters = {};
|
|
1158
|
+
this.oldFormFilters = {};
|
|
1091
1159
|
this.actualFormFilters = [];
|
|
1092
1160
|
this.general = new TabView({ name: 'Geral' });
|
|
1093
|
-
this.totalFiltersActive =
|
|
1161
|
+
this.totalFiltersActive = VALIDATION_CONSTANTS.INITIAL_COUNT;
|
|
1094
1162
|
this.isMobile = false;
|
|
1095
1163
|
this.tabViewOrientation = 'left';
|
|
1096
1164
|
this.error = false;
|
|
@@ -1109,19 +1177,24 @@
|
|
|
1109
1177
|
}
|
|
1110
1178
|
FormFilterComponent.prototype.onResizeWindow = function (event) {
|
|
1111
1179
|
var innerWidth = event.target.innerWidth;
|
|
1112
|
-
this.isMobile = innerWidth <=
|
|
1180
|
+
this.isMobile = innerWidth <= UI_CONSTANTS.MOBILE_BREAKPOINT;
|
|
1113
1181
|
this.tabViewOrientation = this.isMobile ? 'top' : 'left';
|
|
1114
1182
|
};
|
|
1115
1183
|
FormFilterComponent.prototype.ngOnInit = function () {
|
|
1116
1184
|
var _this = this;
|
|
1117
|
-
this.isMobile = innerWidth <=
|
|
1185
|
+
this.isMobile = innerWidth <= UI_CONSTANTS.MOBILE_BREAKPOINT;
|
|
1118
1186
|
this.tabViewOrientation = this.isMobile ? 'top' : 'left';
|
|
1119
1187
|
this.subscribeContextsObservable();
|
|
1120
1188
|
this.subscribeFiltersObservable();
|
|
1121
1189
|
window.addEventListener('message', function (event) {
|
|
1122
1190
|
var _a;
|
|
1191
|
+
var _b;
|
|
1192
|
+
// Verificar origem da mensagem por segurança
|
|
1193
|
+
if (event.origin !== window.location.origin) {
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1123
1196
|
var data = event.data;
|
|
1124
|
-
var message = data
|
|
1197
|
+
var message = (_b = data === null || data === void 0 ? void 0 : data.message) === null || _b === void 0 ? void 0 : _b.split(':')[VALIDATION_CONSTANTS.MESSAGE_SPLIT_INDEX];
|
|
1125
1198
|
if (message === 'addContext') {
|
|
1126
1199
|
(_a = _this.filterService).addContexts.apply(_a, __spread(data.payload));
|
|
1127
1200
|
}
|
|
@@ -1138,8 +1211,9 @@
|
|
|
1138
1211
|
return true;
|
|
1139
1212
|
}
|
|
1140
1213
|
var filtered = keys.filter(function (key) {
|
|
1214
|
+
var _a;
|
|
1141
1215
|
var currentValue = _this.formFilters[key].value;
|
|
1142
|
-
var oldValue = _this.oldFormFilters[key]
|
|
1216
|
+
var oldValue = (_a = _this.oldFormFilters[key]) === null || _a === void 0 ? void 0 : _a.value;
|
|
1143
1217
|
return !ramda.equals(currentValue, oldValue);
|
|
1144
1218
|
});
|
|
1145
1219
|
return filtered.length > 0;
|
|
@@ -1167,10 +1241,13 @@
|
|
|
1167
1241
|
};
|
|
1168
1242
|
this.sendMessage(message);
|
|
1169
1243
|
}
|
|
1244
|
+
else {
|
|
1245
|
+
// No action needed
|
|
1246
|
+
}
|
|
1170
1247
|
this.oldFormFilters = ramda.clone(this.formFilters);
|
|
1171
1248
|
};
|
|
1172
1249
|
FormFilterComponent.prototype.getDefaultValue = function (defaultValue, isMultiple) {
|
|
1173
|
-
if (defaultValue === undefined || (isMultiple && defaultValue[
|
|
1250
|
+
if (defaultValue === undefined || (isMultiple && defaultValue[VALIDATION_CONSTANTS.FIRST_ELEMENT_INDEX] === '')) {
|
|
1174
1251
|
return [];
|
|
1175
1252
|
}
|
|
1176
1253
|
return defaultValue;
|
|
@@ -1184,9 +1261,9 @@
|
|
|
1184
1261
|
window.parent.postMessage({
|
|
1185
1262
|
message: 'dashboard:close-modal',
|
|
1186
1263
|
payload: {
|
|
1187
|
-
modalName:
|
|
1264
|
+
modalName: UI_CONSTANTS.ADVANCED_FILTER_MODAL_NAME
|
|
1188
1265
|
}
|
|
1189
|
-
},
|
|
1266
|
+
}, window.location.origin);
|
|
1190
1267
|
};
|
|
1191
1268
|
FormFilterComponent.prototype.sendMessage = function (message) {
|
|
1192
1269
|
if (this.showMessages) {
|
|
@@ -1199,7 +1276,7 @@
|
|
|
1199
1276
|
type: 'success',
|
|
1200
1277
|
message: message.detail
|
|
1201
1278
|
}
|
|
1202
|
-
},
|
|
1279
|
+
}, window.location.origin);
|
|
1203
1280
|
}
|
|
1204
1281
|
};
|
|
1205
1282
|
FormFilterComponent.prototype.saveFilters = function (forceSave) {
|
|
@@ -1242,18 +1319,18 @@
|
|
|
1242
1319
|
this.totalFiltersActiveOutput.emit(this.totalFiltersActive);
|
|
1243
1320
|
};
|
|
1244
1321
|
FormFilterComponent.prototype.countActiveFilters = function (tabs) {
|
|
1245
|
-
var totalFiltersActive =
|
|
1322
|
+
var totalFiltersActive = VALIDATION_CONSTANTS.INITIAL_COUNT;
|
|
1246
1323
|
tabs.forEach(function (tabView) {
|
|
1247
1324
|
var value = tabView.form.value;
|
|
1248
1325
|
tabView.activeFilters = Object.keys(value).reduce(function (appliedFilters, key) {
|
|
1249
1326
|
var filterValue = value[key];
|
|
1250
1327
|
var isArray = Array.isArray(filterValue);
|
|
1251
|
-
var isValidArray = isArray && filterValue.length >
|
|
1328
|
+
var isValidArray = isArray && filterValue.length > VALIDATION_CONSTANTS.NO_ITEMS;
|
|
1252
1329
|
if (isValidArray || (!isArray && filterValue)) {
|
|
1253
1330
|
appliedFilters++;
|
|
1254
1331
|
}
|
|
1255
1332
|
return appliedFilters;
|
|
1256
|
-
},
|
|
1333
|
+
}, VALIDATION_CONSTANTS.INITIAL_COUNT);
|
|
1257
1334
|
totalFiltersActive += tabView.activeFilters;
|
|
1258
1335
|
});
|
|
1259
1336
|
return totalFiltersActive;
|
|
@@ -1263,7 +1340,7 @@
|
|
|
1263
1340
|
return ids.reduce(function (all, filterId) {
|
|
1264
1341
|
var _a = filters[filterId], type = _a.type, services = _a.services, name = _a.name, value = _a.value, domain = _a.domain, contexts = _a.contexts;
|
|
1265
1342
|
var filterValue = toUserFormat(value, type);
|
|
1266
|
-
var values = services.map(function (service) { return ({ name: name, service: service,
|
|
1343
|
+
var values = services.map(function (service) { return ({ name: name, service: service, domain: domain, contexts: contexts, value: filterValue }); });
|
|
1267
1344
|
return __spread(all, values);
|
|
1268
1345
|
}, []);
|
|
1269
1346
|
};
|
|
@@ -1272,7 +1349,7 @@
|
|
|
1272
1349
|
return ids.reduce(function (all, filterId) {
|
|
1273
1350
|
var _a = filters[filterId], type = _a.type, services = _a.services, name = _a.name, value = _a.value, domain = _a.domain;
|
|
1274
1351
|
var filterValue = toFilterFormat(value, type);
|
|
1275
|
-
var values = services.map(function (service) { return ({ name: name, service: service,
|
|
1352
|
+
var values = services.map(function (service) { return ({ name: name, service: service, domain: domain, value: filterValue }); });
|
|
1276
1353
|
return __spread(all, values);
|
|
1277
1354
|
}, []);
|
|
1278
1355
|
};
|
|
@@ -1304,7 +1381,7 @@
|
|
|
1304
1381
|
this.counterUpdate();
|
|
1305
1382
|
this.setDependencies(this.formFilters);
|
|
1306
1383
|
this.createChildArray();
|
|
1307
|
-
if (filters.length >
|
|
1384
|
+
if (filters.length > VALIDATION_CONSTANTS.NO_ITEMS && applyFilter) {
|
|
1308
1385
|
this.applyFilters();
|
|
1309
1386
|
}
|
|
1310
1387
|
};
|
|
@@ -1313,7 +1390,7 @@
|
|
|
1313
1390
|
var names = Object.keys(filters);
|
|
1314
1391
|
var dependencies = rxjs.from(names).pipe(operators.map(function (key) { return filters[key]; }), operators.filter(function (_a) {
|
|
1315
1392
|
var dependsOn = _a.dependsOn;
|
|
1316
|
-
return dependsOn && dependsOn.length >
|
|
1393
|
+
return dependsOn && dependsOn.length > VALIDATION_CONSTANTS.NO_ITEMS;
|
|
1317
1394
|
}), operators.tap(function (_a) {
|
|
1318
1395
|
var dependsOn = _a.dependsOn, domain = _a.domain, filterControl = _a.filterControl;
|
|
1319
1396
|
var invalidFilters = dependsOn
|
|
@@ -1329,7 +1406,7 @@
|
|
|
1329
1406
|
}
|
|
1330
1407
|
return dep.required ? !formFilter.value : formFilter.value;
|
|
1331
1408
|
});
|
|
1332
|
-
if (invalidFilters.length >
|
|
1409
|
+
if (invalidFilters.length > VALIDATION_CONSTANTS.NO_ITEMS) {
|
|
1333
1410
|
filterControl.disable();
|
|
1334
1411
|
}
|
|
1335
1412
|
}), operators.map(function (_a) {
|
|
@@ -1345,17 +1422,18 @@
|
|
|
1345
1422
|
}), operators.map(function (filterId) { return filters[filterId]; }), operators.mergeMap(function (formFilter) { return rxjs.from(formFilter.valueChanges); }), operators.map(function (val) {
|
|
1346
1423
|
var comparation = dependsOn.every(function (dep) {
|
|
1347
1424
|
var filterId = getFilterId(domain, dep.filterName);
|
|
1348
|
-
if (_this.formFilters[filterId]) {
|
|
1349
|
-
|
|
1350
|
-
var comparator = dep.comparator;
|
|
1351
|
-
if (comparator && isValidOperator(comparator.operator) && isSupportedType(type)) {
|
|
1352
|
-
var value = parseFilterValue(val, type);
|
|
1353
|
-
return compare(comparator.operator, comparator.value, value);
|
|
1354
|
-
}
|
|
1355
|
-
return true;
|
|
1425
|
+
if (!_this.formFilters[filterId]) {
|
|
1426
|
+
return false;
|
|
1356
1427
|
}
|
|
1428
|
+
var type = _this.formFilters[filterId].type;
|
|
1429
|
+
var comparator = dep.comparator;
|
|
1430
|
+
if (comparator && isValidOperator(comparator.operator) && isSupportedType(type)) {
|
|
1431
|
+
var value = parseFilterValue(val, type);
|
|
1432
|
+
return compare(comparator.operator, comparator.value, value);
|
|
1433
|
+
}
|
|
1434
|
+
return true;
|
|
1357
1435
|
});
|
|
1358
|
-
return !_this.
|
|
1436
|
+
return !_this.isEmpty(val) && comparation ? 'enable' : 'disable';
|
|
1359
1437
|
}))
|
|
1360
1438
|
.subscribe(function (status) { return filterControl[status](); });
|
|
1361
1439
|
});
|
|
@@ -1391,59 +1469,111 @@
|
|
|
1391
1469
|
return true;
|
|
1392
1470
|
}
|
|
1393
1471
|
var allContexts = this.contexts.map(function (data) { return data.contextId; });
|
|
1394
|
-
|
|
1472
|
+
var sortedMyContexts = __spread(myContexts).sort(function (a, b) { return a.localeCompare(b); });
|
|
1473
|
+
var sortedAllContexts = __spread(allContexts).sort(function (a, b) { return a.localeCompare(b); });
|
|
1474
|
+
return ramda.equals(sortedMyContexts, sortedAllContexts);
|
|
1395
1475
|
};
|
|
1396
1476
|
/**
|
|
1397
|
-
*
|
|
1398
|
-
*
|
|
1399
|
-
*
|
|
1477
|
+
* Cria as tabs de contexto a partir dos filtros fornecidos.
|
|
1478
|
+
* Este método orquestra a criação de FormFilters e distribui os campos entre as tabs.
|
|
1400
1479
|
*/
|
|
1401
1480
|
FormFilterComponent.prototype.createTabs = function (filters) {
|
|
1402
1481
|
var _this = this;
|
|
1403
1482
|
return filters.reduce(function (tabs, filter) {
|
|
1404
|
-
var domain = filter.domain,
|
|
1405
|
-
var isNotMultiple = search && getSearchType(search).output.maxSelectedItems === 1;
|
|
1483
|
+
var domain = filter.domain, name = filter.name, scope = filter.scope, contexts = filter.contexts;
|
|
1406
1484
|
var field = _this.createField(filter);
|
|
1407
1485
|
var filterId = getFilterId(domain, name);
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
contexts: contexts,
|
|
1411
|
-
services: services,
|
|
1412
|
-
name: name,
|
|
1413
|
-
dependsOn: dependsOn,
|
|
1414
|
-
value: fromJson(value, type, isNotMultiple),
|
|
1415
|
-
type: type,
|
|
1416
|
-
isMultiple: !isNotMultiple,
|
|
1417
|
-
defaultValue: fromJson(defaultValue, type, isNotMultiple)
|
|
1418
|
-
};
|
|
1419
|
-
_this.formFilters[filterId] = new FormFilter(filterConfig);
|
|
1486
|
+
// Cria e registra o FormFilter
|
|
1487
|
+
_this.createAndRegisterFormFilter(filter, filterId);
|
|
1420
1488
|
var formFilter = _this.formFilters[filterId];
|
|
1489
|
+
// Adiciona ao tab geral se for de escopo DOMAIN e aplicável a todos os contextos
|
|
1421
1490
|
if (scope === exports.Scope.DOMAIN && _this.containsAllContexts(contexts)) {
|
|
1422
1491
|
_this.addGeneralField(filter);
|
|
1423
1492
|
}
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
var tabId_1 = getTabId(domain, contextId);
|
|
1427
|
-
var fieldControl = createFormControl(filter);
|
|
1428
|
-
if (!tabs.has(tabId_1)) {
|
|
1429
|
-
var contextLabel = _this.contexts.find(function (context) { return context.contextId === contextId; }).contextLabel;
|
|
1430
|
-
var tab = new ContextTab({ domain: domain, name: contextLabel });
|
|
1431
|
-
tabs.set(tabId_1, tab);
|
|
1432
|
-
}
|
|
1433
|
-
fieldControl.valueChanges
|
|
1434
|
-
.pipe(operators.takeUntil(_this.destroy$))
|
|
1435
|
-
.subscribe(function (val) { return _this.updateFilterValue(tabId_1, name, val, domain, type); });
|
|
1436
|
-
var contextTab = tabs.get(tabId_1);
|
|
1437
|
-
contextTab.fields.push(field);
|
|
1438
|
-
contextTab.form.addControl(filter.name, fieldControl);
|
|
1439
|
-
if (!formFilter.filterControl) {
|
|
1440
|
-
formFilter.filterControl = fieldControl;
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
});
|
|
1493
|
+
// Processa cada contexto do filtro
|
|
1494
|
+
_this.processFilterContexts(filter, field, formFilter, tabs);
|
|
1444
1495
|
return tabs;
|
|
1445
1496
|
}, new Map());
|
|
1446
1497
|
};
|
|
1498
|
+
/**
|
|
1499
|
+
* Cria a configuração e instância do FormFilter, registrando-o no mapa de filtros.
|
|
1500
|
+
*/
|
|
1501
|
+
FormFilterComponent.prototype.createAndRegisterFormFilter = function (filter, filterId) {
|
|
1502
|
+
var domain = filter.domain, services = filter.services, name = filter.name, type = filter.type, contexts = filter.contexts, dependsOn = filter.dependsOn, value = filter.value, search = filter.search, defaultValue = filter.defaultValue;
|
|
1503
|
+
var isNotMultiple = search && getSearchType(search).output.maxSelectedItems === VALIDATION_CONSTANTS.SINGLE_ITEM;
|
|
1504
|
+
var filterConfig = {
|
|
1505
|
+
domain: domain,
|
|
1506
|
+
contexts: contexts,
|
|
1507
|
+
services: services,
|
|
1508
|
+
name: name,
|
|
1509
|
+
dependsOn: dependsOn,
|
|
1510
|
+
type: type,
|
|
1511
|
+
value: fromJson(value, type, isNotMultiple),
|
|
1512
|
+
isMultiple: !isNotMultiple,
|
|
1513
|
+
defaultValue: fromJson(defaultValue, type, isNotMultiple)
|
|
1514
|
+
};
|
|
1515
|
+
this.formFilters[filterId] = new FormFilter(filterConfig);
|
|
1516
|
+
};
|
|
1517
|
+
/**
|
|
1518
|
+
* Processa os contextos de um filtro, criando ou atualizando as tabs correspondentes.
|
|
1519
|
+
*/
|
|
1520
|
+
FormFilterComponent.prototype.processFilterContexts = function (filter, field, formFilter, tabs) {
|
|
1521
|
+
var _this = this;
|
|
1522
|
+
var domain = filter.domain, name = filter.name, type = filter.type, contexts = filter.contexts;
|
|
1523
|
+
contexts.forEach(function (contextId) {
|
|
1524
|
+
if (_this.shouldProcessContext(contextId)) {
|
|
1525
|
+
var tabId = getTabId(domain, contextId);
|
|
1526
|
+
// Garante que a tab existe
|
|
1527
|
+
_this.ensureTabExists(tabs, tabId, domain, contextId);
|
|
1528
|
+
// Cria e configura o controle do campo
|
|
1529
|
+
var fieldControl = _this.createAndConfigureFieldControl(filter, tabId, name, domain, type);
|
|
1530
|
+
// Adiciona o campo à tab
|
|
1531
|
+
_this.addFieldToTab(tabs.get(tabId), field, filter.name, fieldControl);
|
|
1532
|
+
// Define o controle principal do FormFilter (primeira ocorrência)
|
|
1533
|
+
if (!formFilter.filterControl) {
|
|
1534
|
+
formFilter.filterControl = fieldControl;
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
});
|
|
1538
|
+
};
|
|
1539
|
+
/**
|
|
1540
|
+
* Verifica se um contexto deve ser processado com base no contextId atual.
|
|
1541
|
+
*/
|
|
1542
|
+
FormFilterComponent.prototype.shouldProcessContext = function (contextId) {
|
|
1543
|
+
return contextId === this.contextId || this.contextId === '';
|
|
1544
|
+
};
|
|
1545
|
+
/**
|
|
1546
|
+
* Garante que uma tab existe no mapa, criando-a se necessário.
|
|
1547
|
+
*/
|
|
1548
|
+
FormFilterComponent.prototype.ensureTabExists = function (tabs, tabId, domain, contextId) {
|
|
1549
|
+
var _a;
|
|
1550
|
+
if (!tabs.has(tabId)) {
|
|
1551
|
+
var contextData = this.contexts.find(function (context) { return context.contextId === contextId; });
|
|
1552
|
+
var tab = new ContextTab({
|
|
1553
|
+
domain: domain,
|
|
1554
|
+
name: (_a = contextData === null || contextData === void 0 ? void 0 : contextData.contextLabel) !== null && _a !== void 0 ? _a : contextId
|
|
1555
|
+
});
|
|
1556
|
+
tabs.set(tabId, tab);
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
/**
|
|
1560
|
+
* Cria um FormControl para o campo e configura o observable de mudanças de valor.
|
|
1561
|
+
*/
|
|
1562
|
+
FormFilterComponent.prototype.createAndConfigureFieldControl = function (filter, tabId, filterName, domain, type) {
|
|
1563
|
+
var _this = this;
|
|
1564
|
+
var fieldControl = createFormControl(filter);
|
|
1565
|
+
fieldControl.valueChanges
|
|
1566
|
+
.pipe(operators.takeUntil(this.destroy$))
|
|
1567
|
+
.subscribe(function (val) { return _this.updateFilterValue(tabId, filterName, val, domain, type); });
|
|
1568
|
+
return fieldControl;
|
|
1569
|
+
};
|
|
1570
|
+
/**
|
|
1571
|
+
* Adiciona um campo ao formulário de uma tab específica.
|
|
1572
|
+
*/
|
|
1573
|
+
FormFilterComponent.prototype.addFieldToTab = function (contextTab, field, filterName, fieldControl) {
|
|
1574
|
+
contextTab.fields.push(field);
|
|
1575
|
+
contextTab.form.addControl(filterName, fieldControl);
|
|
1576
|
+
};
|
|
1447
1577
|
FormFilterComponent.prototype.updateFilterValue = function (tabId, filterName, value, domain, type) {
|
|
1448
1578
|
var _this = this;
|
|
1449
1579
|
var controlOpts = { emitEvent: false };
|
|
@@ -1458,8 +1588,8 @@
|
|
|
1458
1588
|
}
|
|
1459
1589
|
});
|
|
1460
1590
|
var childs = this.formFilters[filterId].childs;
|
|
1461
|
-
childs
|
|
1462
|
-
generalFieldControl
|
|
1591
|
+
childs === null || childs === void 0 ? void 0 : childs.forEach(function (child) { return _this.cleanFieldAndSetDefaultValue(child.filter.key); });
|
|
1592
|
+
generalFieldControl === null || generalFieldControl === void 0 ? void 0 : generalFieldControl.setValue(value, controlOpts);
|
|
1463
1593
|
this.formFilters[filterId].value = fieldValue;
|
|
1464
1594
|
};
|
|
1465
1595
|
FormFilterComponent.prototype.cleanFieldAndSetDefaultValue = function (key) {
|
|
@@ -1497,11 +1627,11 @@
|
|
|
1497
1627
|
var _a;
|
|
1498
1628
|
var _this = this;
|
|
1499
1629
|
var name = filter.name, label = filter.label, enumItems = filter.enumItems, type = filter.type, mask = filter.mask;
|
|
1500
|
-
var translatedEnumItems = enumItems
|
|
1630
|
+
var translatedEnumItems = enumItems === null || enumItems === void 0 ? void 0 : enumItems.map(function (item) { return ({ label: _this.translate.instant(item.label), value: item.value }); });
|
|
1501
1631
|
var field = { name: name, label: this.translate.instant(label), placeholder: '' };
|
|
1502
1632
|
var creators = (_a = {},
|
|
1503
1633
|
_a[exports.FilterType.STRING] = function () { return new angularComponents.TextField(__assign(__assign({}, field), { mask: mask ? function () { return mask; } : null, type: angularComponents.FieldType.String })); },
|
|
1504
|
-
_a[exports.FilterType.MONEY] = function () { return new angularComponents.
|
|
1634
|
+
_a[exports.FilterType.MONEY] = function () { return new angularComponents.BignumberField(__assign(__assign({}, field), { type: angularComponents.FieldType.Money })); },
|
|
1505
1635
|
_a[exports.FilterType.BOOLEAN] = function () { return _this.createRadioButton(__assign({}, field)); },
|
|
1506
1636
|
_a[exports.FilterType.DATE] = function () { return _this.createCalendar(__assign(__assign({}, field), { type: angularComponents.FieldType.Date })); },
|
|
1507
1637
|
_a[exports.FilterType.DATETIME] = function () { return _this.createCalendar(__assign(__assign({}, field), { type: angularComponents.FieldType.DateTime })); },
|
|
@@ -1510,9 +1640,9 @@
|
|
|
1510
1640
|
return new angularComponents.SelectField(__assign(__assign({}, field), { placeholder: _this.translate.instant('platform.filter_service.select'), options: __spread(translatedEnumItems), type: angularComponents.FieldType.Enum }));
|
|
1511
1641
|
},
|
|
1512
1642
|
_a[exports.FilterType.INTEGER] = function () {
|
|
1513
|
-
return new angularComponents.
|
|
1643
|
+
return new angularComponents.BignumberField(__assign(__assign({}, field), { numberLocaleOptions: _this.optionsInteger(), mask: mask ? function () { return mask; } : null, type: angularComponents.FieldType.Integer }));
|
|
1514
1644
|
},
|
|
1515
|
-
_a[exports.FilterType.DOUBLE] = function () { return new angularComponents.
|
|
1645
|
+
_a[exports.FilterType.DOUBLE] = function () { return new angularComponents.BignumberField(__assign(__assign({}, field), { type: angularComponents.FieldType.Double })); },
|
|
1516
1646
|
_a[exports.FilterType.SEARCH] = function () { return _this.createAutocompleteField(field, filter); },
|
|
1517
1647
|
_a);
|
|
1518
1648
|
return creators[type]();
|
|
@@ -1527,8 +1657,9 @@
|
|
|
1527
1657
|
FormFilterComponent.prototype.createCalendar = function (config) {
|
|
1528
1658
|
var calendar = new angularComponents.CalendarField(config);
|
|
1529
1659
|
calendar.calendarLocaleOptions = this.calendarOptionsService.getOptions();
|
|
1530
|
-
if (!this.isModal)
|
|
1660
|
+
if (!this.isModal) {
|
|
1531
1661
|
calendar.appendTo = 'body';
|
|
1662
|
+
}
|
|
1532
1663
|
return calendar;
|
|
1533
1664
|
};
|
|
1534
1665
|
FormFilterComponent.prototype.createAutocompleteField = function (field, _a) {
|
|
@@ -1539,7 +1670,7 @@
|
|
|
1539
1670
|
var _b = getSearchType(search).output, displayFields = _b.displayFields, keyFields = _b.keyFields, resultDataJsonPath = _b.resultDataJsonPath, displayFieldConcatToken = _b.displayFieldConcatToken, maxSelectedItems = _b.maxSelectedItems;
|
|
1540
1671
|
var filterId = getFilterId(domain, name);
|
|
1541
1672
|
var suggestionsError = function (messageError) {
|
|
1542
|
-
var messageDetail = messageError ? messageError : _this.translate.instant(TRANSLATE_PREFIX$1 + ".find_suggestions_error", { activeFilters: _this.totalFiltersActive });
|
|
1673
|
+
var messageDetail = messageError !== null && messageError !== void 0 ? messageError : _this.translate.instant(TRANSLATE_PREFIX$1 + ".find_suggestions_error", { activeFilters: _this.totalFiltersActive });
|
|
1543
1674
|
var message = {
|
|
1544
1675
|
key: 'filterServiceToastKey',
|
|
1545
1676
|
severity: 'error',
|
|
@@ -1562,27 +1693,72 @@
|
|
|
1562
1693
|
suggestionsObservable.next(result);
|
|
1563
1694
|
_this.changeDetectorRef.detectChanges();
|
|
1564
1695
|
}, function (error) {
|
|
1565
|
-
var
|
|
1566
|
-
|
|
1696
|
+
var _a;
|
|
1697
|
+
var messageError = null;
|
|
1698
|
+
if ((_a = error === null || error === void 0 ? void 0 : error.error) === null || _a === void 0 ? void 0 : _a.message) {
|
|
1567
1699
|
messageError = error.error.message;
|
|
1700
|
+
}
|
|
1568
1701
|
suggestionsError(messageError);
|
|
1569
1702
|
});
|
|
1570
1703
|
};
|
|
1571
|
-
return new angularComponents.AutocompleteField(__assign(__assign({}, field), { onSearch: onSearch, appendTo: 'body', suggestionsObservable: suggestionsObservable, displayField: searchDisplayName, dataKey: searchKeyName, multiple: maxSelectedItems >
|
|
1704
|
+
return new angularComponents.AutocompleteField(__assign(__assign({}, field), { onSearch: onSearch, appendTo: 'body', suggestionsObservable: suggestionsObservable, displayField: searchDisplayName, dataKey: searchKeyName, multiple: maxSelectedItems > VALIDATION_CONSTANTS.SINGLE_ITEM, size: GRID_CONFIG.DEFAULT_SIZE, emptyMessage: this.translate.instant(TRANSLATE_PREFIX$1 + ".search_empty_message") }));
|
|
1572
1705
|
};
|
|
1573
1706
|
FormFilterComponent.prototype.getEntitySearchUrl = function (search, value, dependsOn) {
|
|
1574
1707
|
var _this = this;
|
|
1575
1708
|
var attributes = search.attributes, domainName = search.domainName, entityName = search.entityName, serviceName = search.serviceName;
|
|
1576
1709
|
var url = domainName + "/" + serviceName + "/entities/" + entityName + "/?filter=";
|
|
1577
1710
|
var filters = attributes.map(function (attr) { return filterOperators[attr.comparator](attr.name, value); });
|
|
1578
|
-
dependsOn
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1711
|
+
dependsOn === null || dependsOn === void 0 ? void 0 : dependsOn.forEach(function (obj) {
|
|
1712
|
+
var filterId = getFilterId(domainName, obj.filterName);
|
|
1713
|
+
var fieldValue = _this.formFilters[filterId].value[searchKeyName];
|
|
1714
|
+
filters.push(obj.entityAttribute + " eq '" + fieldValue + "'");
|
|
1715
|
+
});
|
|
1716
|
+
return url.concat(this.joinFiltersWithOperator(filters, search.operator));
|
|
1717
|
+
};
|
|
1718
|
+
/**
|
|
1719
|
+
* Joins filter strings with the specified operator, avoiding commas inside parentheses.
|
|
1720
|
+
* This method is safe from ReDoS attacks by using a character-by-character scan
|
|
1721
|
+
* instead of complex regex patterns.
|
|
1722
|
+
*/
|
|
1723
|
+
FormFilterComponent.prototype.joinFiltersWithOperator = function (filters, operator) {
|
|
1724
|
+
var e_1, _a;
|
|
1725
|
+
var joined = filters.join(',');
|
|
1726
|
+
var result = [];
|
|
1727
|
+
var depth = 0;
|
|
1728
|
+
var currentSegment = '';
|
|
1729
|
+
try {
|
|
1730
|
+
for (var joined_1 = __values(joined), joined_1_1 = joined_1.next(); !joined_1_1.done; joined_1_1 = joined_1.next()) {
|
|
1731
|
+
var char = joined_1_1.value;
|
|
1732
|
+
if (char === '(') {
|
|
1733
|
+
depth++;
|
|
1734
|
+
currentSegment += char;
|
|
1735
|
+
}
|
|
1736
|
+
else if (char === ')') {
|
|
1737
|
+
depth--;
|
|
1738
|
+
currentSegment += char;
|
|
1739
|
+
}
|
|
1740
|
+
else if (char === ',' && depth === 0) {
|
|
1741
|
+
if (currentSegment) {
|
|
1742
|
+
result.push(currentSegment);
|
|
1743
|
+
currentSegment = '';
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
else {
|
|
1747
|
+
currentSegment += char;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1752
|
+
finally {
|
|
1753
|
+
try {
|
|
1754
|
+
if (joined_1_1 && !joined_1_1.done && (_a = joined_1.return)) _a.call(joined_1);
|
|
1755
|
+
}
|
|
1756
|
+
finally { if (e_1) throw e_1.error; }
|
|
1757
|
+
}
|
|
1758
|
+
if (currentSegment) {
|
|
1759
|
+
result.push(currentSegment);
|
|
1760
|
+
}
|
|
1761
|
+
return result.join(" " + operator + " ");
|
|
1586
1762
|
};
|
|
1587
1763
|
FormFilterComponent.prototype.addSuggestionFields = function (suggestions, displayFields, keyFields, separator, filterId) {
|
|
1588
1764
|
var _this = this;
|
|
@@ -1591,20 +1767,18 @@
|
|
|
1591
1767
|
var _a;
|
|
1592
1768
|
return (__assign(__assign({}, suggestion), (_a = {}, _a[searchDisplayName] = displayFields.reduce(function (value, display) {
|
|
1593
1769
|
return addValue(value, _this.translate.instant(suggestion[display]), separator);
|
|
1594
|
-
}, ''), _a[searchKeyName] = keyFields.reduce(function (value, key) {
|
|
1770
|
+
}, ''), _a[searchKeyName] = keyFields.reduce(function (value, key) {
|
|
1771
|
+
return addValue(value, suggestion[key], ', ');
|
|
1772
|
+
}, ''), _a)));
|
|
1595
1773
|
});
|
|
1596
|
-
this.formFilters[filterId].invalidValue = result.length ===
|
|
1774
|
+
this.formFilters[filterId].invalidValue = result.length === VALIDATION_CONSTANTS.NO_ITEMS;
|
|
1597
1775
|
return result.filter(function (item) {
|
|
1598
1776
|
var value = _this.formFilters[filterId].value;
|
|
1599
1777
|
if (Array.isArray(value)) {
|
|
1600
1778
|
var index = value.findIndex(function (i) { return i.$$__keyValue__ === item.$$__keyValue__; });
|
|
1601
|
-
|
|
1602
|
-
return item;
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
else {
|
|
1606
|
-
return item;
|
|
1779
|
+
return index === VALIDATION_CONSTANTS.NOT_FOUND_INDEX;
|
|
1607
1780
|
}
|
|
1781
|
+
return true;
|
|
1608
1782
|
});
|
|
1609
1783
|
};
|
|
1610
1784
|
FormFilterComponent.prototype.getDependenciesValues = function (dependencies, domain) {
|
|
@@ -1612,28 +1786,29 @@
|
|
|
1612
1786
|
return dependencies.reduce(function (params, _a) {
|
|
1613
1787
|
var filterName = _a.filterName;
|
|
1614
1788
|
var filterId = getFilterId(domain, filterName);
|
|
1615
|
-
if (_this.formFilters[filterId]) {
|
|
1616
|
-
var _b = _this.formFilters[filterId], value = _b.value, type = _b.type;
|
|
1617
|
-
if (type === 'ENUMERATION') {
|
|
1618
|
-
params[filterName] = value;
|
|
1619
|
-
}
|
|
1620
|
-
else {
|
|
1621
|
-
if (Array.isArray(value)) {
|
|
1622
|
-
params[filterName] = value.map(function (arr) { return arr[searchKeyName]; });
|
|
1623
|
-
}
|
|
1624
|
-
else {
|
|
1625
|
-
params[filterName] = value ? value[searchKeyName] : [''];
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
_this.IsEmpty(params[filterName]) && delete params[filterName];
|
|
1789
|
+
if (!_this.formFilters[filterId]) {
|
|
1629
1790
|
return params;
|
|
1630
1791
|
}
|
|
1792
|
+
var _b = _this.formFilters[filterId], value = _b.value, type = _b.type;
|
|
1793
|
+
if (type === 'ENUMERATION') {
|
|
1794
|
+
params[filterName] = value;
|
|
1795
|
+
}
|
|
1796
|
+
else if (Array.isArray(value)) {
|
|
1797
|
+
params[filterName] = value.map(function (arr) { return arr[searchKeyName]; });
|
|
1798
|
+
}
|
|
1799
|
+
else {
|
|
1800
|
+
params[filterName] = value ? value[searchKeyName] : [''];
|
|
1801
|
+
}
|
|
1802
|
+
if (_this.isEmpty(params[filterName])) {
|
|
1803
|
+
delete params[filterName];
|
|
1804
|
+
}
|
|
1805
|
+
return params;
|
|
1631
1806
|
}, {});
|
|
1632
1807
|
};
|
|
1633
1808
|
/*
|
|
1634
1809
|
* Verifica se o valor informado é falso, em arrays, é verificado cada item
|
|
1635
1810
|
*/
|
|
1636
|
-
FormFilterComponent.prototype.
|
|
1811
|
+
FormFilterComponent.prototype.isEmpty = function (value) {
|
|
1637
1812
|
return Array.isArray(value) ? value.every(function (data) { return !data; }) : !value;
|
|
1638
1813
|
};
|
|
1639
1814
|
/**
|
|
@@ -1676,7 +1851,7 @@
|
|
|
1676
1851
|
FormFilterComponent = __decorate([
|
|
1677
1852
|
core.Component({
|
|
1678
1853
|
selector: 's-app-form-filter',
|
|
1679
|
-
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",
|
|
1854
|
+
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 \n *ngIf=\"tabs && tabs.size > 1\" \n [orientation]=\"tabViewOrientation\" \n selected=\"false\"\n [attr.role]=\"'tablist'\"\n [attr.aria-label]=\"'platform.filter_service.filter_tabs' | translate\">\n <p-tabPanel \n *ngIf=\"general.fields.length\" \n [selected]=\"false\" \n [header]=\"general.name\"\n [attr.role]=\"'tab'\">\n <s-dynamic-form [errorMessages]=\"errorMessages\" [fields]=\"general.fields\" [form]=\"general.form\"></s-dynamic-form>\n </p-tabPanel>\n\n <p-tabPanel \n *ngFor=\"let tab of (tabs | mapValues); let i = index\" \n [selected]=\"i === 0\" \n [header]=\"tab.label\"\n [attr.role]=\"'tab'\">\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",
|
|
1680
1855
|
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%}}"]
|
|
1681
1856
|
})
|
|
1682
1857
|
], FormFilterComponent);
|
|
@@ -1813,19 +1988,14 @@
|
|
|
1813
1988
|
AdvancedFilterComponent = __decorate([
|
|
1814
1989
|
core.Component({
|
|
1815
1990
|
selector: 's-advanced-filter',
|
|
1816
|
-
template: "<s-button\n *ngIf=\"!onlyContent\"\n [id]=\"'filterButton'\"\n [disabled]=\"!canOpenFilter\"\n (
|
|
1991
|
+
template: "<s-button\n *ngIf=\"!onlyContent\"\n [id]=\"'filterButton'\"\n [disabled]=\"!canOpenFilter\"\n (onClick)=\"canOpenFilter ? toggleDialog() : ''\"\n iconClass=\"fa fa-filter\"\n priority=\"default\"\n [label]=\"labelButton\"\n [auxiliary]=\"true\"\n [tooltip]=\"appliedFiltersTooltip\"\n [attr.aria-label]=\"'platform.filter_service.open_filters' | translate\"\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 <button \n class=\"close_btn\" \n (click)=\"close()\" \n [attr.aria-label]=\"'platform.filter_service.close' | translate\"\n type=\"button\">\n <span class=\"pi pi-times\" aria-hidden=\"true\"></span>\n </button>\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 (onClick)=\"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 (onClick)=\"clearFilters()\"\n ></s-button>\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.save')\"\n (onClick)=\"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 (onClick)=\"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 [attr.role]=\"'dialog'\"\n [attr.aria-modal]=\"'true'\"\n [attr.aria-label]=\"'platform.filter_service.filters' | translate\"\n>\n <p-header>\n <div class=\"dialog-header\">\n {{ 'platform.filter_service.filters' | translate }}\n <button \n class=\"close_btn\" \n (click)=\"toggleDialog(); close()\" \n [attr.aria-label]=\"'platform.filter_service.close' | translate\"\n type=\"button\">\n <span class=\"pi pi-times\" aria-hidden=\"true\"></span>\n </button>\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 (onClick)=\"applyFilters()\"\n ></s-button>\n <ng-container *ngIf=\"!isMobile\">\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.save')\"\n (onClick)=\"saveFilters()\"\n ></s-button>\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.clear')\"\n (onClick)=\"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 (onClick)=\"toggleDialog(); close()\"\n ></s-button>\n </p-footer>\n</p-dialog>\n\n<p-toast key=\"filterServiceToastKey\" [baseZIndex]=\"5000\"></p-toast>\n",
|
|
1817
1992
|
encapsulation: core.ViewEncapsulation.None,
|
|
1818
|
-
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%}}"]
|
|
1993
|
+
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;background:0 0;border:none;padding:0;cursor:pointer;font-size:inherit;color:inherit;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.close_btn:hover{cursor:pointer}.close_btn:focus{outline:#06c solid 2px;outline-offset:2px}.header{text-transform:uppercase;display:-ms-flexbox;display:flex;width:100%;border-bottom:1px solid #e5eaea;padding:15px;margin-left:0}.dialog-header{display:-ms-flexbox;display:flex}@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%}}"]
|
|
1819
1994
|
})
|
|
1820
1995
|
], AdvancedFilterComponent);
|
|
1821
1996
|
return AdvancedFilterComponent;
|
|
1822
1997
|
}());
|
|
1823
1998
|
|
|
1824
|
-
var AppRoutingModule = /** @class */ (function () {
|
|
1825
|
-
function AppRoutingModule() {
|
|
1826
|
-
}
|
|
1827
|
-
return AppRoutingModule;
|
|
1828
|
-
}());
|
|
1829
1999
|
var AdvancedFilterModule = /** @class */ (function () {
|
|
1830
2000
|
function AdvancedFilterModule() {
|
|
1831
2001
|
}
|
|
@@ -1853,6 +2023,8 @@
|
|
|
1853
2023
|
return AdvancedFilterModule;
|
|
1854
2024
|
}());
|
|
1855
2025
|
|
|
2026
|
+
// Module exports
|
|
2027
|
+
|
|
1856
2028
|
var CyclicJsonInterceptor = /** @class */ (function () {
|
|
1857
2029
|
function CyclicJsonInterceptor() {
|
|
1858
2030
|
}
|
|
@@ -1924,7 +2096,7 @@
|
|
|
1924
2096
|
var _this = this;
|
|
1925
2097
|
if (!originalReq.url.includes("://")) {
|
|
1926
2098
|
var getAuthHeader = rxjs.defer(function () { return rxjs.from(seniorPlatformData.user.getAuthHeader()); });
|
|
1927
|
-
if (/^\/?[
|
|
2099
|
+
if (/^\/?[^/]+\/[^/]+\/api\/(?:latest|v\d+)\/.+$/g.test(originalReq.url)) {
|
|
1928
2100
|
var getXServicesUrl = this.xServicesUrl.get();
|
|
1929
2101
|
return rxjs.forkJoin([getXServicesUrl, getAuthHeader]).pipe(operators.mergeMap(function (values) {
|
|
1930
2102
|
var _a = __read(values, 2), xUrl = _a[0], authHeader = _a[1];
|
|
@@ -1982,7 +2154,7 @@
|
|
|
1982
2154
|
return Environment;
|
|
1983
2155
|
}());
|
|
1984
2156
|
|
|
1985
|
-
|
|
2157
|
+
var HTTP_STATUS_FORBIDDEN = 403;
|
|
1986
2158
|
var PermissionsService = /** @class */ (function () {
|
|
1987
2159
|
function PermissionsService(resources, environment, http, router, messageService, translate) {
|
|
1988
2160
|
this.resources = resources;
|
|
@@ -1993,9 +2165,23 @@
|
|
|
1993
2165
|
this.translate = translate;
|
|
1994
2166
|
this.checkedPermissions = [];
|
|
1995
2167
|
this.actionUrl = 'platform/authorization/queries';
|
|
2168
|
+
this.promise = null;
|
|
1996
2169
|
}
|
|
1997
2170
|
// v2
|
|
1998
2171
|
PermissionsService.prototype.checkAccess = function (resources) {
|
|
2172
|
+
var _this = this;
|
|
2173
|
+
var permissions = this.buildPermissionsArray(resources);
|
|
2174
|
+
return this.http.post(this.actionUrl + "/checkAccess", { includeFilters: true, permissions: permissions }).pipe(operators.map(function (_a) {
|
|
2175
|
+
var checkedPermissions = _a.permissions;
|
|
2176
|
+
_this.checkedPermissions = __spread(_this.checkedPermissions, checkedPermissions);
|
|
2177
|
+
if (_this.shouldRedirectToForbiddenPage(checkedPermissions, resources)) {
|
|
2178
|
+
_this.router.navigate(['error', HTTP_STATUS_FORBIDDEN]);
|
|
2179
|
+
return rxjs.throwError('forbidden');
|
|
2180
|
+
}
|
|
2181
|
+
return _this.buildValuesFromPermissions(checkedPermissions, resources);
|
|
2182
|
+
}));
|
|
2183
|
+
};
|
|
2184
|
+
PermissionsService.prototype.buildPermissionsArray = function (resources) {
|
|
1999
2185
|
var _this = this;
|
|
2000
2186
|
var permissions = [];
|
|
2001
2187
|
resources.forEach(function (rec) {
|
|
@@ -2007,48 +2193,49 @@
|
|
|
2007
2193
|
permissions.push({ action: action, resource: rec.uri });
|
|
2008
2194
|
});
|
|
2009
2195
|
});
|
|
2010
|
-
return
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2196
|
+
return permissions;
|
|
2197
|
+
};
|
|
2198
|
+
PermissionsService.prototype.buildValuesFromPermissions = function (checkedPermissions, resources) {
|
|
2199
|
+
var values = {};
|
|
2200
|
+
checkedPermissions.forEach(function (permission) {
|
|
2201
|
+
var _a;
|
|
2202
|
+
var resource = resources.find(function (res) { return res.uri === permission.resource; });
|
|
2203
|
+
if (!resource) {
|
|
2204
|
+
return;
|
|
2017
2205
|
}
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
}
|
|
2028
|
-
permission.resourceFilters.forEach(function (resourceFilter) {
|
|
2029
|
-
values[name]['resourceFilters'].push(resourceFilter);
|
|
2030
|
-
});
|
|
2206
|
+
var name = resource.name;
|
|
2207
|
+
if (!values[name]) {
|
|
2208
|
+
values[name] = {};
|
|
2209
|
+
}
|
|
2210
|
+
values[name][permission.action] = permission.authorized;
|
|
2211
|
+
values[name][permission.action.toLowerCase()] = permission.authorized;
|
|
2212
|
+
if ((_a = permission.resourceFilters) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2213
|
+
if (!values[name].resourceFilters) {
|
|
2214
|
+
values[name].resourceFilters = [];
|
|
2031
2215
|
}
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2216
|
+
permission.resourceFilters.forEach(function (resourceFilter) {
|
|
2217
|
+
values[name].resourceFilters.push(resourceFilter);
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
});
|
|
2221
|
+
return values;
|
|
2035
2222
|
};
|
|
2036
2223
|
// v1
|
|
2037
2224
|
PermissionsService.prototype.get = function (resource) {
|
|
2038
2225
|
var _this = this;
|
|
2039
2226
|
if (resource === void 0) { resource = ''; }
|
|
2040
|
-
|
|
2041
|
-
|
|
2227
|
+
var hasPromise = this.promise !== null;
|
|
2228
|
+
if (!hasPromise) {
|
|
2229
|
+
this.promise = this.getPermissions();
|
|
2042
2230
|
}
|
|
2043
|
-
return rxjs.from(
|
|
2044
|
-
_this.checkedPermissions = permissions;
|
|
2231
|
+
return rxjs.from(this.promise).pipe(operators.map(function (permissions) {
|
|
2045
2232
|
if (resource) {
|
|
2046
2233
|
var resourceKey = Object.keys(permissions).find(function (key) { return key.toLowerCase() === resource.toLowerCase(); });
|
|
2047
|
-
return permissions[resourceKey];
|
|
2234
|
+
return resourceKey ? permissions[resourceKey] : undefined;
|
|
2048
2235
|
}
|
|
2049
2236
|
return permissions;
|
|
2050
|
-
}), operators.catchError(function (
|
|
2051
|
-
|
|
2237
|
+
}), operators.catchError(function () {
|
|
2238
|
+
_this.promise = null;
|
|
2052
2239
|
_this.messageService.add({
|
|
2053
2240
|
severity: 'error',
|
|
2054
2241
|
summary: _this.translate.instant('permission_error_summary'),
|
|
@@ -2058,47 +2245,54 @@
|
|
|
2058
2245
|
}));
|
|
2059
2246
|
};
|
|
2060
2247
|
PermissionsService.prototype.isAuthorized = function (resourceName, action, isEntity) {
|
|
2248
|
+
if (isEntity === void 0) { isEntity = false; }
|
|
2249
|
+
var _a;
|
|
2061
2250
|
if (!this.checkedPermissions.length) {
|
|
2062
|
-
|
|
2251
|
+
throw new Error('\'Permissions\' are not defined. You should call \'get\' or \'checkAccess\' method first.');
|
|
2063
2252
|
}
|
|
2064
2253
|
var resourceUri = this.getUriByResourceName(resourceName, isEntity);
|
|
2065
2254
|
var permissionsOfResource = this.checkedPermissions.filter(function (perm) { return perm.resource === resourceUri; });
|
|
2066
2255
|
var permissionOfAction = permissionsOfResource.find(function (permRec) { return permRec.action.toLowerCase() === action.toLowerCase(); });
|
|
2067
|
-
return permissionOfAction
|
|
2256
|
+
return (_a = permissionOfAction === null || permissionOfAction === void 0 ? void 0 : permissionOfAction.authorized) !== null && _a !== void 0 ? _a : false;
|
|
2068
2257
|
};
|
|
2069
2258
|
PermissionsService.prototype.getUriByResourceName = function (resourceName, isEntity) {
|
|
2259
|
+
if (isEntity === void 0) { isEntity = false; }
|
|
2070
2260
|
var _a = this.environment, domain = _a.domain, service = _a.service;
|
|
2071
2261
|
if (!domain || !service) {
|
|
2072
|
-
|
|
2262
|
+
throw new Error('You must inform domain and service name');
|
|
2073
2263
|
}
|
|
2074
2264
|
var uriBase = "res://senior.com.br/" + domain + "/" + service;
|
|
2075
2265
|
if (isEntity) {
|
|
2076
2266
|
return uriBase + "/entities/" + resourceName;
|
|
2077
2267
|
}
|
|
2078
|
-
|
|
2079
|
-
return uriBase + "/" + resourceName;
|
|
2080
|
-
}
|
|
2268
|
+
return uriBase + "/" + resourceName;
|
|
2081
2269
|
};
|
|
2082
2270
|
/**
|
|
2083
2271
|
* Valida com base nas propriedade redirectToError e actionsToCheck
|
|
2084
2272
|
* se a ação de um recurso deve enviar para a página de erro caso não tenha autorização
|
|
2085
2273
|
*/
|
|
2086
|
-
PermissionsService.prototype.shouldRedirectToForbiddenPage = function (
|
|
2274
|
+
PermissionsService.prototype.shouldRedirectToForbiddenPage = function (permissions, resources) {
|
|
2087
2275
|
if (resources === void 0) { resources = []; }
|
|
2088
2276
|
var permissionsDenied = permissions.filter(function (perm) { return !perm.authorized; });
|
|
2089
|
-
if (permissionsDenied
|
|
2090
|
-
var resourcesToCheck = resources.filter(function (resource) { return resource.redirectToError; });
|
|
2091
|
-
if (resourcesToCheck && resourcesToCheck.length) {
|
|
2092
|
-
return resourcesToCheck.every(function (resource) {
|
|
2093
|
-
var actionsToCheck = resource.actionsToCheck && resource.actionsToCheck.length ? resource.actionsToCheck : resource.actions;
|
|
2094
|
-
return actionsToCheck.every(function (action) {
|
|
2095
|
-
return permissionsDenied.some(function (permissionDenied) { return permissionDenied.resource === resource.uri && permissionDenied.action === action; });
|
|
2096
|
-
});
|
|
2097
|
-
});
|
|
2098
|
-
}
|
|
2277
|
+
if (!(permissionsDenied === null || permissionsDenied === void 0 ? void 0 : permissionsDenied.length)) {
|
|
2099
2278
|
return false;
|
|
2100
2279
|
}
|
|
2101
|
-
return
|
|
2280
|
+
var resourcesToCheck = resources.filter(function (resource) { return resource.redirectToError; });
|
|
2281
|
+
if (!(resourcesToCheck === null || resourcesToCheck === void 0 ? void 0 : resourcesToCheck.length)) {
|
|
2282
|
+
return false;
|
|
2283
|
+
}
|
|
2284
|
+
return this.checkIfAllActionsAreDenied(resourcesToCheck, permissionsDenied);
|
|
2285
|
+
};
|
|
2286
|
+
PermissionsService.prototype.checkIfAllActionsAreDenied = function (resourcesToCheck, permissionsDenied) {
|
|
2287
|
+
return resourcesToCheck.every(function (resource) {
|
|
2288
|
+
var _a;
|
|
2289
|
+
var actionsToCheck = ((_a = resource.actionsToCheck) === null || _a === void 0 ? void 0 : _a.length) ? resource.actionsToCheck : resource.actions;
|
|
2290
|
+
return actionsToCheck.every(function (action) {
|
|
2291
|
+
return permissionsDenied.some(function (permissionDenied) {
|
|
2292
|
+
return permissionDenied.resource === resource.uri && permissionDenied.action === action;
|
|
2293
|
+
});
|
|
2294
|
+
});
|
|
2295
|
+
});
|
|
2102
2296
|
};
|
|
2103
2297
|
PermissionsService.prototype.getFlatEnvironment = function () {
|
|
2104
2298
|
return this.environment.ignorePermissions;
|
|
@@ -2115,18 +2309,22 @@
|
|
|
2115
2309
|
}, []);
|
|
2116
2310
|
};
|
|
2117
2311
|
PermissionsService.prototype.getPermissionObject = function (defaultValue) {
|
|
2312
|
+
var _this = this;
|
|
2118
2313
|
return this.getFlatResources().reduce(function (resources, resource) {
|
|
2119
|
-
resources[resource.name] = resource.actions
|
|
2120
|
-
actions[action] = defaultValue;
|
|
2121
|
-
actions[action.toLowerCase()] = defaultValue;
|
|
2122
|
-
return actions;
|
|
2123
|
-
}, {});
|
|
2314
|
+
resources[resource.name] = _this.buildActionsObject(resource.actions, defaultValue);
|
|
2124
2315
|
return resources;
|
|
2125
2316
|
}, {});
|
|
2126
2317
|
};
|
|
2318
|
+
PermissionsService.prototype.buildActionsObject = function (actions, defaultValue) {
|
|
2319
|
+
return actions.reduce(function (actionsObj, action) {
|
|
2320
|
+
actionsObj[action] = defaultValue;
|
|
2321
|
+
actionsObj[action.toLowerCase()] = defaultValue;
|
|
2322
|
+
return actionsObj;
|
|
2323
|
+
}, {});
|
|
2324
|
+
};
|
|
2127
2325
|
PermissionsService.prototype.getPermissions = function () {
|
|
2128
2326
|
return __awaiter(this, void 0, void 0, function () {
|
|
2129
|
-
var resources, perm,
|
|
2327
|
+
var resources, perm, response;
|
|
2130
2328
|
return __generator(this, function (_a) {
|
|
2131
2329
|
switch (_a.label) {
|
|
2132
2330
|
case 0:
|
|
@@ -2134,31 +2332,41 @@
|
|
|
2134
2332
|
return [2 /*return*/, this.getPermissionObject(true)];
|
|
2135
2333
|
}
|
|
2136
2334
|
resources = this.getFlatResources();
|
|
2137
|
-
perm = resources
|
|
2138
|
-
.map(function (resource) { return resource.actions.map(function (action) { return ({ action: action, resource: resource.uri }); }); })
|
|
2139
|
-
.reduce(function (acc, val) { return __spread(acc, val); });
|
|
2335
|
+
perm = this.buildPermissionsForCheck(resources);
|
|
2140
2336
|
return [4 /*yield*/, this.http
|
|
2141
2337
|
.post(this.actionUrl + "/checkAccess", {
|
|
2142
2338
|
includeFilters: false,
|
|
2143
2339
|
permissions: perm
|
|
2144
2340
|
})
|
|
2145
|
-
.toPromise()
|
|
2146
|
-
.then(function (response) { return response.permissions; })];
|
|
2341
|
+
.toPromise()];
|
|
2147
2342
|
case 1:
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
permissions.forEach(function (permission) {
|
|
2151
|
-
var resource = resources.find(function (res) { return res.uri === permission.resource; });
|
|
2152
|
-
var name = resource.name;
|
|
2153
|
-
values[name] = values[name] ? values[name] : {};
|
|
2154
|
-
values[name][permission.action] = permission.authorized;
|
|
2155
|
-
values[name][permission.action.toLowerCase()] = permission.authorized;
|
|
2156
|
-
});
|
|
2157
|
-
return [2 /*return*/, values];
|
|
2343
|
+
response = _a.sent();
|
|
2344
|
+
return [2 /*return*/, this.buildPermissionsResponse(response.permissions, resources)];
|
|
2158
2345
|
}
|
|
2159
2346
|
});
|
|
2160
2347
|
});
|
|
2161
2348
|
};
|
|
2349
|
+
PermissionsService.prototype.buildPermissionsForCheck = function (resources) {
|
|
2350
|
+
return resources
|
|
2351
|
+
.map(function (resource) { return resource.actions.map(function (action) { return ({ action: action, resource: resource.uri }); }); })
|
|
2352
|
+
.reduce(function (acc, val) { return __spread(acc, val); }, []);
|
|
2353
|
+
};
|
|
2354
|
+
PermissionsService.prototype.buildPermissionsResponse = function (permissions, resources) {
|
|
2355
|
+
var values = {};
|
|
2356
|
+
permissions.forEach(function (permission) {
|
|
2357
|
+
var resource = resources.find(function (res) { return res.uri === permission.resource; });
|
|
2358
|
+
if (!resource) {
|
|
2359
|
+
return;
|
|
2360
|
+
}
|
|
2361
|
+
var name = resource.name;
|
|
2362
|
+
if (!values[name]) {
|
|
2363
|
+
values[name] = {};
|
|
2364
|
+
}
|
|
2365
|
+
values[name][permission.action] = permission.authorized;
|
|
2366
|
+
values[name][permission.action.toLowerCase()] = permission.authorized;
|
|
2367
|
+
});
|
|
2368
|
+
return values;
|
|
2369
|
+
};
|
|
2162
2370
|
PermissionsService.ctorParameters = function () { return [
|
|
2163
2371
|
{ type: undefined, decorators: [{ type: core.Inject, args: [RESOURCES,] }] },
|
|
2164
2372
|
{ type: Environment, decorators: [{ type: core.Inject, args: [ENVIRONMENT,] }] },
|
|
@@ -2646,8 +2854,8 @@
|
|
|
2646
2854
|
SpotlightComponent = __decorate([
|
|
2647
2855
|
core.Component({
|
|
2648
2856
|
selector: 's-spotlight',
|
|
2649
|
-
template: "<
|
|
2650
|
-
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%}}"]
|
|
2857
|
+
template: "<dialog\n class=\"s-spotlight-overlay\"\n id=\"ol\"\n *ngIf=\"canAppear && visible\"\n [open]=\"canAppear && visible\"\n aria-labelledby=\"spotlight-title\"\n aria-describedby=\"spotlight-image\"\n>\n <div class=\"s-spotlight\" id=\"sl\" [ngClass]=\"{ 's-effect-fadein': fade }\">\n <div class=\"s-spotlight-header\">\n <span id=\"spotlight-title\" class=\"s-spotlight-title\">{{ header.toUpperCase() }}</span>\n <button\n type=\"button\"\n class=\"s-spotlight-close\"\n (click)=\"close()\"\n [attr.aria-label]=\"'platform.spotlight.close' | translate\"\n >\n <span class=\"fa fa-times\" aria-hidden=\"true\"></span>\n </button>\n </div>\n <div class=\"s-img\">\n <img\n id=\"spotlight-image\"\n [src]=\"imgUrl\"\n [alt]=\"header || ('platform.spotlight.alt_text' | translate)\"\n width=\"auto\"\n height=\"auto\"\n />\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 [attr.aria-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 [attr.aria-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 [attr.aria-label]=\"primaryButtonLabel\"\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</dialog>\n",
|
|
2858
|
+
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;background:0 0;border:none;padding:0;cursor:pointer;font-size:inherit}.s-spotlight-close:focus{outline:#06c solid 2px;outline-offset:2px}.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%}}"]
|
|
2651
2859
|
})
|
|
2652
2860
|
], SpotlightComponent);
|
|
2653
2861
|
return SpotlightComponent;
|
|
@@ -2707,12 +2915,13 @@
|
|
|
2707
2915
|
exports.AdvancedFilterComponent = AdvancedFilterComponent;
|
|
2708
2916
|
exports.AdvancedFilterModule = AdvancedFilterModule;
|
|
2709
2917
|
exports.AdvancedFilterService = AdvancedFilterService;
|
|
2710
|
-
exports.AppRoutingModule = AppRoutingModule;
|
|
2711
2918
|
exports.CyclicJsonInterceptorModule = CyclicJsonInterceptorModule;
|
|
2919
|
+
exports.FILTER_CONSTANTS = FILTER_CONSTANTS;
|
|
2712
2920
|
exports.FeatureToggleModule = FeatureToggleModule;
|
|
2713
2921
|
exports.FeatureToggleService = FeatureToggleService;
|
|
2714
2922
|
exports.Filter = Filter;
|
|
2715
2923
|
exports.FormFilter = FormFilter;
|
|
2924
|
+
exports.GRID_CONFIG = GRID_CONFIG;
|
|
2716
2925
|
exports.HttpInterceptorModule = HttpInterceptorModule;
|
|
2717
2926
|
exports.LENGTH_DEFAULT = LENGTH_DEFAULT;
|
|
2718
2927
|
exports.PermissionsModule = PermissionsModule;
|
|
@@ -2722,7 +2931,9 @@
|
|
|
2722
2931
|
exports.SpotlightModule = SpotlightModule;
|
|
2723
2932
|
exports.TranslationsConfig = TranslationsConfig;
|
|
2724
2933
|
exports.TranslationsModule = TranslationsModule;
|
|
2934
|
+
exports.UI_CONSTANTS = UI_CONSTANTS;
|
|
2725
2935
|
exports.USER_INFO = USER_INFO;
|
|
2936
|
+
exports.VALIDATION_CONSTANTS = VALIDATION_CONSTANTS;
|
|
2726
2937
|
exports.XServicesUrl = XServicesUrl;
|
|
2727
2938
|
exports.factory = factory;
|
|
2728
2939
|
exports.ɵa = fallback;
|