strapi-plugin-content-manager
Advanced tools
Comparing version 3.0.0-alpha.11.2 to 3.0.0-alpha.11.3
@@ -151,2 +151,3 @@ /** | ||
name={attr} | ||
onBlur={this.props.onBlur} | ||
onChange={this.props.onChange} | ||
@@ -172,2 +173,3 @@ selectOptions={get(this.props.attributes, [attr, 'enum'])} | ||
layout: {}, | ||
onBlur: () => {}, | ||
onChange: () => {}, | ||
@@ -184,2 +186,3 @@ record: {}, | ||
layout: PropTypes.object, | ||
onBlur: PropTypes.func, | ||
onChange: PropTypes.func, | ||
@@ -186,0 +189,0 @@ record: PropTypes.object, |
@@ -56,2 +56,8 @@ /** | ||
); | ||
const record = Object.keys(attributes).reduce((acc, current) => { | ||
if (attributes[current].default) { | ||
acc[current] = attributes[current].default; | ||
} | ||
return acc; | ||
}, {}); | ||
@@ -63,2 +69,3 @@ return { | ||
modelName, | ||
record, | ||
source, | ||
@@ -65,0 +72,0 @@ }; |
@@ -13,3 +13,3 @@ /** | ||
import PropTypes from 'prop-types'; | ||
import { get, includes, isEmpty, isObject, toNumber, toString, replace } from 'lodash'; | ||
import { cloneDeep, findIndex, get, includes, isEmpty, isObject, toNumber, toString, replace } from 'lodash'; | ||
import cn from 'classnames'; | ||
@@ -34,2 +34,4 @@ | ||
import { bindLayout } from 'utils/bindLayout'; | ||
import inputValidations from 'utils/inputsValidations'; | ||
import { checkFormValidity } from 'utils/formValidations'; | ||
@@ -115,2 +117,10 @@ | ||
/** | ||
* | ||
* | ||
* @type {[type]} | ||
*/ | ||
getAttributeValidations = (name) => get(this.props.editPage.formValidations, [findIndex(this.props.editPage.formValidations, ['name', name]), 'validations'], {}) | ||
/** | ||
* Retrieve the model | ||
@@ -122,2 +132,9 @@ * @type {Object} | ||
/** | ||
* Retrieve specific attribute | ||
* @type {String} name | ||
*/ | ||
getModelAttribute = (name) => get(this.getModelAttributes(), name); | ||
/** | ||
* Retrieve the model's attributes | ||
@@ -149,5 +166,31 @@ * @return {Object} | ||
handleBlur = ({ target }) => { | ||
const defaultValue = get(this.getModelAttribute(target.name), 'default'); | ||
if (isEmpty(target.value) && defaultValue && target.value !== false) { | ||
return this.props.changeData({ | ||
target: { | ||
name: `record.${target.name}`, | ||
value: defaultValue, | ||
}, | ||
}); | ||
} | ||
const errorIndex = findIndex(this.props.editPage.formErrors, ['name', target.name]); | ||
const errors = inputValidations(target.value, this.getAttributeValidations(target.name), target.type); | ||
const formErrors = cloneDeep(this.props.editPage.formErrors); | ||
if (errorIndex === -1 && !isEmpty(errors)) { | ||
formErrors.push({ name: target.name, errors }); | ||
} else if (errorIndex !== -1 && isEmpty(errors)) { | ||
formErrors.splice(errorIndex, 1); | ||
} else if (!isEmpty(errors)) { | ||
formErrors.splice(errorIndex, 1, { name: target.name, errors }); | ||
} | ||
return this.props.setFormErrors(formErrors); | ||
} | ||
handleChange = (e) => { | ||
let value = e.target.value; | ||
// Check if date | ||
@@ -244,2 +287,3 @@ if (isObject(e.target.value) && e.target.value._isAMomentObject === true) { | ||
modelName={this.getModelName()} | ||
onBlur={this.handleBlur} | ||
onChange={this.handleChange} | ||
@@ -246,0 +290,0 @@ record={editPage.record} |
@@ -52,2 +52,3 @@ /** | ||
.update('modelName', () => action.modelName) | ||
.update('record', () => Map(action.record)) | ||
.update('source', () => action.source); | ||
@@ -54,0 +55,0 @@ case ON_CANCEL: |
@@ -18,3 +18,3 @@ { | ||
"EditRelations.title": "Relational data", | ||
"EditRelations.title": "Dane relacyjne", | ||
@@ -21,0 +21,0 @@ "emptyAttributes.title": "Nie ma jeszcze żadnych atrybutów", |
@@ -7,3 +7,9 @@ const _ = require('lodash'); | ||
_.forEach(params.where, (where, key) => { | ||
qb.where(key, where[0].symbol, where[0].value); | ||
if (_.isArray(where.value)) { | ||
for (const value in where.value) { | ||
qb[value ? 'where' : 'orWhere'](key, where.symbol, where.value[value]) | ||
} | ||
} else { | ||
qb.where(key, where.symbol, where.value); | ||
} | ||
}); | ||
@@ -10,0 +16,0 @@ |
{ | ||
"name": "strapi-plugin-content-manager", | ||
"version": "3.0.0-alpha.11.2", | ||
"version": "3.0.0-alpha.11.3", | ||
"description": "A powerful UI to easily manage your data.", | ||
@@ -27,3 +27,3 @@ "strapi": { | ||
"react-select": "^1.0.0-rc.5", | ||
"strapi-helper-plugin": "3.0.0-alpha.11.2" | ||
"strapi-helper-plugin": "3.0.0-alpha.11.3" | ||
}, | ||
@@ -30,0 +30,0 @@ "author": { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1382617
8272