mirror of
https://github.com/strapi/strapi.git
synced 2025-07-23 17:10:08 +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 { connectRelation, disconnectRelation, loadRelation, modifiedData, slug, initialData } =
|
||||
useCMEditViewDataManager();
|
||||
const relationsCount = initialData[name]?.count ?? 0;
|
||||
const [{ query }] = useQueryParams();
|
||||
|
||||
const { relations, search, searchFor } = useRelation(`${slug}-${name}-${initialData?.id ?? ''}`, {
|
||||
relation: {
|
||||
enabled: relationsCount > 0 && !!endpoints.relation,
|
||||
enabled: initialData[name]?.count !== 0 && !!endpoints.relation,
|
||||
endpoint: endpoints.relation,
|
||||
pageParams: {
|
||||
...defaultParams,
|
||||
@ -141,13 +140,10 @@ export const RelationInputDataManger = ({
|
||||
description={description}
|
||||
disabled={isDisabled}
|
||||
id={name}
|
||||
label={formatMessage(
|
||||
{
|
||||
id: intlLabel.id,
|
||||
defaultMessage: `${intlLabel.defaultMessage} ({numberOfEntries})`,
|
||||
},
|
||||
{ numberOfEntries: relationsCount }
|
||||
)}
|
||||
label={`${formatMessage({
|
||||
id: intlLabel.id,
|
||||
defaultMessage: intlLabel.defaultMessage,
|
||||
})} ${initialData[name]?.count ? `(${initialData[name].count})` : ''}`}
|
||||
labelAction={labelAction}
|
||||
labelLoadMore={
|
||||
// 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);
|
||||
} else {
|
||||
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