Handle display edit layout

This commit is contained in:
soupette 2018-07-26 13:33:57 +02:00
parent 5830ed4a73
commit fb8c3d2297
2 changed files with 47 additions and 36 deletions

View File

@ -14,15 +14,12 @@ import {
isFunction,
upperFirst,
} from 'lodash';
// You can find these components in either
// ./node_modules/strapi-helper-plugin/lib/src
// or strapi/packages/strapi-helper-plugin/lib/src
import Input from 'components/InputsIndex';
import InputJSONWithErrors from 'components/InputJSONWithErrors';
import WysiwygWithErrors from 'components/WysiwygWithErrors';
import styles from './styles.scss';
const getInputType = (type = '') => {
@ -115,11 +112,13 @@ class Edit extends React.PureComponent {
orderAttributes = () => get(this.props.schema, ['editDisplay', 'fields'], []);
render(){
return (
<div className={styles.form}>
<div className="row">
{this.orderAttributes().map((attr, key) => {
renderAttr = (attr, key) => {
if (attr.includes('__col-md')) {
const className = attr.split('__')[1];
return <div key={key} className={className} />;
}
const details = get(this.props.schema, ['editDisplay', 'availableFields', attr]);
// Retrieve the input's bootstrapClass from the layout
const layout = this.getInputLayout(attr);
@ -149,7 +148,13 @@ class Edit extends React.PureComponent {
value={this.props.record[attr]}
/>
);
})}
}
render(){
return (
<div className={styles.form}>
<div className="row">
{this.orderAttributes().map(this.renderAttr)}
</div>
</div>
);

View File

@ -16,9 +16,8 @@ module.exports = async cb => {
'associations'
]);
const tempLayout = Object.keys(strapi.plugins).reduce((acc, current) => {
const pluginsLayout = Object.keys(strapi.plugins).reduce((acc, current) => {
const models = _.get(strapi.plugins, [current, 'config', 'layout'], {});
Object.keys(models).forEach(model => {
const layout = _.get(strapi.plugins, [current, 'config', 'layout', model], {});
acc[model] = layout;
@ -27,6 +26,13 @@ module.exports = async cb => {
return acc;
}, {});
const tempLayout = Object.keys(strapi.models)
.filter(m => m !== 'core_store')
.reduce((acc, current) => {
acc[current] = { attributes: {} };
return acc;
}, pluginsLayout);
const models = _.mapValues(strapi.models, pickData);
delete models['core_store'];