fix entry editor bugs in kitchen sink entry

This commit is contained in:
Shawn Erquhart 2017-05-19 12:52:47 -04:00 committed by Shawn Erquhart
parent 195f822739
commit 3176fa1b3f
13 changed files with 30 additions and 15 deletions

View File

@ -147,7 +147,7 @@
"react-simple-dnd": "^0.1.2",
"react-sortable": "^1.2.0",
"react-split-pane": "^0.1.57",
"react-textarea-autosize-inputref": "^4.1.0",
"react-textarea-autosize": "^4.3.2",
"react-toolbox": "^1.2.1",
"react-topbar-progress-indicator": "^1.0.0",
"react-waypoint": "^3.1.3",

View File

@ -15,7 +15,7 @@ export default class PreviewPane extends React.Component {
getWidget = (field, value, props) => {
const { fieldsMetaData, getAsset } = props;
const widget = resolveWidget(field.get('widget'));
return React.createElement(widget.preview, {
return !widget.preview ? null : React.createElement(widget.preview, {
field,
key: field.get('name'),
value: value && Map.isMap(value) ? value.get(field.get('name')) : value,

View File

@ -0,0 +1,3 @@
.switch {
display: inline-block;
}

View File

@ -1,6 +1,8 @@
import React, { PropTypes } from 'react';
import ImmutablePropTypes from "react-immutable-proptypes";
import Switch from 'react-toolbox/lib/switch';
import { isBoolean } from 'lodash';
import styles from './BooleanControl.css';
export default class BooleanControl extends React.Component {
render() {
@ -8,7 +10,8 @@ export default class BooleanControl extends React.Component {
return (
<Switch
id={forID}
checked={value === undefined ? field.get('defaultValue', false) : value}
className={styles.switch}
checked={isBoolean(value) ? value : field.get('defaultValue', false)}
onChange={onChange}
/>
);

View File

@ -9,8 +9,10 @@ class ControlHOC extends Component {
controlComponent: PropTypes.func.isRequired,
field: ImmutablePropTypes.map.isRequired,
value: PropTypes.oneOfType([
PropTypes.node,
PropTypes.object,
PropTypes.string,
PropTypes.bool,
]),
metadata: ImmutablePropTypes.map,
onChange: PropTypes.func.isRequired,

View File

@ -6,5 +6,5 @@ export default function DatePreview({ value }) {
}
DatePreview.propTypes = {
value: PropTypes.node,
value: PropTypes.object,
};

View File

@ -1,10 +1,10 @@
import React, { PropTypes } from 'react';
import previewStyle from './defaultPreviewStyle';
export default function DatePreview({ value }) {
export default function DateTimePreview({ value }) {
return <div style={previewStyle}>{value ? value.toString() : null}</div>;
}
DatePreview.propTypes = {
value: PropTypes.node,
DateTimePreview.propTypes = {
value: PropTypes.object,
};

View File

@ -3,7 +3,7 @@ import MarkupIt from 'markup-it';
import markdownSyntax from 'markup-it/syntaxes/markdown';
import htmlSyntax from 'markup-it/syntaxes/html';
import CaretPosition from 'textarea-caret-position';
import TextareaAutosize from 'react-textarea-autosize-inputref';
import TextareaAutosize from 'react-textarea-autosize';
import registry from '../../../../lib/registry';
import { createAssetProxy } from '../../../../valueObjects/AssetProxy';
import Toolbar from '../Toolbar/Toolbar';

View File

@ -10,7 +10,11 @@ export default class ObjectControl extends Component {
onAddAsset: PropTypes.func.isRequired,
onRemoveAsset: PropTypes.func.isRequired,
getAsset: PropTypes.func.isRequired,
value: PropTypes.node,
value: PropTypes.oneOfType([
PropTypes.node,
PropTypes.object,
PropTypes.bool,
]),
field: PropTypes.object,
forID: PropTypes.string,
className: PropTypes.string,
@ -35,6 +39,7 @@ export default class ObjectControl extends Component {
onAddAsset,
onRemoveAsset,
getAsset,
forID: field.get('name'),
})
}
</div>

View File

@ -6,7 +6,7 @@ export default class ObjectPreview extends Component {
widgetFor = (field) => {
const { value, getAsset } = this.props;
const widget = resolveWidget(field.get('widget'));
return (
return !widget.preview ? null : (
<div key={field.get('name')}>
{React.createElement(widget.preview, {
key: field.get('name'),

View File

@ -34,7 +34,7 @@ SelectControl.propTypes = {
value: PropTypes.node,
forID: PropTypes.string.isRequired,
field: ImmutablePropTypes.contains({
options: ImmutablePropTypes.listOf(PropTypes.oneOf([
options: ImmutablePropTypes.listOf(PropTypes.oneOfType([
PropTypes.string,
ImmutablePropTypes.contains({
label: PropTypes.string.isRequired,

View File

@ -2,7 +2,7 @@ import React, { PropTypes } from 'react';
import previewStyle from './defaultPreviewStyle';
export default function TextPreview({ value }) {
return <div style={previewStyle}>{value ? value.toString() : null}</div>;
return <div style={previewStyle}>{value}</div>;
}
TextPreview.propTypes = {

View File

@ -7090,9 +7090,11 @@ react-style-proptype@^3.0.0:
dependencies:
prop-types "^15.5.4"
react-textarea-autosize-inputref@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/react-textarea-autosize-inputref/-/react-textarea-autosize-inputref-4.1.0.tgz#4a12921f9c992a8e2c6ce569ab46982a96ca48f6"
react-textarea-autosize@^4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-4.3.2.tgz#962a52c68caceae408c18acecec29049b81e42fa"
dependencies:
prop-types "^15.5.8"
react-themeable@^1.1.0:
version "1.1.0"