Fields default to Blank String (#1126)

This commit is contained in:
Mike Romani 2018-03-28 10:07:20 -04:00 committed by Shawn Erquhart
parent cd10a713d8
commit 55f01e6f1d
11 changed files with 37 additions and 2 deletions

View File

@ -259,7 +259,7 @@ export function createEmptyDraft(collection) {
return (dispatch) => {
const dataFields = {};
collection.get('fields', List()).forEach((field) => {
dataFields[field.get('name')] = field.get('default', null);
dataFields[field.get('name')] = field.get('default');
});
const newEntry = createEntry(collection.get('name'), '', '', { data: dataFields });
dispatch(emptyDraftCreated(newEntry));

View File

@ -38,3 +38,7 @@ BooleanControl.propTypes = {
forID: PropTypes.string,
value: PropTypes.bool,
};
BooleanControl.defaultProps = {
value: false,
};

View File

@ -51,7 +51,6 @@ export default class RawEditor extends React.Component {
render() {
const { className } = this.props;
return (
<div className="nc-rawEditor-rawWrapper">
<div className="nc-visualEditor-editorControlBar">

View File

@ -21,6 +21,10 @@ export default class MarkdownControl extends React.Component {
value: PropTypes.string,
};
static defaultProps = {
value: '',
};
constructor(props) {
super(props);
editorControl = props.editorControl;

View File

@ -15,6 +15,10 @@ export default class NumberControl extends React.Component {
max: PropTypes.number,
};
static defaultProps = {
value: '',
};
handleChange = (e) => {
const valueType = this.props.field.get('valueType');
const { onChange } = this.props;

View File

@ -37,6 +37,10 @@ export default class ObjectControl extends Component {
forList: PropTypes.bool,
};
static defaultProps = {
value: Map(),
};
constructor(props) {
super(props);
this.state = {

View File

@ -30,6 +30,10 @@ class RelationControl extends Component {
setInactiveStyle: PropTypes.func.isRequired,
};
static defaultProps = {
value: '',
};
constructor(props, ctx) {
super(props, ctx);
this.controlID = uuid();

View File

@ -22,6 +22,10 @@ export default class SelectControl extends React.Component {
}),
};
static defaultProps = {
value: '',
};
handleChange = (e) => {
this.props.onChange(e.target.value);
};

View File

@ -11,6 +11,10 @@ export default class StringControl extends React.Component {
setInactiveStyle: PropTypes.func.isRequired,
};
static defaultProps = {
value: '',
};
render() {
const {
forID,

View File

@ -12,6 +12,10 @@ export default class TextControl extends React.Component {
setInactiveStyle: PropTypes.func.isRequired,
};
static defaultProps = {
value: '',
};
/**
* Always update to ensure `react-textarea-autosize` properly calculates
* height. Certain situations, such as this widget being nested in a list

View File

@ -20,6 +20,10 @@ export default function withMediaControl(forImage) {
value: PropTypes.node,
};
static defaultProps = {
value: '',
};
constructor(props) {
super(props);
this.controlID = uuid();