mirror of
https://github.com/strapi/strapi.git
synced 2025-07-25 09:56:53 +00:00
fix xtoOne + conditions to enbale fetch + count label
This commit is contained in:
parent
3143aecbab
commit
c407c20d05
@ -30,12 +30,11 @@ export const RelationInputDataManger = ({
|
|||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const { connectRelation, disconnectRelation, loadRelation, modifiedData, slug, initialData } =
|
const { connectRelation, disconnectRelation, loadRelation, modifiedData, slug, initialData } =
|
||||||
useCMEditViewDataManager();
|
useCMEditViewDataManager();
|
||||||
const relationsCount = initialData[name]?.count ?? 0;
|
|
||||||
const [{ query }] = useQueryParams();
|
const [{ query }] = useQueryParams();
|
||||||
|
|
||||||
const { relations, search, searchFor } = useRelation(`${slug}-${name}-${initialData?.id ?? ''}`, {
|
const { relations, search, searchFor } = useRelation(`${slug}-${name}-${initialData?.id ?? ''}`, {
|
||||||
relation: {
|
relation: {
|
||||||
enabled: relationsCount > 0 && !!endpoints.relation,
|
enabled: initialData[name]?.count !== 0 && !!endpoints.relation,
|
||||||
endpoint: endpoints.relation,
|
endpoint: endpoints.relation,
|
||||||
pageParams: {
|
pageParams: {
|
||||||
...defaultParams,
|
...defaultParams,
|
||||||
@ -141,13 +140,10 @@ export const RelationInputDataManger = ({
|
|||||||
description={description}
|
description={description}
|
||||||
disabled={isDisabled}
|
disabled={isDisabled}
|
||||||
id={name}
|
id={name}
|
||||||
label={formatMessage(
|
label={`${formatMessage({
|
||||||
{
|
id: intlLabel.id,
|
||||||
id: intlLabel.id,
|
defaultMessage: intlLabel.defaultMessage,
|
||||||
defaultMessage: `${intlLabel.defaultMessage} ({numberOfEntries})`,
|
})} ${initialData[name]?.count ? `(${initialData[name].count})` : ''}`}
|
||||||
},
|
|
||||||
{ numberOfEntries: relationsCount }
|
|
||||||
)}
|
|
||||||
labelAction={labelAction}
|
labelAction={labelAction}
|
||||||
labelLoadMore={
|
labelLoadMore={
|
||||||
// TODO: only display if there are more; derive from count
|
// TODO: only display if there are more; derive from count
|
||||||
|
@ -208,7 +208,8 @@ module.exports = {
|
|||||||
ctx.body = await strapi.entityService.findPage(targetedModel.uid, queryParams);
|
ctx.body = await strapi.entityService.findPage(targetedModel.uid, queryParams);
|
||||||
} else {
|
} else {
|
||||||
const results = await strapi.entityService.findMany(targetedModel.uid, queryParams);
|
const results = await strapi.entityService.findMany(targetedModel.uid, queryParams);
|
||||||
ctx.body = results[0];
|
// TODO: Temporary fix (use data instead)
|
||||||
|
ctx.body = { results, pagination: { page: 1, pageSize: 5, pageCount: 1, total: 1 } };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user