@8base/utils
Advanced tools
Comparing version 0.6.11 to 0.6.12
@@ -154,2 +154,7 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var SMART_FORMATS = { | ||
ADDRESS: 'ADDRESS', | ||
PHONE: 'PHONE' | ||
}; | ||
var DATE_FORMATS = { | ||
@@ -206,2 +211,17 @@ DATE: 'DATE', | ||
// CONCATENATED MODULE: ./src/verifiers/isAddressField.js | ||
var isAddressField = external_ramda_["allPass"]([external_ramda_["propEq"]('fieldType', FIELD_TYPE.SMART), external_ramda_["pathEq"](['fieldTypeAttributes', 'format'], SMART_FORMATS.ADDRESS)]); | ||
// CONCATENATED MODULE: ./src/verifiers/isEmptyAddress.js | ||
var isEmpty = external_ramda_["anyPass"]([external_ramda_["isEmpty"], external_ramda_["isNil"]]); | ||
var isEmptyAddress = external_ramda_["anyPass"]([isEmpty, external_ramda_["allPass"]([external_ramda_["propSatisfies"](isEmpty, 'street1'), external_ramda_["propSatisfies"](isEmpty, 'street2'), external_ramda_["propSatisfies"](isEmpty, 'zip'), external_ramda_["propSatisfies"](isEmpty, 'city'), external_ramda_["propSatisfies"](isEmpty, 'state'), external_ramda_["propSatisfies"](isEmpty, 'country')])]); | ||
// CONCATENATED MODULE: ./src/verifiers/isFileField.js | ||
@@ -242,2 +262,4 @@ | ||
// CONCATENATED MODULE: ./src/formatters/formatFieldDataListItem.js | ||
@@ -312,2 +334,4 @@ | ||
var formatFieldDataForMutation_formatFieldDataForMutation = function formatFieldDataForMutation(type, fieldSchema, data, schema) { | ||
@@ -322,2 +346,12 @@ var nextData = data; | ||
} | ||
} else if (isAddressField(fieldSchema)) { | ||
if (isListField(fieldSchema)) { | ||
if (Array.isArray(nextData)) { | ||
nextData = external_ramda_["reject"](isEmptyAddress, nextData); | ||
} | ||
} else { | ||
if (isEmptyAddress(nextData)) { | ||
nextData = null; | ||
} | ||
} | ||
} | ||
@@ -478,2 +512,3 @@ | ||
/* concated harmony reexport FILE_FORMATS */__webpack_require__.d(__webpack_exports__, "FILE_FORMATS", function() { return FILE_FORMATS; }); | ||
/* concated harmony reexport SMART_FORMATS */__webpack_require__.d(__webpack_exports__, "SMART_FORMATS", function() { return SMART_FORMATS; }); | ||
/* concated harmony reexport DATE_FORMATS */__webpack_require__.d(__webpack_exports__, "DATE_FORMATS", function() { return DATE_FORMATS; }); | ||
@@ -487,2 +522,4 @@ /* concated harmony reexport MUTATION_TYPE */__webpack_require__.d(__webpack_exports__, "MUTATION_TYPE", function() { return MUTATION_TYPE; }); | ||
/* concated harmony reexport getTableSchemaById */__webpack_require__.d(__webpack_exports__, "getTableSchemaById", function() { return getTableSchemaById_getTableSchemaById; }); | ||
/* concated harmony reexport isAddressField */__webpack_require__.d(__webpack_exports__, "isAddressField", function() { return isAddressField; }); | ||
/* concated harmony reexport isEmptyAddress */__webpack_require__.d(__webpack_exports__, "isEmptyAddress", function() { return isEmptyAddress; }); | ||
/* concated harmony reexport isFileField */__webpack_require__.d(__webpack_exports__, "isFileField", function() { return isFileField; }); | ||
@@ -489,0 +526,0 @@ /* concated harmony reexport isListField */__webpack_require__.d(__webpack_exports__, "isListField", function() { return isListField; }); |
{ | ||
"name": "@8base/utils", | ||
"version": "0.6.11", | ||
"version": "0.6.12", | ||
"main": "lib/utils.js", | ||
@@ -22,3 +22,3 @@ "scripts": { | ||
"devDependencies": { | ||
"@8base/webpack-configuration": "^0.6.11", | ||
"@8base/webpack-configuration": "^0.6.12", | ||
"babel-cli": "^6.26.0", | ||
@@ -25,0 +25,0 @@ "babel-core": "^6.26.3", |
@@ -46,2 +46,7 @@ //@flow | ||
export const SMART_FORMATS = { | ||
ADDRESS: 'ADDRESS', | ||
PHONE: 'PHONE', | ||
}; | ||
export const DATE_FORMATS = { | ||
@@ -48,0 +53,0 @@ DATE: 'DATE', |
//@flow | ||
import { isListField, isFileField, isRelationField } from '../verifiers'; | ||
import * as R from 'ramda'; | ||
import { isListField, isFileField, isRelationField, isAddressField, isEmptyAddress } from '../verifiers'; | ||
import { formatFieldDataList } from './formatFieldDataList'; | ||
@@ -17,2 +19,12 @@ import { formatFieldData } from './formatFieldData'; | ||
} | ||
} else if (isAddressField(fieldSchema)) { | ||
if (isListField(fieldSchema)) { | ||
if (Array.isArray(nextData)) { | ||
nextData = R.reject(isEmptyAddress, nextData); | ||
} | ||
} else { | ||
if (isEmptyAddress(nextData)) { | ||
nextData = null; | ||
} | ||
} | ||
} | ||
@@ -19,0 +31,0 @@ |
@@ -0,1 +1,3 @@ | ||
export { isAddressField } from './isAddressField'; | ||
export { isEmptyAddress } from './isEmptyAddress'; | ||
export { isFileField } from './isFileField'; | ||
@@ -2,0 +4,0 @@ export { isListField } from './isListField'; |
Sorry, the diff of this file is not supported yet
300606
29
789