@senior-gestao-empresarial/angular-components 7.17.0 → 7.18.0

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.
@@ -513,10 +513,31 @@ class ErpLookups {
513
513
  this.lookupService
514
514
  .list({ page, sort, filterQuery, displayFields }, this.entity, options.domain || this.domain, options.service || this.service)
515
515
  .pipe(takeUntil(this.ngUnsubscribe))
516
- .pipe(map((list) => ({
517
- gridData: list.contents.map((item) => (Object.assign(Object.assign({}, item), { label: this.getItemLabel(item, prefix, lookupDisplayFields) }))),
518
- totalRecords: list.totalElements
519
- })))
516
+ .pipe(map((list) => {
517
+ // Criar um mapa de campos com maxLength definido
518
+ const fieldsWithMaxLength = new Map();
519
+ [...(options.searchFields || this.searchFields), ...(options.searchGridFields || this.searchGridFields)]
520
+ .forEach((field) => {
521
+ if (field.maxLength &&
522
+ (field.type === FieldType.String || field.type === FieldType.Text)) {
523
+ fieldsWithMaxLength.set(field.name, field.maxLength);
524
+ }
525
+ });
526
+ return {
527
+ gridData: list.contents.map((item) => {
528
+ const processedItem = Object.assign({}, item);
529
+ // Aplicar maxLength nos campos que possuem a configuração
530
+ fieldsWithMaxLength.forEach((maxLength, fieldName) => {
531
+ if (processedItem[fieldName] && typeof processedItem[fieldName] === 'string'
532
+ && processedItem[fieldName].length > maxLength) {
533
+ processedItem[fieldName] = processedItem[fieldName].substring(0, maxLength) + '...';
534
+ }
535
+ });
536
+ return Object.assign(Object.assign({}, processedItem), { label: this.getItemLabel(processedItem, prefix, lookupDisplayFields) });
537
+ }),
538
+ totalRecords: list.totalElements
539
+ };
540
+ }))
520
541
  .subscribe((data) => {
521
542
  this.lookupSearchObservable.next(data);
522
543
  });