Skip to content

Commit

Permalink
enhancements embed eea
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiggr committed Nov 3, 2022
1 parent 5dbca0b commit f01cf33
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 5 deletions.
23 changes: 21 additions & 2 deletions src/Blocks/EmbedEEAVisualization/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import { SidebarPortal } from '@plone/volto/components';
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
import ConnectedChart2 from '@eeacms/volto-plotlycharts/ConnectedChart2';
import { connect } from 'react-redux';
import { compose } from 'redux';

import '@eeacms/volto-plotlycharts/less/visualization.less';
import Schema from './schema';
Expand All @@ -24,7 +26,6 @@ const Edit = (props) => {
});
}
}, [block, data, onChangeBlock]);

return (
<>
<ConnectedChart2
Expand All @@ -39,6 +40,10 @@ const Edit = (props) => {
vis_url: data.vis_url,
with_sources: data.show_sources,
include_core_metadata_download: data.include_core_metadata_download,
include_sources_download: data?.include_sources_download,
include_other_org_download: data?.include_other_org_download,
include_temporal_coverage_download:
data?.include_temporal_coverage_download,
}}
hoverFormatXY={data.hover_format_xy}
withSources={data.show_sources}
Expand All @@ -64,4 +69,18 @@ const Edit = (props) => {
);
};

export default Edit;
export default compose(
connect(
(state, props) => ({
//mapped core metadata data to props. Include more if needed
temporal_coverage:
state.content.subrequests?.[props.id]?.data?.temporal_coverage,
other_organisations:
state.content.subrequests?.[props.id]?.data?.other_organisations,
data_provenance:
state.content.subrequests?.[props.id]?.data?.data_provenance,
}),
{},
),
//add extra hoc here
)(Edit);
4 changes: 4 additions & 0 deletions src/Blocks/EmbedEEAVisualization/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ const View = (props) => {
with_sources: data.show_sources,
include_core_metadata_download:
data.include_core_metadata_download,
include_sources_download: data?.include_sources_download,
include_other_org_download: data?.include_other_org_download,
include_temporal_coverage_download:
data?.include_temporal_coverage_download,
}}
hoverFormatXY={data.hover_format_xy}
withSources={data.show_sources}
Expand Down
36 changes: 36 additions & 0 deletions src/Blocks/EmbedEEAVisualization/schema.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import React from 'react';

const Schema = (props) => {
const hasSources =
props.data_provenance &&
props.data_provenance.data &&
props.data_provenance.data.length > 0;
const hasOtherOrg =
props.other_organisations && props.other_organisations.length > 0;
const hasTemporalCoverage =
props.temporal_coverage &&
props.temporal_coverage.temporal &&
props.temporal_coverage.temporal.length > 0;

return {
title: 'Embed EEA visualization',

Expand All @@ -17,6 +28,16 @@ const Schema = (props) => {
...(props.data.download_button
? ['include_core_metadata_download']
: []),
...(props.data.download_button &&
props.data.include_core_metadata_download
? [
...(hasSources ? ['include_sources_download'] : []),
...(hasOtherOrg ? ['include_other_org_download'] : []),
...(hasTemporalCoverage
? ['include_temporal_coverage_download']
: []),
]
: []),
],
},
{
Expand Down Expand Up @@ -67,6 +88,21 @@ const Schema = (props) => {
description: 'Include core metadata in the dowloaded CSV',
type: 'boolean',
},
include_sources_download: {
title: 'Download sources',
description: 'Include sources in the dowloaded CSV',
type: 'boolean',
},
include_other_org_download: {
title: 'Download other organisations',
description: 'Include other organisations in the dowloaded CSV',
type: 'boolean',
},
include_temporal_coverage_download: {
title: 'Download temporal coverage',
description: 'Include temporal coverage in the dowloaded CSV',
type: 'boolean',
},
show_sources: {
title: 'Toggle sources',
type: 'boolean',
Expand Down
12 changes: 9 additions & 3 deletions src/ConnectedChart2/ConnectedChart2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,15 @@ function ConnectedChart2(props) {
props.data.include_core_metadata_download
}
core_metadata={{
data_provenance: data_provenance?.data,
other_organisations,
temporal_coverage: temporal_coverage?.temporal,
data_provenance: props.data?.include_sources_download
? data_provenance?.data
: '',
other_organisations: props.data?.include_other_org_download
? other_organisations
: '',
temporal_coverage: props.data?.include_temporal_coverage_download
? temporal_coverage?.temporal
: '',
}}
/>
)}
Expand Down

0 comments on commit f01cf33

Please sign in to comment.