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