mirror of
https://github.com/strapi/strapi.git
synced 2025-12-26 14:44:31 +00:00
Fix components ordering
This commit is contained in:
parent
549773698a
commit
704ff5a612
@ -226,7 +226,7 @@ const createQueryBuilder = (uid, db) => {
|
||||
});
|
||||
const orderByColumns = state.orderBy.map(({ column }) => column);
|
||||
|
||||
state.select = _.uniq([...state.select, ...orderByColumns, ...joinsOrderByColumns]);
|
||||
state.select = _.uniq([...joinsOrderByColumns, ...orderByColumns, ...state.select]);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -131,11 +131,26 @@ const updateComponents = async (uid, entityToUpdate, data) => {
|
||||
componentValue.map(value => updateOrCreateComponent(componentUID, value))
|
||||
);
|
||||
|
||||
// TODO: add order
|
||||
componentBody[attributeName] = components.filter(_.negate(_.isNil)).map(({ id }) => id);
|
||||
componentBody[attributeName] = components.filter(_.negate(_.isNil)).map(({ id }, idx) => {
|
||||
return {
|
||||
id,
|
||||
__pivot: {
|
||||
order: idx + 1,
|
||||
field: attributeName,
|
||||
component_type: componentUID,
|
||||
},
|
||||
};
|
||||
});
|
||||
} else {
|
||||
const component = await updateOrCreateComponent(componentUID, componentValue);
|
||||
componentBody[attributeName] = component && component.id;
|
||||
componentBody[attributeName] = component && {
|
||||
id: component.id,
|
||||
__pivot: {
|
||||
order: 1,
|
||||
field: attributeName,
|
||||
component_type: componentUID,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
continue;
|
||||
@ -151,9 +166,17 @@ const updateComponents = async (uid, entityToUpdate, data) => {
|
||||
}
|
||||
|
||||
componentBody[attributeName] = await Promise.all(
|
||||
dynamiczoneValues.map(async value => {
|
||||
dynamiczoneValues.map(async (value, idx) => {
|
||||
const { id } = await updateOrCreateComponent(value.__component, value);
|
||||
return { id, __component: value.__component };
|
||||
|
||||
return {
|
||||
id,
|
||||
__component: value.__component,
|
||||
__pivot: {
|
||||
order: idx + 1,
|
||||
field: attributeName,
|
||||
},
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user