Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed May 11, 2021
1 parent e96ab4f commit 1f0efdc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
21 changes: 15 additions & 6 deletions src/components/manage/Blocks/SiteBlocks/BatConclusions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ import infoSVG from '@plone/volto/icons/info.svg';
import rightSVG from '@plone/volto/icons/right-key.svg';
import downSVG from '@plone/volto/icons/down-key.svg';

const hasConclusions = (data, installations) => {
if (!installations.length) return false;
for (let i = 0; i < installations.length; i++) {
const conclusions = Object.keys(data[installations[i]] || {});
if (conclusions.length) return true;
}
return false;
};

const View = (props) => {
const [activeAels, setActiveAels] = React.useState({});
const { data = {}, installationsNth = {}, entity = '' } = props;
Expand All @@ -18,7 +27,7 @@ const View = (props) => {
<div
className={cx({
title: true,
marginless: !installations.length,
marginless: !hasConclusions(data, installations),
})}
>
<h3 className="blue">BAT conclusions</h3>
Expand All @@ -33,12 +42,12 @@ const View = (props) => {
/>
</div>

{installations.length ? (
{hasConclusions(data, installations) ? (
<div className="bat-conclusions-wrapper">
{installations.map((installation) => {
const conclusions = Object.keys(data[installation] || {}).sort();

return (
return conclusions.length ? (
<div
key={installation}
className="installation-conclusions-wrapper"
Expand Down Expand Up @@ -180,13 +189,13 @@ const View = (props) => {
})
: ''}
</div>
) : (
''
);
})}
</div>
) : (
<p className="info">
No information provided about competent authority
</p>
<p className="info">No information provided about bat conclusions</p>
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ const View = (props) => {
facility: provider_data['facilityInspireId'][index],
};
}
if (!newBatConclusions[installation][batConclusionName]) {
if (
batConclusionName &&
!newBatConclusions[installation][batConclusionName]
) {
newBatConclusions[installation][batConclusionName] = [];
keys.forEach((key) => {
obj[key] = provider_data[key][index];
});
newBatConclusions[installation][batConclusionName].push({ ...obj });
}
keys.forEach((key) => {
obj[key] = provider_data[key][index];
});
newBatConclusions[installation][batConclusionName].push({ ...obj });
});

Object.keys(newBatConclusions)
Expand Down
8 changes: 6 additions & 2 deletions src/components/manage/Blocks/SiteTableau/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const getDevice = (config, width) => {

const View = (props) => {
const [error, setError] = React.useState(null);
const [loaded, setLoaded] = React.useState(false);
const [mounted, setMounted] = React.useState(false);
const [extraFilters, setExtraFilters] = React.useState({});
const { data = {}, query = {}, screen = {}, provider_data = null } = props;
Expand Down Expand Up @@ -80,8 +81,8 @@ const View = (props) => {
)}
{!disabled ? (
<>
{title ? <h3 className="tableau-title">{title}</h3> : ''}
{description ? (
{loaded && title ? <h3 className="tableau-title">{title}</h3> : ''}
{loaded && description ? (
<p className="tableau-description">{description}</p>
) : (
''
Expand All @@ -92,7 +93,9 @@ const View = (props) => {
extraFilters={extraFilters}
extraOptions={{ device }}
error={error}
loaded={loaded}
setError={setError}
setLoaded={setLoaded}
version={version}
url={url}
/>
Expand All @@ -112,6 +115,7 @@ export default compose(
...(qs.parse(state.router.location?.search?.replace('?', '')) || {}),
...(state.discodata_query?.search || {}),
},
tableau: state.tableau,
screen: state.screen,
})),
)(connectBlockToProviderData(View));

0 comments on commit 1f0efdc

Please sign in to comment.