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

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.
@@ -525,12 +525,12 @@ class ErpLookups {
525
525
  });
526
526
  return {
527
527
  gridData: list.contents.map((item) => {
528
- const processedItem = Object.assign({}, item);
528
+ const processedItem = JSON.parse(JSON.stringify(item));
529
529
  // Aplicar maxLength nos campos que possuem a configuração
530
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) + '...';
531
+ const fieldValue = this.getNestedValue(processedItem, fieldName);
532
+ if (fieldValue && typeof fieldValue === 'string' && fieldValue.length > maxLength) {
533
+ this.setNestedValue(processedItem, fieldName, fieldValue.substring(0, maxLength) + '...');
534
534
  }
535
535
  });
536
536
  return Object.assign(Object.assign({}, processedItem), { label: this.getItemLabel(processedItem, prefix, lookupDisplayFields) });
@@ -553,6 +553,21 @@ class ErpLookups {
553
553
  })
554
554
  .join(" - ");
555
555
  }
556
+ getNestedValue(obj, path) {
557
+ return path.split(".").reduce((current, key) => {
558
+ return current && current[key] !== undefined ? current[key] : undefined;
559
+ }, obj);
560
+ }
561
+ setNestedValue(obj, path, value) {
562
+ const keys = path.split(".");
563
+ const lastKey = keys.pop();
564
+ const target = keys.reduce((current, key) => {
565
+ return current && current[key] !== undefined ? current[key] : undefined;
566
+ }, obj);
567
+ if (target && lastKey) {
568
+ target[lastKey] = value;
569
+ }
570
+ }
556
571
  };
557
572
  ErpLookups.ctorParameters = () => [
558
573
  { type: ErpLookupsService },