mirror of
https://github.com/strapi/strapi.git
synced 2025-11-09 06:40:42 +00:00
Clean code
This commit is contained in:
parent
570a520d10
commit
3c372ebde6
@ -8,10 +8,7 @@ import styled from 'styled-components';
|
|||||||
|
|
||||||
const StyledCustomCheckbox = styled.div`
|
const StyledCustomCheckbox = styled.div`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
// padding: 0 15px;
|
|
||||||
padding: 0;
|
padding: 0;
|
||||||
// margin-top: -6px;
|
|
||||||
// margin-bottom: 16px;
|
|
||||||
> label {
|
> label {
|
||||||
font-weight: 500 !important;
|
font-weight: 500 !important;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
@ -32,10 +29,11 @@ const StyledCustomCheckbox = styled.div`
|
|||||||
line-height: 10px;
|
line-height: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// input[type='number'] {
|
.no-label {
|
||||||
// margin-top: -10px;
|
label {
|
||||||
// margin-bottom: -4px;
|
display: none;
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default StyledCustomCheckbox;
|
export default StyledCustomCheckbox;
|
||||||
|
|||||||
@ -33,13 +33,15 @@ const CustomCheckbox = ({ label, name, onChange, value, ...rest }) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{checked && (
|
{checked && (
|
||||||
<Inputs
|
<div className="no-label col-6">
|
||||||
{...rest}
|
<Inputs
|
||||||
name={name}
|
{...rest}
|
||||||
onChange={onChange}
|
name={name}
|
||||||
value={value}
|
onChange={onChange}
|
||||||
type="number"
|
value={value}
|
||||||
/>
|
type="number"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</StyledCustomCheckbox>
|
</StyledCustomCheckbox>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -175,7 +175,7 @@ const DataManagerProvider = ({ children }) => {
|
|||||||
return <Redirect to={`/plugins/${pluginId}/content-types/${firstCTUid}`} />;
|
return <Redirect to={`/plugins/${pluginId}/content-types/${firstCTUid}`} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log({ components });
|
console.log({ d: modifiedData });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DataManagerContext.Provider
|
<DataManagerContext.Provider
|
||||||
|
|||||||
@ -95,7 +95,11 @@ const forms = {
|
|||||||
max: yup.lazy(() => {
|
max: yup.lazy(() => {
|
||||||
let schema = yup.number();
|
let schema = yup.number();
|
||||||
|
|
||||||
if (attributeType === 'integer' || attributeType === 'biginteger') {
|
if (
|
||||||
|
attributeType === 'integer' ||
|
||||||
|
attributeType === 'biginteger' ||
|
||||||
|
attributeType === 'dynamiczone'
|
||||||
|
) {
|
||||||
schema = schema.integer();
|
schema = schema.integer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +108,11 @@ const forms = {
|
|||||||
min: yup.lazy(() => {
|
min: yup.lazy(() => {
|
||||||
let schema = yup.number();
|
let schema = yup.number();
|
||||||
|
|
||||||
if (attributeType === 'integer' || attributeType === 'biginteger') {
|
if (
|
||||||
|
attributeType === 'integer' ||
|
||||||
|
attributeType === 'biginteger' ||
|
||||||
|
attributeType === 'dynamiczone'
|
||||||
|
) {
|
||||||
schema = schema.integer();
|
schema = schema.integer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +153,11 @@ const forms = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
switch (attributeType) {
|
switch (attributeType) {
|
||||||
|
case 'dynamiczone':
|
||||||
|
return yup.object().shape({
|
||||||
|
...commonShape,
|
||||||
|
...numberTypeShape,
|
||||||
|
});
|
||||||
case 'enumeration':
|
case 'enumeration':
|
||||||
return yup.object().shape({
|
return yup.object().shape({
|
||||||
...commonShape,
|
...commonShape,
|
||||||
@ -240,7 +253,6 @@ const forms = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
const defaultItems = [
|
const defaultItems = [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -287,14 +299,36 @@ const forms = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
const dynamiczoneItems = [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
autoFocus: false,
|
||||||
|
name: 'max',
|
||||||
|
type: 'customCheckboxWithChildren',
|
||||||
|
label: {
|
||||||
|
id: getTrad(`form.attribute.item.maximum`),
|
||||||
|
},
|
||||||
|
validations: {},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
autoFocus: false,
|
||||||
|
name: 'min',
|
||||||
|
type: 'customCheckboxWithChildren',
|
||||||
|
label: {
|
||||||
|
id: getTrad(`form.attribute.item.minimum`),
|
||||||
|
},
|
||||||
|
validations: {},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
const items = defaultItems.slice();
|
const items = defaultItems.slice();
|
||||||
|
|
||||||
if (type === 'media') {
|
if (type === 'media') {
|
||||||
items.splice(0, 1);
|
items.splice(0, 1);
|
||||||
}
|
} else if (type === 'boolean') {
|
||||||
|
|
||||||
if (type === 'boolean') {
|
|
||||||
items.splice(0, 1, [
|
items.splice(0, 1, [
|
||||||
{
|
{
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
@ -311,9 +345,7 @@ const forms = {
|
|||||||
validations: {},
|
validations: {},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
}
|
} else if (type === 'enumeration') {
|
||||||
|
|
||||||
if (type === 'enumeration') {
|
|
||||||
items.splice(0, 1, [
|
items.splice(0, 1, [
|
||||||
{
|
{
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
@ -361,9 +393,7 @@ const forms = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
}
|
} else if (type === 'date') {
|
||||||
|
|
||||||
if (type === 'date') {
|
|
||||||
items.splice(0, 1, [
|
items.splice(0, 1, [
|
||||||
{
|
{
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
@ -416,6 +446,12 @@ const forms = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type === 'dynamiczone') {
|
||||||
|
return {
|
||||||
|
items: dynamiczoneItems,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (type === 'relation') {
|
if (type === 'relation') {
|
||||||
return {
|
return {
|
||||||
items: relationItems,
|
items: relationItems,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user