Handle relations

This commit is contained in:
soupette 2019-11-04 17:11:45 +01:00 committed by Alexandre Bodin
parent ebbc22ba75
commit d347612dcf
3 changed files with 19 additions and 2 deletions

View File

@ -7,7 +7,8 @@
"collectionName": "components_dishes",
"attributes": {
"name": {
"type": "string"
"type": "string",
"required": true
},
"description": {
"type": "text"

View File

@ -7,6 +7,7 @@ import { Inputs as InputsIndex } from '@buffetjs/custom';
import useDataManager from '../../hooks/useDataManager';
import InputJSONWithErrors from '../InputJSONWithErrors';
import SelectWrapper from '../SelectWrapper';
import WysiwygWithErrors from '../WysiwygWithErrors';
const getInputType = (type = '') => {
@ -99,6 +100,21 @@ function Inputs({ autoFocus, keys, layout, name, onBlur }) {
// TODO format error for the JSON, the WYSIWYG and also the file inputs
// TODO check if the height for the textarea is 196px (not mandatory)
if (type === 'relation') {
return (
<div className="col-6" key={keys}>
<SelectWrapper
{...metadatas}
name={keys}
plugin={attribute.plugin}
relationType={attribute.relationType}
targetModel={attribute.targetModel}
value={get(modifiedData, keys)}
/>
</div>
);
}
return (
<FormattedMessage id={errorId}>
{error => {

View File

@ -210,7 +210,7 @@ WysiwygWithErrors.propTypes = {
style: PropTypes.object,
tabIndex: PropTypes.string,
validations: PropTypes.object,
value: PropTypes.string.isRequired,
value: PropTypes.string,
};
export default WysiwygWithErrors;