Add ordering to displayed fields in ctm

This commit is contained in:
cyril lopez 2018-02-26 18:33:19 +01:00
parent 8d176dee31
commit 6bc6862b14
4 changed files with 7 additions and 4 deletions

View File

@ -73,7 +73,7 @@ class InputFileWithErrors extends React.Component {
InputFileWithErrors.defaultProps = {
className: '',
customBootstrapClass: 'col-md-6',
customBootstrapClass: 'col-md-12',
inputDescription: '',
inputDescriptionClassName: '',
inputDescriptionStyle: {},

View File

@ -70,6 +70,7 @@ class Edit extends React.PureComponent {
setLayout = (props) => {
const currentLayout = get(props.layout, [props.modelName, 'attributes']);
const displayedFields = merge(this.getUploadRelations(props), get(currentLayout), omit(props.schema.fields, 'id'));
this.setState({ currentLayout, displayedFields });
}
@ -125,11 +126,13 @@ class Edit extends React.PureComponent {
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(){
return (
<div className={styles.form}>
<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];
// Retrieve the input's bootstrapClass from the layout
const layout = this.getInputLayout(attr);

View File

@ -79,7 +79,7 @@ module.exports = {
update: async ctx => {
const { source } = ctx.request.query;
console.log('hhhh', ctx.request.body);
try {
// 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);

View File

@ -87,7 +87,7 @@ function* search() {
} : {};
const response = yield call(request, requestURL, { method: 'GET', params });
const entries = response.length === 0 ? [] : response.map(obj => Map(obj));
yield put(onSearchSuccess(entries));
} catch(err) {
strapi.notification.error('notification.error');