@seniorsistemas/platform-components 7.1.0 → 7.2.0-develop-a5cdf6fe

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.
@@ -27,8 +27,8 @@ import { TranslateService, TranslateModule } from '@ngx-translate/core';
27
27
  import { HttpClient, provideHttpClient, withInterceptorsFromDi, HttpParams, HttpHeaders, HttpResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
28
28
  import { user, service } from '@seniorsistemas/senior-platform-data';
29
29
  import { CookieService } from 'ngx-cookie-service';
30
- import { Subject, BehaviorSubject, Observable, from, defer, forkJoin, throwError, of, takeUntil as takeUntil$1 } from 'rxjs';
31
- import { map, takeUntil, filter, tap, mergeMap, catchError, shareReplay } from 'rxjs/operators';
30
+ import { Subject, BehaviorSubject, Observable, of, from, defer, forkJoin, throwError, takeUntil as takeUntil$1 } from 'rxjs';
31
+ import { map, switchMap, catchError, takeUntil, filter, tap, mergeMap, shareReplay } from 'rxjs/operators';
32
32
  import { Router, NavigationEnd } from '@angular/router';
33
33
  import { ToastService } from '@seniorsistemas/angular-components/toast';
34
34
  import { contains, equals, clone } from 'ramda';
@@ -397,16 +397,97 @@ class AdvancedFilterService {
397
397
  getFilters(serviceContexts, applyFilter) {
398
398
  this.http
399
399
  .post(GET_FILTERS_URL, { serviceContexts })
400
- .pipe(map((response) => this.mapFilters(response.filters)))
400
+ .pipe(switchMap((response) => this.applyTicketValues(response.filters)), map((filters) => this.mapFilters(filters)))
401
401
  .subscribe((filters) => this.filtersObservable.next({ filters, applyFilter }), //
402
402
  (err) => this.filtersObservable.next({ error: true, message: err }));
403
403
  }
404
+ applyTicketValues(filters) {
405
+ if (!this.ticketFilter) {
406
+ return of(filters);
407
+ }
408
+ return this.fetchFiltersByTicket().pipe(map((ticketFilters) => this.mergeTicketValues(filters, ticketFilters)));
409
+ }
410
+ fetchFiltersByTicket() {
411
+ return this.http
412
+ .get(GET_FILTERS_BY_TICKET, { params: { ticket: this.ticketFilter } })
413
+ .pipe(map((response) => response.filters ?? []), catchError(() => of([])));
414
+ }
415
+ mergeTicketValues(filters, ticketFilters) {
416
+ if (!ticketFilters.length) {
417
+ return filters;
418
+ }
419
+ const ticketValueMap = this.buildTicketValueMap(ticketFilters);
420
+ return filters.map((filter) => {
421
+ const key = this.getTicketKey(filter.domain, filter.name);
422
+ const ticketValue = ticketValueMap.get(key);
423
+ if (ticketValue === undefined) {
424
+ return filter;
425
+ }
426
+ return { ...filter, value: this.buildMergedValue(filter, ticketValue) };
427
+ });
428
+ }
429
+ /**
430
+ * Reconstrói o valor do filtro a partir dos itens do ticket (que contém apenas as chaves),
431
+ * reaproveitando o objeto completo já presente no filtro base quando a chave corresponde —
432
+ * preservando assim o texto de exibição. Chaves ausentes no base são mantidas como estão
433
+ * e resolvidas posteriormente pela busca de sugestões.
434
+ */
435
+ buildMergedValue(filter, ticketValue) {
436
+ const ticketItems = this.parseJsonArray(ticketValue);
437
+ if (!ticketItems) {
438
+ return ticketValue;
439
+ }
440
+ const baseItemsByKey = this.indexBaseItemsByKey(filter);
441
+ const mergedItems = ticketItems.map((ticketItem) => baseItemsByKey.get(String(ticketItem)) ?? ticketItem);
442
+ return JSON.stringify(mergedItems);
443
+ }
444
+ indexBaseItemsByKey(filter) {
445
+ const baseItems = this.parseJsonArray(filter.value);
446
+ const keyFields = this.getSearchOutput(filter)?.keyFields ?? [];
447
+ const itemsByKey = new Map();
448
+ if (!baseItems || !keyFields.length) {
449
+ return itemsByKey;
450
+ }
451
+ baseItems.forEach((item) => {
452
+ if (item && typeof item === 'object') {
453
+ const record = item;
454
+ const compositeKey = keyFields.map((field) => record[field]).join(', ');
455
+ itemsByKey.set(compositeKey, item);
456
+ }
457
+ });
458
+ return itemsByKey;
459
+ }
460
+ getSearchOutput(filter) {
461
+ return filter.search?.basicSearch?.output ?? filter.search?.entitySearch?.output;
462
+ }
463
+ parseJsonArray(value) {
464
+ try {
465
+ const parsed = value && JSON.parse(value);
466
+ return Array.isArray(parsed) ? parsed : null;
467
+ }
468
+ catch {
469
+ return null;
470
+ }
471
+ }
472
+ buildTicketValueMap(ticketFilters) {
473
+ return ticketFilters.reduce((valueMap, ticketFilter) => {
474
+ const key = this.getTicketKey(ticketFilter.domain, ticketFilter.name);
475
+ valueMap.set(key, this.normalizeTicketValue(ticketFilter.value));
476
+ return valueMap;
477
+ }, new Map());
478
+ }
479
+ normalizeTicketValue(value) {
480
+ return typeof value === 'string' ? value : JSON.stringify(value);
481
+ }
482
+ getTicketKey(domain, name) {
483
+ return `${domain}:${name}`;
484
+ }
404
485
  mapFilters(filters) {
405
486
  return filters.map((filter) => {
406
487
  try {
407
488
  const value = filter.value && JSON.parse(filter.value);
408
- this.applySearchMapping(filter, value);
409
- this.assignFilterValue(filter, value);
489
+ const mappedValue = this.applySearchMapping(filter, value);
490
+ this.assignFilterValue(filter, mappedValue);
410
491
  }
411
492
  catch (ex) {
412
493
  console.error(`Global: filter ${filter.name} has value error. `, ex);
@@ -416,15 +497,11 @@ class AdvancedFilterService {
416
497
  });
417
498
  }
418
499
  applySearchMapping(filter, value) {
419
- const basicOutput = filter.search?.basicSearch?.output;
420
- if (value && basicOutput) {
421
- this.mapValues(value, basicOutput.keyFields, basicOutput.displayFields);
422
- return;
423
- }
424
- const entityOutput = filter.search?.entitySearch?.output;
425
- if (value && entityOutput) {
426
- this.mapValues(value, entityOutput.keyFields, entityOutput.displayFields);
500
+ const output = filter.search?.basicSearch?.output ?? filter.search?.entitySearch?.output;
501
+ if (value && output) {
502
+ return this.mapValues(value, output.keyFields, output.displayFields);
427
503
  }
504
+ return value;
428
505
  }
429
506
  assignFilterValue(filter, value) {
430
507
  if (!value) {
@@ -453,29 +530,31 @@ class AdvancedFilterService {
453
530
  }
454
531
  mapValues(value, keyFields, displayFields) {
455
532
  if (Array.isArray(value)) {
456
- value.forEach((e) => {
457
- this.mapValue(e, keyFields, displayFields);
458
- });
459
- }
460
- else {
461
- this.mapValue(value, keyFields, displayFields);
533
+ return value.map((item) => this.mapValue(item, keyFields, displayFields));
462
534
  }
535
+ return this.mapValue(value, keyFields, displayFields);
463
536
  }
464
537
  mapValue(value, keyFields, displayFields) {
465
538
  if (!value) {
466
- return;
539
+ return value;
467
540
  }
468
- const ids = [];
469
- const displays = [];
470
- keyFields.filter((e) => value[e] !== undefined).forEach((e) => ids.push(value[e]));
471
- displayFields.filter((e) => value[e] !== undefined).forEach((e) => displays.push(value[e]));
472
- if (ids.length > 0 && displays.length > 0) {
473
- value[searchKeyName] = ids.join(', ');
474
- value[searchDisplayName] = displays.join(', ');
541
+ if (this.isPrimitiveValue(value)) {
542
+ return { [searchKeyName]: value, [searchDisplayName]: value };
475
543
  }
476
- else {
477
- value = [''];
544
+ const ids = keyFields.filter((field) => value[field] !== undefined).map((field) => value[field]);
545
+ const displays = displayFields.filter((field) => value[field] !== undefined).map((field) => value[field]);
546
+ const { value: _conflictingValue, ...rest } = value;
547
+ if (ids.length > 0 && displays.length > 0) {
548
+ return {
549
+ ...rest,
550
+ [searchKeyName]: ids.join(', '),
551
+ [searchDisplayName]: displays.join(', ')
552
+ };
478
553
  }
554
+ return rest;
555
+ }
556
+ isPrimitiveValue(value) {
557
+ return typeof value === 'string' || typeof value === 'number';
479
558
  }
480
559
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AdvancedFilterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
481
560
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AdvancedFilterService });
@@ -892,6 +971,7 @@ class FormFilterComponent {
892
971
  formFilters = [];
893
972
  oldFormFilters = [];
894
973
  actualFormFilters = [];
974
+ lastSuggestions = new Map();
895
975
  general = new TabView({ name: 'Geral' });
896
976
  totalFiltersActive = 0;
897
977
  isMobile = false;
@@ -919,7 +999,7 @@ class FormFilterComponent {
919
999
  this.tabViewOrientation = this.isMobile ? 'top' : 'left';
920
1000
  this.subscribeContextsObservable();
921
1001
  this.subscribeFiltersObservable();
922
- window.addEventListener('message', event => {
1002
+ window.addEventListener('message', (event) => {
923
1003
  const data = event.data;
924
1004
  const message = data.message && data.message.split(':')[1];
925
1005
  if (message === 'addContext') {
@@ -958,7 +1038,9 @@ class FormFilterComponent {
958
1038
  const message = {
959
1039
  severity: 'info',
960
1040
  duration: TOAST_LIFE,
961
- text: this.translate.instant(`${TRANSLATE_PREFIX$1}.applied_filter_nochange`, { activeFilters: this.totalFiltersActive })
1041
+ text: this.translate.instant(`${TRANSLATE_PREFIX$1}.applied_filter_nochange`, {
1042
+ activeFilters: this.totalFiltersActive
1043
+ })
962
1044
  };
963
1045
  this.sendMessage(message);
964
1046
  }
@@ -972,7 +1054,7 @@ class FormFilterComponent {
972
1054
  }
973
1055
  clearFilters() {
974
1056
  const keys = Object.keys(this.formFilters);
975
- keys.forEach(key => this.cleanFieldAndSetDefaultValue(key));
1057
+ keys.forEach((key) => this.cleanFieldAndSetDefaultValue(key));
976
1058
  }
977
1059
  sendCloseMessage() {
978
1060
  window.parent.postMessage({
@@ -1003,7 +1085,9 @@ class FormFilterComponent {
1003
1085
  const message = {
1004
1086
  severity: 'info',
1005
1087
  duration: TOAST_LIFE,
1006
- text: this.translate.instant(`${TRANSLATE_PREFIX$1}.saved_filters_success`, { activeFilters: this.totalFiltersActive })
1088
+ text: this.translate.instant(`${TRANSLATE_PREFIX$1}.saved_filters_success`, {
1089
+ activeFilters: this.totalFiltersActive
1090
+ })
1007
1091
  };
1008
1092
  this.sendMessage(message);
1009
1093
  }
@@ -1013,19 +1097,17 @@ class FormFilterComponent {
1013
1097
  const message = {
1014
1098
  severity: 'error',
1015
1099
  duration: TOAST_LIFE,
1016
- text: this.translate.instant(`${TRANSLATE_PREFIX$1}.saved_filters_error`, { activeFilters: this.totalFiltersActive })
1100
+ text: this.translate.instant(`${TRANSLATE_PREFIX$1}.saved_filters_error`, {
1101
+ activeFilters: this.totalFiltersActive
1102
+ })
1017
1103
  };
1018
1104
  this.sendMessage(message);
1019
1105
  };
1020
- this.filterService
1021
- .saveFilters(filters)
1022
- .subscribe(savedFilterSuccess, savedFiltersError);
1106
+ this.filterService.saveFilters(filters).subscribe(savedFilterSuccess, savedFiltersError);
1023
1107
  }
1024
1108
  saveFiltersWithCallbackFunction(callbackFunction) {
1025
1109
  const filters = this.parseToUserFilters(this.formFilters);
1026
- this.filterService
1027
- .saveFilters(filters)
1028
- .subscribe(callbackFunction);
1110
+ this.filterService.saveFilters(filters).subscribe(callbackFunction);
1029
1111
  }
1030
1112
  counterUpdate() {
1031
1113
  this.totalFiltersActive = this.countActiveFilters(this.tabs);
@@ -1033,7 +1115,7 @@ class FormFilterComponent {
1033
1115
  }
1034
1116
  countActiveFilters(tabs) {
1035
1117
  let totalFiltersActive = 0;
1036
- tabs.forEach(tabView => {
1118
+ tabs.forEach((tabView) => {
1037
1119
  const { value } = tabView.form;
1038
1120
  tabView.activeFilters = Object.keys(value).reduce((appliedFilters, key) => {
1039
1121
  const filterValue = value[key];
@@ -1054,7 +1136,7 @@ class FormFilterComponent {
1054
1136
  return ids.reduce((all, filterId) => {
1055
1137
  const { type, services, name, value, domain, contexts } = filtersAsObject[filterId];
1056
1138
  const filterValue = toUserFormat(value, type);
1057
- const values = services.map(service => ({ name, service, value: filterValue, domain, contexts }));
1139
+ const values = services.map((service) => ({ name, service, value: filterValue, domain, contexts }));
1058
1140
  return [...all, ...values];
1059
1141
  }, []);
1060
1142
  }
@@ -1064,7 +1146,7 @@ class FormFilterComponent {
1064
1146
  return ids.reduce((all, filterId) => {
1065
1147
  const { type, services, name, value, domain } = filtersAsObject[filterId];
1066
1148
  const filterValue = toFilterFormat(value, type);
1067
- const values = services.map(service => ({ name, service, value: filterValue, domain }));
1149
+ const values = services.map((service) => ({ name, service, value: filterValue, domain }));
1068
1150
  return [...all, ...values];
1069
1151
  }, []);
1070
1152
  }
@@ -1077,9 +1159,7 @@ class FormFilterComponent {
1077
1159
  }
1078
1160
  subscribeFiltersObservable() {
1079
1161
  const { filtersObserver } = this.filterService;
1080
- filtersObserver
1081
- .pipe(takeUntil(this.destroy$))
1082
- .subscribe(({ filters, applyFilter, error, message }) => {
1162
+ filtersObserver.pipe(takeUntil(this.destroy$)).subscribe(({ filters, applyFilter, error, message }) => {
1083
1163
  this.errorOutput.emit(error);
1084
1164
  this.error = error;
1085
1165
  this.errorState = message;
@@ -1099,15 +1179,15 @@ class FormFilterComponent {
1099
1179
  }
1100
1180
  setDependencies(filters) {
1101
1181
  const filtersMap = {};
1102
- filters.forEach(f => {
1182
+ filters.forEach((f) => {
1103
1183
  const id = getFilterId(f.domain, f.name);
1104
1184
  filtersMap[id] = f;
1105
1185
  });
1106
1186
  const names = Object.keys(filtersMap);
1107
- const dependencies = from(names).pipe(map(key => filtersMap[key]), filter(({ dependsOn }) => dependsOn && dependsOn.length > 0), tap(({ dependsOn, domain, filterControl }) => {
1187
+ const dependencies = from(names).pipe(map((key) => filtersMap[key]), filter(({ dependsOn }) => dependsOn && dependsOn.length > 0), tap(({ dependsOn, domain, filterControl }) => {
1108
1188
  const invalidFilters = dependsOn
1109
- .filter(dep => dep.required)
1110
- .filter(dep => {
1189
+ .filter((dep) => dep.required)
1190
+ .filter((dep) => {
1111
1191
  const id = getFilterId(domain, dep.filterName);
1112
1192
  const formFilter = filtersMap[id];
1113
1193
  if (!formFilter) {
@@ -1126,8 +1206,8 @@ class FormFilterComponent {
1126
1206
  }
1127
1207
  }), map(({ domain, dependsOn, filterControl }) => ({ domain, dependsOn, filterControl })));
1128
1208
  dependencies.subscribe(({ dependsOn, domain, filterControl }) => from(dependsOn)
1129
- .pipe(filter(dep => dep.required), map(({ filterName }) => getFilterId(domain, filterName)), map(filterId => filtersMap[filterId]), mergeMap(formFilter => from(formFilter.valueChanges || [])), map(val => {
1130
- const comparation = dependsOn.every(dep => {
1209
+ .pipe(filter((dep) => dep.required), map(({ filterName }) => getFilterId(domain, filterName)), map((filterId) => filtersMap[filterId]), mergeMap((formFilter) => from(formFilter.valueChanges || [])), map((val) => {
1210
+ const comparation = dependsOn.every((dep) => {
1131
1211
  const filterId = getFilterId(domain, dep.filterName);
1132
1212
  if (this.formFilters[filterId]) {
1133
1213
  const type = this.formFilters[filterId].type;
@@ -1142,15 +1222,15 @@ class FormFilterComponent {
1142
1222
  });
1143
1223
  return !this.IsEmpty(val) && comparation ? 'enable' : 'disable';
1144
1224
  }))
1145
- .subscribe(status => filterControl[status]()));
1225
+ .subscribe((status) => filterControl[status]()));
1146
1226
  }
1147
1227
  addGeneralField(filter) {
1148
1228
  const { name, domain, type } = filter;
1149
1229
  const controlName = getFilterId(domain, name);
1150
1230
  const fieldControl = createFormControl(filter);
1151
1231
  fieldControl.valueChanges
1152
- .pipe(takeUntil(this.destroy$), map(v => parseFilterValue(v, type)), tap(value => (this.formFilters[controlName].value = value)))
1153
- .subscribe(val => this.tabs.forEach(tab => {
1232
+ .pipe(takeUntil(this.destroy$), map((v) => parseFilterValue(v, type)), tap((value) => (this.formFilters[controlName].value = value)))
1233
+ .subscribe((val) => this.tabs.forEach((tab) => {
1154
1234
  const control = tab.form.controls[name];
1155
1235
  if (control && tab.domain === domain) {
1156
1236
  control.setValue(val, { emitEvent: false });
@@ -1171,7 +1251,7 @@ class FormFilterComponent {
1171
1251
  if (!myContexts.length) {
1172
1252
  return true;
1173
1253
  }
1174
- const allContexts = this.contexts.map(data => data.contextId);
1254
+ const allContexts = this.contexts.map((data) => data.contextId);
1175
1255
  return equals(myContexts.sort(), allContexts.sort());
1176
1256
  }
1177
1257
  /**
@@ -1201,18 +1281,18 @@ class FormFilterComponent {
1201
1281
  if (scope === Scope.DOMAIN && this.containsAllContexts(contexts)) {
1202
1282
  this.addGeneralField(filter);
1203
1283
  }
1204
- contexts.forEach(contextId => {
1205
- if ((contextId === this.contextId) || (this.contextId === '')) {
1284
+ contexts.forEach((contextId) => {
1285
+ if (contextId === this.contextId || this.contextId === '') {
1206
1286
  const tabId = getTabId(domain, contextId);
1207
1287
  const fieldControl = createFormControl(filter);
1208
1288
  if (!tabs.has(tabId)) {
1209
- const { contextLabel } = this.contexts.find(context => context.contextId === contextId);
1289
+ const { contextLabel } = this.contexts.find((context) => context.contextId === contextId);
1210
1290
  const tab = new ContextTab({ domain, name: contextLabel });
1211
1291
  tabs.set(tabId, tab);
1212
1292
  }
1213
- fieldControl.valueChanges
1214
- .pipe(takeUntil(this.destroy$))
1215
- .subscribe((val) => this.updateFilterValue(tabId, name, val, domain, type));
1293
+ fieldControl.valueChanges.pipe(takeUntil(this.destroy$)).subscribe((val) => {
1294
+ this.updateFilterValue(tabId, name, val, domain, type);
1295
+ });
1216
1296
  const contextTab = tabs.get(tabId);
1217
1297
  contextTab.addField(field);
1218
1298
  contextTab.form.addControl(filter.name, fieldControl);
@@ -1226,20 +1306,36 @@ class FormFilterComponent {
1226
1306
  }
1227
1307
  updateFilterValue(tabId, filterName, value, domain, type) {
1228
1308
  const controlOpts = { emitEvent: false };
1229
- const fieldValue = parseFilterValue(value, type);
1230
1309
  const filterId = getFilterId(domain, filterName);
1310
+ const normalizedValue = this.normalizeSearchValue(value, type, filterId);
1311
+ const fieldValue = parseFilterValue(normalizedValue, type);
1231
1312
  const generalFieldControl = this.general.form.controls[filterId];
1313
+ const valueChanged = !equals(value, normalizedValue);
1232
1314
  this.tabs.forEach(({ form }, key) => {
1233
1315
  const control = form.controls[filterName];
1234
- if (tabId !== key && control) {
1235
- control.setValue(value, controlOpts);
1316
+ if (control && (tabId !== key || valueChanged)) {
1317
+ control.setValue(normalizedValue, controlOpts);
1236
1318
  }
1237
1319
  });
1238
1320
  const { childs } = this.formFilters[filterId];
1239
1321
  childs && childs.forEach((child) => this.cleanFieldAndSetDefaultValue(child.filter.key));
1240
- generalFieldControl && generalFieldControl.setValue(value, controlOpts);
1322
+ generalFieldControl && generalFieldControl.setValue(normalizedValue, controlOpts);
1241
1323
  this.formFilters[filterId].value = fieldValue;
1242
1324
  }
1325
+ normalizeSearchValue(value, type, filterId) {
1326
+ if (type !== FilterType.SEARCH || !Array.isArray(value)) {
1327
+ return value;
1328
+ }
1329
+ const suggestions = this.lastSuggestions.get(filterId) ?? [];
1330
+ return value.map((item) => this.resolveSearchItem(item, suggestions));
1331
+ }
1332
+ resolveSearchItem(item, suggestions) {
1333
+ if (item === null || item === '' || typeof item === 'object') {
1334
+ return item;
1335
+ }
1336
+ const matched = suggestions.find((suggestion) => suggestion[searchDisplayName] === item || suggestion[searchKeyName] === item);
1337
+ return matched ?? { [searchKeyName]: item, [searchDisplayName]: item };
1338
+ }
1243
1339
  cleanFieldAndSetDefaultValue(key) {
1244
1340
  const { isMultiple, defaultValue, filterControl, type } = this.formFilters[key];
1245
1341
  const finalValue = this.getDefaultValue(defaultValue, isMultiple);
@@ -1257,7 +1353,7 @@ class FormFilterComponent {
1257
1353
  }
1258
1354
  createChildArray() {
1259
1355
  const keys = Object.keys(this.formFilters);
1260
- keys.forEach(key => {
1356
+ keys.forEach((key) => {
1261
1357
  const { dependsOn, domain } = this.formFilters[key];
1262
1358
  dependsOn.forEach((field) => {
1263
1359
  const filterId = getFilterId(domain, field.filterName);
@@ -1272,11 +1368,16 @@ class FormFilterComponent {
1272
1368
  }
1273
1369
  createField(filter) {
1274
1370
  const { name, label, enumItems, type, mask } = filter;
1275
- const translatedEnumItems = enumItems && enumItems.map((item) => ({ label: this.translate.instant(item.label), value: item.value }));
1276
- const field = { name, label: this.translate.instant(label), placeholder: '' };
1371
+ const translatedEnumItems = enumItems &&
1372
+ enumItems.map((item) => ({ label: this.translate.instant(item.label), value: item.value }));
1373
+ const field = {
1374
+ name,
1375
+ label: this.translate.instant(label),
1376
+ placeholder: ''
1377
+ };
1277
1378
  const creators = {
1278
1379
  [FilterType.STRING]: () => ({ ...field, mask: mask ? () => mask : null, type: 'string' }),
1279
- [FilterType.MONEY]: () => ({ ...field, type: 'money', }),
1380
+ [FilterType.MONEY]: () => ({ ...field, type: 'money' }),
1280
1381
  [FilterType.BOOLEAN]: () => this.createRadioButton({ ...field }),
1281
1382
  [FilterType.DATE]: () => this.createCalendar({ ...field, type: 'date' }),
1282
1383
  [FilterType.DATETIME]: () => this.createCalendar({ ...field, type: 'dateTime' }),
@@ -1310,7 +1411,7 @@ class FormFilterComponent {
1310
1411
  const calendar = {
1311
1412
  ...config,
1312
1413
  type: config.type,
1313
- name: config.name ?? '',
1414
+ name: config.name ?? ''
1314
1415
  };
1315
1416
  calendar.appendTo = 'body';
1316
1417
  calendar.calendarLocaleOptions = this.calendarOptionsService.getOptions();
@@ -1322,7 +1423,11 @@ class FormFilterComponent {
1322
1423
  const { displayFields, keyFields, resultDataJsonPath, displayFieldConcatToken, maxSelectedItems } = getSearchType(search).output;
1323
1424
  const filterId = getFilterId(domain, name);
1324
1425
  const suggestionsError = (messageError) => {
1325
- const messageDetail = messageError ? messageError : this.translate.instant(`${TRANSLATE_PREFIX$1}.find_suggestions_error`, { activeFilters: this.totalFiltersActive });
1426
+ const messageDetail = messageError
1427
+ ? messageError
1428
+ : this.translate.instant(`${TRANSLATE_PREFIX$1}.find_suggestions_error`, {
1429
+ activeFilters: this.totalFiltersActive
1430
+ });
1326
1431
  const message = {
1327
1432
  severity: 'error',
1328
1433
  duration: TOAST_LIFE,
@@ -1338,8 +1443,8 @@ class FormFilterComponent {
1338
1443
  : getSearchType(search).input.url;
1339
1444
  this.filterService
1340
1445
  .searchFieldSuggestions(searchUrl, params, search.type)
1341
- .pipe(map(response => jsonPath(response, resultDataJsonPath)), map((suggestions) => this.addSuggestionFields(suggestions, displayFields, keyFields, displayFieldConcatToken, filterId)))
1342
- .subscribe(result => {
1446
+ .pipe(map((response) => jsonPath(response, resultDataJsonPath)), map((suggestions) => this.addSuggestionFields(suggestions, displayFields, keyFields, displayFieldConcatToken, filterId)))
1447
+ .subscribe((result) => {
1343
1448
  suggestionsObservable.next(result);
1344
1449
  this.changeDetectorRef.detectChanges();
1345
1450
  }, (error) => {
@@ -1360,7 +1465,7 @@ class FormFilterComponent {
1360
1465
  dataKey: searchKeyName,
1361
1466
  multiple: maxSelectedItems > 1,
1362
1467
  size: { lg: 12, md: 12, xl: 12 },
1363
- emptyMessage: this.translate.instant(`${TRANSLATE_PREFIX$1}.search_empty_message`),
1468
+ emptyMessage: this.translate.instant(`${TRANSLATE_PREFIX$1}.search_empty_message`)
1364
1469
  };
1365
1470
  }
1366
1471
  safeReplaceCommas(input, operator) {
@@ -1421,9 +1526,9 @@ class FormFilterComponent {
1421
1526
  getEntitySearchUrl(search, value, dependsOn) {
1422
1527
  const { attributes, domainName, entityName, serviceName } = search;
1423
1528
  const url = `${domainName}/${serviceName}/entities/${entityName}/?filter=`;
1424
- const filters = attributes.map(attr => filterOperators[attr.comparator](attr.name, value));
1529
+ const filters = attributes.map((attr) => filterOperators[attr.comparator](attr.name, value));
1425
1530
  dependsOn &&
1426
- dependsOn.forEach(obj => {
1531
+ dependsOn.forEach((obj) => {
1427
1532
  const filterId = getFilterId(domainName, obj.filterName);
1428
1533
  const fieldValue = this.formFilters[filterId].value[searchKeyName];
1429
1534
  filters.push(`${obj.entityAttribute} eq '${fieldValue}'`);
@@ -1434,18 +1539,22 @@ class FormFilterComponent {
1434
1539
  }
1435
1540
  addSuggestionFields(suggestions, displayFields, keyFields, separator, filterId) {
1436
1541
  const addValue = (acc, value, token) => (acc ? `${acc}${token}${value}` : value);
1437
- const result = suggestions.map(suggestion => ({
1438
- ...suggestion,
1439
- [searchDisplayName]: displayFields.reduce((value, display) => {
1440
- return addValue(value, this.translate.instant(suggestion[display]), separator);
1441
- }, ''),
1442
- [searchKeyName]: keyFields.reduce((value, key) => addValue(value, suggestion[key], ', '), '')
1443
- }));
1542
+ const result = suggestions.map((suggestion) => {
1543
+ const { value: _conflictingValue, ...rest } = suggestion;
1544
+ return {
1545
+ ...rest,
1546
+ [searchDisplayName]: displayFields.reduce((display, field) => {
1547
+ return addValue(display, this.translate.instant(suggestion[field]), separator);
1548
+ }, ''),
1549
+ [searchKeyName]: keyFields.reduce((key, field) => addValue(key, suggestion[field], ', '), '')
1550
+ };
1551
+ });
1444
1552
  this.formFilters[filterId].invalidValue = result.length === 0;
1445
- return result.filter(item => {
1553
+ this.lastSuggestions.set(filterId, result);
1554
+ return result.filter((item) => {
1446
1555
  const { value } = this.formFilters[filterId];
1447
1556
  if (Array.isArray(value)) {
1448
- const index = value.findIndex((i) => i.$$__keyValue__ === item.$$__keyValue__);
1557
+ const index = value.findIndex((selected) => this.isSameSuggestion(selected, item));
1449
1558
  if (index === -1) {
1450
1559
  return item;
1451
1560
  }
@@ -1455,6 +1564,33 @@ class FormFilterComponent {
1455
1564
  }
1456
1565
  });
1457
1566
  }
1567
+ /**
1568
+ * Verifica se um item já selecionado corresponde a uma sugestão retornada pela busca.
1569
+ * A comparação primária é pelo keyValue. Para filtros salvos em formato antigo — onde o
1570
+ * keyValue foi gravado com o displayValue (ou o item é uma string pura) e portanto não casa
1571
+ * com o id atual das sugestões — é feito fallback pela comparação de displayValue.
1572
+ */
1573
+ isSameSuggestion(selected, suggestion) {
1574
+ const selectedKey = this.getSuggestionKey(selected);
1575
+ const selectedDisplay = this.getSuggestionDisplay(selected);
1576
+ if (selectedKey !== undefined && selectedKey === suggestion[searchKeyName]) {
1577
+ return true;
1578
+ }
1579
+ const isLegacySelected = selectedKey === undefined || selectedKey === selectedDisplay;
1580
+ return isLegacySelected && selectedDisplay !== undefined && selectedDisplay === suggestion[searchDisplayName];
1581
+ }
1582
+ getSuggestionKey(selected) {
1583
+ if (selected === null || selected === undefined) {
1584
+ return undefined;
1585
+ }
1586
+ return typeof selected === 'object' ? selected[searchKeyName] : selected;
1587
+ }
1588
+ getSuggestionDisplay(selected) {
1589
+ if (selected === null || selected === undefined) {
1590
+ return undefined;
1591
+ }
1592
+ return typeof selected === 'object' ? selected[searchDisplayName] : selected;
1593
+ }
1458
1594
  getDependenciesValues(dependencies, domain) {
1459
1595
  return dependencies.reduce((params, { filterName }) => {
1460
1596
  const filterId = getFilterId(domain, filterName);
@@ -1465,7 +1601,7 @@ class FormFilterComponent {
1465
1601
  }
1466
1602
  else {
1467
1603
  if (Array.isArray(value)) {
1468
- params[filterName] = value.map(arr => arr[searchKeyName]);
1604
+ params[filterName] = value.map((arr) => arr[searchKeyName]);
1469
1605
  }
1470
1606
  else {
1471
1607
  params[filterName] = value ? value[searchKeyName] : [''];
@@ -1480,7 +1616,7 @@ class FormFilterComponent {
1480
1616
  * Verifica se o valor informado é falso, em arrays, é verificado cada item
1481
1617
  */
1482
1618
  IsEmpty(value) {
1483
- return Array.isArray(value) ? value.every(data => !data) : !value;
1619
+ return Array.isArray(value) ? value.every((data) => !data) : !value;
1484
1620
  }
1485
1621
  /**
1486
1622
  * Return format to specify for integer type field
@@ -1620,7 +1756,7 @@ class AdvancedFilterComponent {
1620
1756
  this.totalFiltersActive = event;
1621
1757
  }
1622
1758
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AdvancedFilterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1623
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: AdvancedFilterComponent, selector: "s-advanced-filter", inputs: { labelButton: "labelButton", onlyContent: "onlyContent", hideButtons: "hideButtons", canOpenFilter: "canOpenFilter", showActiveFiltersCountBadge: "showActiveFiltersCountBadge", filterAndSave: "filterAndSave", contextId: "contextId" }, host: { listeners: { "window:resize": "onResizeWindow($event)" } }, viewQueries: [{ propertyName: "modalComponent", first: true, predicate: FormFilterComponent, descendants: true }, { propertyName: "filterButtonRef", first: true, predicate: ["filterButtonRef"], descendants: true, read: ElementRef }], ngImport: i0, template: "<s-button\n #filterButtonRef\n *ngIf=\"!onlyContent\"\n [id]=\"'filterButton'\"\n [disabled]=\"!canOpenFilter\"\n (clicked)=\"canOpenFilter ? toggleDialog() : ''\"\n iconClass=\"fa fa-filter\"\n priority=\"default\"\n [label]=\"labelButton\"\n [auxiliary]=\"true\"\n [tooltip]=\"appliedFiltersTooltip\"\n>\n <span aria-live=\"polite\">\n <span\n *ngIf=\"totalFiltersActive && showActiveFiltersCountBadge\"\n class=\"sds-badge-number sds-color-primary custom-badge\"\n >{{ totalFiltersActive }}</span\n >\n <span class=\"sr-only\" *ngIf=\"totalFiltersActive && showActiveFiltersCountBadge\">\n {{ totalFiltersActive }} {{ 'platform.filter_service.active_filters' | translate }}\n </span>\n </span>\n</s-button>\n\n<section *ngIf=\"onlyContent\">\n <div class=\"only-content-wrapper\">\n <div class=\"header\">\n <h3 id=\"filter-heading\">{{ 'platform.filter_service.filters' | translate }}</h3>\n <button\n type=\"button\"\n (click)=\"close()\"\n class=\"close_btn\"\n [attr.aria-label]=\"'platform.filter_service.aria_close_filters' | translate\"\n >\n <span class=\"fa fa-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 [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 (clicked)=\"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 [menuOptions]=\"mobileButtonActions\"\n ></s-button>\n <ng-container *ngIf=\"!isMobile\">\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.clear')\"\n (clicked)=\"clearFilters()\"\n ></s-button>\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.save')\"\n (clicked)=\"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 (clicked)=\"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 [header]=\"'platform.filter_service.filters' | translate\"\n [closeAriaLabel]=\"'platform.filter_service.aria_close_dialog' | translate\"\n [draggable]=\"false\"\n [modal]=\"true\"\n [(visible)]=\"showDialog\"\n [blockScroll]=\"true\"\n [closable]=\"true\"\n [closeOnEscape]=\"true\"\n [focusOnShow]=\"false\"\n (onShow)=\"focusFirstField()\"\n (onHide)=\"onDialogHide()\"\n>\n\n <s-app-form-filter\n [showMessages]=\"true\"\n (errorOutput)=\"onError($event)\"\n (totalFiltersActiveOutput)=\"updateTotalFiltersActive($event)\"\n [contextId]=\"contextId\"\n ></s-app-form-filter>\n\n <ng-template pTemplate=\"footer\">\n <ng-container *ngIf=\"!error && !hideButtons\">\n <s-button\n type=\"submit\"\n priority=\"primary\"\n [label]=\"translate.instant('platform.filter_service.filter')\"\n (clicked)=\"applyFilters()\"\n ></s-button>\n <ng-container *ngIf=\"!isMobile\">\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.save')\"\n (clicked)=\"saveFilters()\"\n ></s-button>\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.clear')\"\n (clicked)=\"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 [menuOptions]=\"mobileButtonActions\"\n ></s-button>\n <s-button\n priority=\"link\"\n [label]=\"translate.instant('platform.filter_service.cancel')\"\n (clicked)=\"toggleDialog(); close()\"\n ></s-button>\n </ng-container>\n </ng-template>\n</p-dialog>\n\n<p-toast key=\"filterServiceToastKey\" [baseZIndex]=\"5000\"></p-toast>\n", 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:solid 1px black;border-radius:1.5rem;background:transparent;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{align-content:center;justify-self:right;margin-left:auto;background:none;border:none;padding:0;font:inherit;color:inherit}.close_btn:hover{cursor:pointer}.header{text-transform:uppercase;display:flex;width:100%;border-bottom:1px solid #e5eaea;padding:15px;margin-left:0}@media (min-width: 641px) and (max-width: 1024px){.filter-dialog{width:75%}.filter-dialog>.ui-dialog-content{height:300px}}@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation: portrait){.filter-dialog{width:75%}.filter-dialog>.ui-dialog-content{height:90%}}@media (min-width: 320px) and (max-width: 640px){.filter-dialog{width:95%;left:0;top:0;opacity:1;margin:auto;height:93%}.filter-dialog>.ui-dialog-content{height:85%}}@media (min-width: 320px) and (max-width: 640px) and (max-width: 360px){.filter-dialog button{padding:0!important}.filter-dialog>.ui-dialog-content{height:81%}}\n"], dependencies: [{ kind: "component", type: i1$2.Dialog, selector: "p-dialog", inputs: ["header", "draggable", "resizable", "positionLeft", "positionTop", "contentStyle", "contentStyleClass", "modal", "closeOnEscape", "dismissableMask", "rtl", "closable", "responsive", "appendTo", "breakpoints", "styleClass", "maskStyleClass", "maskStyle", "showHeader", "breakpoint", "blockScroll", "autoZIndex", "baseZIndex", "minX", "minY", "focusOnShow", "maximizable", "keepInViewport", "focusTrap", "transitionOptions", "closeIcon", "closeAriaLabel", "closeTabindex", "minimizeIcon", "maximizeIcon", "closeButtonProps", "maximizeButtonProps", "visible", "style", "position", "role", "content", "contentTemplate", "footerTemplate", "closeIconTemplate", "maximizeIconTemplate", "minimizeIconTemplate", "headlessTemplate"], outputs: ["onShow", "onHide", "visibleChange", "onResizeInit", "onResizeEnd", "onDragEnd", "onMaximize"] }, { kind: "directive", type: i2$1.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "component", type: i3$1.ButtonComponent, selector: "s-button", inputs: ["id", "label", "tooltip", "tooltipPosition", "iconClass", "rightIconClass", "caret", "styleClass", "baseZIndex", "disabled", "auxiliary", "type", "priority", "menuOptions", "size", "slide", "animation", "badge", "iconColor"], outputs: ["clicked"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i5.Toast, selector: "p-toast", inputs: ["key", "autoZIndex", "baseZIndex", "life", "style", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "breakpoints"], outputs: ["onClose"] }, { kind: "component", type: FormFilterComponent, selector: "s-app-form-filter", inputs: ["showMessages", "contextId"], outputs: ["totalFiltersActiveOutput", "errorOutput", "showDialogOutput", "closeModalOutput"] }, { kind: "pipe", type: TranslatePipe$1, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
1759
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: AdvancedFilterComponent, selector: "s-advanced-filter", inputs: { labelButton: "labelButton", onlyContent: "onlyContent", hideButtons: "hideButtons", canOpenFilter: "canOpenFilter", showActiveFiltersCountBadge: "showActiveFiltersCountBadge", filterAndSave: "filterAndSave", contextId: "contextId" }, host: { listeners: { "window:resize": "onResizeWindow($event)" } }, viewQueries: [{ propertyName: "modalComponent", first: true, predicate: FormFilterComponent, descendants: true }, { propertyName: "filterButtonRef", first: true, predicate: ["filterButtonRef"], descendants: true, read: ElementRef }], ngImport: i0, template: "<s-button\n #filterButtonRef\n *ngIf=\"!onlyContent\"\n [id]=\"'filterButton'\"\n [disabled]=\"!canOpenFilter\"\n (clicked)=\"canOpenFilter ? toggleDialog() : ''\"\n iconClass=\"fa fa-filter\"\n priority=\"default\"\n [label]=\"labelButton\"\n [auxiliary]=\"true\"\n [tooltip]=\"appliedFiltersTooltip\"\n>\n <span aria-live=\"polite\">\n <span\n *ngIf=\"totalFiltersActive && showActiveFiltersCountBadge\"\n class=\"sds-badge-number sds-color-primary custom-badge\"\n >{{ totalFiltersActive }}</span\n >\n <span class=\"sr-only\" *ngIf=\"totalFiltersActive && showActiveFiltersCountBadge\">\n {{ totalFiltersActive }} {{ 'platform.filter_service.active_filters' | translate }}\n </span>\n </span>\n</s-button>\n\n<section *ngIf=\"onlyContent\">\n <div class=\"only-content-wrapper\">\n <div class=\"header\">\n <h3 id=\"filter-heading\">{{ 'platform.filter_service.filters' | translate }}</h3>\n <button\n type=\"button\"\n (click)=\"close()\"\n class=\"close_btn\"\n [attr.aria-label]=\"'platform.filter_service.aria_close_filters' | translate\"\n >\n <span class=\"fa fa-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 [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 (clicked)=\"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 [menuOptions]=\"mobileButtonActions\"\n ></s-button>\n <ng-container *ngIf=\"!isMobile\">\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.clear')\"\n (clicked)=\"clearFilters()\"\n ></s-button>\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.save')\"\n (clicked)=\"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 (clicked)=\"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 [header]=\"'platform.filter_service.filters' | translate\"\n [closeAriaLabel]=\"'platform.filter_service.aria_close_dialog' | translate\"\n [draggable]=\"false\"\n [modal]=\"true\"\n [(visible)]=\"showDialog\"\n [blockScroll]=\"true\"\n [closable]=\"true\"\n [closeOnEscape]=\"true\"\n [focusOnShow]=\"false\"\n (onShow)=\"focusFirstField()\"\n (onHide)=\"onDialogHide()\"\n>\n\n <s-app-form-filter\n [showMessages]=\"true\"\n (errorOutput)=\"onError($event)\"\n (totalFiltersActiveOutput)=\"updateTotalFiltersActive($event)\"\n [contextId]=\"contextId\"\n ></s-app-form-filter>\n\n <ng-template pTemplate=\"footer\">\n <ng-container *ngIf=\"!error && !hideButtons\">\n <s-button\n type=\"submit\"\n priority=\"primary\"\n [label]=\"translate.instant('platform.filter_service.filter')\"\n (clicked)=\"applyFilters()\"\n ></s-button>\n <ng-container *ngIf=\"!isMobile\">\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.save')\"\n (clicked)=\"saveFilters()\"\n ></s-button>\n <s-button\n priority=\"secondary\"\n [label]=\"translate.instant('platform.filter_service.clear')\"\n (clicked)=\"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 [menuOptions]=\"mobileButtonActions\"\n ></s-button>\n <s-button\n priority=\"link\"\n [label]=\"translate.instant('platform.filter_service.cancel')\"\n (clicked)=\"toggleDialog(); close()\"\n ></s-button>\n </ng-container>\n </ng-template>\n</p-dialog>\n\n<p-toast key=\"filterServiceToastKey\" [baseZIndex]=\"5000\"></p-toast>\n", 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:solid 1px black;border-radius:1.5rem;background:transparent;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{align-content:center;justify-self:right;margin-left:auto;background:none;border:none;padding:0;font:inherit;color:inherit}.close_btn:hover{cursor:pointer}.header{text-transform:uppercase;display:flex;width:100%;border-bottom:1px solid #e5eaea;padding:15px;margin-left:0}@media (min-width: 641px) and (max-width: 1024px){.filter-dialog{width:75%}.filter-dialog>.ui-dialog-content{height:300px}}@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation: portrait){.filter-dialog{width:75%}.filter-dialog>.ui-dialog-content{height:90%}}@media (min-width: 320px) and (max-width: 640px){.filter-dialog{width:95%;left:0;top:0;opacity:1;margin:auto;height:93%}.filter-dialog>.ui-dialog-content{height:85%}}@media (min-width: 320px) and (max-width: 640px) and (max-width: 360px){.filter-dialog button{padding:0!important}.filter-dialog>.ui-dialog-content{height:81%}}\n"], dependencies: [{ kind: "component", type: i1$2.Dialog, selector: "p-dialog", inputs: ["header", "draggable", "resizable", "positionLeft", "positionTop", "contentStyle", "contentStyleClass", "modal", "closeOnEscape", "dismissableMask", "rtl", "closable", "responsive", "appendTo", "breakpoints", "styleClass", "maskStyleClass", "maskStyle", "showHeader", "breakpoint", "blockScroll", "autoZIndex", "baseZIndex", "minX", "minY", "focusOnShow", "maximizable", "keepInViewport", "focusTrap", "transitionOptions", "closeIcon", "closeAriaLabel", "closeTabindex", "minimizeIcon", "maximizeIcon", "closeButtonProps", "maximizeButtonProps", "visible", "style", "position", "role", "content", "contentTemplate", "footerTemplate", "closeIconTemplate", "maximizeIconTemplate", "minimizeIconTemplate", "headlessTemplate"], outputs: ["onShow", "onHide", "visibleChange", "onResizeInit", "onResizeEnd", "onDragEnd", "onMaximize"] }, { kind: "directive", type: i2$1.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "component", type: i3$1.ButtonComponent, selector: "s-button", inputs: ["id", "label", "tooltip", "tooltipPosition", "iconClass", "rightIconClass", "caret", "styleClass", "baseZIndex", "disabled", "auxiliary", "type", "priority", "menuOptions", "size", "slide", "animation", "badge", "iconColor", "menuAriaLabel", "ariaLabel"], outputs: ["clicked", "tieredMenuOpened", "tieredMenuClosed"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i5.Toast, selector: "p-toast", inputs: ["key", "autoZIndex", "baseZIndex", "life", "style", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "breakpoints"], outputs: ["onClose"] }, { kind: "component", type: FormFilterComponent, selector: "s-app-form-filter", inputs: ["showMessages", "contextId"], outputs: ["totalFiltersActiveOutput", "errorOutput", "showDialogOutput", "closeModalOutput"] }, { kind: "pipe", type: TranslatePipe$1, name: "translate" }], encapsulation: i0.ViewEncapsulation.None });
1624
1760
  }
1625
1761
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AdvancedFilterComponent, decorators: [{
1626
1762
  type: Component,
@@ -1817,9 +1953,24 @@ class Environment {
1817
1953
  domain;
1818
1954
  service;
1819
1955
  ignorePermissions;
1956
+ /**
1957
+ * Quando `true`, `PermissionsService.get()` propaga o erro da verificação de acesso
1958
+ * ao consumidor (como já faz `checkAccess()`), em vez de convertê-lo em permissões
1959
+ * negadas. Permite que o consumidor distinga uma falha de verificação de um "negado"
1960
+ * legítimo. Default: `false` (comportamento legado).
1961
+ */
1962
+ propagatePermissionErrors;
1820
1963
  }
1821
1964
 
1822
1965
  let promise;
1966
+ /**
1967
+ * Reinicia o cache interno de permissões (`promise`). Destinado a cenários de teste que
1968
+ * precisam garantir estado limpo entre casos, já que o cache é uma variável de módulo
1969
+ * compartilhada. Não faz parte da API pública da library (não é re-exportado em `public-api`).
1970
+ */
1971
+ function resetPermissionsCache() {
1972
+ promise = undefined;
1973
+ }
1823
1974
  class PermissionsService {
1824
1975
  resources = inject(RESOURCES);
1825
1976
  environment = inject(ENVIRONMENT);
@@ -1880,8 +2031,11 @@ class PermissionsService {
1880
2031
  return permissions[resourceKey];
1881
2032
  }
1882
2033
  return permissions;
1883
- }), catchError(() => {
2034
+ }), catchError((error) => {
1884
2035
  promise = undefined;
2036
+ if (this.environment.propagatePermissionErrors) {
2037
+ return throwError(() => error);
2038
+ }
1885
2039
  this.toastService.show({
1886
2040
  severity: 'error',
1887
2041
  title: this.translate.instant('permission_error_summary'),