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

package.cjs.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":["_neetoCist","require","_ramda","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","buildNestedAttributesPayload","exports","_ref","modifiedValues","initialValues","nestedKeyToModify","nestedAttributeKeyInPayload","nestedAttributesForArrayKey","itemsToDestroy","initialItem","isNotPresent","findBy","value","itemsToDestroyAttrs","map","item","id","itemsToBeCreated","modifiedItem","toLowerCase","itemsToCreateAttrs","nestedAttributes","concat","_toConsumableArray2","omit"],"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};\n"],"mappings":";;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAA6B,SAAAE,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,QAAAe,gBAAA,aAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CAAAlB,CAAA,EAAAG,MAAA,CAAAc,yBAAA,CAAAf,CAAA,KAAAH,OAAA,CAAAI,MAAA,CAAAD,CAAA,GAAAa,OAAA,WAAAd,CAAA,IAAAE,MAAA,CAAAgB,cAAA,CAAAnB,CAAA,EAAAC,CAAA,EAAAE,MAAA,CAAAK,wBAAA,CAAAN,CAAA,EAAAD,CAAA,iBAAAD,CAAA;A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