@seniorsistemas/platform-components 5.3.3-develop-73308358 → 5.3.3-feature-ptfgap-1001-71043a1b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/bundles/seniorsistemas-platform-components.umd.js +3083 -0
  2. package/bundles/seniorsistemas-platform-components.umd.js.map +1 -0
  3. package/bundles/seniorsistemas-platform-components.umd.min.js +17 -0
  4. package/bundles/seniorsistemas-platform-components.umd.min.js.map +1 -0
  5. package/esm2015/modules/advanced-filter/advanced-filter.module.js +45 -0
  6. package/esm2015/modules/advanced-filter/components/advanced-filter/advanced-filter.component.js +141 -0
  7. package/esm2015/modules/advanced-filter/components/form-filter/form-filter.component.js +728 -0
  8. package/esm2015/modules/advanced-filter/constants/form-filter.constants.js +45 -0
  9. package/esm2015/modules/advanced-filter/index.js +13 -0
  10. package/esm2015/modules/advanced-filter/locale/fallback.js +73 -0
  11. package/esm2015/modules/advanced-filter/models/context.js +1 -0
  12. package/esm2015/modules/advanced-filter/models/depends-on.js +1 -0
  13. package/esm2015/modules/advanced-filter/models/enum-item.js +1 -0
  14. package/esm2015/modules/advanced-filter/models/filter-type.js +14 -0
  15. package/esm2015/modules/advanced-filter/models/filter-value.js +1 -0
  16. package/esm2015/modules/advanced-filter/models/filter.js +23 -0
  17. package/esm2015/modules/advanced-filter/models/form-filter.js +19 -0
  18. package/esm2015/modules/advanced-filter/models/index.js +5 -0
  19. package/esm2015/modules/advanced-filter/models/scope.js +6 -0
  20. package/esm2015/modules/advanced-filter/models/search.js +1 -0
  21. package/esm2015/modules/advanced-filter/models/tab-view.js +18 -0
  22. package/esm2015/modules/advanced-filter/models/ticked-filter.js +1 -0
  23. package/esm2015/modules/advanced-filter/pipes/map-values.pipe.js +12 -0
  24. package/esm2015/modules/advanced-filter/pipes/translate.pipe.js +22 -0
  25. package/esm2015/modules/advanced-filter/services/advanced-filter.service.js +146 -0
  26. package/esm2015/modules/advanced-filter/services/calendar-options.service.js +81 -0
  27. package/esm2015/modules/advanced-filter/services/constants.js +6 -0
  28. package/esm2015/modules/advanced-filter/shared/constants.js +3 -0
  29. package/esm2015/modules/advanced-filter/utils/comparator.js +55 -0
  30. package/esm2015/modules/advanced-filter/utils/filter-id/index.js +8 -0
  31. package/esm2015/modules/advanced-filter/utils/filter-value/index.js +20 -0
  32. package/esm2015/modules/advanced-filter/utils/filterOperators.js +11 -0
  33. package/esm2015/modules/advanced-filter/utils/form-field/index.js +46 -0
  34. package/esm2015/modules/advanced-filter/utils/index.js +57 -0
  35. package/esm2015/modules/advanced-filter/utils/json-path.js +12 -0
  36. package/esm2015/modules/cyclic-json-interceptor/cyclic-json-interceptor.module.js +14 -0
  37. package/esm2015/modules/cyclic-json-interceptor/cyclic-json-interceptor.service.js +27 -0
  38. package/esm2015/modules/cyclic-json-interceptor/index.js +2 -0
  39. package/esm2015/modules/feature-toggle/constants/endpoint.constant.js +26 -0
  40. package/esm2015/modules/feature-toggle/feature-toggle.module.js +15 -0
  41. package/esm2015/modules/feature-toggle/feature-toggle.service.js +48 -0
  42. package/esm2015/modules/feature-toggle/index.js +3 -0
  43. package/esm2015/modules/feature-toggle/models/feature.js +1 -0
  44. package/esm2015/modules/http-interceptor/http-interceptor.module.js +16 -0
  45. package/esm2015/modules/http-interceptor/http-interceptor.service.js +47 -0
  46. package/esm2015/modules/http-interceptor/index.js +4 -0
  47. package/esm2015/modules/http-interceptor/rest-url.service.js +14 -0
  48. package/esm2015/modules/http-interceptor/x-services-url.service.js +17 -0
  49. package/esm2015/modules/permissions/permissions.config.js +11 -0
  50. package/esm2015/modules/permissions/permissions.module.js +42 -0
  51. package/esm2015/modules/permissions/permissions.service.js +226 -0
  52. package/esm2015/modules/spotlight/component/spotlight.component.js +290 -0
  53. package/esm2015/modules/spotlight/index.js +3 -0
  54. package/esm2015/modules/spotlight/locale/fallback.js +5 -0
  55. package/esm2015/modules/spotlight/models/display-type.enum.js +6 -0
  56. package/esm2015/modules/spotlight/models/index.js +4 -0
  57. package/esm2015/modules/spotlight/models/spotlight-control-list.interface.js +1 -0
  58. package/esm2015/modules/spotlight/models/spotlight-control.interface.js +3 -0
  59. package/esm2015/modules/spotlight/models/spotlight-notification.interface.js +1 -0
  60. package/esm2015/modules/spotlight/models/spotlight-screen-list.interface.js +1 -0
  61. package/esm2015/modules/spotlight/models/spotlight-screen.interface.js +1 -0
  62. package/esm2015/modules/spotlight/models/spotlight-status.enum.js +8 -0
  63. package/esm2015/modules/spotlight/models/spotlight-user.interface.js +1 -0
  64. package/esm2015/modules/spotlight/models/spotlight-users-list.interface.js +1 -0
  65. package/esm2015/modules/spotlight/models/spotlight.interface.js +1 -0
  66. package/esm2015/modules/spotlight/models/user-action.enum.js +7 -0
  67. package/esm2015/modules/spotlight/pipes/translate.pipe.js +22 -0
  68. package/esm2015/modules/spotlight/service/spotlight.service.js +38 -0
  69. package/esm2015/modules/spotlight/spotlight.module.js +37 -0
  70. package/esm2015/modules/translations/translations.module.js +193 -0
  71. package/esm2015/public-api.js +9 -0
  72. package/esm2015/seniorsistemas-platform-components.js +16 -0
  73. package/esm2015/utils/accessibility-utils.js +48 -0
  74. package/esm5/modules/advanced-filter/advanced-filter.module.js +48 -0
  75. package/esm5/modules/advanced-filter/components/advanced-filter/advanced-filter.component.js +149 -0
  76. package/esm5/modules/advanced-filter/components/form-filter/form-filter.component.js +794 -0
  77. package/esm5/modules/advanced-filter/constants/form-filter.constants.js +45 -0
  78. package/esm5/modules/advanced-filter/index.js +13 -0
  79. package/esm5/modules/advanced-filter/locale/fallback.js +73 -0
  80. package/esm5/modules/advanced-filter/models/context.js +1 -0
  81. package/esm5/modules/advanced-filter/models/depends-on.js +1 -0
  82. package/esm5/modules/advanced-filter/models/enum-item.js +1 -0
  83. package/esm5/modules/advanced-filter/models/filter-type.js +14 -0
  84. package/esm5/modules/advanced-filter/models/filter-value.js +1 -0
  85. package/esm5/modules/advanced-filter/models/filter.js +25 -0
  86. package/esm5/modules/advanced-filter/models/form-filter.js +25 -0
  87. package/esm5/modules/advanced-filter/models/index.js +5 -0
  88. package/esm5/modules/advanced-filter/models/scope.js +6 -0
  89. package/esm5/modules/advanced-filter/models/search.js +1 -0
  90. package/esm5/modules/advanced-filter/models/tab-view.js +29 -0
  91. package/esm5/modules/advanced-filter/models/ticked-filter.js +1 -0
  92. package/esm5/modules/advanced-filter/pipes/map-values.pipe.js +16 -0
  93. package/esm5/modules/advanced-filter/pipes/translate.pipe.js +23 -0
  94. package/esm5/modules/advanced-filter/services/advanced-filter.service.js +158 -0
  95. package/esm5/modules/advanced-filter/services/calendar-options.service.js +82 -0
  96. package/esm5/modules/advanced-filter/services/constants.js +6 -0
  97. package/esm5/modules/advanced-filter/shared/constants.js +3 -0
  98. package/esm5/modules/advanced-filter/utils/comparator.js +55 -0
  99. package/esm5/modules/advanced-filter/utils/filter-id/index.js +8 -0
  100. package/esm5/modules/advanced-filter/utils/filter-value/index.js +21 -0
  101. package/esm5/modules/advanced-filter/utils/filterOperators.js +11 -0
  102. package/esm5/modules/advanced-filter/utils/form-field/index.js +48 -0
  103. package/esm5/modules/advanced-filter/utils/index.js +57 -0
  104. package/esm5/modules/advanced-filter/utils/json-path.js +12 -0
  105. package/esm5/modules/cyclic-json-interceptor/cyclic-json-interceptor.module.js +17 -0
  106. package/esm5/modules/cyclic-json-interceptor/cyclic-json-interceptor.service.js +30 -0
  107. package/esm5/modules/cyclic-json-interceptor/index.js +2 -0
  108. package/esm5/modules/feature-toggle/constants/endpoint.constant.js +27 -0
  109. package/esm5/modules/feature-toggle/feature-toggle.module.js +18 -0
  110. package/esm5/modules/feature-toggle/feature-toggle.service.js +51 -0
  111. package/esm5/modules/feature-toggle/index.js +3 -0
  112. package/esm5/modules/feature-toggle/models/feature.js +1 -0
  113. package/esm5/modules/http-interceptor/http-interceptor.module.js +19 -0
  114. package/esm5/modules/http-interceptor/http-interceptor.service.js +49 -0
  115. package/esm5/modules/http-interceptor/index.js +4 -0
  116. package/esm5/modules/http-interceptor/rest-url.service.js +17 -0
  117. package/esm5/modules/http-interceptor/x-services-url.service.js +20 -0
  118. package/esm5/modules/permissions/permissions.config.js +17 -0
  119. package/esm5/modules/permissions/permissions.module.js +46 -0
  120. package/esm5/modules/permissions/permissions.service.js +248 -0
  121. package/esm5/modules/spotlight/component/spotlight.component.js +312 -0
  122. package/esm5/modules/spotlight/index.js +3 -0
  123. package/esm5/modules/spotlight/locale/fallback.js +5 -0
  124. package/esm5/modules/spotlight/models/display-type.enum.js +6 -0
  125. package/esm5/modules/spotlight/models/index.js +4 -0
  126. package/esm5/modules/spotlight/models/spotlight-control-list.interface.js +1 -0
  127. package/esm5/modules/spotlight/models/spotlight-control.interface.js +7 -0
  128. package/esm5/modules/spotlight/models/spotlight-notification.interface.js +1 -0
  129. package/esm5/modules/spotlight/models/spotlight-screen-list.interface.js +1 -0
  130. package/esm5/modules/spotlight/models/spotlight-screen.interface.js +1 -0
  131. package/esm5/modules/spotlight/models/spotlight-status.enum.js +8 -0
  132. package/esm5/modules/spotlight/models/spotlight-user.interface.js +1 -0
  133. package/esm5/modules/spotlight/models/spotlight-users-list.interface.js +1 -0
  134. package/esm5/modules/spotlight/models/spotlight.interface.js +1 -0
  135. package/esm5/modules/spotlight/models/user-action.enum.js +7 -0
  136. package/esm5/modules/spotlight/pipes/translate.pipe.js +23 -0
  137. package/esm5/modules/spotlight/service/spotlight.service.js +39 -0
  138. package/esm5/modules/spotlight/spotlight.module.js +40 -0
  139. package/esm5/modules/translations/translations.module.js +251 -0
  140. package/esm5/public-api.js +9 -0
  141. package/esm5/seniorsistemas-platform-components.js +16 -0
  142. package/esm5/utils/accessibility-utils.js +53 -0
  143. package/fesm2015/seniorsistemas-platform-components.js +2584 -0
  144. package/fesm2015/seniorsistemas-platform-components.js.map +1 -0
  145. package/fesm5/seniorsistemas-platform-components.js +2842 -0
  146. package/fesm5/seniorsistemas-platform-components.js.map +1 -0
  147. package/modules/advanced-filter/advanced-filter.module.d.ts +0 -21
  148. package/modules/advanced-filter/components/advanced-filter/advanced-filter.component.d.ts +2 -3
  149. package/modules/advanced-filter/components/form-filter/form-filter.component.d.ts +51 -20
  150. package/modules/advanced-filter/constants/form-filter.constants.d.ts +40 -0
  151. package/modules/advanced-filter/index.d.ts +14 -5
  152. package/modules/advanced-filter/models/form-filter.d.ts +9 -2
  153. package/modules/advanced-filter/models/tab-view.d.ts +1 -1
  154. package/modules/advanced-filter/pipes/map-values.pipe.d.ts +0 -3
  155. package/modules/advanced-filter/pipes/translate.pipe.d.ts +3 -4
  156. package/modules/advanced-filter/services/advanced-filter.service.d.ts +8 -9
  157. package/modules/advanced-filter/services/calendar-options.service.d.ts +3 -4
  158. package/modules/advanced-filter/services/constants.d.ts +4 -4
  159. package/modules/advanced-filter/utils/filterOperators.d.ts +7 -7
  160. package/modules/advanced-filter/utils/form-field/index.d.ts +1 -1
  161. package/modules/advanced-filter/utils/json-path.d.ts +3 -1
  162. package/modules/cyclic-json-interceptor/cyclic-json-interceptor.module.d.ts +0 -4
  163. package/modules/cyclic-json-interceptor/cyclic-json-interceptor.service.d.ts +0 -3
  164. package/modules/feature-toggle/feature-toggle.module.d.ts +0 -5
  165. package/modules/feature-toggle/feature-toggle.service.d.ts +3 -4
  166. package/modules/http-interceptor/http-interceptor.module.d.ts +0 -4
  167. package/modules/http-interceptor/http-interceptor.service.d.ts +3 -3
  168. package/modules/http-interceptor/rest-url.service.d.ts +0 -3
  169. package/modules/http-interceptor/x-services-url.service.d.ts +0 -3
  170. package/modules/permissions/permissions.config.d.ts +1 -7
  171. package/modules/permissions/permissions.module.d.ts +0 -4
  172. package/modules/permissions/permissions.service.d.ts +19 -7
  173. package/modules/spotlight/component/spotlight.component.d.ts +13 -6
  174. package/modules/spotlight/pipes/translate.pipe.d.ts +3 -4
  175. package/modules/spotlight/service/spotlight.service.d.ts +3 -4
  176. package/modules/spotlight/spotlight.module.d.ts +0 -11
  177. package/modules/translations/translations.module.d.ts +1 -6
  178. package/package.json +19 -22
  179. package/public-api.d.ts +0 -1
  180. package/seniorsistemas-platform-components.d.ts +15 -0
  181. package/seniorsistemas-platform-components.metadata.json +1 -0
  182. package/utils/accessibility-utils.d.ts +12 -0
  183. package/esm2022/modules/advanced-filter/advanced-filter.module.mjs +0 -75
  184. package/esm2022/modules/advanced-filter/components/advanced-filter/advanced-filter.component.mjs +0 -128
  185. package/esm2022/modules/advanced-filter/components/form-filter/form-filter.component.mjs +0 -651
  186. package/esm2022/modules/advanced-filter/index.mjs +0 -6
  187. package/esm2022/modules/advanced-filter/locale/fallback.mjs +0 -73
  188. package/esm2022/modules/advanced-filter/models/context.mjs +0 -2
  189. package/esm2022/modules/advanced-filter/models/depends-on.mjs +0 -2
  190. package/esm2022/modules/advanced-filter/models/enum-item.mjs +0 -2
  191. package/esm2022/modules/advanced-filter/models/filter-type.mjs +0 -14
  192. package/esm2022/modules/advanced-filter/models/filter-value.mjs +0 -2
  193. package/esm2022/modules/advanced-filter/models/filter.mjs +0 -41
  194. package/esm2022/modules/advanced-filter/models/form-filter.mjs +0 -28
  195. package/esm2022/modules/advanced-filter/models/index.mjs +0 -11
  196. package/esm2022/modules/advanced-filter/models/scope.mjs +0 -6
  197. package/esm2022/modules/advanced-filter/models/search.mjs +0 -2
  198. package/esm2022/modules/advanced-filter/models/tab-view.mjs +0 -18
  199. package/esm2022/modules/advanced-filter/models/ticked-filter.mjs +0 -2
  200. package/esm2022/modules/advanced-filter/pipes/map-values.pipe.mjs +0 -14
  201. package/esm2022/modules/advanced-filter/pipes/translate.pipe.mjs +0 -19
  202. package/esm2022/modules/advanced-filter/services/advanced-filter.service.mjs +0 -146
  203. package/esm2022/modules/advanced-filter/services/calendar-options.service.mjs +0 -77
  204. package/esm2022/modules/advanced-filter/services/constants.mjs +0 -6
  205. package/esm2022/modules/advanced-filter/shared/constants.mjs +0 -3
  206. package/esm2022/modules/advanced-filter/utils/comparator.mjs +0 -53
  207. package/esm2022/modules/advanced-filter/utils/filter-id/index.mjs +0 -8
  208. package/esm2022/modules/advanced-filter/utils/filter-value/index.mjs +0 -26
  209. package/esm2022/modules/advanced-filter/utils/filterOperators.mjs +0 -9
  210. package/esm2022/modules/advanced-filter/utils/form-field/index.mjs +0 -52
  211. package/esm2022/modules/advanced-filter/utils/index.mjs +0 -57
  212. package/esm2022/modules/advanced-filter/utils/json-path.mjs +0 -13
  213. package/esm2022/modules/cyclic-json-interceptor/cyclic-json-interceptor.module.mjs +0 -14
  214. package/esm2022/modules/cyclic-json-interceptor/cyclic-json-interceptor.service.mjs +0 -29
  215. package/esm2022/modules/cyclic-json-interceptor/index.mjs +0 -2
  216. package/esm2022/modules/feature-toggle/constants/endpoint.constant.mjs +0 -26
  217. package/esm2022/modules/feature-toggle/feature-toggle.module.mjs +0 -15
  218. package/esm2022/modules/feature-toggle/feature-toggle.service.mjs +0 -42
  219. package/esm2022/modules/feature-toggle/index.mjs +0 -4
  220. package/esm2022/modules/feature-toggle/models/feature.mjs +0 -2
  221. package/esm2022/modules/http-interceptor/http-interceptor.module.mjs +0 -16
  222. package/esm2022/modules/http-interceptor/http-interceptor.service.mjs +0 -42
  223. package/esm2022/modules/http-interceptor/index.mjs +0 -4
  224. package/esm2022/modules/http-interceptor/rest-url.service.mjs +0 -15
  225. package/esm2022/modules/http-interceptor/x-services-url.service.mjs +0 -18
  226. package/esm2022/modules/permissions/permissions.config.mjs +0 -17
  227. package/esm2022/modules/permissions/permissions.module.mjs +0 -43
  228. package/esm2022/modules/permissions/permissions.service.mjs +0 -169
  229. package/esm2022/modules/spotlight/component/spotlight.component.mjs +0 -274
  230. package/esm2022/modules/spotlight/index.mjs +0 -3
  231. package/esm2022/modules/spotlight/locale/fallback.mjs +0 -5
  232. package/esm2022/modules/spotlight/models/display-type.enum.mjs +0 -6
  233. package/esm2022/modules/spotlight/models/index.mjs +0 -10
  234. package/esm2022/modules/spotlight/models/spotlight-control-list.interface.mjs +0 -2
  235. package/esm2022/modules/spotlight/models/spotlight-control.interface.mjs +0 -11
  236. package/esm2022/modules/spotlight/models/spotlight-notification.interface.mjs +0 -2
  237. package/esm2022/modules/spotlight/models/spotlight-screen-list.interface.mjs +0 -2
  238. package/esm2022/modules/spotlight/models/spotlight-screen.interface.mjs +0 -2
  239. package/esm2022/modules/spotlight/models/spotlight-status.enum.mjs +0 -8
  240. package/esm2022/modules/spotlight/models/spotlight-user.interface.mjs +0 -2
  241. package/esm2022/modules/spotlight/models/spotlight-users-list.interface.mjs +0 -2
  242. package/esm2022/modules/spotlight/models/spotlight.interface.mjs +0 -2
  243. package/esm2022/modules/spotlight/models/user-action.enum.mjs +0 -7
  244. package/esm2022/modules/spotlight/pipes/translate.pipe.mjs +0 -19
  245. package/esm2022/modules/spotlight/service/spotlight.service.mjs +0 -34
  246. package/esm2022/modules/spotlight/spotlight.module.mjs +0 -53
  247. package/esm2022/modules/translations/translations.module.mjs +0 -192
  248. package/esm2022/public-api.mjs +0 -10
  249. package/esm2022/seniorsistemas-platform-components.mjs +0 -5
  250. package/fesm2022/seniorsistemas-platform-components.mjs +0 -2432
  251. package/fesm2022/seniorsistemas-platform-components.mjs.map +0 -1
  252. package/index.d.ts +0 -5
@@ -0,0 +1,3083 @@
1
+ (function (global, factory) {
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
+ 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.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
+
7
+ var momentNs__default__default = 'default' in momentNs__default ? momentNs__default['default'] : momentNs__default;
8
+ jsonCycle = jsonCycle && Object.prototype.hasOwnProperty.call(jsonCycle, 'default') ? jsonCycle['default'] : jsonCycle;
9
+
10
+ /*! *****************************************************************************
11
+ Copyright (c) Microsoft Corporation.
12
+
13
+ Permission to use, copy, modify, and/or distribute this software for any
14
+ purpose with or without fee is hereby granted.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
17
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
19
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
20
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
+ PERFORMANCE OF THIS SOFTWARE.
23
+ ***************************************************************************** */
24
+ /* global Reflect, Promise */
25
+
26
+ var extendStatics = function(d, b) {
27
+ extendStatics = Object.setPrototypeOf ||
28
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
30
+ return extendStatics(d, b);
31
+ };
32
+
33
+ function __extends(d, b) {
34
+ extendStatics(d, b);
35
+ function __() { this.constructor = d; }
36
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
37
+ }
38
+
39
+ var __assign = function() {
40
+ __assign = Object.assign || function __assign(t) {
41
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
42
+ s = arguments[i];
43
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
44
+ }
45
+ return t;
46
+ };
47
+ return __assign.apply(this, arguments);
48
+ };
49
+
50
+ function __rest(s, e) {
51
+ var t = {};
52
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
53
+ t[p] = s[p];
54
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
55
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
56
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
57
+ t[p[i]] = s[p[i]];
58
+ }
59
+ return t;
60
+ }
61
+
62
+ function __decorate(decorators, target, key, desc) {
63
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
64
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
65
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
66
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
67
+ }
68
+
69
+ function __param(paramIndex, decorator) {
70
+ return function (target, key) { decorator(target, key, paramIndex); }
71
+ }
72
+
73
+ function __metadata(metadataKey, metadataValue) {
74
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
75
+ }
76
+
77
+ function __awaiter(thisArg, _arguments, P, generator) {
78
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
79
+ return new (P || (P = Promise))(function (resolve, reject) {
80
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
81
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
82
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
83
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
84
+ });
85
+ }
86
+
87
+ function __generator(thisArg, body) {
88
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
89
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
90
+ function verb(n) { return function (v) { return step([n, v]); }; }
91
+ function step(op) {
92
+ if (f) throw new TypeError("Generator is already executing.");
93
+ while (_) try {
94
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
95
+ if (y = 0, t) op = [op[0] & 2, t.value];
96
+ switch (op[0]) {
97
+ case 0: case 1: t = op; break;
98
+ case 4: _.label++; return { value: op[1], done: false };
99
+ case 5: _.label++; y = op[1]; op = [0]; continue;
100
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
101
+ default:
102
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
103
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
104
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
105
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
106
+ if (t[2]) _.ops.pop();
107
+ _.trys.pop(); continue;
108
+ }
109
+ op = body.call(thisArg, _);
110
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
111
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
112
+ }
113
+ }
114
+
115
+ function __createBinding(o, m, k, k2) {
116
+ if (k2 === undefined) k2 = k;
117
+ o[k2] = m[k];
118
+ }
119
+
120
+ function __exportStar(m, exports) {
121
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
122
+ }
123
+
124
+ function __values(o) {
125
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
126
+ if (m) return m.call(o);
127
+ if (o && typeof o.length === "number") return {
128
+ next: function () {
129
+ if (o && i >= o.length) o = void 0;
130
+ return { value: o && o[i++], done: !o };
131
+ }
132
+ };
133
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
134
+ }
135
+
136
+ function __read(o, n) {
137
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
138
+ if (!m) return o;
139
+ var i = m.call(o), r, ar = [], e;
140
+ try {
141
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
142
+ }
143
+ catch (error) { e = { error: error }; }
144
+ finally {
145
+ try {
146
+ if (r && !r.done && (m = i["return"])) m.call(i);
147
+ }
148
+ finally { if (e) throw e.error; }
149
+ }
150
+ return ar;
151
+ }
152
+
153
+ function __spread() {
154
+ for (var ar = [], i = 0; i < arguments.length; i++)
155
+ ar = ar.concat(__read(arguments[i]));
156
+ return ar;
157
+ }
158
+
159
+ function __spreadArrays() {
160
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
161
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
162
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
163
+ r[k] = a[j];
164
+ return r;
165
+ };
166
+
167
+ function __await(v) {
168
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
169
+ }
170
+
171
+ function __asyncGenerator(thisArg, _arguments, generator) {
172
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
173
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
174
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
175
+ function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
176
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
177
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
178
+ function fulfill(value) { resume("next", value); }
179
+ function reject(value) { resume("throw", value); }
180
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
181
+ }
182
+
183
+ function __asyncDelegator(o) {
184
+ var i, p;
185
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
186
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
187
+ }
188
+
189
+ function __asyncValues(o) {
190
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
191
+ var m = o[Symbol.asyncIterator], i;
192
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
193
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
194
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
195
+ }
196
+
197
+ function __makeTemplateObject(cooked, raw) {
198
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
199
+ return cooked;
200
+ };
201
+
202
+ function __importStar(mod) {
203
+ if (mod && mod.__esModule) return mod;
204
+ var result = {};
205
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
206
+ result.default = mod;
207
+ return result;
208
+ }
209
+
210
+ function __importDefault(mod) {
211
+ return (mod && mod.__esModule) ? mod : { default: mod };
212
+ }
213
+
214
+ function __classPrivateFieldGet(receiver, privateMap) {
215
+ if (!privateMap.has(receiver)) {
216
+ throw new TypeError("attempted to get private field on non-instance");
217
+ }
218
+ return privateMap.get(receiver);
219
+ }
220
+
221
+ function __classPrivateFieldSet(receiver, privateMap, value) {
222
+ if (!privateMap.has(receiver)) {
223
+ throw new TypeError("attempted to set private field on non-instance");
224
+ }
225
+ privateMap.set(receiver, value);
226
+ return value;
227
+ }
228
+
229
+ var MapValuesPipe = /** @class */ (function () {
230
+ function MapValuesPipe() {
231
+ }
232
+ MapValuesPipe.prototype.transform = function (map, args) {
233
+ if (args === void 0) { args = null; }
234
+ return Array.from(map.values());
235
+ };
236
+ MapValuesPipe = __decorate([
237
+ core.Pipe({ name: 'mapValues', pure: false })
238
+ ], MapValuesPipe);
239
+ return MapValuesPipe;
240
+ }());
241
+
242
+ var TranslatePipe = /** @class */ (function () {
243
+ function TranslatePipe(translationService) {
244
+ this.translationService = translationService;
245
+ }
246
+ TranslatePipe.prototype.transform = function (value, args) {
247
+ return this.translationService.instant(value);
248
+ };
249
+ TranslatePipe.ctorParameters = function () { return [
250
+ { type: core$1.TranslateService }
251
+ ]; };
252
+ TranslatePipe = __decorate([
253
+ core.Pipe({
254
+ name: 'translate',
255
+ pure: false,
256
+ })
257
+ ], TranslatePipe);
258
+ return TranslatePipe;
259
+ }());
260
+
261
+ var TranslationsConfig = new core.InjectionToken('translationConfig');
262
+ var USER_INFO = 'com.senior.token';
263
+ var LENGTH_DEFAULT = 2;
264
+ var TranslationsModule = /** @class */ (function () {
265
+ function TranslationsModule() {
266
+ }
267
+ TranslationsModule_1 = TranslationsModule;
268
+ TranslationsModule.forRoot = function (translationsConfigs) {
269
+ return {
270
+ ngModule: TranslationsModule_1,
271
+ providers: [
272
+ {
273
+ provide: core.APP_INITIALIZER,
274
+ useFactory: factory,
275
+ deps: [core$1.TranslateService, core.Injector, http.HttpClient, ngxCookieService.CookieService],
276
+ multi: true
277
+ },
278
+ {
279
+ provide: TranslationsConfig,
280
+ useValue: translationsConfigs,
281
+ multi: true
282
+ }
283
+ ]
284
+ };
285
+ };
286
+ TranslationsModule.forChild = function (translationsConfigs) {
287
+ return {
288
+ ngModule: TranslationsModule_1,
289
+ providers: [
290
+ {
291
+ provide: TranslationsConfig,
292
+ useValue: translationsConfigs,
293
+ multi: true
294
+ }
295
+ ]
296
+ };
297
+ };
298
+ var TranslationsModule_1;
299
+ TranslationsModule = TranslationsModule_1 = __decorate([
300
+ core.NgModule({
301
+ imports: [http.HttpClientModule, core$1.TranslateModule.forChild()],
302
+ providers: [ngxCookieService.CookieService]
303
+ })
304
+ ], TranslationsModule);
305
+ return TranslationsModule;
306
+ }());
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) {
314
+ translate.setTranslation(locale, fallbackByLocale, true);
315
+ }
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*/];
364
+ }
365
+ });
366
+ });
367
+ }
368
+ function getFlatArray(array) {
369
+ return array.reduce(function (result, item) {
370
+ if (Array.isArray(item)) {
371
+ return __spread(result, item);
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
+ });
392
+ }
393
+ if (result['foundLocaleUser']) {
394
+ result['fallbackByLocale'] = result['foundLocaleUser']['translation'];
395
+ }
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*/];
450
+ }
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
+ });
500
+ }
501
+ return initFactory;
502
+ }
503
+
504
+ var fallback = {
505
+ 'platform.filter_service.cancel': 'Cancelar',
506
+ 'platform.filter_service.try': 'Tentar Novamente',
507
+ 'platform.filter_service.actions': 'Ações',
508
+ 'platform.filter_service.save': 'Salvar',
509
+ 'platform.filter_service.filter': 'Filtrar',
510
+ 'platform.filter_service.error_state': 'O serviço de filtro está indisponível no momento e as informações apresentadas não são as mais recentes. Tente novamente mais tarde.',
511
+ 'platform.filter_service.saved_filters_success': 'Filtros salvos com sucesso! Clique em "Filtrar" para visualizar o resultado.',
512
+ 'platform.filter_service.saved_filters_error': 'Ocorreu um erro ao tentar salvar os filtros. Verifique os valores e tente novamente.',
513
+ 'platform.filter_service.applied_filter_nochange': 'Não houve alterações no filtro.',
514
+ 'platform.filter_service.applied_filter_change': 'Filtros aplicados com sucesso!',
515
+ 'platform.filter_service.invalid_pattern': 'O valor não atende ao padrão especificado.',
516
+ 'platform.filter_service.error_max_value': 'O valor excede o tamanho máximo especificado.',
517
+ 'platform.filter_service.error_min_value': 'O valor é menor que o minímo especificado.',
518
+ 'platform.filter_service.applied_filters_message': '{{totalActiveFilters}} filtros aplicados',
519
+ 'platform.filter_service.applied_filter_message': '{{totalActiveFilters}} filtro aplicado',
520
+ 'platform.filter_service.find_suggestions_error': 'Erro ao encontrar sugestões!',
521
+ 'platform.filter_service.select': 'Selecionar',
522
+ 'platform.filter_service.filters': 'Filtros',
523
+ 'platform.filter_service.date_format': 'dd/mm/yy',
524
+ 'platform.filter_service.hour_format': '24',
525
+ 'platform.filter_service.clear': 'Limpar',
526
+ 'platform.filter_service.today': 'Hoje',
527
+ 'platform.filter_service.name_january': 'Janeiro',
528
+ 'platform.filter_service.name_february': 'Fevereiro',
529
+ 'platform.filter_service.name_march': 'Março',
530
+ 'platform.filter_service.name_april': 'Abril',
531
+ 'platform.filter_service.name_may': 'Maio',
532
+ 'platform.filter_service.name_june': 'Junho',
533
+ 'platform.filter_service.name_july': 'Julho',
534
+ 'platform.filter_service.name_august': 'Agosto',
535
+ 'platform.filter_service.name_september': 'Setembro',
536
+ 'platform.filter_service.name_october': 'Outubro',
537
+ 'platform.filter_service.name_november': 'Novembro',
538
+ 'platform.filter_service.name_december': 'Dezembro',
539
+ 'platform.filter_service.short_january': 'Jan',
540
+ 'platform.filter_service.short_february': 'Fev',
541
+ 'platform.filter_service.short_march': 'Mar',
542
+ 'platform.filter_service.short_april': 'Abr',
543
+ 'platform.filter_service.short_may': 'Mai',
544
+ 'platform.filter_service.short_june': 'Jun',
545
+ 'platform.filter_service.short_july': 'Jul',
546
+ 'platform.filter_service.short_august': 'Ago',
547
+ 'platform.filter_service.short_september': 'Set',
548
+ 'platform.filter_service.short_october': 'Out',
549
+ 'platform.filter_service.short_november': 'Nov',
550
+ 'platform.filter_service.short_december': 'Dez',
551
+ 'platform.filter_service.name_sunday': 'Domingo',
552
+ 'platform.filter_service.name_monday': 'Segunda',
553
+ 'platform.filter_service.name_tuesday': 'Terça',
554
+ 'platform.filter_service.name_wednesday': 'Quarta',
555
+ 'platform.filter_service.name_thursday': 'Quinta',
556
+ 'platform.filter_service.name_friday': 'Sexta',
557
+ 'platform.filter_service.name_saturday': 'Sábado',
558
+ 'platform.filter_service.min_sunday': 'D',
559
+ 'platform.filter_service.min_monday': 'S',
560
+ 'platform.filter_service.min_tuesday': 'T',
561
+ 'platform.filter_service.min_wednesday': 'Q',
562
+ 'platform.filter_service.min_thursday': 'Q',
563
+ 'platform.filter_service.min_friday': 'S',
564
+ 'platform.filter_service.min_saturday': 'S',
565
+ 'platform.filter_service.short_sunday': 'Dom',
566
+ 'platform.filter_service.short_monday': 'Seg',
567
+ 'platform.filter_service.short_tuesday': 'Ter',
568
+ 'platform.filter_service.short_wednesday': 'Qua',
569
+ 'platform.filter_service.short_thursday': 'Qui',
570
+ 'platform.filter_service.short_friday': 'Sex',
571
+ 'platform.filter_service.short_saturday': 'Sab',
572
+ 'platform.filter_service.yes': 'Sim',
573
+ 'platform.filter_service.no': 'Não',
574
+ 'platform.filter_service.search_empty_message': 'Nenhum resultado encontrado'
575
+ };
576
+
577
+ var URL_PREFIX = 'platform/filter_service';
578
+ var GET_FILTERS_URL = URL_PREFIX + "/queries/getFilters";
579
+ var SAVE_FILTERS_URL = URL_PREFIX + "/actions/saveUserFilters";
580
+ var SAVE_TICKED_FILTER_URL = URL_PREFIX + "/actions/setTicketFilters";
581
+ var GET_FILTERS_BY_TICKET = URL_PREFIX + "/queries/getFiltersByTicket";
582
+
583
+ var searchDisplayName = '$$__displayValue__';
584
+ var searchKeyName = '$$__keyValue__';
585
+
586
+ var AdvancedFilterService = /** @class */ (function () {
587
+ function AdvancedFilterService(http) {
588
+ var _this = this;
589
+ this.http = http;
590
+ this.filtersObservable = new rxjs.Subject();
591
+ this.contextsObservable = new rxjs.BehaviorSubject([]);
592
+ this.ticketFilterObservable = new rxjs.Subject();
593
+ this.destroy$ = new rxjs.Subject();
594
+ this.contextsObserver = this.contextsObservable.asObservable();
595
+ this.filtersObserver = this.filtersObservable.asObservable();
596
+ this.ticketFilterObserver = this.ticketFilterObservable.asObservable();
597
+ this.contextsObservable.subscribe(function (contexts) { return contexts.length && _this.getAndApplyFilters(contexts); });
598
+ }
599
+ AdvancedFilterService.prototype.saveTickedFilters = function (filters) {
600
+ var _this = this;
601
+ var requestBody = this.ticketFilter ? { filters: filters, ticketFilter: this.ticketFilter } : { filters: filters };
602
+ this.http
603
+ .post(SAVE_TICKED_FILTER_URL, requestBody)
604
+ .pipe(operators.map(function (response) { return response.ticket; }))
605
+ .subscribe(function (ticketFilter) {
606
+ _this.ticketFilter = ticketFilter;
607
+ _this.ticketFilterObservable.next({ ticketFilter: ticketFilter });
608
+ window.parent.postMessage({ message: 'advanced-filter:success', payload: ticketFilter }, window.location.origin);
609
+ }, function (err) {
610
+ _this.ticketFilterObservable.next({ error: true, message: err });
611
+ window.parent.postMessage({ message: 'advanced-filter:error', payload: err }, window.location.origin);
612
+ });
613
+ };
614
+ AdvancedFilterService.prototype.addContexts = function () {
615
+ var _this = this;
616
+ var contexts = [];
617
+ for (var _i = 0; _i < arguments.length; _i++) {
618
+ contexts[_i] = arguments[_i];
619
+ }
620
+ var currentContexts = this.contextsObservable.getValue();
621
+ this.contextsObservable.next(__spread(currentContexts, contexts));
622
+ return new rxjs.Observable(function () { return function () { return _this.removeContexts(contexts); }; });
623
+ };
624
+ AdvancedFilterService.prototype.removeContexts = function (contexts) {
625
+ var allContexts = this.contextsObservable.getValue();
626
+ var filteredContexts = allContexts.filter(function (context) { return contexts.indexOf(context) === -1; });
627
+ this.contextsObservable.next(filteredContexts);
628
+ };
629
+ AdvancedFilterService.prototype.saveFilters = function (filters) {
630
+ return this.http.post(SAVE_FILTERS_URL, { filters: filters });
631
+ };
632
+ AdvancedFilterService.prototype.searchFieldSuggestions = function (url, params, type) {
633
+ var headers = new http.HttpHeaders({ 'Content-Type': 'application/json; charset=utf-8' });
634
+ if (type === 'ENTITY') {
635
+ return this.http.get(url, { headers: headers });
636
+ }
637
+ return this.http.post(url, params, { headers: headers });
638
+ };
639
+ AdvancedFilterService.prototype.tryAgain = function (serviceContexts) {
640
+ this.getFilters(serviceContexts);
641
+ };
642
+ AdvancedFilterService.prototype.getAndApplyFilters = function (serviceContexts) {
643
+ this.getFilters(serviceContexts, true);
644
+ };
645
+ AdvancedFilterService.prototype.getFilters = function (serviceContexts, applyFilter) {
646
+ var _this = this;
647
+ if (applyFilter === void 0) { applyFilter = false; }
648
+ this.http
649
+ .post(GET_FILTERS_URL, { serviceContexts: serviceContexts })
650
+ .pipe(operators.map(function (response) { return _this.mapFilters(response.filters); }))
651
+ .subscribe(function (filters) { return _this.filtersObservable.next({ filters: filters, applyFilter: applyFilter }); }, //
652
+ function (//
653
+ err) { return _this.filtersObservable.next({ error: true, message: err }); });
654
+ };
655
+ AdvancedFilterService.prototype.mapFilters = function (filters) {
656
+ var _this = this;
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);
665
+ }
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('');
692
+ };
693
+ AdvancedFilterService.prototype.isMultiple = function (filter) {
694
+ var _a, _b, _c, _d;
695
+ return (filter.type === 'SEARCH' &&
696
+ filter.search &&
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)));
699
+ };
700
+ AdvancedFilterService.prototype.mapValues = function (value, keyFields, displayFields) {
701
+ var _this = this;
702
+ if (Array.isArray(value)) {
703
+ value.forEach(function (e) {
704
+ _this.mapValue(e, keyFields, displayFields);
705
+ });
706
+ }
707
+ else {
708
+ this.mapValue(value, keyFields, displayFields);
709
+ }
710
+ };
711
+ AdvancedFilterService.prototype.mapValue = function (value, keyFields, displayFields) {
712
+ if (!value) {
713
+ return;
714
+ }
715
+ var ids = [];
716
+ var displays = [];
717
+ keyFields.filter(function (e) { return value[e] !== undefined; }).forEach(function (e) { return ids.push(value[e]); });
718
+ displayFields.filter(function (e) { return value[e] !== undefined; }).forEach(function (e) { return displays.push(value[e]); });
719
+ if (ids.length > 0 && displays.length > 0) {
720
+ value[searchKeyName] = ids.join(', ');
721
+ value[searchDisplayName] = displays.join(', ');
722
+ }
723
+ else {
724
+ value = [''];
725
+ }
726
+ };
727
+ AdvancedFilterService.ctorParameters = function () { return [
728
+ { type: http.HttpClient }
729
+ ]; };
730
+ AdvancedFilterService = __decorate([
731
+ core.Injectable()
732
+ ], AdvancedFilterService);
733
+ return AdvancedFilterService;
734
+ }());
735
+
736
+ var Filter = /** @class */ (function () {
737
+ function Filter(type, required, label, domain, scope, name, contexts, services, value, enumItems, defaultValue, search, tabIndex, minValue, maxValue, dependsOn, mask, regExp) {
738
+ this.type = type;
739
+ this.required = required;
740
+ this.label = label;
741
+ this.domain = domain;
742
+ this.scope = scope;
743
+ this.name = name;
744
+ this.contexts = contexts;
745
+ this.services = services;
746
+ this.value = value;
747
+ this.enumItems = enumItems;
748
+ this.defaultValue = defaultValue;
749
+ this.search = search;
750
+ this.tabIndex = tabIndex;
751
+ this.minValue = minValue;
752
+ this.maxValue = maxValue;
753
+ this.dependsOn = dependsOn;
754
+ this.mask = mask;
755
+ this.regExp = regExp;
756
+ }
757
+ return Filter;
758
+ }());
759
+
760
+
761
+ (function (FilterType) {
762
+ FilterType["STRING"] = "STRING";
763
+ FilterType["BOOLEAN"] = "BOOLEAN";
764
+ FilterType["INTEGER"] = "INTEGER";
765
+ FilterType["DOUBLE"] = "DOUBLE";
766
+ FilterType["DATE"] = "DATE";
767
+ FilterType["DATETIME"] = "DATETIME";
768
+ FilterType["TIME"] = "TIME";
769
+ FilterType["MONEY"] = "MONEY";
770
+ FilterType["ENUMERATION"] = "ENUMERATION";
771
+ FilterType["SEARCH"] = "SEARCH";
772
+ })(exports.FilterType || (exports.FilterType = {}));
773
+
774
+
775
+ (function (Scope) {
776
+ Scope["DOMAIN"] = "DOMAIN";
777
+ Scope["SERVICE"] = "SERVICE";
778
+ })(exports.Scope || (exports.Scope = {}));
779
+
780
+ var FormFilter = /** @class */ (function () {
781
+ function FormFilter(_a) {
782
+ var value = _a.value, config = __rest(_a, ["value"]);
783
+ this._valueObserver = new rxjs.Subject();
784
+ this.valueChanges = this._valueObserver.asObservable();
785
+ this._value = value;
786
+ Object.assign(this, config);
787
+ }
788
+ Object.defineProperty(FormFilter.prototype, "value", {
789
+ get: function () {
790
+ return this._value;
791
+ },
792
+ set: function (value) {
793
+ this._value = value;
794
+ this._valueObserver.next(value);
795
+ },
796
+ enumerable: true,
797
+ configurable: true
798
+ });
799
+ return FormFilter;
800
+ }());
801
+
802
+ var TabView = /** @class */ (function () {
803
+ function TabView(config) {
804
+ this.fields = [];
805
+ this.form = new forms.FormGroup({});
806
+ Object.assign(this, config);
807
+ }
808
+ return TabView;
809
+ }());
810
+ var ContextTab = /** @class */ (function (_super) {
811
+ __extends(ContextTab, _super);
812
+ function ContextTab() {
813
+ var _this = _super !== null && _super.apply(this, arguments) || this;
814
+ _this.activeFilters = 0;
815
+ return _this;
816
+ }
817
+ Object.defineProperty(ContextTab.prototype, "label", {
818
+ get: function () {
819
+ return this.name + " (" + this.activeFilters + ")";
820
+ },
821
+ enumerable: true,
822
+ configurable: true
823
+ });
824
+ return ContextTab;
825
+ }(TabView));
826
+
827
+ var FILTER_ID_SEPARATOR = ':';
828
+ function getFilterId(domain, filterName) {
829
+ return "" + domain + FILTER_ID_SEPARATOR + filterName;
830
+ }
831
+ function getTabId(domain, contextId) {
832
+ return "" + domain + FILTER_ID_SEPARATOR + contextId;
833
+ }
834
+
835
+ var _a;
836
+ var moment = momentNs__default__default || momentNs__default;
837
+ var parsers = (_a = {},
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); },
841
+ _a);
842
+ function parseFilterValue(value, type) {
843
+ var parser = parsers[type];
844
+ if (value !== undefined && value !== null && value !== '') {
845
+ return parser ? parser(value) : value;
846
+ }
847
+ return value;
848
+ }
849
+ function dateParser(value, format) {
850
+ var date = moment(value);
851
+ return format ? date.format(format) : date.format();
852
+ }
853
+
854
+ function jsonPath(object, path) {
855
+ path = path.replace('$.', '');
856
+ var allPaths = path.split('.');
857
+ var currentPath = allPaths[0];
858
+ var value = object[currentPath];
859
+ allPaths.shift();
860
+ if (allPaths.length) {
861
+ return jsonPath(value, allPaths.join('.'));
862
+ }
863
+ return value;
864
+ }
865
+
866
+ var ɵ0 = function (attr, value) { return "containing(" + attr + ", '" + value + "')"; }, ɵ1 = function (attr, value) { return attr + " eq " + value; }, ɵ2 = function (attr, value) { return attr + " ne " + value; }, ɵ3 = function (attr, value) { return attr + " gt " + value; }, ɵ4 = function (attr, value) { return attr + " lt " + value; }, ɵ5 = function (attr, value) { return attr + " ge " + value; };
867
+ var filterOperators = {
868
+ 'contains': ɵ0,
869
+ '=': ɵ1,
870
+ '!=': ɵ2,
871
+ '>': ɵ3,
872
+ '<': ɵ4,
873
+ '>=': ɵ5
874
+ };
875
+
876
+ function toUserFormat(value, type) {
877
+ var parsedValue;
878
+ if (type !== exports.FilterType.SEARCH || !Array.isArray(value)) {
879
+ parsedValue = [(value === null || value === undefined) ? '' : value];
880
+ }
881
+ else if (Array.isArray(value)) {
882
+ if (value.length) {
883
+ parsedValue = value[0] === null ? [''] : value;
884
+ }
885
+ else {
886
+ parsedValue = [''];
887
+ }
888
+ }
889
+ else {
890
+ parsedValue = value ? value : [''];
891
+ }
892
+ return JSON.stringify(parsedValue);
893
+ }
894
+ function toFilterFormat(value, type) {
895
+ var parsedValue;
896
+ if (type !== exports.FilterType.SEARCH) {
897
+ parsedValue = [(value === null || value === undefined) ? '' : value];
898
+ }
899
+ else if (Array.isArray(value)) {
900
+ /*
901
+ Deve enviar para o backend o valor contido no keyValue em array.
902
+
903
+ Exemplo:
904
+ Quando tenho dois objetos selecionados [{1,'Base'},{2,'Other'}] deve enviar no padrão: [1,'Base'], [2,'Other']
905
+ */
906
+ parsedValue = [''];
907
+ if (value !== null && value.length > 0 && value[0] !== '') {
908
+ parsedValue = value.map(function (v) { return v[searchKeyName]; });
909
+ }
910
+ }
911
+ else {
912
+ parsedValue = [value === null ? '' : value[searchKeyName]];
913
+ }
914
+ return JSON.stringify(parsedValue);
915
+ }
916
+ function fromJson(value, type, isNotMultiple) {
917
+ var parsedValue = JSON.parse(value);
918
+ if (type !== exports.FilterType.SEARCH || isNotMultiple) {
919
+ return parsedValue[0];
920
+ }
921
+ return parsedValue;
922
+ }
923
+ function getSearchType(search) {
924
+ return search.basicSearch ? search.basicSearch : search.entitySearch;
925
+ }
926
+
927
+ var _a$1;
928
+ var moment$1 = momentNs__default__default || momentNs__default;
929
+ var parsers$1 = (_a$1 = {},
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'); },
933
+ _a$1);
934
+ function parseFormValue(value, type, search) {
935
+ var parser = parsers$1[type];
936
+ var parsedValue = JSON.parse(value);
937
+ var isNotMultiple = search && getSearchType(search).output.maxSelectedItems === 1;
938
+ var formValue;
939
+ if ((type === exports.FilterType.INTEGER || type === exports.FilterType.DOUBLE || type === exports.FilterType.MONEY) && parsedValue[0] === '') {
940
+ formValue = null;
941
+ }
942
+ else if (type !== exports.FilterType.SEARCH || isNotMultiple) {
943
+ formValue = parsedValue[0];
944
+ }
945
+ else {
946
+ formValue = parsedValue[0] ? parsedValue : [];
947
+ }
948
+ if (parser) {
949
+ return parser(formValue);
950
+ }
951
+ return formValue;
952
+ }
953
+ function createFormControl(_a) {
954
+ var minValue = _a.minValue, maxValue = _a.maxValue, regExp = _a.regExp, value = _a.value, type = _a.type, search = _a.search;
955
+ var validators = createValidators(minValue, maxValue, regExp);
956
+ var formValue = parseFormValue(value, type, search);
957
+ return new forms.FormControl(formValue, { validators: validators });
958
+ }
959
+ function createValidators(minValue, maxValue, regExp) {
960
+ var pattern = forms.Validators.pattern, min = forms.Validators.min, max = forms.Validators.max;
961
+ var validators = [];
962
+ regExp && validators.push(pattern(regExp));
963
+ minValue !== undefined && validators.push(min(minValue));
964
+ maxValue !== undefined && validators.push(max(maxValue));
965
+ return validators;
966
+ }
967
+ function dateParser$1(value, format) {
968
+ return value !== null && value !== '' ? moment$1(value, format).toDate() : '';
969
+ }
970
+
971
+ var supportedTypes = [
972
+ exports.FilterType.STRING,
973
+ exports.FilterType.BOOLEAN,
974
+ exports.FilterType.INTEGER,
975
+ exports.FilterType.ENUMERATION,
976
+ exports.FilterType.TIME,
977
+ exports.FilterType.MONEY,
978
+ exports.FilterType.DATETIME,
979
+ exports.FilterType.DATE,
980
+ exports.FilterType.DOUBLE
981
+ ];
982
+ var ɵ0$1 = function (value, otherValue) {
983
+ return value > otherValue;
984
+ }, ɵ1$1 = function (value, otherValue) {
985
+ return value < otherValue;
986
+ }, ɵ2$1 = function (value, otherValue) {
987
+ return value >= otherValue;
988
+ }, ɵ3$1 = function (value, otherValue) {
989
+ return value <= otherValue;
990
+ }, ɵ4$1 = function (value, otherValue) {
991
+ return ramda.contains(value, otherValue);
992
+ }, ɵ5$1 = function (value, otherValue) {
993
+ if (typeof otherValue === 'number') {
994
+ return ramda.equals(Number(value), otherValue);
995
+ }
996
+ return ramda.equals(value, otherValue);
997
+ }, ɵ6 = function (value, otherValue) {
998
+ if (typeof otherValue === 'number') {
999
+ return !ramda.equals(Number(value), otherValue);
1000
+ }
1001
+ return !ramda.equals(value, otherValue);
1002
+ };
1003
+ var operation = {
1004
+ '>': ɵ0$1,
1005
+ '<': ɵ1$1,
1006
+ '>=': ɵ2$1,
1007
+ '<=': ɵ3$1,
1008
+ 'contains': ɵ4$1,
1009
+ '=': ɵ5$1,
1010
+ '!=': ɵ6
1011
+ };
1012
+ function compare(operator, value, otherValue) {
1013
+ var comparator = operation[operator];
1014
+ return comparator(value, otherValue);
1015
+ }
1016
+ function isValidOperator(operator) {
1017
+ return !!operation[operator];
1018
+ }
1019
+ function isSupportedType(type) {
1020
+ return ramda.contains(type, supportedTypes);
1021
+ }
1022
+
1023
+ var AccessibilityUtils = /** @class */ (function () {
1024
+ function AccessibilityUtils(elementRef, renderer) {
1025
+ this.elementRef = elementRef;
1026
+ this.renderer = renderer;
1027
+ }
1028
+ AccessibilityUtils.prototype.init = function (customFixesCallback) {
1029
+ var _this = this;
1030
+ setTimeout(function () {
1031
+ _this.applyAllAccessibilityFixes(customFixesCallback);
1032
+ _this.setupMutationObserver(customFixesCallback);
1033
+ }, 100);
1034
+ };
1035
+ AccessibilityUtils.prototype.destroy = function () {
1036
+ if (this.observer) {
1037
+ this.observer.disconnect();
1038
+ }
1039
+ };
1040
+ AccessibilityUtils.prototype.setupMutationObserver = function (customFixesCallback) {
1041
+ var _this = this;
1042
+ this.observer = new MutationObserver(function (mutations) {
1043
+ var shouldReapplyFixes = false;
1044
+ mutations.forEach(function (mutation) {
1045
+ if (mutation.addedNodes.length > 0) {
1046
+ shouldReapplyFixes = true;
1047
+ }
1048
+ });
1049
+ if (shouldReapplyFixes) {
1050
+ setTimeout(function () { return _this.applyAllAccessibilityFixes(customFixesCallback); }, 100);
1051
+ }
1052
+ });
1053
+ this.observer.observe(this.elementRef.nativeElement, {
1054
+ childList: true,
1055
+ subtree: true
1056
+ });
1057
+ };
1058
+ AccessibilityUtils.prototype.applyAllAccessibilityFixes = function (customFixesCallback) {
1059
+ if (customFixesCallback) {
1060
+ customFixesCallback();
1061
+ }
1062
+ this.removeIncompatibleAriaAttributes();
1063
+ };
1064
+ AccessibilityUtils.prototype.removeIncompatibleAriaAttributes = function () {
1065
+ var _this = this;
1066
+ // Remove aria-selected from elements with role="button"
1067
+ var buttons = this.elementRef.nativeElement.querySelectorAll('[role="button"][aria-selected]');
1068
+ buttons.forEach(function (button) {
1069
+ _this.renderer.removeAttribute(button, 'aria-selected');
1070
+ });
1071
+ };
1072
+ return AccessibilityUtils;
1073
+ }());
1074
+
1075
+ var TRANSLATE_PREFIX = 'platform.filter_service';
1076
+ var CalendarOptionsService = /** @class */ (function () {
1077
+ function CalendarOptionsService(translate) {
1078
+ this.translate = translate;
1079
+ }
1080
+ CalendarOptionsService.prototype.getOptions = function () {
1081
+ return {
1082
+ clear: this.translate.instant(TRANSLATE_PREFIX + ".clear"),
1083
+ dateFormat: this.translate.instant(TRANSLATE_PREFIX + ".date_format"),
1084
+ dayNames: [
1085
+ this.translate.instant(TRANSLATE_PREFIX + ".name_sunday"),
1086
+ this.translate.instant(TRANSLATE_PREFIX + ".name_monday"),
1087
+ this.translate.instant(TRANSLATE_PREFIX + ".name_tuesday"),
1088
+ this.translate.instant(TRANSLATE_PREFIX + ".name_wednesday"),
1089
+ this.translate.instant(TRANSLATE_PREFIX + ".name_thursday"),
1090
+ this.translate.instant(TRANSLATE_PREFIX + ".name_friday"),
1091
+ this.translate.instant(TRANSLATE_PREFIX + ".name_saturday")
1092
+ ],
1093
+ dayNamesMin: [
1094
+ this.translate.instant(TRANSLATE_PREFIX + ".min_sunday"),
1095
+ this.translate.instant(TRANSLATE_PREFIX + ".min_monday"),
1096
+ this.translate.instant(TRANSLATE_PREFIX + ".min_tuesday"),
1097
+ this.translate.instant(TRANSLATE_PREFIX + ".min_wednesday"),
1098
+ this.translate.instant(TRANSLATE_PREFIX + ".min_thursday"),
1099
+ this.translate.instant(TRANSLATE_PREFIX + ".min_friday"),
1100
+ this.translate.instant(TRANSLATE_PREFIX + ".min_saturday")
1101
+ ],
1102
+ dayNamesShort: [
1103
+ this.translate.instant(TRANSLATE_PREFIX + ".short_sunday"),
1104
+ this.translate.instant(TRANSLATE_PREFIX + ".short_monday"),
1105
+ this.translate.instant(TRANSLATE_PREFIX + ".short_tuesday"),
1106
+ this.translate.instant(TRANSLATE_PREFIX + ".short_wednesday"),
1107
+ this.translate.instant(TRANSLATE_PREFIX + ".short_thursday"),
1108
+ this.translate.instant(TRANSLATE_PREFIX + ".short_friday"),
1109
+ this.translate.instant(TRANSLATE_PREFIX + ".short_saturday")
1110
+ ],
1111
+ firstDayOfWeek: 0,
1112
+ hourFormat: this.translate.instant(TRANSLATE_PREFIX + ".hour_format"),
1113
+ monthNames: [
1114
+ this.translate.instant(TRANSLATE_PREFIX + ".name_january"),
1115
+ this.translate.instant(TRANSLATE_PREFIX + ".name_february"),
1116
+ this.translate.instant(TRANSLATE_PREFIX + ".name_march"),
1117
+ this.translate.instant(TRANSLATE_PREFIX + ".name_april"),
1118
+ this.translate.instant(TRANSLATE_PREFIX + ".name_may"),
1119
+ this.translate.instant(TRANSLATE_PREFIX + ".name_june"),
1120
+ this.translate.instant(TRANSLATE_PREFIX + ".name_july"),
1121
+ this.translate.instant(TRANSLATE_PREFIX + ".name_august"),
1122
+ this.translate.instant(TRANSLATE_PREFIX + ".name_september"),
1123
+ this.translate.instant(TRANSLATE_PREFIX + ".name_october"),
1124
+ this.translate.instant(TRANSLATE_PREFIX + ".name_november"),
1125
+ this.translate.instant(TRANSLATE_PREFIX + ".name_december"),
1126
+ ],
1127
+ monthNamesShort: [
1128
+ this.translate.instant(TRANSLATE_PREFIX + ".short_january"),
1129
+ this.translate.instant(TRANSLATE_PREFIX + ".short_february"),
1130
+ this.translate.instant(TRANSLATE_PREFIX + ".short_march"),
1131
+ this.translate.instant(TRANSLATE_PREFIX + ".short_april"),
1132
+ this.translate.instant(TRANSLATE_PREFIX + ".short_may"),
1133
+ this.translate.instant(TRANSLATE_PREFIX + ".short_june"),
1134
+ this.translate.instant(TRANSLATE_PREFIX + ".short_july"),
1135
+ this.translate.instant(TRANSLATE_PREFIX + ".short_august"),
1136
+ this.translate.instant(TRANSLATE_PREFIX + ".short_september"),
1137
+ this.translate.instant(TRANSLATE_PREFIX + ".short_october"),
1138
+ this.translate.instant(TRANSLATE_PREFIX + ".short_november"),
1139
+ this.translate.instant(TRANSLATE_PREFIX + ".short_december"),
1140
+ ],
1141
+ today: this.translate.instant(TRANSLATE_PREFIX + ".today")
1142
+ };
1143
+ };
1144
+ CalendarOptionsService.ctorParameters = function () { return [
1145
+ { type: core$1.TranslateService }
1146
+ ]; };
1147
+ CalendarOptionsService = __decorate([
1148
+ core.Injectable()
1149
+ ], CalendarOptionsService);
1150
+ return CalendarOptionsService;
1151
+ }());
1152
+
1153
+ /**
1154
+ * Constantes para o componente FormFilter
1155
+ * Centraliza todos os valores mágicos para facilitar manutenção e reutilização
1156
+ */
1157
+ // Configurações de UI e Layout
1158
+ var UI_CONSTANTS = {
1159
+ /** Breakpoint em pixels para considerar dispositivo móvel */
1160
+ MOBILE_BREAKPOINT: 640,
1161
+ /** Tempo de vida padrão das mensagens toast em milissegundos */
1162
+ TOAST_LIFE_TIME: 5000,
1163
+ /** Tamanho padrão de grid para componentes AutocompleteField */
1164
+ DEFAULT_GRID_SIZE: 12,
1165
+ /** Nome padrão do modal de filtro avançado */
1166
+ ADVANCED_FILTER_MODAL_NAME: 'advanced-filter-1'
1167
+ };
1168
+ // Valores de controle e validação
1169
+ var VALIDATION_CONSTANTS = {
1170
+ /** Valor inicial para contadores */
1171
+ INITIAL_COUNT: 0,
1172
+ /** Indica que não há itens/elementos */
1173
+ NO_ITEMS: 0,
1174
+ /** Valor para indicar item único em seleção */
1175
+ SINGLE_ITEM: 1,
1176
+ /** Índice que indica item não encontrado em arrays */
1177
+ NOT_FOUND_INDEX: -1,
1178
+ /** Posição do índice para extrair mensagem de evento */
1179
+ MESSAGE_SPLIT_INDEX: 1,
1180
+ /** Índice do primeiro elemento em array */
1181
+ FIRST_ELEMENT_INDEX: 0
1182
+ };
1183
+ // Configurações de grid responsivo
1184
+ var GRID_CONFIG = {
1185
+ /** Configuração padrão de tamanhos de grid para AutocompleteField */
1186
+ DEFAULT_SIZE: {
1187
+ lg: UI_CONSTANTS.DEFAULT_GRID_SIZE,
1188
+ md: UI_CONSTANTS.DEFAULT_GRID_SIZE,
1189
+ xl: UI_CONSTANTS.DEFAULT_GRID_SIZE
1190
+ }
1191
+ };
1192
+ // Prefixos e identificadores
1193
+ var FILTER_CONSTANTS = {
1194
+ /** Prefixo para chaves de tradução do serviço de filtros */
1195
+ TRANSLATE_PREFIX: 'platform.filter_service'
1196
+ };
1197
+
1198
+ var TRANSLATE_PREFIX$1 = FILTER_CONSTANTS.TRANSLATE_PREFIX;
1199
+ var TOAST_LIFE = UI_CONSTANTS.TOAST_LIFE_TIME;
1200
+ var ARIA_LABEL = 'aria-label';
1201
+ var FormFilterComponent = /** @class */ (function () {
1202
+ function FormFilterComponent(filterService, translate, messageService, calendarOptionsService, changeDetectorRef, elementRef, renderer) {
1203
+ this.filterService = filterService;
1204
+ this.translate = translate;
1205
+ this.messageService = messageService;
1206
+ this.calendarOptionsService = calendarOptionsService;
1207
+ this.changeDetectorRef = changeDetectorRef;
1208
+ this.elementRef = elementRef;
1209
+ this.renderer = renderer;
1210
+ this.destroy$ = new rxjs.Subject();
1211
+ this.contexts = [];
1212
+ this.formFilters = {};
1213
+ this.oldFormFilters = {};
1214
+ this.actualFormFilters = [];
1215
+ this.general = new TabView({ name: 'Geral' });
1216
+ this.totalFiltersActive = VALIDATION_CONSTANTS.INITIAL_COUNT;
1217
+ this.isMobile = false;
1218
+ this.tabViewOrientation = 'left';
1219
+ this.error = false;
1220
+ this.errorMessages = {
1221
+ min: this.translate.instant(TRANSLATE_PREFIX$1 + ".error_min_value"),
1222
+ max: this.translate.instant(TRANSLATE_PREFIX$1 + ".error_max_value"),
1223
+ pattern: this.translate.instant(TRANSLATE_PREFIX$1 + ".invalid_pattern")
1224
+ };
1225
+ this.showMessages = true;
1226
+ this.isModal = false;
1227
+ this.contextId = '';
1228
+ this.totalFiltersActiveOutput = new core.EventEmitter();
1229
+ this.errorOutput = new core.EventEmitter();
1230
+ this.showDialogOutput = new core.EventEmitter();
1231
+ this.closeModalOutput = new core.EventEmitter();
1232
+ }
1233
+ FormFilterComponent.prototype.onResizeWindow = function (event) {
1234
+ var innerWidth = event.target.innerWidth;
1235
+ this.isMobile = innerWidth <= UI_CONSTANTS.MOBILE_BREAKPOINT;
1236
+ this.tabViewOrientation = this.isMobile ? 'top' : 'left';
1237
+ };
1238
+ FormFilterComponent.prototype.ngOnInit = function () {
1239
+ var _this = this;
1240
+ this.isMobile = innerWidth <= UI_CONSTANTS.MOBILE_BREAKPOINT;
1241
+ this.tabViewOrientation = this.isMobile ? 'top' : 'left';
1242
+ this.subscribeContextsObservable();
1243
+ this.subscribeFiltersObservable();
1244
+ window.addEventListener('message', function (event) {
1245
+ var _a;
1246
+ var _b;
1247
+ // Verificar origem da mensagem por segurança
1248
+ if (event.origin !== window.location.origin) {
1249
+ return;
1250
+ }
1251
+ var data = event.data;
1252
+ 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];
1253
+ if (message === 'addContext') {
1254
+ (_a = _this.filterService).addContexts.apply(_a, __spread(data.payload));
1255
+ }
1256
+ });
1257
+ };
1258
+ FormFilterComponent.prototype.ngAfterViewInit = function () {
1259
+ var _this = this;
1260
+ this.accessibilityUtils = new AccessibilityUtils(this.elementRef, this.renderer);
1261
+ this.accessibilityUtils.init(function () {
1262
+ _this.fixDropdownAccessibility();
1263
+ _this.fixTabAccessibility();
1264
+ });
1265
+ };
1266
+ FormFilterComponent.prototype.ngOnDestroy = function () {
1267
+ this.destroy$.next(true);
1268
+ if (this.accessibilityUtils) {
1269
+ this.accessibilityUtils.destroy();
1270
+ }
1271
+ };
1272
+ FormFilterComponent.prototype.hasChanges = function () {
1273
+ var _this = this;
1274
+ var keys = Object.keys(this.formFilters);
1275
+ var oldKeys = Object.keys(this.oldFormFilters);
1276
+ if (!oldKeys.length) {
1277
+ return true;
1278
+ }
1279
+ var filtered = keys.filter(function (key) {
1280
+ var _a;
1281
+ var currentValue = _this.formFilters[key].value;
1282
+ var oldValue = (_a = _this.oldFormFilters[key]) === null || _a === void 0 ? void 0 : _a.value;
1283
+ return !ramda.equals(currentValue, oldValue);
1284
+ });
1285
+ return filtered.length > 0;
1286
+ };
1287
+ FormFilterComponent.prototype.onApplyFilters = function () {
1288
+ this.hasChanges() && this.closeModalOutput.emit();
1289
+ };
1290
+ FormFilterComponent.prototype.getFilters = function () {
1291
+ this.hasChanges() && this.filterService.tryAgain(this.contexts);
1292
+ };
1293
+ FormFilterComponent.prototype.applyFilters = function (showToast) {
1294
+ if (showToast === void 0) { showToast = false; }
1295
+ if (this.hasChanges()) {
1296
+ this.showDialogOutput.emit(false);
1297
+ this.counterUpdate();
1298
+ var filters = this.getFiltersValues(this.formFilters);
1299
+ this.filterService.saveTickedFilters(filters);
1300
+ }
1301
+ else if (showToast) {
1302
+ var message = {
1303
+ key: 'filterServiceToastKey',
1304
+ severity: 'info',
1305
+ life: TOAST_LIFE,
1306
+ detail: this.translate.instant(TRANSLATE_PREFIX$1 + ".applied_filter_nochange", {
1307
+ activeFilters: this.totalFiltersActive
1308
+ })
1309
+ };
1310
+ this.sendMessage(message);
1311
+ }
1312
+ else {
1313
+ // No action needed
1314
+ }
1315
+ this.oldFormFilters = ramda.clone(this.formFilters);
1316
+ };
1317
+ FormFilterComponent.prototype.getDefaultValue = function (defaultValue, isMultiple) {
1318
+ if (defaultValue === undefined || (isMultiple && defaultValue[VALIDATION_CONSTANTS.FIRST_ELEMENT_INDEX] === '')) {
1319
+ return [];
1320
+ }
1321
+ return defaultValue;
1322
+ };
1323
+ FormFilterComponent.prototype.clearFilters = function () {
1324
+ var _this = this;
1325
+ var keys = Object.keys(this.formFilters);
1326
+ keys.forEach(function (key) { return _this.cleanFieldAndSetDefaultValue(key); });
1327
+ };
1328
+ FormFilterComponent.prototype.sendCloseMessage = function () {
1329
+ window.parent.postMessage({
1330
+ message: 'dashboard:close-modal',
1331
+ payload: {
1332
+ modalName: UI_CONSTANTS.ADVANCED_FILTER_MODAL_NAME
1333
+ }
1334
+ }, window.location.origin);
1335
+ };
1336
+ FormFilterComponent.prototype.sendMessage = function (message) {
1337
+ if (this.showMessages) {
1338
+ this.messageService.add(message);
1339
+ }
1340
+ else {
1341
+ window.parent.postMessage({
1342
+ message: 'dashboard:toastr',
1343
+ payload: {
1344
+ type: 'success',
1345
+ message: message.detail
1346
+ }
1347
+ }, window.location.origin);
1348
+ }
1349
+ };
1350
+ FormFilterComponent.prototype.saveFilters = function (forceSave) {
1351
+ var _this = this;
1352
+ if (forceSave === void 0) { forceSave = false; }
1353
+ var filters = this.parseToUserFilters(this.formFilters);
1354
+ var savedFilterSuccess = function () {
1355
+ if (!forceSave) {
1356
+ var message = {
1357
+ key: 'filterServiceToastKey',
1358
+ severity: 'info',
1359
+ life: TOAST_LIFE,
1360
+ detail: _this.translate.instant(TRANSLATE_PREFIX$1 + ".saved_filters_success", {
1361
+ activeFilters: _this.totalFiltersActive
1362
+ })
1363
+ };
1364
+ _this.sendMessage(message);
1365
+ }
1366
+ _this.counterUpdate();
1367
+ };
1368
+ var savedFiltersError = function () {
1369
+ var message = {
1370
+ key: 'filterServiceToastKey',
1371
+ severity: 'error',
1372
+ life: TOAST_LIFE,
1373
+ detail: _this.translate.instant(TRANSLATE_PREFIX$1 + ".saved_filters_error", {
1374
+ activeFilters: _this.totalFiltersActive
1375
+ })
1376
+ };
1377
+ _this.sendMessage(message);
1378
+ };
1379
+ this.filterService.saveFilters(filters).subscribe(savedFilterSuccess, savedFiltersError);
1380
+ };
1381
+ FormFilterComponent.prototype.saveFiltersWithCallbackFunction = function (callbackFunction) {
1382
+ var filters = this.parseToUserFilters(this.formFilters);
1383
+ this.filterService.saveFilters(filters).subscribe(callbackFunction);
1384
+ };
1385
+ FormFilterComponent.prototype.counterUpdate = function () {
1386
+ this.totalFiltersActive = this.countActiveFilters(this.tabs);
1387
+ this.totalFiltersActiveOutput.emit(this.totalFiltersActive);
1388
+ };
1389
+ FormFilterComponent.prototype.countActiveFilters = function (tabs) {
1390
+ var totalFiltersActive = VALIDATION_CONSTANTS.INITIAL_COUNT;
1391
+ tabs.forEach(function (tabView) {
1392
+ var value = tabView.form.value;
1393
+ tabView.activeFilters = Object.keys(value).reduce(function (appliedFilters, key) {
1394
+ var filterValue = value[key];
1395
+ var isArray = Array.isArray(filterValue);
1396
+ var isValidArray = isArray && filterValue.length > VALIDATION_CONSTANTS.NO_ITEMS;
1397
+ if (isValidArray || (!isArray && filterValue)) {
1398
+ appliedFilters++;
1399
+ }
1400
+ return appliedFilters;
1401
+ }, VALIDATION_CONSTANTS.INITIAL_COUNT);
1402
+ totalFiltersActive += tabView.activeFilters;
1403
+ });
1404
+ return totalFiltersActive;
1405
+ };
1406
+ FormFilterComponent.prototype.parseToUserFilters = function (filters) {
1407
+ var ids = Object.keys(filters);
1408
+ return ids.reduce(function (all, filterId) {
1409
+ var _a = filters[filterId], type = _a.type, services = _a.services, name = _a.name, value = _a.value, domain = _a.domain, contexts = _a.contexts;
1410
+ var filterValue = toUserFormat(value, type);
1411
+ var values = services.map(function (service) { return ({ name: name, service: service, domain: domain, contexts: contexts, value: filterValue }); });
1412
+ return __spread(all, values);
1413
+ }, []);
1414
+ };
1415
+ FormFilterComponent.prototype.getFiltersValues = function (filters) {
1416
+ var ids = Object.keys(filters);
1417
+ return ids.reduce(function (all, filterId) {
1418
+ var _a = filters[filterId], type = _a.type, services = _a.services, name = _a.name, value = _a.value, domain = _a.domain;
1419
+ var filterValue = toFilterFormat(value, type);
1420
+ var values = services.map(function (service) { return ({ name: name, service: service, domain: domain, value: filterValue }); });
1421
+ return __spread(all, values);
1422
+ }, []);
1423
+ };
1424
+ FormFilterComponent.prototype.subscribeContextsObservable = function () {
1425
+ var _this = this;
1426
+ var contextsObserver = this.filterService.contextsObserver;
1427
+ contextsObserver.pipe(operators.takeUntil(this.destroy$)).subscribe(function (contexts) { return (_this.contexts = contexts); });
1428
+ };
1429
+ FormFilterComponent.prototype.errorStateAction = function () {
1430
+ this.filterService.tryAgain(this.contexts);
1431
+ };
1432
+ FormFilterComponent.prototype.subscribeFiltersObservable = function () {
1433
+ var _this = this;
1434
+ var filtersObserver = this.filterService.filtersObserver;
1435
+ filtersObserver.pipe(operators.takeUntil(this.destroy$)).subscribe(function (_a) {
1436
+ var filters = _a.filters, applyFilter = _a.applyFilter, error = _a.error, message = _a.message;
1437
+ _this.errorOutput.emit(error);
1438
+ _this.error = error;
1439
+ _this.errorState = message;
1440
+ if (!error) {
1441
+ _this.createForm(filters, applyFilter);
1442
+ }
1443
+ });
1444
+ };
1445
+ FormFilterComponent.prototype.createForm = function (filters, applyFilter) {
1446
+ this.tabs = this.createTabs(filters);
1447
+ this.counterUpdate();
1448
+ this.setDependencies(this.formFilters);
1449
+ this.createChildArray();
1450
+ if (filters.length > VALIDATION_CONSTANTS.NO_ITEMS && applyFilter) {
1451
+ this.applyFilters();
1452
+ }
1453
+ };
1454
+ FormFilterComponent.prototype.setDependencies = function (filters) {
1455
+ var _this = this;
1456
+ var names = Object.keys(filters);
1457
+ var dependencies = rxjs.from(names).pipe(operators.map(function (key) { return filters[key]; }), operators.filter(function (_a) {
1458
+ var dependsOn = _a.dependsOn;
1459
+ return dependsOn && dependsOn.length > VALIDATION_CONSTANTS.NO_ITEMS;
1460
+ }), operators.tap(function (_a) {
1461
+ var dependsOn = _a.dependsOn, domain = _a.domain, filterControl = _a.filterControl;
1462
+ var invalidFilters = dependsOn
1463
+ .filter(function (dep) { return dep.required; })
1464
+ .filter(function (dep) {
1465
+ var id = getFilterId(domain, dep.filterName);
1466
+ var formFilter = filters[id];
1467
+ var value = formFilter.value, type = formFilter.type;
1468
+ var comparator = dep.comparator;
1469
+ if (comparator && isValidOperator(comparator.operator) && isSupportedType(type)) {
1470
+ var fieldValue = parseFilterValue(value, type);
1471
+ return !compare(comparator.operator, comparator.value, fieldValue);
1472
+ }
1473
+ return dep.required ? !formFilter.value : formFilter.value;
1474
+ });
1475
+ if (invalidFilters.length > VALIDATION_CONSTANTS.NO_ITEMS) {
1476
+ filterControl.disable();
1477
+ }
1478
+ }), operators.map(function (_a) {
1479
+ var domain = _a.domain, dependsOn = _a.dependsOn, filterControl = _a.filterControl;
1480
+ return ({ domain: domain, dependsOn: dependsOn, filterControl: filterControl });
1481
+ }));
1482
+ dependencies.subscribe(function (_a) {
1483
+ var dependsOn = _a.dependsOn, domain = _a.domain, filterControl = _a.filterControl;
1484
+ return rxjs.from(dependsOn)
1485
+ .pipe(operators.filter(function (dep) { return dep.required; }), operators.map(function (_a) {
1486
+ var filterName = _a.filterName;
1487
+ return getFilterId(domain, filterName);
1488
+ }), operators.map(function (filterId) { return filters[filterId]; }), operators.mergeMap(function (formFilter) { return rxjs.from(formFilter.valueChanges); }), operators.map(function (val) {
1489
+ var comparation = dependsOn.every(function (dep) {
1490
+ var filterId = getFilterId(domain, dep.filterName);
1491
+ if (!_this.formFilters[filterId]) {
1492
+ return false;
1493
+ }
1494
+ var type = _this.formFilters[filterId].type;
1495
+ var comparator = dep.comparator;
1496
+ if (comparator && isValidOperator(comparator.operator) && isSupportedType(type)) {
1497
+ var value = parseFilterValue(val, type);
1498
+ return compare(comparator.operator, comparator.value, value);
1499
+ }
1500
+ return true;
1501
+ });
1502
+ return !_this.isEmpty(val) && comparation ? 'enable' : 'disable';
1503
+ }))
1504
+ .subscribe(function (status) { return filterControl[status](); });
1505
+ });
1506
+ };
1507
+ FormFilterComponent.prototype.addGeneralField = function (filter) {
1508
+ var _this = this;
1509
+ var name = filter.name, domain = filter.domain, type = filter.type;
1510
+ var controlName = getFilterId(domain, name);
1511
+ var fieldControl = createFormControl(filter);
1512
+ fieldControl.valueChanges
1513
+ .pipe(operators.takeUntil(this.destroy$), operators.map(function (v) { return parseFilterValue(v, type); }), operators.tap(function (value) { return (_this.formFilters[controlName].value = value); }))
1514
+ .subscribe(function (val) {
1515
+ return _this.tabs.forEach(function (tab) {
1516
+ var control = tab.form.controls[name];
1517
+ if (control && tab.domain === domain) {
1518
+ control.setValue(val, { emitEvent: false });
1519
+ }
1520
+ });
1521
+ });
1522
+ var newFilter = __assign(__assign({}, filter), { name: controlName });
1523
+ var newField = this.createField(newFilter);
1524
+ this.general.form.addControl(controlName, fieldControl);
1525
+ this.general.fields.push(newField);
1526
+ };
1527
+ /*
1528
+ * Verifica os contextos de cada filtro, caso todos os contextos foram informados:
1529
+ * @return true
1530
+ * Caso não tenha nenhum contexto, considera-se por padrão que é todos:
1531
+ * @return true
1532
+ */
1533
+ FormFilterComponent.prototype.containsAllContexts = function (myContexts) {
1534
+ if (!myContexts.length) {
1535
+ return true;
1536
+ }
1537
+ var allContexts = this.contexts.map(function (data) { return data.contextId; });
1538
+ var sortedMyContexts = __spread(myContexts).sort(function (a, b) { return a.localeCompare(b); });
1539
+ var sortedAllContexts = __spread(allContexts).sort(function (a, b) { return a.localeCompare(b); });
1540
+ return ramda.equals(sortedMyContexts, sortedAllContexts);
1541
+ };
1542
+ /**
1543
+ * Cria as tabs de contexto a partir dos filtros fornecidos.
1544
+ * Este método orquestra a criação de FormFilters e distribui os campos entre as tabs.
1545
+ */
1546
+ FormFilterComponent.prototype.createTabs = function (filters) {
1547
+ var _this = this;
1548
+ return filters.reduce(function (tabs, filter) {
1549
+ var domain = filter.domain, name = filter.name, scope = filter.scope, contexts = filter.contexts;
1550
+ var field = _this.createField(filter);
1551
+ var filterId = getFilterId(domain, name);
1552
+ // Cria e registra o FormFilter
1553
+ _this.createAndRegisterFormFilter(filter, filterId);
1554
+ var formFilter = _this.formFilters[filterId];
1555
+ // Adiciona ao tab geral se for de escopo DOMAIN e aplicável a todos os contextos
1556
+ if (scope === exports.Scope.DOMAIN && _this.containsAllContexts(contexts)) {
1557
+ _this.addGeneralField(filter);
1558
+ }
1559
+ // Processa cada contexto do filtro
1560
+ _this.processFilterContexts(filter, field, formFilter, tabs);
1561
+ return tabs;
1562
+ }, new Map());
1563
+ };
1564
+ /**
1565
+ * Cria a configuração e instância do FormFilter, registrando-o no mapa de filtros.
1566
+ */
1567
+ FormFilterComponent.prototype.createAndRegisterFormFilter = function (filter, filterId) {
1568
+ 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;
1569
+ var isNotMultiple = search && getSearchType(search).output.maxSelectedItems === VALIDATION_CONSTANTS.SINGLE_ITEM;
1570
+ var filterConfig = {
1571
+ domain: domain,
1572
+ contexts: contexts,
1573
+ services: services,
1574
+ name: name,
1575
+ dependsOn: dependsOn,
1576
+ type: type,
1577
+ value: fromJson(value, type, isNotMultiple),
1578
+ isMultiple: !isNotMultiple,
1579
+ defaultValue: fromJson(defaultValue, type, isNotMultiple)
1580
+ };
1581
+ this.formFilters[filterId] = new FormFilter(filterConfig);
1582
+ };
1583
+ /**
1584
+ * Processa os contextos de um filtro, criando ou atualizando as tabs correspondentes.
1585
+ */
1586
+ FormFilterComponent.prototype.processFilterContexts = function (filter, field, formFilter, tabs) {
1587
+ var _this = this;
1588
+ var domain = filter.domain, name = filter.name, type = filter.type, contexts = filter.contexts;
1589
+ contexts.forEach(function (contextId) {
1590
+ if (_this.shouldProcessContext(contextId)) {
1591
+ var tabId = getTabId(domain, contextId);
1592
+ // Garante que a tab existe
1593
+ _this.ensureTabExists(tabs, tabId, domain, contextId);
1594
+ // Cria e configura o controle do campo
1595
+ var fieldControl = _this.createAndConfigureFieldControl(filter, tabId, name, domain, type);
1596
+ // Adiciona o campo à tab
1597
+ _this.addFieldToTab(tabs.get(tabId), field, filter.name, fieldControl);
1598
+ // Define o controle principal do FormFilter (primeira ocorrência)
1599
+ if (!formFilter.filterControl) {
1600
+ formFilter.filterControl = fieldControl;
1601
+ }
1602
+ }
1603
+ });
1604
+ };
1605
+ /**
1606
+ * Verifica se um contexto deve ser processado com base no contextId atual.
1607
+ */
1608
+ FormFilterComponent.prototype.shouldProcessContext = function (contextId) {
1609
+ return contextId === this.contextId || this.contextId === '';
1610
+ };
1611
+ /**
1612
+ * Garante que uma tab existe no mapa, criando-a se necessário.
1613
+ */
1614
+ FormFilterComponent.prototype.ensureTabExists = function (tabs, tabId, domain, contextId) {
1615
+ var _a;
1616
+ if (!tabs.has(tabId)) {
1617
+ var contextData = this.contexts.find(function (context) { return context.contextId === contextId; });
1618
+ var tab = new ContextTab({
1619
+ domain: domain,
1620
+ name: (_a = contextData === null || contextData === void 0 ? void 0 : contextData.contextLabel) !== null && _a !== void 0 ? _a : contextId
1621
+ });
1622
+ tabs.set(tabId, tab);
1623
+ }
1624
+ };
1625
+ /**
1626
+ * Cria um FormControl para o campo e configura o observable de mudanças de valor.
1627
+ */
1628
+ FormFilterComponent.prototype.createAndConfigureFieldControl = function (filter, tabId, filterName, domain, type) {
1629
+ var _this = this;
1630
+ var fieldControl = createFormControl(filter);
1631
+ fieldControl.valueChanges
1632
+ .pipe(operators.takeUntil(this.destroy$))
1633
+ .subscribe(function (val) { return _this.updateFilterValue(tabId, filterName, val, domain, type); });
1634
+ return fieldControl;
1635
+ };
1636
+ /**
1637
+ * Adiciona um campo ao formulário de uma tab específica.
1638
+ */
1639
+ FormFilterComponent.prototype.addFieldToTab = function (contextTab, field, filterName, fieldControl) {
1640
+ contextTab.fields.push(field);
1641
+ contextTab.form.addControl(filterName, fieldControl);
1642
+ };
1643
+ FormFilterComponent.prototype.updateFilterValue = function (tabId, filterName, value, domain, type) {
1644
+ var _this = this;
1645
+ var controlOpts = { emitEvent: false };
1646
+ var fieldValue = parseFilterValue(value, type);
1647
+ var filterId = getFilterId(domain, filterName);
1648
+ var generalFieldControl = this.general.form.controls[filterId];
1649
+ this.tabs.forEach(function (_a, key) {
1650
+ var form = _a.form;
1651
+ var control = form.controls[filterName];
1652
+ if (tabId !== key && control) {
1653
+ control.setValue(value, controlOpts);
1654
+ }
1655
+ });
1656
+ var childs = this.formFilters[filterId].childs;
1657
+ childs === null || childs === void 0 ? void 0 : childs.forEach(function (child) { return _this.cleanFieldAndSetDefaultValue(child.filter.key); });
1658
+ generalFieldControl === null || generalFieldControl === void 0 ? void 0 : generalFieldControl.setValue(value, controlOpts);
1659
+ this.formFilters[filterId].value = fieldValue;
1660
+ };
1661
+ FormFilterComponent.prototype.cleanFieldAndSetDefaultValue = function (key) {
1662
+ var _a = this.formFilters[key], isMultiple = _a.isMultiple, defaultValue = _a.defaultValue, filterControl = _a.filterControl, type = _a.type;
1663
+ var finalValue = this.getDefaultValue(defaultValue, isMultiple);
1664
+ if (filterControl) {
1665
+ if (type === 'DATE' || (type === 'SEARCH' && isMultiple)) {
1666
+ filterControl.setValue(finalValue);
1667
+ }
1668
+ if (type === 'INTEGER' || type === 'DOUBLE' || type === 'MONEY') {
1669
+ finalValue === '' ? filterControl.setValue(null) : filterControl.setValue(finalValue);
1670
+ }
1671
+ else {
1672
+ filterControl.setValue(finalValue, { onlySelf: true });
1673
+ }
1674
+ }
1675
+ };
1676
+ FormFilterComponent.prototype.createChildArray = function () {
1677
+ var _this = this;
1678
+ var keys = Object.keys(this.formFilters);
1679
+ keys.forEach(function (key) {
1680
+ var _a = _this.formFilters[key], dependsOn = _a.dependsOn, domain = _a.domain;
1681
+ dependsOn.forEach(function (field) {
1682
+ var filterId = getFilterId(domain, field.filterName);
1683
+ if (_this.formFilters[filterId]) {
1684
+ if (!_this.formFilters[filterId].childs) {
1685
+ _this.formFilters[filterId].childs = [];
1686
+ }
1687
+ _this.formFilters[filterId].childs.push({ filter: { key: key, required: field.required } });
1688
+ }
1689
+ });
1690
+ });
1691
+ };
1692
+ FormFilterComponent.prototype.createField = function (filter) {
1693
+ var _a;
1694
+ var _this = this;
1695
+ var name = filter.name, label = filter.label, enumItems = filter.enumItems, type = filter.type, mask = filter.mask;
1696
+ var translatedEnumItems = enumItems === null || enumItems === void 0 ? void 0 : enumItems.map(function (item) { return ({
1697
+ label: _this.translate.instant(item.label),
1698
+ value: item.value
1699
+ }); });
1700
+ var field = {
1701
+ name: name,
1702
+ label: this.translate.instant(label),
1703
+ placeholder: '',
1704
+ ariaLabel: this.translate.instant(label)
1705
+ };
1706
+ var creators = (_a = {},
1707
+ _a[exports.FilterType.STRING] = function () { return new angularComponents.TextField(__assign(__assign({}, field), { mask: mask ? function () { return mask; } : null, type: angularComponents.FieldType.String })); },
1708
+ _a[exports.FilterType.MONEY] = function () { return new angularComponents.BignumberField(__assign(__assign({}, field), { type: angularComponents.FieldType.Money })); },
1709
+ _a[exports.FilterType.BOOLEAN] = function () { return _this.createRadioButton(__assign({}, field)); },
1710
+ _a[exports.FilterType.DATE] = function () { return _this.createCalendar(__assign(__assign({}, field), { type: angularComponents.FieldType.Date })); },
1711
+ _a[exports.FilterType.DATETIME] = function () { return _this.createCalendar(__assign(__assign({}, field), { type: angularComponents.FieldType.DateTime })); },
1712
+ _a[exports.FilterType.TIME] = function () { return _this.createCalendar(__assign(__assign({}, field), { type: angularComponents.FieldType.Time })); },
1713
+ _a[exports.FilterType.ENUMERATION] = function () {
1714
+ return new angularComponents.SelectField(__assign(__assign({}, field), { placeholder: _this.translate.instant('platform.filter_service.select'), options: __spread(translatedEnumItems), type: angularComponents.FieldType.Enum }));
1715
+ },
1716
+ _a[exports.FilterType.INTEGER] = function () {
1717
+ return new angularComponents.BignumberField(__assign(__assign({}, field), { numberLocaleOptions: _this.optionsInteger(), mask: mask ? function () { return mask; } : null, type: angularComponents.FieldType.Integer }));
1718
+ },
1719
+ _a[exports.FilterType.DOUBLE] = function () { return new angularComponents.BignumberField(__assign(__assign({}, field), { type: angularComponents.FieldType.Double })); },
1720
+ _a[exports.FilterType.SEARCH] = function () { return _this.createAutocompleteField(field, filter); },
1721
+ _a);
1722
+ return creators[type]();
1723
+ };
1724
+ FormFilterComponent.prototype.createRadioButton = function (field) {
1725
+ var options = [
1726
+ { label: this.translate.instant(TRANSLATE_PREFIX$1 + ".yes"), value: true },
1727
+ { label: this.translate.instant(TRANSLATE_PREFIX$1 + ".no"), value: false }
1728
+ ];
1729
+ return new angularComponents.RadioButtonField(__assign(__assign({}, field), { type: angularComponents.FieldType.Radio, options: options }));
1730
+ };
1731
+ FormFilterComponent.prototype.createCalendar = function (config) {
1732
+ var calendar = new angularComponents.CalendarField(config);
1733
+ calendar.calendarLocaleOptions = this.calendarOptionsService.getOptions();
1734
+ if (!this.isModal) {
1735
+ calendar.appendTo = 'body';
1736
+ }
1737
+ return calendar;
1738
+ };
1739
+ FormFilterComponent.prototype.createAutocompleteField = function (field, _a) {
1740
+ var _this = this;
1741
+ var dependsOn = _a.dependsOn, search = _a.search, domain = _a.domain, name = _a.name;
1742
+ var suggestionsObservable = new rxjs.BehaviorSubject([]);
1743
+ var queryParam = getSearchType(search).input.queryParam;
1744
+ var _b = getSearchType(search).output, displayFields = _b.displayFields, keyFields = _b.keyFields, resultDataJsonPath = _b.resultDataJsonPath, displayFieldConcatToken = _b.displayFieldConcatToken, maxSelectedItems = _b.maxSelectedItems;
1745
+ var filterId = getFilterId(domain, name);
1746
+ var suggestionsError = function (messageError) {
1747
+ var messageDetail = messageError !== null && messageError !== void 0 ? messageError : _this.translate.instant(TRANSLATE_PREFIX$1 + ".find_suggestions_error", {
1748
+ activeFilters: _this.totalFiltersActive
1749
+ });
1750
+ var message = {
1751
+ key: 'filterServiceToastKey',
1752
+ severity: 'error',
1753
+ life: TOAST_LIFE,
1754
+ detail: messageDetail
1755
+ };
1756
+ _this.sendMessage(message);
1757
+ };
1758
+ var onSearch = function (val) {
1759
+ var _a;
1760
+ var params = (_a = {}, _a[queryParam] = val, _a);
1761
+ dependsOn && Object.assign(params, _this.getDependenciesValues(dependsOn, domain));
1762
+ var searchUrl = (search === null || search === void 0 ? void 0 : search.type) === 'ENTITY'
1763
+ ? _this.getEntitySearchUrl(search.entitySearch.input, val, dependsOn)
1764
+ : getSearchType(search).input.url;
1765
+ _this.filterService
1766
+ .searchFieldSuggestions(searchUrl, params, search.type)
1767
+ .pipe(operators.map(function (response) { return jsonPath(response, resultDataJsonPath); }), operators.map(function (suggestions) {
1768
+ return _this.addSuggestionFields(suggestions, displayFields, keyFields, displayFieldConcatToken, filterId);
1769
+ }))
1770
+ .subscribe(function (result) {
1771
+ suggestionsObservable.next(result);
1772
+ _this.changeDetectorRef.detectChanges();
1773
+ }, function (error) {
1774
+ var _a;
1775
+ var messageError = null;
1776
+ if ((_a = error === null || error === void 0 ? void 0 : error.error) === null || _a === void 0 ? void 0 : _a.message) {
1777
+ messageError = error.error.message;
1778
+ }
1779
+ suggestionsError(messageError);
1780
+ });
1781
+ };
1782
+ 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") }));
1783
+ };
1784
+ FormFilterComponent.prototype.getEntitySearchUrl = function (search, value, dependsOn) {
1785
+ var _this = this;
1786
+ var attributes = search.attributes, domainName = search.domainName, entityName = search.entityName, serviceName = search.serviceName;
1787
+ var url = domainName + "/" + serviceName + "/entities/" + entityName + "/?filter=";
1788
+ var filters = attributes.map(function (attr) { return filterOperators[attr.comparator](attr.name, value); });
1789
+ dependsOn === null || dependsOn === void 0 ? void 0 : dependsOn.forEach(function (obj) {
1790
+ var filterId = getFilterId(domainName, obj.filterName);
1791
+ var fieldValue = _this.formFilters[filterId].value[searchKeyName];
1792
+ filters.push(obj.entityAttribute + " eq '" + fieldValue + "'");
1793
+ });
1794
+ return url.concat(this.joinFiltersWithOperator(filters, search.operator));
1795
+ };
1796
+ /**
1797
+ * Joins filter strings with the specified operator, avoiding commas inside parentheses.
1798
+ * This method is safe from ReDoS attacks by using a character-by-character scan
1799
+ * instead of complex regex patterns.
1800
+ */
1801
+ FormFilterComponent.prototype.joinFiltersWithOperator = function (filters, operator) {
1802
+ var e_1, _a;
1803
+ var joined = filters.join(',');
1804
+ var result = [];
1805
+ var depth = 0;
1806
+ var currentSegment = '';
1807
+ try {
1808
+ for (var joined_1 = __values(joined), joined_1_1 = joined_1.next(); !joined_1_1.done; joined_1_1 = joined_1.next()) {
1809
+ var char = joined_1_1.value;
1810
+ if (char === '(') {
1811
+ depth++;
1812
+ currentSegment += char;
1813
+ }
1814
+ else if (char === ')') {
1815
+ depth--;
1816
+ currentSegment += char;
1817
+ }
1818
+ else if (char === ',' && depth === 0) {
1819
+ if (currentSegment) {
1820
+ result.push(currentSegment);
1821
+ currentSegment = '';
1822
+ }
1823
+ }
1824
+ else {
1825
+ currentSegment += char;
1826
+ }
1827
+ }
1828
+ }
1829
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1830
+ finally {
1831
+ try {
1832
+ if (joined_1_1 && !joined_1_1.done && (_a = joined_1.return)) _a.call(joined_1);
1833
+ }
1834
+ finally { if (e_1) throw e_1.error; }
1835
+ }
1836
+ if (currentSegment) {
1837
+ result.push(currentSegment);
1838
+ }
1839
+ return result.join(" " + operator + " ");
1840
+ };
1841
+ FormFilterComponent.prototype.addSuggestionFields = function (suggestions, displayFields, keyFields, separator, filterId) {
1842
+ var _this = this;
1843
+ var addValue = function (acc, value, token) { return (acc ? "" + acc + token + value : value); };
1844
+ var result = suggestions.map(function (suggestion) {
1845
+ var _a;
1846
+ return (__assign(__assign({}, suggestion), (_a = {}, _a[searchDisplayName] = displayFields.reduce(function (value, display) {
1847
+ return addValue(value, _this.translate.instant(suggestion[display]), separator);
1848
+ }, ''), _a[searchKeyName] = keyFields.reduce(function (value, key) {
1849
+ return addValue(value, suggestion[key], ', ');
1850
+ }, ''), _a)));
1851
+ });
1852
+ this.formFilters[filterId].invalidValue = result.length === VALIDATION_CONSTANTS.NO_ITEMS;
1853
+ return result.filter(function (item) {
1854
+ var value = _this.formFilters[filterId].value;
1855
+ if (Array.isArray(value)) {
1856
+ var index = value.findIndex(function (i) { return i.$$__keyValue__ === item.$$__keyValue__; });
1857
+ return index === VALIDATION_CONSTANTS.NOT_FOUND_INDEX;
1858
+ }
1859
+ return true;
1860
+ });
1861
+ };
1862
+ FormFilterComponent.prototype.getDependenciesValues = function (dependencies, domain) {
1863
+ var _this = this;
1864
+ return dependencies.reduce(function (params, _a) {
1865
+ var filterName = _a.filterName;
1866
+ var filterId = getFilterId(domain, filterName);
1867
+ if (!_this.formFilters[filterId]) {
1868
+ return params;
1869
+ }
1870
+ var _b = _this.formFilters[filterId], value = _b.value, type = _b.type;
1871
+ if (type === 'ENUMERATION') {
1872
+ params[filterName] = value;
1873
+ }
1874
+ else if (Array.isArray(value)) {
1875
+ params[filterName] = value.map(function (arr) { return arr[searchKeyName]; });
1876
+ }
1877
+ else {
1878
+ params[filterName] = value ? value[searchKeyName] : [''];
1879
+ }
1880
+ if (_this.isEmpty(params[filterName])) {
1881
+ delete params[filterName];
1882
+ }
1883
+ return params;
1884
+ }, {});
1885
+ };
1886
+ /*
1887
+ * Verifica se o valor informado é falso, em arrays, é verificado cada item
1888
+ */
1889
+ FormFilterComponent.prototype.isEmpty = function (value) {
1890
+ return Array.isArray(value) ? value.every(function (data) { return !data; }) : !value;
1891
+ };
1892
+ /**
1893
+ * Return format to specify for integer type field
1894
+ */
1895
+ FormFilterComponent.prototype.optionsInteger = function () {
1896
+ return { currencySymbol: '', decimalSeparator: '', thousandsSeparator: '' };
1897
+ };
1898
+ FormFilterComponent.prototype.fixDropdownAccessibility = function () {
1899
+ var _this = this;
1900
+ var dropdowns = this.elementRef.nativeElement.querySelectorAll('p-dropdown');
1901
+ dropdowns.forEach(function (dropdown) {
1902
+ var input = dropdown.querySelector('div[role="button"], input, .ui-dropdown-label-container');
1903
+ if (input) {
1904
+ var aria = dropdown.getAttribute('placeholder') || dropdown.getAttribute(ARIA_LABEL);
1905
+ if (!input.hasAttribute(ARIA_LABEL)) {
1906
+ _this.renderer.setAttribute(input, ARIA_LABEL, aria);
1907
+ }
1908
+ _this.renderer.setAttribute(input, 'aria-expanded', 'false');
1909
+ }
1910
+ });
1911
+ };
1912
+ FormFilterComponent.prototype.fixTabAccessibility = function () {
1913
+ var _this = this;
1914
+ var tabLists = this.elementRef.nativeElement.querySelectorAll('ul[role="tablist"], .ui-tabview-nav');
1915
+ tabLists.forEach(function (tabList) {
1916
+ _this.renderer.setAttribute(tabList, 'role', 'tablist');
1917
+ var tabs = tabList.querySelectorAll('li');
1918
+ tabs.forEach(function (tab) {
1919
+ _this.renderer.setAttribute(tab, 'role', 'presentation');
1920
+ var anchor = tab.querySelector('a');
1921
+ if (anchor) {
1922
+ _this.renderer.setAttribute(anchor, 'role', 'tab');
1923
+ // Ensure only the selected tab is focusable if needed, or manage tabindex
1924
+ // PrimeNG usually handles tabindex, but we ensure role is correct
1925
+ }
1926
+ });
1927
+ });
1928
+ };
1929
+ FormFilterComponent.ctorParameters = function () { return [
1930
+ { type: AdvancedFilterService },
1931
+ { type: core$1.TranslateService },
1932
+ { type: api.MessageService },
1933
+ { type: CalendarOptionsService },
1934
+ { type: core.ChangeDetectorRef },
1935
+ { type: core.ElementRef },
1936
+ { type: core.Renderer2 }
1937
+ ]; };
1938
+ __decorate([
1939
+ core.Input()
1940
+ ], FormFilterComponent.prototype, "showMessages", void 0);
1941
+ __decorate([
1942
+ core.Input()
1943
+ ], FormFilterComponent.prototype, "isModal", void 0);
1944
+ __decorate([
1945
+ core.Input()
1946
+ ], FormFilterComponent.prototype, "contextId", void 0);
1947
+ __decorate([
1948
+ core.Output()
1949
+ ], FormFilterComponent.prototype, "totalFiltersActiveOutput", void 0);
1950
+ __decorate([
1951
+ core.Output()
1952
+ ], FormFilterComponent.prototype, "errorOutput", void 0);
1953
+ __decorate([
1954
+ core.Output()
1955
+ ], FormFilterComponent.prototype, "showDialogOutput", void 0);
1956
+ __decorate([
1957
+ core.Output()
1958
+ ], FormFilterComponent.prototype, "closeModalOutput", void 0);
1959
+ __decorate([
1960
+ core.HostListener('window:resize', ['$event'])
1961
+ ], FormFilterComponent.prototype, "onResizeWindow", null);
1962
+ FormFilterComponent = __decorate([
1963
+ core.Component({
1964
+ selector: 's-app-form-filter',
1965
+ 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",
1966
+ 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%}}"]
1967
+ })
1968
+ ], FormFilterComponent);
1969
+ return FormFilterComponent;
1970
+ }());
1971
+
1972
+ var TRANSLATE_PREFIX$2 = 'platform.filter_service';
1973
+ var INNNER_WIDTH_MOBILE_THRESHOLD = 640;
1974
+ var AdvancedFilterComponent = /** @class */ (function () {
1975
+ function AdvancedFilterComponent(translate, router) {
1976
+ var _this = this;
1977
+ this.translate = translate;
1978
+ this.router = router;
1979
+ this.labelButton = 'Filters';
1980
+ this.onlyContent = false;
1981
+ this.hideButtons = false;
1982
+ this.canOpenFilter = true;
1983
+ this.showActiveFiltersCountBadge = true;
1984
+ this.filterAndSave = false;
1985
+ this.contextId = '';
1986
+ this.subscriptions = [];
1987
+ this.isMobile = false;
1988
+ this.tabViewOrientation = 'left';
1989
+ this.totalFiltersActive = 0;
1990
+ this.showDialog = false;
1991
+ this.error = false;
1992
+ this.currentTicket = '';
1993
+ this.mobileButtonActions = [
1994
+ { id: 'save', label: this.translate.instant('save'), command: function () { return _this.modalComponent.saveFilters(); } },
1995
+ { id: 'clear', label: this.translate.instant('clear'), command: function () { return _this.modalComponent.clearFilters(); } }
1996
+ ];
1997
+ }
1998
+ AdvancedFilterComponent.prototype.ngOnInit = function () {
1999
+ var _this = this;
2000
+ this.isMobile = innerWidth <= INNNER_WIDTH_MOBILE_THRESHOLD;
2001
+ this.tabViewOrientation = this.isMobile ? 'top' : 'left';
2002
+ var sub = this.router.events.subscribe(function (e) {
2003
+ if (e instanceof router.NavigationEnd) {
2004
+ _this.modalComponent.getFilters();
2005
+ }
2006
+ });
2007
+ this.subscriptions.push(sub);
2008
+ };
2009
+ AdvancedFilterComponent.prototype.ngOnDestroy = function () {
2010
+ this.subscriptions.forEach(function (v) { return v.unsubscribe(); });
2011
+ };
2012
+ AdvancedFilterComponent.prototype.onResizeWindow = function (event) {
2013
+ var innerWidth = event.target.innerWidth;
2014
+ this.isMobile = innerWidth <= INNNER_WIDTH_MOBILE_THRESHOLD;
2015
+ this.tabViewOrientation = this.isMobile ? 'top' : 'left';
2016
+ };
2017
+ Object.defineProperty(AdvancedFilterComponent.prototype, "appliedFiltersTooltip", {
2018
+ get: function () {
2019
+ return this.totalFiltersActive > 1
2020
+ ? this.translate.instant(TRANSLATE_PREFIX$2 + ".applied_filters_message", {
2021
+ totalActiveFilters: this.totalFiltersActive
2022
+ })
2023
+ : this.translate.instant(TRANSLATE_PREFIX$2 + ".applied_filter_message", {
2024
+ totalActiveFilters: this.totalFiltersActive
2025
+ });
2026
+ },
2027
+ enumerable: true,
2028
+ configurable: true
2029
+ });
2030
+ AdvancedFilterComponent.prototype.onError = function (event) {
2031
+ this.error = event;
2032
+ };
2033
+ AdvancedFilterComponent.prototype.saveFilters = function (forceSave) {
2034
+ if (forceSave === void 0) { forceSave = false; }
2035
+ this.modalComponent.saveFilters(forceSave);
2036
+ };
2037
+ AdvancedFilterComponent.prototype.saveFiltersWithCallbackFunction = function (callbackFunction) {
2038
+ this.modalComponent.saveFiltersWithCallbackFunction(callbackFunction);
2039
+ };
2040
+ AdvancedFilterComponent.prototype.clearFilters = function () {
2041
+ this.modalComponent.clearFilters();
2042
+ };
2043
+ AdvancedFilterComponent.prototype.close = function () {
2044
+ this.modalComponent.getFilters();
2045
+ window.parent.postMessage({
2046
+ message: 'dashboard:close-modal',
2047
+ payload: {
2048
+ modalName: 'advanced-filter-1'
2049
+ }
2050
+ }, '*');
2051
+ };
2052
+ AdvancedFilterComponent.prototype.applyFilters = function () {
2053
+ if (this.modalComponent.hasChanges()) {
2054
+ this.showDialog = false;
2055
+ }
2056
+ if (this.filterAndSave) {
2057
+ this.modalComponent.saveFilters();
2058
+ }
2059
+ this.modalComponent.applyFilters(true);
2060
+ };
2061
+ AdvancedFilterComponent.prototype.onApplyFilters = function () {
2062
+ if (this.filterAndSave) {
2063
+ this.modalComponent.saveFilters();
2064
+ }
2065
+ this.modalComponent.onApplyFilters();
2066
+ };
2067
+ AdvancedFilterComponent.prototype.toggleDialog = function () {
2068
+ this.showDialog = !this.showDialog;
2069
+ };
2070
+ AdvancedFilterComponent.prototype.updateTotalFiltersActive = function (event) {
2071
+ this.totalFiltersActive = event;
2072
+ };
2073
+ AdvancedFilterComponent.ctorParameters = function () { return [
2074
+ { type: core$1.TranslateService },
2075
+ { type: router.Router }
2076
+ ]; };
2077
+ __decorate([
2078
+ core.Input()
2079
+ ], AdvancedFilterComponent.prototype, "labelButton", void 0);
2080
+ __decorate([
2081
+ core.Input()
2082
+ ], AdvancedFilterComponent.prototype, "onlyContent", void 0);
2083
+ __decorate([
2084
+ core.Input()
2085
+ ], AdvancedFilterComponent.prototype, "hideButtons", void 0);
2086
+ __decorate([
2087
+ core.Input()
2088
+ ], AdvancedFilterComponent.prototype, "canOpenFilter", void 0);
2089
+ __decorate([
2090
+ core.Input()
2091
+ ], AdvancedFilterComponent.prototype, "showActiveFiltersCountBadge", void 0);
2092
+ __decorate([
2093
+ core.Input()
2094
+ ], AdvancedFilterComponent.prototype, "filterAndSave", void 0);
2095
+ __decorate([
2096
+ core.Input()
2097
+ ], AdvancedFilterComponent.prototype, "contextId", void 0);
2098
+ __decorate([
2099
+ core.ViewChild(FormFilterComponent)
2100
+ ], AdvancedFilterComponent.prototype, "modalComponent", void 0);
2101
+ __decorate([
2102
+ core.HostListener('window:resize', ['$event'])
2103
+ ], AdvancedFilterComponent.prototype, "onResizeWindow", null);
2104
+ AdvancedFilterComponent = __decorate([
2105
+ core.Component({
2106
+ selector: 's-advanced-filter',
2107
+ 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",
2108
+ encapsulation: core.ViewEncapsulation.None,
2109
+ 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%}}"]
2110
+ })
2111
+ ], AdvancedFilterComponent);
2112
+ return AdvancedFilterComponent;
2113
+ }());
2114
+
2115
+ var AdvancedFilterModule = /** @class */ (function () {
2116
+ function AdvancedFilterModule() {
2117
+ }
2118
+ AdvancedFilterModule = __decorate([
2119
+ core.NgModule({
2120
+ imports: [
2121
+ dialog.DialogModule,
2122
+ angularComponents.ButtonModule,
2123
+ button.ButtonModule,
2124
+ tabview.TabViewModule,
2125
+ common.CommonModule,
2126
+ forms.FormsModule,
2127
+ forms.ReactiveFormsModule,
2128
+ angularComponents.DynamicFormModule,
2129
+ toast.ToastModule,
2130
+ angularComponents.EmptyStateModule,
2131
+ tooltip.TooltipModule,
2132
+ TranslationsModule.forChild([{ domain: 'platform', service: 'filter_service', fallback: fallback }]),
2133
+ ],
2134
+ providers: [AdvancedFilterService, angularComponents.LocaleService, api.MessageService, core$1.TranslateService, CalendarOptionsService],
2135
+ declarations: [AdvancedFilterComponent, FormFilterComponent, MapValuesPipe, TranslatePipe],
2136
+ exports: [AdvancedFilterComponent, FormFilterComponent]
2137
+ })
2138
+ ], AdvancedFilterModule);
2139
+ return AdvancedFilterModule;
2140
+ }());
2141
+
2142
+ // Module exports
2143
+
2144
+ var CyclicJsonInterceptor = /** @class */ (function () {
2145
+ function CyclicJsonInterceptor() {
2146
+ }
2147
+ CyclicJsonInterceptor.prototype.intercept = function (req, next) {
2148
+ if (req.body instanceof Blob === false && req.body instanceof FormData === false) {
2149
+ req = req.clone({ body: jsonCycle.decycle(req.body) });
2150
+ }
2151
+ return next.handle(req).pipe(operators.map(function (event) {
2152
+ if (event instanceof http.HttpResponse) {
2153
+ event = event.clone({ body: jsonCycle.retrocycle(event.body) });
2154
+ }
2155
+ return event;
2156
+ }));
2157
+ };
2158
+ CyclicJsonInterceptor.ɵprov = core.ɵɵdefineInjectable({ factory: function CyclicJsonInterceptor_Factory() { return new CyclicJsonInterceptor(); }, token: CyclicJsonInterceptor, providedIn: "root" });
2159
+ CyclicJsonInterceptor = __decorate([
2160
+ core.Injectable({
2161
+ providedIn: 'root',
2162
+ })
2163
+ ], CyclicJsonInterceptor);
2164
+ return CyclicJsonInterceptor;
2165
+ }());
2166
+
2167
+ var CyclicJsonInterceptorModule = /** @class */ (function () {
2168
+ function CyclicJsonInterceptorModule() {
2169
+ }
2170
+ CyclicJsonInterceptorModule = __decorate([
2171
+ core.NgModule({
2172
+ imports: [http.HttpClientModule],
2173
+ providers: [{ provide: http.HTTP_INTERCEPTORS, useClass: CyclicJsonInterceptor, multi: true }]
2174
+ })
2175
+ ], CyclicJsonInterceptorModule);
2176
+ return CyclicJsonInterceptorModule;
2177
+ }());
2178
+
2179
+ var RestUrl = /** @class */ (function () {
2180
+ function RestUrl() {
2181
+ }
2182
+ RestUrl.prototype.get = function () {
2183
+ return rxjs.defer(function () { return rxjs.from(seniorPlatformData.service.getRestUrl()); });
2184
+ };
2185
+ RestUrl = __decorate([
2186
+ core.Injectable()
2187
+ ], RestUrl);
2188
+ return RestUrl;
2189
+ }());
2190
+
2191
+ var XServicesUrl = /** @class */ (function () {
2192
+ function XServicesUrl() {
2193
+ }
2194
+ XServicesUrl.prototype.get = function () {
2195
+ return rxjs.defer(function () {
2196
+ var url = seniorPlatformData.service.getXServicesUrl();
2197
+ return rxjs.from(url);
2198
+ });
2199
+ };
2200
+ XServicesUrl = __decorate([
2201
+ core.Injectable()
2202
+ ], XServicesUrl);
2203
+ return XServicesUrl;
2204
+ }());
2205
+
2206
+ var HttpInterceptor = /** @class */ (function () {
2207
+ function HttpInterceptor(restUrl, xServicesUrl) {
2208
+ this.restUrl = restUrl;
2209
+ this.xServicesUrl = xServicesUrl;
2210
+ }
2211
+ HttpInterceptor.prototype.intercept = function (originalReq, next) {
2212
+ var _this = this;
2213
+ if (!originalReq.url.includes("://")) {
2214
+ var getAuthHeader = rxjs.defer(function () { return rxjs.from(seniorPlatformData.user.getAuthHeader()); });
2215
+ if (/^\/?[^/]+\/[^/]+\/api\/(?:latest|v\d+)\/.+$/g.test(originalReq.url)) {
2216
+ var getXServicesUrl = this.xServicesUrl.get();
2217
+ return rxjs.forkJoin([getXServicesUrl, getAuthHeader]).pipe(operators.mergeMap(function (values) {
2218
+ var _a = __read(values, 2), xUrl = _a[0], authHeader = _a[1];
2219
+ return _this.injectBaseUrl(originalReq, next, xUrl, authHeader);
2220
+ }));
2221
+ }
2222
+ var getRestUrl = this.restUrl.get();
2223
+ return rxjs.forkJoin([getRestUrl, getAuthHeader]).pipe(operators.mergeMap(function (values) {
2224
+ var _a = __read(values, 2), bridgeUrl = _a[0], authHeader = _a[1];
2225
+ return _this.injectBaseUrl(originalReq, next, bridgeUrl, authHeader);
2226
+ }));
2227
+ }
2228
+ return next.handle(originalReq);
2229
+ };
2230
+ HttpInterceptor.prototype.injectBaseUrl = function (originalReq, next, baseUrl, authorization) {
2231
+ var request = originalReq.clone({
2232
+ url: baseUrl + originalReq.url,
2233
+ headers: originalReq.headers.set("Authorization", authorization)
2234
+ });
2235
+ return next.handle(request);
2236
+ };
2237
+ HttpInterceptor.ctorParameters = function () { return [
2238
+ { type: RestUrl },
2239
+ { type: XServicesUrl }
2240
+ ]; };
2241
+ HttpInterceptor = __decorate([
2242
+ core.Injectable()
2243
+ ], HttpInterceptor);
2244
+ return HttpInterceptor;
2245
+ }());
2246
+
2247
+ var HttpInterceptorModule = /** @class */ (function () {
2248
+ function HttpInterceptorModule() {
2249
+ }
2250
+ HttpInterceptorModule = __decorate([
2251
+ core.NgModule({
2252
+ imports: [http.HttpClientModule],
2253
+ providers: [RestUrl, XServicesUrl, { provide: http.HTTP_INTERCEPTORS, useClass: HttpInterceptor, multi: true }]
2254
+ })
2255
+ ], HttpInterceptorModule);
2256
+ return HttpInterceptorModule;
2257
+ }());
2258
+
2259
+ var RESOURCES = new core.InjectionToken('RESOURCES');
2260
+ var ENVIRONMENT = new core.InjectionToken('ENVIRONMENT');
2261
+ var Resource = /** @class */ (function () {
2262
+ function Resource() {
2263
+ this.redirectToError = false;
2264
+ }
2265
+ return Resource;
2266
+ }());
2267
+ var Environment = /** @class */ (function () {
2268
+ function Environment() {
2269
+ }
2270
+ return Environment;
2271
+ }());
2272
+
2273
+ var HTTP_STATUS_FORBIDDEN = 403;
2274
+ var PermissionsService = /** @class */ (function () {
2275
+ function PermissionsService(resources, environment, http, router, messageService, translate) {
2276
+ this.resources = resources;
2277
+ this.environment = environment;
2278
+ this.http = http;
2279
+ this.router = router;
2280
+ this.messageService = messageService;
2281
+ this.translate = translate;
2282
+ this.checkedPermissions = [];
2283
+ this.actionUrl = 'platform/authorization/queries';
2284
+ this.promise = null;
2285
+ }
2286
+ // v2
2287
+ PermissionsService.prototype.checkAccess = function (resources) {
2288
+ var _this = this;
2289
+ var permissions = this.buildPermissionsArray(resources);
2290
+ return this.http.post(this.actionUrl + "/checkAccess", { includeFilters: true, permissions: permissions }).pipe(operators.map(function (_a) {
2291
+ var checkedPermissions = _a.permissions;
2292
+ _this.checkedPermissions = __spread(_this.checkedPermissions, checkedPermissions);
2293
+ if (_this.shouldRedirectToForbiddenPage(checkedPermissions, resources)) {
2294
+ _this.router.navigate(['error', HTTP_STATUS_FORBIDDEN]);
2295
+ return rxjs.throwError('forbidden');
2296
+ }
2297
+ return _this.buildValuesFromPermissions(checkedPermissions, resources);
2298
+ }));
2299
+ };
2300
+ PermissionsService.prototype.buildPermissionsArray = function (resources) {
2301
+ var _this = this;
2302
+ var permissions = [];
2303
+ resources.forEach(function (rec) {
2304
+ rec.actions.forEach(function (action) {
2305
+ if (!rec.uri) {
2306
+ var resource = _this.getUriByResourceName(rec.name, rec.entity);
2307
+ rec.uri = resource;
2308
+ }
2309
+ permissions.push({ action: action, resource: rec.uri });
2310
+ });
2311
+ });
2312
+ return permissions;
2313
+ };
2314
+ PermissionsService.prototype.buildValuesFromPermissions = function (checkedPermissions, resources) {
2315
+ var values = {};
2316
+ checkedPermissions.forEach(function (permission) {
2317
+ var _a;
2318
+ var resource = resources.find(function (res) { return res.uri === permission.resource; });
2319
+ if (!resource) {
2320
+ return;
2321
+ }
2322
+ var name = resource.name;
2323
+ if (!values[name]) {
2324
+ values[name] = {};
2325
+ }
2326
+ values[name][permission.action] = permission.authorized;
2327
+ values[name][permission.action.toLowerCase()] = permission.authorized;
2328
+ if ((_a = permission.resourceFilters) === null || _a === void 0 ? void 0 : _a.length) {
2329
+ if (!values[name].resourceFilters) {
2330
+ values[name].resourceFilters = [];
2331
+ }
2332
+ permission.resourceFilters.forEach(function (resourceFilter) {
2333
+ values[name].resourceFilters.push(resourceFilter);
2334
+ });
2335
+ }
2336
+ });
2337
+ return values;
2338
+ };
2339
+ // v1
2340
+ PermissionsService.prototype.get = function (resource) {
2341
+ var _this = this;
2342
+ if (resource === void 0) { resource = ''; }
2343
+ var hasPromise = this.promise !== null;
2344
+ if (!hasPromise) {
2345
+ this.promise = this.getPermissions();
2346
+ }
2347
+ return rxjs.from(this.promise).pipe(operators.map(function (permissions) {
2348
+ if (resource) {
2349
+ var resourceKey = Object.keys(permissions).find(function (key) { return key.toLowerCase() === resource.toLowerCase(); });
2350
+ return resourceKey ? permissions[resourceKey] : undefined;
2351
+ }
2352
+ return permissions;
2353
+ }), operators.catchError(function () {
2354
+ _this.promise = null;
2355
+ _this.messageService.add({
2356
+ severity: 'error',
2357
+ summary: _this.translate.instant('permission_error_summary'),
2358
+ detail: _this.translate.instant('permission_error_detail')
2359
+ });
2360
+ return rxjs.of(_this.getPermissionObject(false));
2361
+ }));
2362
+ };
2363
+ PermissionsService.prototype.isAuthorized = function (resourceName, action, isEntity) {
2364
+ if (isEntity === void 0) { isEntity = false; }
2365
+ var _a;
2366
+ if (!this.checkedPermissions.length) {
2367
+ throw new Error('\'Permissions\' are not defined. You should call \'get\' or \'checkAccess\' method first.');
2368
+ }
2369
+ var resourceUri = this.getUriByResourceName(resourceName, isEntity);
2370
+ var permissionsOfResource = this.checkedPermissions.filter(function (perm) { return perm.resource === resourceUri; });
2371
+ var permissionOfAction = permissionsOfResource.find(function (permRec) { return permRec.action.toLowerCase() === action.toLowerCase(); });
2372
+ return (_a = permissionOfAction === null || permissionOfAction === void 0 ? void 0 : permissionOfAction.authorized) !== null && _a !== void 0 ? _a : false;
2373
+ };
2374
+ PermissionsService.prototype.getUriByResourceName = function (resourceName, isEntity) {
2375
+ if (isEntity === void 0) { isEntity = false; }
2376
+ var _a = this.environment, domain = _a.domain, service = _a.service;
2377
+ if (!domain || !service) {
2378
+ throw new Error('You must inform domain and service name');
2379
+ }
2380
+ var uriBase = "res://senior.com.br/" + domain + "/" + service;
2381
+ if (isEntity) {
2382
+ return uriBase + "/entities/" + resourceName;
2383
+ }
2384
+ return uriBase + "/" + resourceName;
2385
+ };
2386
+ /**
2387
+ * Valida com base nas propriedade redirectToError e actionsToCheck
2388
+ * se a ação de um recurso deve enviar para a página de erro caso não tenha autorização
2389
+ */
2390
+ PermissionsService.prototype.shouldRedirectToForbiddenPage = function (permissions, resources) {
2391
+ if (resources === void 0) { resources = []; }
2392
+ var permissionsDenied = permissions.filter(function (perm) { return !perm.authorized; });
2393
+ if (!(permissionsDenied === null || permissionsDenied === void 0 ? void 0 : permissionsDenied.length)) {
2394
+ return false;
2395
+ }
2396
+ var resourcesToCheck = resources.filter(function (resource) { return resource.redirectToError; });
2397
+ if (!(resourcesToCheck === null || resourcesToCheck === void 0 ? void 0 : resourcesToCheck.length)) {
2398
+ return false;
2399
+ }
2400
+ return this.checkIfAllActionsAreDenied(resourcesToCheck, permissionsDenied);
2401
+ };
2402
+ PermissionsService.prototype.checkIfAllActionsAreDenied = function (resourcesToCheck, permissionsDenied) {
2403
+ return resourcesToCheck.every(function (resource) {
2404
+ var _a;
2405
+ var actionsToCheck = ((_a = resource.actionsToCheck) === null || _a === void 0 ? void 0 : _a.length) ? resource.actionsToCheck : resource.actions;
2406
+ return actionsToCheck.every(function (action) {
2407
+ return permissionsDenied.some(function (permissionDenied) {
2408
+ return permissionDenied.resource === resource.uri && permissionDenied.action === action;
2409
+ });
2410
+ });
2411
+ });
2412
+ };
2413
+ PermissionsService.prototype.getFlatEnvironment = function () {
2414
+ return this.environment.ignorePermissions;
2415
+ };
2416
+ PermissionsService.prototype.getFlatResources = function () {
2417
+ return this.resources.reduce(function (result, item) {
2418
+ if (!item) {
2419
+ return result;
2420
+ }
2421
+ if (Array.isArray(item)) {
2422
+ return __spread(result, item);
2423
+ }
2424
+ return __spread(result, [item]);
2425
+ }, []);
2426
+ };
2427
+ PermissionsService.prototype.getPermissionObject = function (defaultValue) {
2428
+ var _this = this;
2429
+ return this.getFlatResources().reduce(function (resources, resource) {
2430
+ resources[resource.name] = _this.buildActionsObject(resource.actions, defaultValue);
2431
+ return resources;
2432
+ }, {});
2433
+ };
2434
+ PermissionsService.prototype.buildActionsObject = function (actions, defaultValue) {
2435
+ return actions.reduce(function (actionsObj, action) {
2436
+ actionsObj[action] = defaultValue;
2437
+ actionsObj[action.toLowerCase()] = defaultValue;
2438
+ return actionsObj;
2439
+ }, {});
2440
+ };
2441
+ PermissionsService.prototype.getPermissions = function () {
2442
+ return __awaiter(this, void 0, void 0, function () {
2443
+ var resources, perm, response;
2444
+ return __generator(this, function (_a) {
2445
+ switch (_a.label) {
2446
+ case 0:
2447
+ if (this.getFlatEnvironment()) {
2448
+ return [2 /*return*/, this.getPermissionObject(true)];
2449
+ }
2450
+ resources = this.getFlatResources();
2451
+ perm = this.buildPermissionsForCheck(resources);
2452
+ return [4 /*yield*/, this.http
2453
+ .post(this.actionUrl + "/checkAccess", {
2454
+ includeFilters: false,
2455
+ permissions: perm
2456
+ })
2457
+ .toPromise()];
2458
+ case 1:
2459
+ response = _a.sent();
2460
+ return [2 /*return*/, this.buildPermissionsResponse(response.permissions, resources)];
2461
+ }
2462
+ });
2463
+ });
2464
+ };
2465
+ PermissionsService.prototype.buildPermissionsForCheck = function (resources) {
2466
+ return resources
2467
+ .map(function (resource) { return resource.actions.map(function (action) { return ({ action: action, resource: resource.uri }); }); })
2468
+ .reduce(function (acc, val) { return __spread(acc, val); }, []);
2469
+ };
2470
+ PermissionsService.prototype.buildPermissionsResponse = function (permissions, resources) {
2471
+ var values = {};
2472
+ permissions.forEach(function (permission) {
2473
+ var resource = resources.find(function (res) { return res.uri === permission.resource; });
2474
+ if (!resource) {
2475
+ return;
2476
+ }
2477
+ var name = resource.name;
2478
+ if (!values[name]) {
2479
+ values[name] = {};
2480
+ }
2481
+ values[name][permission.action] = permission.authorized;
2482
+ values[name][permission.action.toLowerCase()] = permission.authorized;
2483
+ });
2484
+ return values;
2485
+ };
2486
+ PermissionsService.ctorParameters = function () { return [
2487
+ { type: undefined, decorators: [{ type: core.Inject, args: [RESOURCES,] }] },
2488
+ { type: Environment, decorators: [{ type: core.Inject, args: [ENVIRONMENT,] }] },
2489
+ { type: http.HttpClient },
2490
+ { type: router.Router },
2491
+ { type: api.MessageService },
2492
+ { type: core$1.TranslateService }
2493
+ ]; };
2494
+ PermissionsService.ɵprov = core.ɵɵdefineInjectable({ factory: function PermissionsService_Factory() { return new PermissionsService(core.ɵɵinject(RESOURCES), core.ɵɵinject(ENVIRONMENT), core.ɵɵinject(http.HttpClient), core.ɵɵinject(router.Router), core.ɵɵinject(api.MessageService), core.ɵɵinject(core$1.TranslateService)); }, token: PermissionsService, providedIn: "root" });
2495
+ PermissionsService = __decorate([
2496
+ core.Injectable({
2497
+ providedIn: 'root'
2498
+ }),
2499
+ __param(0, core.Inject(RESOURCES)),
2500
+ __param(1, core.Inject(ENVIRONMENT))
2501
+ ], PermissionsService);
2502
+ return PermissionsService;
2503
+ }());
2504
+
2505
+ var PermissionsModule = /** @class */ (function () {
2506
+ function PermissionsModule() {
2507
+ }
2508
+ PermissionsModule_1 = PermissionsModule;
2509
+ PermissionsModule.forRoot = function (resources, environment) {
2510
+ return {
2511
+ ngModule: PermissionsModule_1,
2512
+ providers: [
2513
+ PermissionsService,
2514
+ {
2515
+ provide: RESOURCES,
2516
+ multi: true,
2517
+ useValue: resources
2518
+ },
2519
+ {
2520
+ provide: ENVIRONMENT,
2521
+ multi: false,
2522
+ useValue: environment
2523
+ }
2524
+ ]
2525
+ };
2526
+ };
2527
+ PermissionsModule.forChild = function (resources) {
2528
+ return {
2529
+ ngModule: PermissionsModule_1,
2530
+ providers: [
2531
+ {
2532
+ provide: RESOURCES,
2533
+ multi: true,
2534
+ useValue: resources
2535
+ }
2536
+ ]
2537
+ };
2538
+ };
2539
+ var PermissionsModule_1;
2540
+ PermissionsModule = PermissionsModule_1 = __decorate([
2541
+ core.NgModule()
2542
+ ], PermissionsModule);
2543
+ return PermissionsModule;
2544
+ }());
2545
+
2546
+ function ResourceFactory(_a) {
2547
+ var domain = _a.domain, service = _a.service, resource = _a.resource;
2548
+ return "res://senior.com.br/" + domain + "/" + service + "/" + resource;
2549
+ }
2550
+ function endpointFactoryFunction(domain, service) {
2551
+ // The @seniorsistemas/platform-components http interceptor is handling the base url portion of the final URL
2552
+ var create = function (method, endpoint) { return domain + "/" + service + "/" + method + "/" + endpoint; };
2553
+ var resource = function (resource) { return ResourceFactory({ domain: domain, service: service, resource: resource }); };
2554
+ return {
2555
+ resource: resource,
2556
+ query: create.bind(null, 'queries'),
2557
+ action: create.bind(null, 'actions'),
2558
+ signal: create.bind(null, 'signals'),
2559
+ entity: function (entity) {
2560
+ var URL = create('entities', entity);
2561
+ return {
2562
+ create: function () { return URL; },
2563
+ update: function (id) { return URL + '/' + id; },
2564
+ remove: function (id) { return URL + '/' + id; }
2565
+ };
2566
+ }
2567
+ };
2568
+ }
2569
+ var endpointFactory = endpointFactoryFunction;
2570
+ // ADD HERE YOUR NEW ENDPOINT
2571
+ var PLATFORM_FEATURE_TOGGLE = endpointFactoryFunction('platform', 'feature_toggle');
2572
+
2573
+ var FeatureToggleService = /** @class */ (function () {
2574
+ function FeatureToggleService(http) {
2575
+ this.http = http;
2576
+ this.cache = {};
2577
+ }
2578
+ FeatureToggleService.prototype.isEnabled = function (_a, tenant) {
2579
+ var _this = this;
2580
+ var domain = _a.domain, service = _a.service, name = _a.name;
2581
+ var tenantObs;
2582
+ if (tenant) {
2583
+ tenantObs = rxjs.of(tenant);
2584
+ }
2585
+ else {
2586
+ tenantObs = rxjs.from(seniorPlatformData.user.getUserData()).pipe(operators.map(function (userData) { return userData.tenantName; }));
2587
+ }
2588
+ return tenantObs.pipe(operators.mergeMap(function (tenant) {
2589
+ var key = JSON.stringify({ tenant: tenant, domain: domain, service: service });
2590
+ if (!_this.cache[key]) {
2591
+ _this.cache[key] = _this.http
2592
+ .post(PLATFORM_FEATURE_TOGGLE.query('getEnabledFeatures'), { tenant: tenant, domain: domain, service: service })
2593
+ .pipe(operators.map(function (output) { return output.features; }), operators.shareReplay(1), operators.catchError(function (err) {
2594
+ console.error(err);
2595
+ delete _this.cache[key];
2596
+ return rxjs.of([]);
2597
+ }));
2598
+ }
2599
+ return _this.cache[key];
2600
+ }), operators.map(function (features) {
2601
+ return features.findIndex(function (f) { return f.name === name; }) !== -1;
2602
+ }));
2603
+ };
2604
+ FeatureToggleService.ctorParameters = function () { return [
2605
+ { type: http.HttpClient }
2606
+ ]; };
2607
+ FeatureToggleService.ɵprov = core.ɵɵdefineInjectable({ factory: function FeatureToggleService_Factory() { return new FeatureToggleService(core.ɵɵinject(http.HttpClient)); }, token: FeatureToggleService, providedIn: "root" });
2608
+ FeatureToggleService = __decorate([
2609
+ core.Injectable({ providedIn: 'root' })
2610
+ ], FeatureToggleService);
2611
+ return FeatureToggleService;
2612
+ }());
2613
+
2614
+ var FeatureToggleModule = /** @class */ (function () {
2615
+ function FeatureToggleModule() {
2616
+ }
2617
+ FeatureToggleModule = __decorate([
2618
+ core.NgModule({
2619
+ imports: [http.HttpClientModule, HttpInterceptorModule],
2620
+ providers: [FeatureToggleService]
2621
+ })
2622
+ ], FeatureToggleModule);
2623
+ return FeatureToggleModule;
2624
+ }());
2625
+
2626
+ var UserAction;
2627
+ (function (UserAction) {
2628
+ UserAction["CONFIRMED"] = "CONFIRMED";
2629
+ UserAction["POSTPONED"] = "POSTPONED";
2630
+ UserAction["REFUSED"] = "REFUSED";
2631
+ })(UserAction || (UserAction = {}));
2632
+
2633
+ var SpotlightService = /** @class */ (function () {
2634
+ function SpotlightService(http) {
2635
+ this.http = http;
2636
+ this.API_URL = 'platform/spotlight/';
2637
+ }
2638
+ SpotlightService.prototype.getUser = function () {
2639
+ return this.http.post('platform/user/queries/getUser', {}).toPromise();
2640
+ };
2641
+ SpotlightService.prototype.listSpotlightScreen = function () {
2642
+ return this.http.get(this.API_URL + 'queries/listSpotlightScreen');
2643
+ };
2644
+ SpotlightService.prototype.listSpotlightUsers = function () {
2645
+ return this.http.get(this.API_URL + 'queries/listSpotlightUsers').toPromise();
2646
+ };
2647
+ SpotlightService.prototype.listSpotlightControl = function () {
2648
+ return this.http.get(this.API_URL + 'queries/listSpotlightControl').toPromise();
2649
+ };
2650
+ SpotlightService.prototype.saveSpotlightUser = function (content) {
2651
+ return this.http.post(this.API_URL + 'actions/saveSpotlightUsers', { content: content });
2652
+ };
2653
+ SpotlightService.prototype.saveSpotlightControl = function (content) {
2654
+ return this.http.post(this.API_URL + 'actions/saveSpotlightControl', { content: content });
2655
+ };
2656
+ SpotlightService.prototype.notificateSpotlight = function (content) {
2657
+ return this.http.post(this.API_URL + 'actions/notificateSpotlight', content);
2658
+ };
2659
+ SpotlightService.ctorParameters = function () { return [
2660
+ { type: http.HttpClient }
2661
+ ]; };
2662
+ SpotlightService = __decorate([
2663
+ core.Injectable()
2664
+ ], SpotlightService);
2665
+ return SpotlightService;
2666
+ }());
2667
+
2668
+ var EnumDisplayType;
2669
+ (function (EnumDisplayType) {
2670
+ EnumDisplayType["ADVERSITING"] = "ADVERSITING";
2671
+ EnumDisplayType["INTEGRATION"] = "INTEGRATION";
2672
+ })(EnumDisplayType || (EnumDisplayType = {}));
2673
+
2674
+ var SpotlightControl = /** @class */ (function () {
2675
+ function SpotlightControl() {
2676
+ }
2677
+ return SpotlightControl;
2678
+ }());
2679
+
2680
+ var EnumSpotlightStatus;
2681
+ (function (EnumSpotlightStatus) {
2682
+ EnumSpotlightStatus["ACTIVE"] = "ACTIVE";
2683
+ EnumSpotlightStatus["IN_PROGRESS"] = "IN_PROGRESS";
2684
+ EnumSpotlightStatus["NO_STARTED"] = "NO_STARTED";
2685
+ EnumSpotlightStatus["REFUSED"] = "REFUSED";
2686
+ })(EnumSpotlightStatus || (EnumSpotlightStatus = {}));
2687
+
2688
+ var DATE_FORMAT = 'yyyy-MM-dd';
2689
+ var SpotlightComponent = /** @class */ (function () {
2690
+ function SpotlightComponent(spotlightService, cookieService, datePipe, elementRef, renderer) {
2691
+ this.spotlightService = spotlightService;
2692
+ this.cookieService = cookieService;
2693
+ this.datePipe = datePipe;
2694
+ this.elementRef = elementRef;
2695
+ this.renderer = renderer;
2696
+ this.canAppear = false;
2697
+ this.visible = false;
2698
+ this.fade = false;
2699
+ this.visibleChange = new core.EventEmitter();
2700
+ }
2701
+ SpotlightComponent.prototype.ngOnInit = function () {
2702
+ var _this = this;
2703
+ this.setValues().then(function () {
2704
+ _this.fetchSpotlight();
2705
+ });
2706
+ };
2707
+ SpotlightComponent.prototype.setValues = function () {
2708
+ return __awaiter(this, void 0, void 0, function () {
2709
+ var userData, _a, _b;
2710
+ return __generator(this, function (_c) {
2711
+ switch (_c.label) {
2712
+ case 0:
2713
+ userData = JSON.parse(this.cookieService.get('com.senior.token'));
2714
+ this.currentUser = userData.username;
2715
+ _a = this;
2716
+ return [4 /*yield*/, this.spotlightService.listSpotlightUsers()];
2717
+ case 1:
2718
+ _a.spotlightUsersList = _c.sent();
2719
+ _b = this;
2720
+ return [4 /*yield*/, this.spotlightService.listSpotlightControl()];
2721
+ case 2:
2722
+ _b.spotlightControlsList = _c.sent();
2723
+ return [2 /*return*/];
2724
+ }
2725
+ });
2726
+ });
2727
+ };
2728
+ SpotlightComponent.prototype.setValuesInSpotlight = function (values) {
2729
+ this.header = values.spotlightTitle;
2730
+ this.imgUrl = values.bannerUrl;
2731
+ this.primaryButtonLabel = values.primaryButtonLabel;
2732
+ this.primaryButtonTooltip = values.primaryButtonHint;
2733
+ };
2734
+ SpotlightComponent.prototype.getShowDate = function (days) {
2735
+ var currentDate = new Date();
2736
+ return this.datePipe.transform(currentDate.setDate(currentDate.getDate() + days).toString(), DATE_FORMAT);
2737
+ };
2738
+ SpotlightComponent.prototype.fetchSpotlight = function () {
2739
+ var _this = this;
2740
+ this.spotlightService.listSpotlightScreen().subscribe(function (value) {
2741
+ _this.spotlightScreen = value.contents.filter(function (val) { return val.screenMenuId === _this.menuId; })[0];
2742
+ if (_this.spotlightScreen) {
2743
+ _this.showSpotlight(_this.spotlightScreen.spotlight);
2744
+ }
2745
+ });
2746
+ };
2747
+ SpotlightComponent.prototype.showSpotlight = function (spotlight) {
2748
+ if (this.validateDate(spotlight.initialDate) &&
2749
+ this.validateFinalDate(spotlight.finalDate) &&
2750
+ this.validateSpotlight(spotlight)) {
2751
+ this.setValuesInSpotlight(spotlight);
2752
+ this.canAppear = true;
2753
+ var control = this.getSpotlightControlFromList(this.spotlightScreen.spotlight.id);
2754
+ this.canEmitEvent = !control || this.currentUser !== control.firstUser;
2755
+ }
2756
+ };
2757
+ SpotlightComponent.prototype.validateDate = function (date) {
2758
+ if (date) {
2759
+ var currentDate = this.datePipe.transform(new Date().toString(), DATE_FORMAT);
2760
+ var initialDate = this.datePipe.transform(date, DATE_FORMAT);
2761
+ return new Date(currentDate).getTime() >= new Date(initialDate).getTime();
2762
+ }
2763
+ return false;
2764
+ };
2765
+ SpotlightComponent.prototype.validateFinalDate = function (date) {
2766
+ if (date) {
2767
+ var currentDate = this.datePipe.transform(new Date().toString(), DATE_FORMAT);
2768
+ var finalDate = this.datePipe.transform(date, DATE_FORMAT);
2769
+ return new Date(currentDate).getTime() <= new Date(finalDate).getTime();
2770
+ }
2771
+ return true;
2772
+ };
2773
+ SpotlightComponent.prototype.validateSpotlight = function (spotlight) {
2774
+ if (!this.validateControlsList(this.spotlightControlsList, spotlight, this.currentUser)) {
2775
+ return false;
2776
+ }
2777
+ if (!this.validateDisplayType(spotlight, this.spotlightUsersList, this.spotlightControlsList, this.currentUser)) {
2778
+ return false;
2779
+ }
2780
+ return true;
2781
+ };
2782
+ SpotlightComponent.prototype.validateControlsList = function (controlsList, spotlight, currentUser) {
2783
+ if (controlsList.totalElements) {
2784
+ var notCompatibleControls = controlsList.contents.filter(function (control) {
2785
+ if (control.status === EnumSpotlightStatus.ACTIVE) {
2786
+ return control.spotlightId === spotlight.id;
2787
+ }
2788
+ else if (control.status === EnumSpotlightStatus.IN_PROGRESS) {
2789
+ return control.spotlightId === spotlight.id && control.firstUser !== currentUser;
2790
+ }
2791
+ else {
2792
+ return false;
2793
+ }
2794
+ });
2795
+ if (notCompatibleControls.length > 0) {
2796
+ return false;
2797
+ }
2798
+ }
2799
+ return true;
2800
+ };
2801
+ SpotlightComponent.prototype.validateDisplayType = function (spotlight, usersList, controlsList, currentUser) {
2802
+ var _this = this;
2803
+ if (spotlight.displayType === EnumDisplayType.ADVERSITING) {
2804
+ return usersList.totalElements ? this.validateUser(usersList.contents, spotlight) : true;
2805
+ }
2806
+ if (spotlight.displayType === EnumDisplayType.INTEGRATION && controlsList.totalElements) {
2807
+ var compatibleControls = controlsList.contents.filter(function (control) {
2808
+ return _this.isControlCompatible(control, spotlight, usersList, currentUser);
2809
+ });
2810
+ return compatibleControls.length > 0;
2811
+ }
2812
+ return true;
2813
+ };
2814
+ SpotlightComponent.prototype.isControlCompatible = function (control, spotlight, usersList, currentUser) {
2815
+ switch (control.status) {
2816
+ case EnumSpotlightStatus.NO_STARTED:
2817
+ return control.spotlightId === spotlight.id;
2818
+ case EnumSpotlightStatus.REFUSED:
2819
+ return usersList.totalElements ? this.validateUser(usersList.contents, spotlight) : true;
2820
+ case EnumSpotlightStatus.IN_PROGRESS:
2821
+ return control.firstUser === currentUser && control.spotlightId === spotlight.id;
2822
+ default:
2823
+ return false;
2824
+ }
2825
+ };
2826
+ SpotlightComponent.prototype.validateUser = function (users, spotlight) {
2827
+ var _this = this;
2828
+ var spotlightUsers = users.filter(function (user) { return user.spotlightId === spotlight.id; });
2829
+ if (!spotlightUsers.length) {
2830
+ spotlightUsers = users.filter(function (user) { return user.userOperation === _this.currentUser; });
2831
+ return spotlightUsers.length === 0;
2832
+ }
2833
+ var compatibleUserToValidate = spotlightUsers.filter(function (user) { return user.userOperation === _this.currentUser; })[0];
2834
+ return compatibleUserToValidate ? this.validateDate(compatibleUserToValidate.showDate) : true;
2835
+ };
2836
+ SpotlightComponent.prototype.saveSpotlightUser = function (days) {
2837
+ var _this = this;
2838
+ var spotlight = this.spotlightScreen.spotlight;
2839
+ var user = this.spotlightUsersList.contents.filter(function (val) {
2840
+ return val.spotlightId === spotlight.id && val.userOperation === _this.currentUser;
2841
+ })[0];
2842
+ var spotlightUser = {
2843
+ spotlightId: spotlight.id,
2844
+ showDate: days ? this.getShowDate(days) : null,
2845
+ userOperation: this.currentUser
2846
+ };
2847
+ if (user) {
2848
+ spotlightUser = __assign({ id: user.id }, spotlightUser);
2849
+ }
2850
+ this.spotlightService.saveSpotlightUser(spotlightUser).subscribe();
2851
+ };
2852
+ SpotlightComponent.prototype.onPrimary = function () {
2853
+ var spotlight = this.spotlightScreen.spotlight;
2854
+ var notification = this.buildNotification(UserAction.CONFIRMED);
2855
+ this.saveSpotlightControl();
2856
+ this.saveSpotlightUser();
2857
+ if (this.canEmitEvent) {
2858
+ this.spotlightService.notificateSpotlight(notification).subscribe();
2859
+ }
2860
+ if (spotlight.primaryButtonUrl) {
2861
+ window.open(spotlight.primaryButtonUrl);
2862
+ }
2863
+ this.close();
2864
+ };
2865
+ SpotlightComponent.prototype.onSecondary = function () {
2866
+ var notification = this.buildNotification(UserAction.POSTPONED);
2867
+ this.saveSpotlightControl(EnumSpotlightStatus.REFUSED);
2868
+ this.saveSpotlightUser(this.spotlightScreen.spotlight.daysRememberLate);
2869
+ this.spotlightService.notificateSpotlight(notification).subscribe();
2870
+ this.close();
2871
+ };
2872
+ SpotlightComponent.prototype.onTertiary = function () {
2873
+ var notification = this.buildNotification(UserAction.REFUSED);
2874
+ this.saveSpotlightControl(EnumSpotlightStatus.REFUSED);
2875
+ this.saveSpotlightUser(this.spotlightScreen.spotlight.daysNotInterested);
2876
+ this.spotlightService.notificateSpotlight(notification).subscribe();
2877
+ this.close();
2878
+ };
2879
+ /**
2880
+ * Verifica se um registro de usuário pertence ao usuário logado e corresponde ao spotlight atual
2881
+ * @param user SpotlightUser Objeto representando o registro do usuário para uma spotlight
2882
+ * @param spotlight Spotlight Spotlight
2883
+ * @returns boolean true se corresponder ao spotlight atual, false caso contrário
2884
+ */
2885
+ SpotlightComponent.prototype.hasThisRegister = function (user, spotlight) {
2886
+ return user.spotlightId === spotlight.id && user.userOperation === this.currentUser;
2887
+ };
2888
+ /**
2889
+ * Verifica se um registro de usuário pertece ao usuário logado, mas não corresponde ao spotlight atual
2890
+ * @param user SpotlightUser Objeto representando o registro do usuário para uma spotlight
2891
+ * @param spotlight Spotlight Spotlight
2892
+ * @returns boolean true se corresponder ao spotlight atual, false caso contrário
2893
+ */
2894
+ SpotlightComponent.prototype.hasAnotherRegister = function (user, spotlight) {
2895
+ return user.spotlightId !== spotlight.id && user.userOperation === this.currentUser;
2896
+ };
2897
+ /**
2898
+ * Persiste um novo registro de controle para o spotlight atual se
2899
+ * não for encontrado nenhum na lista de controles carregada inicialmente
2900
+ * @param status EnumSpotlightStatus Status do controle do spotlight. Se nenhum for informado, IN_PROGRESS será aplicado
2901
+ * @returns SpotlightControl Controle do spotlight recuperado/pesistido
2902
+ */
2903
+ SpotlightComponent.prototype.saveSpotlightControl = function (status) {
2904
+ if (status === void 0) { status = EnumSpotlightStatus.IN_PROGRESS; }
2905
+ var spotlight = this.spotlightScreen.spotlight;
2906
+ var control = this.getSpotlightControlFromList(spotlight.id);
2907
+ if (!control) {
2908
+ control = {
2909
+ status: status,
2910
+ spotlightId: spotlight.id,
2911
+ firstUser: this.currentUser
2912
+ };
2913
+ }
2914
+ if (this.isNewControl(control) || control.status !== EnumSpotlightStatus.IN_PROGRESS) {
2915
+ control.status = status;
2916
+ control.firstUser = status === EnumSpotlightStatus.IN_PROGRESS ? this.currentUser : '';
2917
+ this.spotlightService.saveSpotlightControl(control).subscribe();
2918
+ }
2919
+ return control;
2920
+ };
2921
+ /**
2922
+ * Retorna o controle de spotlight correspondente ao identificador
2923
+ * informado na lista de controles carregada na inicialização do componente
2924
+ * @param id string Identificador do controle de spotlight
2925
+ */
2926
+ SpotlightComponent.prototype.getSpotlightControlFromList = function (id) {
2927
+ return this.spotlightControlsList.contents.filter(function (val) { return val.spotlightId === id; })[0];
2928
+ };
2929
+ /**
2930
+ * Verifica se o controle de spotlight informado não foi registrado ainda
2931
+ * @param spotlightControl SpotlightControl Controle do spotlight
2932
+ * @returns boolean true se ainda não foi registrado na base, false caso contrário
2933
+ */
2934
+ SpotlightComponent.prototype.isNewControl = function (spotlightControl) {
2935
+ return !this.spotlightControlsList.contents.includes(spotlightControl);
2936
+ };
2937
+ /**
2938
+ * Retorna um objeto de notificação referente ao botão clicado pelo usuário.
2939
+ * @param userAction UserAction Ação realizada pelo usuário ao clicar nos botões da modal
2940
+ * @returns SpotlightNotification Objeto de notificação
2941
+ */
2942
+ SpotlightComponent.prototype.buildNotification = function (userAction) {
2943
+ var spotlight = this.spotlightScreen.spotlight;
2944
+ return {
2945
+ clickedButton: userAction,
2946
+ spotlightControlId: spotlight.id,
2947
+ primaryButtonUrl: spotlight.primaryButtonUrl
2948
+ };
2949
+ };
2950
+ SpotlightComponent.prototype.ngAfterViewInit = function () {
2951
+ this.accessibilityUtils = new AccessibilityUtils(this.elementRef, this.renderer);
2952
+ this.accessibilityUtils.init();
2953
+ };
2954
+ SpotlightComponent.prototype.ngOnDestroy = function () {
2955
+ if (this.accessibilityUtils) {
2956
+ this.accessibilityUtils.destroy();
2957
+ }
2958
+ };
2959
+ SpotlightComponent.prototype.close = function () {
2960
+ this.visibleChange.emit(false);
2961
+ };
2962
+ SpotlightComponent.ctorParameters = function () { return [
2963
+ { type: SpotlightService },
2964
+ { type: ngxCookieService.CookieService },
2965
+ { type: common.DatePipe },
2966
+ { type: core.ElementRef },
2967
+ { type: core.Renderer2 }
2968
+ ]; };
2969
+ __decorate([
2970
+ core.Input()
2971
+ ], SpotlightComponent.prototype, "visible", void 0);
2972
+ __decorate([
2973
+ core.Input()
2974
+ ], SpotlightComponent.prototype, "menuId", void 0);
2975
+ __decorate([
2976
+ core.Input()
2977
+ ], SpotlightComponent.prototype, "fade", void 0);
2978
+ __decorate([
2979
+ core.Output()
2980
+ ], SpotlightComponent.prototype, "visibleChange", void 0);
2981
+ SpotlightComponent = __decorate([
2982
+ core.Component({
2983
+ selector: 's-spotlight',
2984
+ 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",
2985
+ 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%}}"]
2986
+ })
2987
+ ], SpotlightComponent);
2988
+ return SpotlightComponent;
2989
+ }());
2990
+
2991
+ var fallback$1 = {
2992
+ 'platform.spotlight.no_interest': 'Não tenho interesse',
2993
+ 'platform.spotlight.remember_late': 'Lembrar mais tarde'
2994
+ };
2995
+
2996
+ var TranslatePipe$1 = /** @class */ (function () {
2997
+ function TranslatePipe(translationService) {
2998
+ this.translationService = translationService;
2999
+ }
3000
+ TranslatePipe.prototype.transform = function (value) {
3001
+ return this.translationService.instant(value);
3002
+ };
3003
+ TranslatePipe.ctorParameters = function () { return [
3004
+ { type: core$1.TranslateService }
3005
+ ]; };
3006
+ TranslatePipe = __decorate([
3007
+ core.Pipe({
3008
+ name: 'translate',
3009
+ pure: false,
3010
+ })
3011
+ ], TranslatePipe);
3012
+ return TranslatePipe;
3013
+ }());
3014
+
3015
+ var SpotlightModule = /** @class */ (function () {
3016
+ function SpotlightModule() {
3017
+ }
3018
+ SpotlightModule = __decorate([
3019
+ core.NgModule({
3020
+ imports: [
3021
+ button.ButtonModule,
3022
+ tooltip.TooltipModule,
3023
+ common.CommonModule,
3024
+ HttpInterceptorModule,
3025
+ TranslationsModule.forChild([{ domain: 'platform', service: 'spotlight', fallback: fallback$1 }]),
3026
+ ],
3027
+ providers: [
3028
+ SpotlightService,
3029
+ common.DatePipe,
3030
+ ngxCookieService.CookieService
3031
+ ],
3032
+ declarations: [
3033
+ SpotlightComponent,
3034
+ TranslatePipe$1
3035
+ ],
3036
+ exports: [SpotlightComponent]
3037
+ })
3038
+ ], SpotlightModule);
3039
+ return SpotlightModule;
3040
+ }());
3041
+
3042
+ exports.AdvancedFilterComponent = AdvancedFilterComponent;
3043
+ exports.AdvancedFilterModule = AdvancedFilterModule;
3044
+ exports.AdvancedFilterService = AdvancedFilterService;
3045
+ exports.CyclicJsonInterceptorModule = CyclicJsonInterceptorModule;
3046
+ exports.FILTER_CONSTANTS = FILTER_CONSTANTS;
3047
+ exports.FeatureToggleModule = FeatureToggleModule;
3048
+ exports.FeatureToggleService = FeatureToggleService;
3049
+ exports.Filter = Filter;
3050
+ exports.FormFilter = FormFilter;
3051
+ exports.GRID_CONFIG = GRID_CONFIG;
3052
+ exports.HttpInterceptorModule = HttpInterceptorModule;
3053
+ exports.LENGTH_DEFAULT = LENGTH_DEFAULT;
3054
+ exports.PermissionsModule = PermissionsModule;
3055
+ exports.PermissionsService = PermissionsService;
3056
+ exports.RestUrl = RestUrl;
3057
+ exports.SpotlightComponent = SpotlightComponent;
3058
+ exports.SpotlightModule = SpotlightModule;
3059
+ exports.TranslationsConfig = TranslationsConfig;
3060
+ exports.TranslationsModule = TranslationsModule;
3061
+ exports.UI_CONSTANTS = UI_CONSTANTS;
3062
+ exports.USER_INFO = USER_INFO;
3063
+ exports.VALIDATION_CONSTANTS = VALIDATION_CONSTANTS;
3064
+ exports.XServicesUrl = XServicesUrl;
3065
+ exports.factory = factory;
3066
+ exports.ɵa = fallback;
3067
+ exports.ɵb = CalendarOptionsService;
3068
+ exports.ɵc = FormFilterComponent;
3069
+ exports.ɵd = MapValuesPipe;
3070
+ exports.ɵe = TranslatePipe;
3071
+ exports.ɵf = CyclicJsonInterceptor;
3072
+ exports.ɵg = HttpInterceptor;
3073
+ exports.ɵh = RESOURCES;
3074
+ exports.ɵi = ENVIRONMENT;
3075
+ exports.ɵk = Environment;
3076
+ exports.ɵl = fallback$1;
3077
+ exports.ɵm = SpotlightService;
3078
+ exports.ɵn = TranslatePipe$1;
3079
+
3080
+ Object.defineProperty(exports, '__esModule', { value: true });
3081
+
3082
+ })));
3083
+ //# sourceMappingURL=seniorsistemas-platform-components.umd.js.map