Skip to content

Commit

Permalink
Merge pull request #49 from eea/develop
Browse files Browse the repository at this point in the history
include more coremetadata, update csv format
  • Loading branch information
andreiggr authored Nov 24, 2022
2 parents 0aead1b + 6e9ae19 commit dc01bef
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 181 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [5.0.4](https://github.com/eea/volto-plotlycharts/compare/5.0.3...5.0.4) - 24 November 2022

#### :hammer_and_wrench: Others

- block query schema updates [andreiggr - [`b29153f`](https://github.com/eea/volto-plotlycharts/commit/b29153fd60e52b9e3a42d204572f3db3015f79f4)]
- remove even out matrix [andreiggr - [`ee7dbf6`](https://github.com/eea/volto-plotlycharts/commit/ee7dbf678a7863aa852721c184ae6e1802a702ba)]
- include more coremetadata, update csv format [andreiggr - [`6311876`](https://github.com/eea/volto-plotlycharts/commit/6311876368639eb2178344c2c95e371fa402185a)]
### [5.0.3](https://github.com/eea/volto-plotlycharts/compare/5.0.2...5.0.3) - 16 November 2022

#### :hammer_and_wrench: Others

- data query updates [andreiggr - [`db6a18c`](https://github.com/eea/volto-plotlycharts/commit/db6a18c5cc310877fdb589aef2a6ac84a35920c5)]
- have data query from context and custom on block [andreiggr - [`7224436`](https://github.com/eea/volto-plotlycharts/commit/72244367c71ce5534d3d21c18b0ee06bc8583194)]
### [5.0.2](https://github.com/eea/volto-plotlycharts/compare/5.0.1...5.0.2) - 10 November 2022

#### :hammer_and_wrench: Others
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-plotlycharts",
"version": "5.0.3",
"version": "5.0.4",
"description": "Plotly Charts and Editor integration for Volto",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
4 changes: 0 additions & 4 deletions src/Blocks/EmbedEEAVisualization/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ const Edit = (props) => {
has_data_query_by_context: data.has_data_query_by_context,
vis_url: data.vis_url,
with_sources: data.show_sources,
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
4 changes: 0 additions & 4 deletions src/Blocks/EmbedEEAVisualization/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ const View = (props) => {
use_live_data: true,
vis_url: data.vis_url,
with_sources: data.show_sources,
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
71 changes: 3 additions & 68 deletions src/Blocks/EmbedEEAVisualization/schema.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,6 @@
import React from 'react';

const makeMetadataOptions = (data) => {
if (data && data.length > 0) {
return data
.map((item) => [...Object.keys(item)]) //get all keys, should be the same for all
.flat(1) // flatten all arrays
.reduce(function (a, b) {
if (a.indexOf(b) < 0) a.push(b);
return a;
}, []) //remove duplicates. We need only one set of keys
.map((item) => [item, item]); //map them for choices
}
return [];
};

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

const data_provenance_options = makeMetadataOptions(
props?.data_provenance?.data,
);

const temporal_coverage_options = makeMetadataOptions(
props?.temporal_coverage?.temporal,
);

const other_organisations_options = makeMetadataOptions(
props?.other_organisations,
);
return {
title: 'Embed EEA visualization',

Expand All @@ -53,14 +13,7 @@ const Schema = (props) => {
{
id: 'download',
title: 'Download',
fields: [
'download_button',
...(hasSources ? ['include_sources_download'] : []),
...(hasOtherOrg ? ['include_other_org_download'] : []),
...(hasTemporalCoverage
? ['include_temporal_coverage_download']
: []),
],
fields: ['download_button'],
},
{
id: 'data_query',
Expand Down Expand Up @@ -101,24 +54,6 @@ const Schema = (props) => {
title: 'Toggle download',
type: 'boolean',
},
include_sources_download: {
title: 'Download sources',
description: 'Include sources in the dowloaded CSV',
choices: data_provenance_options,
isMulti: true,
},
include_other_org_download: {
title: 'Download other organisations',
description: 'Include other organisations in the dowloaded CSV',
choices: other_organisations_options,
isMulti: true,
},
include_temporal_coverage_download: {
title: 'Download temporal coverage',
description: 'Include temporal coverage in the dowloaded CSV',
choices: temporal_coverage_options,
isMulti: true,
},
show_sources: {
title: 'Toggle sources',
type: 'boolean',
Expand All @@ -129,9 +64,9 @@ const Schema = (props) => {
type: 'boolean',
},
data_query: {
title: 'Block Query',
title: 'Specific block criteria',
description:
'Query data on this block. If context queries are present, block queries will be overridden.',
'Query data on this block. Predefined query criteria options are available only when the taxonomies are present in the site ',
widget: 'data_query',
},
},
Expand Down
57 changes: 13 additions & 44 deletions src/ConnectedChart2/ConnectedChart2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { compose } from 'redux';
import loadable from '@loadable/component';
import { connectToProviderData } from '@eeacms/volto-datablocks/hocs';
import { updateChartDataFromProvider } from '@eeacms/volto-datablocks/helpers';
import { toPublicURL } from '@plone/volto/helpers';

import { connect } from 'react-redux';
import { connectBlockToVisualization } from '@eeacms/volto-plotlycharts/hocs';

Expand All @@ -13,23 +15,6 @@ import { Download } from '../Download';
import { Sources } from '../Sources';

const LoadablePlotly = loadable(() => import('react-plotly.js'));

const filterItemsIds = (items, allowedIds) => {
const newItems =
items && items.length > 0
? items
.map((item) => {
var newItem = {};
allowedIds.forEach((id) => {
newItem[id] = item[id];
});
return newItem;
})
.filter((value) => Object.keys(value).length !== 0)
: [];
return newItems;
};

/*
* ConnectedChart
*/
Expand All @@ -47,6 +32,8 @@ function ConnectedChart2(props) {
data_provenance,
other_organisations,
temporal_coverage,
publisher,
geo_coverage,
} = props;
const with_sources = props?.withSources ?? false;

Expand Down Expand Up @@ -100,9 +87,6 @@ function ConnectedChart2(props) {
'',
};
}
// console.log(provider_data, ' provider_data');
// console.log(props.data.data_query, ' props.data.data_query');
// console.log(chartData, ' chartData');
let data = provider_data
? updateChartDataFromProvider(chartData.data || [], provider_data)
: chartData.data || [];
Expand Down Expand Up @@ -147,29 +131,13 @@ function ConnectedChart2(props) {
}
provider_data={provider_data}
provider_metadata={provider_metadata}
url_source={toPublicURL(props?.location?.pathname)}
core_metadata={{
data_provenance: props.data?.include_sources_download
? filterItemsIds(
data_provenance?.data,
props.data?.include_sources_download,
)
: '',
other_organisations: props.data?.include_other_org_download
? filterItemsIds(
other_organisations,
props.data?.include_other_org_download,
)
: '',
temporal_coverage:
props.data?.include_temporal_coverage_download &&
props.data?.include_temporal_coverage_download.length > 0 &&
temporal_coverage?.temporal &&
temporal_coverage?.temporal?.length > 0
? filterItemsIds(
temporal_coverage?.temporal,
props.data?.include_temporal_coverage_download,
)
: '',
data_provenance: data_provenance?.data,
other_organisations: other_organisations,
temporal_coverage: temporal_coverage?.temporal,
publisher: publisher,
geo_coverage: geo_coverage?.geolocation,
}}
/>
)}
Expand All @@ -191,10 +159,11 @@ function ConnectedChart2(props) {
export default compose(
connect(
(state, props) => ({
//mapped core metadata data to props. Include more if needed
subreq: state.content.subrequests?.[props.id]?.data,
visualization:
state.content.subrequests?.[props.id]?.data?.visualization?.chartData,
//mapped core metadata data to props. Include more if needed
publisher: state.content.subrequests?.[props.id]?.data?.publisher,
geo_coverage: state.content.subrequests?.[props.id]?.data?.geo_coverage,
temporal_coverage:
state.content.subrequests?.[props.id]?.data?.temporal_coverage,
other_organisations:
Expand Down
Loading

0 comments on commit dc01bef

Please sign in to comment.