mirror of
https://github.com/strapi/strapi.git
synced 2025-10-28 00:22:51 +00:00
Handle display edit layout
This commit is contained in:
parent
5830ed4a73
commit
fb8c3d2297
@ -14,15 +14,12 @@ import {
|
|||||||
isFunction,
|
isFunction,
|
||||||
upperFirst,
|
upperFirst,
|
||||||
} from 'lodash';
|
} from 'lodash';
|
||||||
|
|
||||||
// You can find these components in either
|
// You can find these components in either
|
||||||
// ./node_modules/strapi-helper-plugin/lib/src
|
// ./node_modules/strapi-helper-plugin/lib/src
|
||||||
// or strapi/packages/strapi-helper-plugin/lib/src
|
// or strapi/packages/strapi-helper-plugin/lib/src
|
||||||
import Input from 'components/InputsIndex';
|
import Input from 'components/InputsIndex';
|
||||||
|
|
||||||
import InputJSONWithErrors from 'components/InputJSONWithErrors';
|
import InputJSONWithErrors from 'components/InputJSONWithErrors';
|
||||||
import WysiwygWithErrors from 'components/WysiwygWithErrors';
|
import WysiwygWithErrors from 'components/WysiwygWithErrors';
|
||||||
|
|
||||||
import styles from './styles.scss';
|
import styles from './styles.scss';
|
||||||
|
|
||||||
const getInputType = (type = '') => {
|
const getInputType = (type = '') => {
|
||||||
@ -115,11 +112,13 @@ class Edit extends React.PureComponent {
|
|||||||
|
|
||||||
orderAttributes = () => get(this.props.schema, ['editDisplay', 'fields'], []);
|
orderAttributes = () => get(this.props.schema, ['editDisplay', 'fields'], []);
|
||||||
|
|
||||||
render(){
|
renderAttr = (attr, key) => {
|
||||||
return (
|
if (attr.includes('__col-md')) {
|
||||||
<div className={styles.form}>
|
const className = attr.split('__')[1];
|
||||||
<div className="row">
|
|
||||||
{this.orderAttributes().map((attr, key) => {
|
return <div key={key} className={className} />;
|
||||||
|
}
|
||||||
|
|
||||||
const details = get(this.props.schema, ['editDisplay', 'availableFields', attr]);
|
const details = get(this.props.schema, ['editDisplay', 'availableFields', attr]);
|
||||||
// Retrieve the input's bootstrapClass from the layout
|
// Retrieve the input's bootstrapClass from the layout
|
||||||
const layout = this.getInputLayout(attr);
|
const layout = this.getInputLayout(attr);
|
||||||
@ -149,7 +148,13 @@ class Edit extends React.PureComponent {
|
|||||||
value={this.props.record[attr]}
|
value={this.props.record[attr]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
}
|
||||||
|
|
||||||
|
render(){
|
||||||
|
return (
|
||||||
|
<div className={styles.form}>
|
||||||
|
<div className="row">
|
||||||
|
{this.orderAttributes().map(this.renderAttr)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -16,9 +16,8 @@ module.exports = async cb => {
|
|||||||
'associations'
|
'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'], {});
|
const models = _.get(strapi.plugins, [current, 'config', 'layout'], {});
|
||||||
|
|
||||||
Object.keys(models).forEach(model => {
|
Object.keys(models).forEach(model => {
|
||||||
const layout = _.get(strapi.plugins, [current, 'config', 'layout', model], {});
|
const layout = _.get(strapi.plugins, [current, 'config', 'layout', model], {});
|
||||||
acc[model] = layout;
|
acc[model] = layout;
|
||||||
@ -27,6 +26,13 @@ module.exports = async cb => {
|
|||||||
return acc;
|
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);
|
const models = _.mapValues(strapi.models, pickData);
|
||||||
delete models['core_store'];
|
delete models['core_store'];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user