mirror of
https://github.com/strapi/strapi.git
synced 2025-12-18 10:43:56 +00:00
Add ordering to displayed fields in ctm
This commit is contained in:
parent
8d176dee31
commit
6bc6862b14
@ -73,7 +73,7 @@ class InputFileWithErrors extends React.Component {
|
|||||||
|
|
||||||
InputFileWithErrors.defaultProps = {
|
InputFileWithErrors.defaultProps = {
|
||||||
className: '',
|
className: '',
|
||||||
customBootstrapClass: 'col-md-6',
|
customBootstrapClass: 'col-md-12',
|
||||||
inputDescription: '',
|
inputDescription: '',
|
||||||
inputDescriptionClassName: '',
|
inputDescriptionClassName: '',
|
||||||
inputDescriptionStyle: {},
|
inputDescriptionStyle: {},
|
||||||
|
|||||||
@ -70,6 +70,7 @@ class Edit extends React.PureComponent {
|
|||||||
setLayout = (props) => {
|
setLayout = (props) => {
|
||||||
const currentLayout = get(props.layout, [props.modelName, 'attributes']);
|
const currentLayout = get(props.layout, [props.modelName, 'attributes']);
|
||||||
const displayedFields = merge(this.getUploadRelations(props), get(currentLayout), omit(props.schema.fields, 'id'));
|
const displayedFields = merge(this.getUploadRelations(props), get(currentLayout), omit(props.schema.fields, 'id'));
|
||||||
|
|
||||||
this.setState({ currentLayout, displayedFields });
|
this.setState({ currentLayout, displayedFields });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,11 +126,13 @@ class Edit extends React.PureComponent {
|
|||||||
|
|
||||||
fileRelationAllowMultipleUpload = (relationName) => has(this.props.schema, ['relations', relationName, 'collection']);
|
fileRelationAllowMultipleUpload = (relationName) => has(this.props.schema, ['relations', relationName, 'collection']);
|
||||||
|
|
||||||
|
orderAttributes = (displayedFields) => Object.keys(displayedFields).sort(name => Object.keys(this.getUploadRelations(this.props)).includes(name));
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
return (
|
return (
|
||||||
<div className={styles.form}>
|
<div className={styles.form}>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
{Object.keys(this.state.displayedFields).map((attr, key) => {
|
{this.orderAttributes(this.state.displayedFields).map((attr, key) => {
|
||||||
const details = this.state.displayedFields[attr];
|
const details = this.state.displayedFields[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);
|
||||||
|
|||||||
@ -79,7 +79,7 @@ module.exports = {
|
|||||||
|
|
||||||
update: async ctx => {
|
update: async ctx => {
|
||||||
const { source } = ctx.request.query;
|
const { source } = ctx.request.query;
|
||||||
|
console.log('hhhh', ctx.request.body);
|
||||||
try {
|
try {
|
||||||
// Return the last one which is the current model.
|
// Return the last one which is the current model.
|
||||||
ctx.body = await strapi.plugins['content-manager'].services['contentmanager'].edit(ctx.params, ctx.request.body, source);
|
ctx.body = await strapi.plugins['content-manager'].services['contentmanager'].edit(ctx.params, ctx.request.body, source);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user