Skip to content

Commit

Permalink
add condtional for columns block
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Nov 7, 2020
1 parent eca7c7e commit 72d849d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/manage/Blocks/Accordion/AccordionEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Icon } from '@plone/volto/components';
import upSVG from '@plone/volto/icons/up-key.svg';
import downSVG from '@plone/volto/icons/down-key.svg';
import AnimateHeight from 'react-animate-height';
export default ({ children, isEditForm }) => {
export default ({ children }) => {
const [activeIndex, setActiveIndex] = React.useState(0);

function handleClick(e, titleProps) {
Expand All @@ -16,7 +16,7 @@ export default ({ children, isEditForm }) => {

return (
<div>
<Accordion fluid styled={!isEditForm}>
<Accordion fluid styled>
<React.Fragment>
<Accordion.Title
active={activeIndex === 0}
Expand Down
25 changes: 22 additions & 3 deletions src/components/manage/Blocks/Accordion/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ import { options } from './layout';
import './editor.less';

const Edit = (props) => {
const { block, data, onChangeBlock, pathname, selected, manage } = props;
const {
block,
data,
onChangeBlock,
pathname,
selected,
manage,
data: { display },
} = props;

const metadata = props.metadata || props.properties;
const properties = isEmpty(data?.data?.blocks)
Expand All @@ -31,7 +39,18 @@ const Edit = (props) => {

return (
<section className="section-block">
{Object.keys(data).length === 1 ? (
{!display && Object.keys(data).length === 1 ? (
<Layout
variants={options}
data={data}
onChange={(initialData) => {
onChangeBlock(block, {
...data,
...createPanes(initialData),
});
}}
/>
) : display && Object.keys(data).length === 2 ? (
<Layout
variants={options}
data={data}
Expand All @@ -45,7 +64,7 @@ const Edit = (props) => {
) : (
<div>
{columnList.map(([colId, column], index) => (
<AccordionEdit isEditForm={pathname.includes('edit')}>
<AccordionEdit>
<BlocksForm
key={colId}
metadata={metadata}
Expand Down

0 comments on commit 72d849d

Please sign in to comment.