All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.utils.buildNestedAttributesPayload.js.map Maven / Gradle / Ivy

Go to download

A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.

There is a newer version: 4.12.3
Show newest version
{"version":3,"file":"buildNestedAttributesPayload.js","names":["findBy","isNotPresent","omit","buildNestedAttributesPayload","_ref","modifiedValues","initialValues","nestedKeyToModify","nestedAttributeKeyInPayload","nestedAttributesForArrayKey","itemsToDestroy","filter","initialItem","value","itemsToDestroyAttrs","map","item","_defineProperty","id","itemsToBeCreated","modifiedItem","toLowerCase","itemsToCreateAttrs","nestedAttributes","concat","_toConsumableArray","_objectSpread"],"sources":["../../src/utils/buildNestedAttributesPayload.js"],"sourcesContent":["import { findBy, isNotPresent } from \"neetocist\";\nimport { omit } from \"ramda\";\n\nexport const buildNestedAttributesPayload = ({\n  modifiedValues,\n  initialValues,\n  nestedKeyToModify,\n  nestedAttributeKeyInPayload,\n  nestedAttributesForArrayKey,\n}) => {\n  const itemsToDestroy = initialValues[nestedKeyToModify].filter(initialItem =>\n    isNotPresent(\n      findBy(\n        { value: initialItem[nestedAttributeKeyInPayload] },\n        modifiedValues[nestedKeyToModify]\n      )\n    )\n  );\n\n  const itemsToDestroyAttrs = itemsToDestroy.map(item => ({\n    id: item.id,\n    [nestedAttributeKeyInPayload]: item[nestedAttributeKeyInPayload],\n    _destroy: true,\n  }));\n\n  const itemsToBeCreated = modifiedValues[nestedKeyToModify].filter(\n    modifiedItem =>\n      isNotPresent(\n        findBy(\n          { [nestedAttributeKeyInPayload]: modifiedItem.value.toLowerCase() },\n          initialValues[nestedKeyToModify]\n        )\n      )\n  );\n\n  const itemsToCreateAttrs = itemsToBeCreated.map(item => ({\n    [nestedAttributeKeyInPayload]: item.value,\n  }));\n\n  const nestedAttributes = [...itemsToCreateAttrs, ...itemsToDestroyAttrs];\n\n  return {\n    ...omit([nestedKeyToModify], modifiedValues),\n    [nestedAttributesForArrayKey]: nestedAttributes,\n  };\n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