mirror of
https://github.com/strapi/strapi.git
synced 2025-09-19 05:23:05 +00:00
Change layout shape
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
f27548e042
commit
ada7ce8b4e
@ -11,7 +11,7 @@ import Wrapper from './Wrapper';
|
|||||||
import RowLabel from '../../RowLabel';
|
import RowLabel from '../../RowLabel';
|
||||||
import { getCheckboxState, removeConditionKeyFromData } from '../../utils';
|
import { getCheckboxState, removeConditionKeyFromData } from '../../utils';
|
||||||
|
|
||||||
const Collapse = ({ availableActions, isActive, isGrey, name, onClickToggle, pathToData }) => {
|
const Collapse = ({ availableActions, isActive, isGrey, label, onClickToggle, pathToData }) => {
|
||||||
const {
|
const {
|
||||||
modifiedData,
|
modifiedData,
|
||||||
onChangeParentCheckbox,
|
onChangeParentCheckbox,
|
||||||
@ -36,7 +36,7 @@ const Collapse = ({ availableActions, isActive, isGrey, name, onClickToggle, pat
|
|||||||
<Padded left size="sm" />
|
<Padded left size="sm" />
|
||||||
<RowLabel
|
<RowLabel
|
||||||
isCollapsable
|
isCollapsable
|
||||||
label={name}
|
label={label}
|
||||||
checkboxName={pathToData}
|
checkboxName={pathToData}
|
||||||
onChange={onChangeParentCheckbox}
|
onChange={onChangeParentCheckbox}
|
||||||
onClick={onClickToggle}
|
onClick={onClickToggle}
|
||||||
@ -96,7 +96,7 @@ Collapse.propTypes = {
|
|||||||
availableActions: PropTypes.array.isRequired,
|
availableActions: PropTypes.array.isRequired,
|
||||||
isActive: PropTypes.bool.isRequired,
|
isActive: PropTypes.bool.isRequired,
|
||||||
isGrey: PropTypes.bool.isRequired,
|
isGrey: PropTypes.bool.isRequired,
|
||||||
name: PropTypes.string.isRequired,
|
label: PropTypes.string.isRequired,
|
||||||
onClickToggle: PropTypes.func.isRequired,
|
onClickToggle: PropTypes.func.isRequired,
|
||||||
pathToData: PropTypes.string.isRequired,
|
pathToData: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,7 @@ import Wrapper from './Wrapper';
|
|||||||
const ContentTypeCollapse = ({
|
const ContentTypeCollapse = ({
|
||||||
allActions,
|
allActions,
|
||||||
contentTypeName,
|
contentTypeName,
|
||||||
|
label,
|
||||||
index,
|
index,
|
||||||
isActive,
|
isActive,
|
||||||
onClickToggleCollapse,
|
onClickToggleCollapse,
|
||||||
@ -30,7 +31,7 @@ const ContentTypeCollapse = ({
|
|||||||
availableActions={availableActions}
|
availableActions={availableActions}
|
||||||
isActive={isActive}
|
isActive={isActive}
|
||||||
isGrey={index % 2 === 0}
|
isGrey={index % 2 === 0}
|
||||||
name={contentTypeName}
|
label={label}
|
||||||
onClickToggle={handleClickToggleCollapse}
|
onClickToggle={handleClickToggleCollapse}
|
||||||
pathToData={pathToData}
|
pathToData={pathToData}
|
||||||
/>
|
/>
|
||||||
@ -58,6 +59,7 @@ ContentTypeCollapse.propTypes = {
|
|||||||
contentTypeName: PropTypes.string.isRequired,
|
contentTypeName: PropTypes.string.isRequired,
|
||||||
index: PropTypes.number.isRequired,
|
index: PropTypes.number.isRequired,
|
||||||
isActive: PropTypes.bool.isRequired,
|
isActive: PropTypes.bool.isRequired,
|
||||||
|
label: PropTypes.string.isRequired,
|
||||||
onClickToggleCollapse: PropTypes.func.isRequired,
|
onClickToggleCollapse: PropTypes.func.isRequired,
|
||||||
pathToData: PropTypes.string.isRequired,
|
pathToData: PropTypes.string.isRequired,
|
||||||
properties: PropTypes.array.isRequired,
|
properties: PropTypes.array.isRequired,
|
||||||
|
@ -14,17 +14,18 @@ const ContentTypeCollapses = ({ actions, pathToData, subjects }) => {
|
|||||||
[collapseToOpen]
|
[collapseToOpen]
|
||||||
);
|
);
|
||||||
|
|
||||||
return Object.keys(subjects).map((subject, index) => {
|
return subjects.map(({ uid, label, properties }, index) => {
|
||||||
return (
|
return (
|
||||||
<ContentTypeCollapse
|
<ContentTypeCollapse
|
||||||
allActions={actions}
|
allActions={actions}
|
||||||
key={subject}
|
key={uid}
|
||||||
contentTypeName={subject}
|
contentTypeName={uid}
|
||||||
isActive={collapseToOpen === subject}
|
label={label}
|
||||||
|
isActive={collapseToOpen === uid}
|
||||||
index={index}
|
index={index}
|
||||||
onClickToggleCollapse={handleClickToggleCollapse}
|
onClickToggleCollapse={handleClickToggleCollapse}
|
||||||
pathToData={`${pathToData}..${subject}`}
|
pathToData={`${pathToData}..${uid}`}
|
||||||
properties={subjects[subject].properties}
|
properties={properties}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -32,13 +33,19 @@ const ContentTypeCollapses = ({ actions, pathToData, subjects }) => {
|
|||||||
|
|
||||||
ContentTypeCollapses.defaultProps = {
|
ContentTypeCollapses.defaultProps = {
|
||||||
actions: [],
|
actions: [],
|
||||||
subjects: {},
|
subjects: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
ContentTypeCollapses.propTypes = {
|
ContentTypeCollapses.propTypes = {
|
||||||
actions: PropTypes.array.isRequired,
|
actions: PropTypes.array.isRequired,
|
||||||
pathToData: PropTypes.string.isRequired,
|
pathToData: PropTypes.string.isRequired,
|
||||||
subjects: PropTypes.object,
|
subjects: PropTypes.arrayOf(
|
||||||
|
PropTypes.shape({
|
||||||
|
uid: PropTypes.string.isRequired,
|
||||||
|
label: PropTypes.string.isRequired,
|
||||||
|
properties: PropTypes.array.isRequired,
|
||||||
|
})
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(ContentTypeCollapses);
|
export default memo(ContentTypeCollapses);
|
||||||
|
@ -20,7 +20,13 @@ ContentTypes.propTypes = {
|
|||||||
kind: PropTypes.string.isRequired,
|
kind: PropTypes.string.isRequired,
|
||||||
layout: PropTypes.shape({
|
layout: PropTypes.shape({
|
||||||
actions: PropTypes.array,
|
actions: PropTypes.array,
|
||||||
subjects: PropTypes.object,
|
subjects: PropTypes.arrayOf(
|
||||||
|
PropTypes.shape({
|
||||||
|
uid: PropTypes.string.isRequired,
|
||||||
|
label: PropTypes.string.isRequired,
|
||||||
|
properties: PropTypes.array.isRequired,
|
||||||
|
})
|
||||||
|
),
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -283,8 +283,10 @@ const data = {
|
|||||||
|
|
||||||
singleTypes: {}, // same format as under,
|
singleTypes: {}, // same format as under,
|
||||||
collectionTypes: {
|
collectionTypes: {
|
||||||
subjects: {
|
subjects: [
|
||||||
address: {
|
{
|
||||||
|
uid: 'address',
|
||||||
|
label: 'Address',
|
||||||
properties: [
|
properties: [
|
||||||
{
|
{
|
||||||
label: 'Fields',
|
label: 'Fields',
|
||||||
@ -315,7 +317,9 @@ const data = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
restaurant: {
|
{
|
||||||
|
uid: 'restaurant',
|
||||||
|
label: 'Restaurant',
|
||||||
properties: [
|
properties: [
|
||||||
{
|
{
|
||||||
label: 'Fields',
|
label: 'Fields',
|
||||||
@ -384,10 +388,12 @@ const data = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
test: {
|
{
|
||||||
|
uid: 'test',
|
||||||
|
label: 'test',
|
||||||
properties: [],
|
properties: [],
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
label: 'Create',
|
label: 'Create',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user