mirror of
https://github.com/strapi/strapi.git
synced 2025-09-23 07:22:51 +00:00
parent
b372f8c185
commit
ef3e693dfc
@ -57,13 +57,10 @@ const ComponentInitializer = ({ error, isReadOnly, onClick }) => {
|
|||||||
</Box>
|
</Box>
|
||||||
{error?.id && (
|
{error?.id && (
|
||||||
<Typography textColor="danger600" variant="pi">
|
<Typography textColor="danger600" variant="pi">
|
||||||
{formatMessage(
|
{formatMessage({
|
||||||
{
|
id: error.id,
|
||||||
id: error.id,
|
defaultMessage: error.id,
|
||||||
defaultMessage: error.defaultMessage,
|
})}
|
||||||
},
|
|
||||||
error.values
|
|
||||||
)}
|
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
@ -78,8 +75,6 @@ ComponentInitializer.defaultProps = {
|
|||||||
ComponentInitializer.propTypes = {
|
ComponentInitializer.propTypes = {
|
||||||
error: PropTypes.shape({
|
error: PropTypes.shape({
|
||||||
id: PropTypes.string.isRequired,
|
id: PropTypes.string.isRequired,
|
||||||
defaultMessage: PropTypes.string.isRequired,
|
|
||||||
values: PropTypes.object,
|
|
||||||
}),
|
}),
|
||||||
isReadOnly: PropTypes.bool,
|
isReadOnly: PropTypes.bool,
|
||||||
onClick: PropTypes.func.isRequired,
|
onClick: PropTypes.func.isRequired,
|
||||||
|
@ -92,7 +92,7 @@ const AccordionGroupCustom = ({ children, footer, label, labelAction, error }) =
|
|||||||
{error && (
|
{error && (
|
||||||
<Box paddingTop={1}>
|
<Box paddingTop={1}>
|
||||||
<Typography variant="pi" textColor="danger600">
|
<Typography variant="pi" textColor="danger600">
|
||||||
{formatMessage({ id: error.id, defaultMessage: error.defaultMessage }, error.values)}
|
{formatMessage({ id: error.id, defaultMessage: error.id })}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
@ -111,8 +111,6 @@ AccordionGroupCustom.propTypes = {
|
|||||||
children: PropTypes.node.isRequired,
|
children: PropTypes.node.isRequired,
|
||||||
error: PropTypes.shape({
|
error: PropTypes.shape({
|
||||||
id: PropTypes.string.isRequired,
|
id: PropTypes.string.isRequired,
|
||||||
defaultMessage: PropTypes.string.isRequired,
|
|
||||||
values: PropTypes.object,
|
|
||||||
}),
|
}),
|
||||||
footer: PropTypes.node,
|
footer: PropTypes.node,
|
||||||
label: PropTypes.string,
|
label: PropTypes.string,
|
||||||
|
@ -29,9 +29,9 @@ import { connect, select } from './utils';
|
|||||||
import getSelectStyles from './utils/getSelectStyles';
|
import getSelectStyles from './utils/getSelectStyles';
|
||||||
|
|
||||||
const initialPaginationState = {
|
const initialPaginationState = {
|
||||||
_contains: '',
|
contains: '',
|
||||||
_limit: 20,
|
limit: 20,
|
||||||
_start: 0,
|
start: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildParams = (query, paramsToKeep) => {
|
const buildParams = (query, paramsToKeep) => {
|
||||||
@ -141,10 +141,10 @@ function SelectWrapper({
|
|||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|
||||||
const params = { _limit: state._limit, ...defaultParams };
|
const params = { limit: state.limit, ...defaultParams, start: state.start };
|
||||||
|
|
||||||
if (state._contains) {
|
if (state.contains) {
|
||||||
params[containsKey] = state._contains;
|
params[`filters[${containsKey}][$contains]`] = state.contains;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -183,10 +183,9 @@ function SelectWrapper({
|
|||||||
isFieldAllowed,
|
isFieldAllowed,
|
||||||
isMorph,
|
isMorph,
|
||||||
mainField.name,
|
mainField.name,
|
||||||
setIsLoading,
|
state.contains,
|
||||||
setOptions,
|
state.limit,
|
||||||
state._contains,
|
state.start,
|
||||||
state._limit,
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -204,11 +203,11 @@ function SelectWrapper({
|
|||||||
const handleInputChange = (inputValue, { action }) => {
|
const handleInputChange = (inputValue, { action }) => {
|
||||||
if (action === 'input-change') {
|
if (action === 'input-change') {
|
||||||
setState(prevState => {
|
setState(prevState => {
|
||||||
if (prevState._contains === inputValue) {
|
if (prevState.contains === inputValue) {
|
||||||
return prevState;
|
return prevState;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { ...prevState, _contains: inputValue, _start: 0 };
|
return { ...prevState, contains: inputValue, start: 0 };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +215,10 @@ function SelectWrapper({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleMenuScrollToBottom = () => {
|
const handleMenuScrollToBottom = () => {
|
||||||
setState(prevState => ({ ...prevState, _limit: prevState._limit + 20 }));
|
setState(prevState => ({
|
||||||
|
...prevState,
|
||||||
|
start: prevState.start + 20,
|
||||||
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMenuClose = () => {
|
const handleMenuClose = () => {
|
||||||
@ -304,7 +306,6 @@ function SelectWrapper({
|
|||||||
move={moveRelation}
|
move={moveRelation}
|
||||||
name={name}
|
name={name}
|
||||||
options={filteredOptions}
|
options={filteredOptions}
|
||||||
// options={temp}
|
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
onInputChange={handleInputChange}
|
onInputChange={handleInputChange}
|
||||||
onMenuClose={handleMenuClose}
|
onMenuClose={handleMenuClose}
|
||||||
@ -320,73 +321,6 @@ function SelectWrapper({
|
|||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|
||||||
// return (
|
|
||||||
// <Padded>
|
|
||||||
// <BaselineAlignment />
|
|
||||||
// <Flex justifyContent="space-between">
|
|
||||||
// <Flex>
|
|
||||||
// <Text fontWeight="semiBold">
|
|
||||||
// <span>
|
|
||||||
// {label}
|
|
||||||
// {!isSingle && ` (${associationsLength})`}
|
|
||||||
// </span>
|
|
||||||
// </Text>
|
|
||||||
// {labelIconformatted && (
|
|
||||||
// <div style={{ lineHeight: '13px' }}>
|
|
||||||
// <LabelIconWrapper title={labelIconformatted.title}>
|
|
||||||
// {labelIconformatted.icon}
|
|
||||||
// </LabelIconWrapper>
|
|
||||||
// </div>
|
|
||||||
// )}
|
|
||||||
// </Flex>
|
|
||||||
// {isSingle && link}
|
|
||||||
// </Flex>
|
|
||||||
// {!isEmpty(description) && (
|
|
||||||
// <Padded top size="xs">
|
|
||||||
// <BaselineAlignment />
|
|
||||||
// <Text fontSize="sm" color="grey" lineHeight="12px" ellipsis>
|
|
||||||
// {description}
|
|
||||||
// </Text>
|
|
||||||
// </Padded>
|
|
||||||
// )}
|
|
||||||
// <Padded top size="sm">
|
|
||||||
// <BaselineAlignment />
|
|
||||||
|
|
||||||
// <Component
|
|
||||||
// addRelation={handleAddRelation}
|
|
||||||
// components={{ ClearIndicator, DropdownIndicator, IndicatorSeparator, Option }}
|
|
||||||
// displayNavigationLink={shouldDisplayRelationLink}
|
|
||||||
// id={name}
|
|
||||||
// isDisabled={isDisabled}
|
|
||||||
// isLoading={isLoading}
|
|
||||||
// isClearable
|
|
||||||
// mainField={mainField}
|
|
||||||
// move={moveRelation}
|
|
||||||
// name={name}
|
|
||||||
// options={filteredOptions}
|
|
||||||
// onChange={handleChange}
|
|
||||||
// onInputChange={handleInputChange}
|
|
||||||
// onMenuClose={handleMenuClose}
|
|
||||||
// onMenuOpen={handleMenuOpen}
|
|
||||||
// onMenuScrollToBottom={handleMenuScrollToBottom}
|
|
||||||
// onRemove={onRemoveRelation}
|
|
||||||
// placeholder={
|
|
||||||
// isEmpty(placeholder) ? (
|
|
||||||
// <FormattedMessage id={getTrad('containers.Edit.addAnItem')} />
|
|
||||||
// ) : (
|
|
||||||
// placeholder
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
// searchToPersist={searchToPersist}
|
|
||||||
// styles={styles}
|
|
||||||
// targetModel={targetModel}
|
|
||||||
// value={value}
|
|
||||||
// />
|
|
||||||
// </Padded>
|
|
||||||
// <div style={{ marginBottom: 28 }} />
|
|
||||||
// </Padded>
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectWrapper.defaultProps = {
|
SelectWrapper.defaultProps = {
|
||||||
|
@ -185,7 +185,7 @@ const generateRelationQueryInfos = (contentTypeConfiguration, fieldName, models)
|
|||||||
|
|
||||||
const queryInfos = {
|
const queryInfos = {
|
||||||
endPoint,
|
endPoint,
|
||||||
containsKey: `${mainField}_contains`,
|
containsKey: `${mainField}`,
|
||||||
defaultParams: {},
|
defaultParams: {},
|
||||||
shouldDisplayRelationLink,
|
shouldDisplayRelationLink,
|
||||||
};
|
};
|
||||||
@ -210,7 +210,7 @@ const generateRelationQueryInfosForComponents = (
|
|||||||
|
|
||||||
const queryInfos = {
|
const queryInfos = {
|
||||||
endPoint,
|
endPoint,
|
||||||
containsKey: `${mainField}_contains`,
|
containsKey: `${mainField}`,
|
||||||
defaultParams: {
|
defaultParams: {
|
||||||
_component: contentTypeConfiguration.uid,
|
_component: contentTypeConfiguration.uid,
|
||||||
},
|
},
|
||||||
|
@ -58,7 +58,7 @@ describe('Content Manager | hooks | useFetchContentTypeLayout | utils ', () => {
|
|||||||
},
|
},
|
||||||
queryInfos: {
|
queryInfos: {
|
||||||
endPoint: '/content-manager/relations/api::address.address/categories',
|
endPoint: '/content-manager/relations/api::address.address/categories',
|
||||||
containsKey: 'name_contains',
|
containsKey: 'name',
|
||||||
defaultParams: {},
|
defaultParams: {},
|
||||||
shouldDisplayRelationLink: true,
|
shouldDisplayRelationLink: true,
|
||||||
},
|
},
|
||||||
@ -124,10 +124,7 @@ describe('Content Manager | hooks | useFetchContentTypeLayout | utils ', () => {
|
|||||||
uid: 'compo',
|
uid: 'compo',
|
||||||
layouts: {
|
layouts: {
|
||||||
edit: [
|
edit: [
|
||||||
[
|
[{ name: 'full_name', size: 6 }, { name: 'city', size: 6 }],
|
||||||
{ name: 'full_name', size: 6 },
|
|
||||||
{ name: 'city', size: 6 },
|
|
||||||
],
|
|
||||||
[{ name: 'compo', size: 12 }],
|
[{ name: 'compo', size: 12 }],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -169,10 +166,7 @@ describe('Content Manager | hooks | useFetchContentTypeLayout | utils ', () => {
|
|||||||
editRelations: [],
|
editRelations: [],
|
||||||
edit: [
|
edit: [
|
||||||
[{ name: 'dz', size: 12 }],
|
[{ name: 'dz', size: 12 }],
|
||||||
[
|
[{ name: 'full_name', size: 6 }, { name: 'city', size: 6 }],
|
||||||
{ name: 'full_name', size: 6 },
|
|
||||||
{ name: 'city', size: 6 },
|
|
||||||
],
|
|
||||||
[{ name: 'compo', size: 12 }],
|
[{ name: 'compo', size: 12 }],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -370,10 +364,7 @@ describe('Content Manager | hooks | useFetchContentTypeLayout | utils ', () => {
|
|||||||
layouts: {
|
layouts: {
|
||||||
edit: [
|
edit: [
|
||||||
[{ name: 'dz', size: 12 }],
|
[{ name: 'dz', size: 12 }],
|
||||||
[
|
[{ name: 'full_name', size: 6 }, { name: 'city', size: 6 }],
|
||||||
{ name: 'full_name', size: 6 },
|
|
||||||
{ name: 'city', size: 6 },
|
|
||||||
],
|
|
||||||
[{ name: 'compo', size: 12 }],
|
[{ name: 'compo', size: 12 }],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -552,7 +543,7 @@ describe('Content Manager | hooks | useFetchContentTypeLayout | utils ', () => {
|
|||||||
it('should return an object with the correct keys', () => {
|
it('should return an object with the correct keys', () => {
|
||||||
expect(generateRelationQueryInfos(addressSchema, 'categories', simpleModels)).toEqual({
|
expect(generateRelationQueryInfos(addressSchema, 'categories', simpleModels)).toEqual({
|
||||||
endPoint: '/content-manager/relations/api::address.address/categories',
|
endPoint: '/content-manager/relations/api::address.address/categories',
|
||||||
containsKey: 'name_contains',
|
containsKey: 'name',
|
||||||
defaultParams: {},
|
defaultParams: {},
|
||||||
shouldDisplayRelationLink: true,
|
shouldDisplayRelationLink: true,
|
||||||
});
|
});
|
||||||
@ -570,7 +561,7 @@ describe('Content Manager | hooks | useFetchContentTypeLayout | utils ', () => {
|
|||||||
)
|
)
|
||||||
).toEqual({
|
).toEqual({
|
||||||
endPoint: '/content-manager/relations/api::address.address/categories',
|
endPoint: '/content-manager/relations/api::address.address/categories',
|
||||||
containsKey: 'name_contains',
|
containsKey: 'name',
|
||||||
defaultParams: {
|
defaultParams: {
|
||||||
_component: 'api::address.address',
|
_component: 'api::address.address',
|
||||||
},
|
},
|
||||||
@ -581,10 +572,7 @@ describe('Content Manager | hooks | useFetchContentTypeLayout | utils ', () => {
|
|||||||
|
|
||||||
describe('getDisplayedModels', () => {
|
describe('getDisplayedModels', () => {
|
||||||
it('should return an array containing only the displayable models', () => {
|
it('should return an array containing only the displayable models', () => {
|
||||||
const models = [
|
const models = [{ uid: 'test', isDisplayed: false }, { uid: 'testtest', isDisplayed: true }];
|
||||||
{ uid: 'test', isDisplayed: false },
|
|
||||||
{ uid: 'testtest', isDisplayed: true },
|
|
||||||
];
|
|
||||||
|
|
||||||
expect(getDisplayedModels([])).toHaveLength(0);
|
expect(getDisplayedModels([])).toHaveLength(0);
|
||||||
expect(getDisplayedModels(models)).toHaveLength(1);
|
expect(getDisplayedModels(models)).toHaveLength(1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user