Skip to content

Commit

Permalink
Render non empty panels in View
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Nov 24, 2020
1 parent 0e5845d commit 7dca60c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/components/manage/Blocks/Accordion/View.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { RenderBlocks } from '@eeacms/volto-blocks-form/components';
import { getColumns, GroupblockHasValue } from './util';
import { getColumns, AccordionblockHasValue } from './util';
import { Accordion } from 'semantic-ui-react';
import { applyTitleSize } from '@eeacms/volto-accordion-block/components/manage/Styles';

Expand All @@ -16,6 +16,7 @@ const View = (props) => {
const {
data: { data = {} },
} = props;

const columnList = getColumns(data);
const metadata = props.metadata || props.properties;
const [activeIndex, setActiveIndex] = React.useState(0);
Expand All @@ -28,7 +29,7 @@ const View = (props) => {
return (
<div>
{columnList.map(([id, column], index) => {
return GroupblockHasValue(column) ? (
return AccordionblockHasValue(column) ? (
<Accordion fluid styled key={id}>
<React.Fragment>
<Accordion.Title
Expand Down
9 changes: 7 additions & 2 deletions src/components/manage/Blocks/Accordion/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@ export const getColumns = (data) => {
]);
};

export const GroupblockHasValue = (content) => {
export const AccordionblockHasValue = (content) => {
const blocksFieldname = getBlocksFieldname(content);
const blocksLayoutFieldname = getBlocksLayoutFieldname(content);
const blockValue = map(content[blocksLayoutFieldname].items, (block) => {
const blockData = content[blocksFieldname]?.[block];
return blockHasValue(blockData);
});
return blockValue.length === 1 ? blockValue[0] : true;
if (
content[blocksLayoutFieldname].hasOwnProperty('title') &&
content[blocksLayoutFieldname]?.title.length > 0
)
return true;
return blockValue.some((item) => item === true);
};

export const deleteBlock = (formData, blockId, colId) => {
Expand Down

0 comments on commit 7dca60c

Please sign in to comment.