mirror of
https://github.com/strapi/strapi.git
synced 2025-11-12 00:03:40 +00:00
refactor: tidy up entityId
This commit is contained in:
parent
c1f8d20245
commit
cabfa37ff3
@ -98,11 +98,15 @@ const RelationInput = ({
|
|||||||
|
|
||||||
const options = useMemo(
|
const options = useMemo(
|
||||||
() =>
|
() =>
|
||||||
data.flat().map((result) => ({
|
data.flat().map((result) =>
|
||||||
|
result
|
||||||
|
? {
|
||||||
...result,
|
...result,
|
||||||
value: result.id,
|
value: result.id,
|
||||||
label: result.mainField,
|
label: result.mainField,
|
||||||
})),
|
}
|
||||||
|
: result
|
||||||
|
),
|
||||||
[data]
|
[data]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import { connect, select, normalizeSearchResults, diffRelations, normalizeRelati
|
|||||||
export const RelationInputDataManager = ({
|
export const RelationInputDataManager = ({
|
||||||
error,
|
error,
|
||||||
componentId,
|
componentId,
|
||||||
|
isComponentRelation,
|
||||||
editable,
|
editable,
|
||||||
description,
|
description,
|
||||||
intlLabel,
|
intlLabel,
|
||||||
@ -64,7 +65,8 @@ export const RelationInputDataManager = ({
|
|||||||
endpoint: endpoints.search,
|
endpoint: endpoints.search,
|
||||||
pageParams: {
|
pageParams: {
|
||||||
...defaultParams,
|
...defaultParams,
|
||||||
entityId: isCreatingEntry ? undefined : componentId ?? initialData.id,
|
// eslint-disable-next-line no-nested-ternary
|
||||||
|
entityId: isCreatingEntry ? undefined : isComponentRelation ? componentId : initialData.id,
|
||||||
pageSize: SEARCH_RESULTS_TO_DISPLAY,
|
pageSize: SEARCH_RESULTS_TO_DISPLAY,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -212,6 +214,7 @@ RelationInputDataManager.defaultProps = {
|
|||||||
error: undefined,
|
error: undefined,
|
||||||
description: '',
|
description: '',
|
||||||
labelAction: null,
|
labelAction: null,
|
||||||
|
isComponentRelation: false,
|
||||||
isFieldAllowed: true,
|
isFieldAllowed: true,
|
||||||
placeholder: null,
|
placeholder: null,
|
||||||
required: false,
|
required: false,
|
||||||
@ -229,6 +232,7 @@ RelationInputDataManager.propTypes = {
|
|||||||
}).isRequired,
|
}).isRequired,
|
||||||
labelAction: PropTypes.element,
|
labelAction: PropTypes.element,
|
||||||
isCreatingEntry: PropTypes.bool.isRequired,
|
isCreatingEntry: PropTypes.bool.isRequired,
|
||||||
|
isComponentRelation: PropTypes.bool,
|
||||||
isFieldAllowed: PropTypes.bool,
|
isFieldAllowed: PropTypes.bool,
|
||||||
isFieldReadable: PropTypes.bool.isRequired,
|
isFieldReadable: PropTypes.bool.isRequired,
|
||||||
mainField: PropTypes.shape({
|
mainField: PropTypes.shape({
|
||||||
|
|||||||
@ -82,6 +82,7 @@ function useSelect({
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
componentId,
|
componentId,
|
||||||
|
isComponentRelation: Boolean(componentUid),
|
||||||
queryInfos: {
|
queryInfos: {
|
||||||
...queryInfos,
|
...queryInfos,
|
||||||
endpoints: {
|
endpoints: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user