Skip to content

Commit

Permalink
Merge pull request #21 from eea/develop
Browse files Browse the repository at this point in the history
Patch
  • Loading branch information
razvanMiu authored Oct 6, 2021
2 parents 32d342e + 1265a41 commit 2f597a3
Show file tree
Hide file tree
Showing 8 changed files with 677 additions and 385 deletions.
68 changes: 59 additions & 9 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docker-image.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eeacms/eprtr-frontend
eeacms/eprtr-frontend:2.2.0
2 changes: 1 addition & 1 deletion locales/de.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion locales/en.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@eeacms/eprtr_frontend",
"description": "Volto-based frontend server and SPA for the Industrial Emissions Portal website (former EPRTR) industry.eea.europa.eu",
"license": "MIT",
"version": "2.2.0",
"version": "2.3.0",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
"homepage": "https://github.com/eea/eprtr_frontend",
Expand Down Expand Up @@ -46,23 +46,23 @@
"@eeacms/volto-tableau"
],
"dependencies": {
"@eeacms/volto-eea-kitkat": "2.0.2",
"@material/react-linear-progress": "^0.15.0",
"@eeacms/volto-embed": "2.0.3",
"@eeacms/volto-datablocks": "2.0.12",
"@eeacms/volto-datablocks": "2.0.13",
"@eeacms/volto-eea-kitkat": "4.0.1",
"@eeacms/volto-embed": "2.0.4",
"@eeacms/volto-grid-block": "github:eea/volto-grid-block#centurion",
"@eeacms/volto-openlayers-map": "0.1.2",
"@eeacms/volto-tableau": "1.2.3",
"@eeacms/volto-grid-block": "github:eea/volto-grid-block#centurion",
"@material/react-linear-progress": "^0.15.0",
"@plone/volto": "13.15.1",
"volto-addons": "github:eea/volto-addons#master",
"axios": "^0.21.1",
"jsonp": "^0.2.1",
"performant-array-to-tree": "^1.7.1",
"react-highlight-words": "^0.16.0",
"react-iframe": "^1.8.0",
"react-tooltip": "^4.2.9",
"react-visibility-sensor": "^5.1.1",
"tableau-api-js": "github:eea/tableau-api-js#1.1.0"
"tableau-api-js": "github:eea/tableau-api-js#1.1.0",
"volto-addons": "github:eea/volto-addons#master"
},
"devDependencies": {
"eslint-plugin-prettier": "3.1.3",
Expand Down
13 changes: 11 additions & 2 deletions src/components/manage/Blocks/DiscodataOpenlayersMapBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,14 @@ const OpenlayersMapView = (props) => {
},
// Facility type
facilityTypes: {
sql: `(facilityTypes LIKE ':options')`,
sql: (options) => {
const isEprtr = options.indexOf('EPRTR') !== -1;
const isNonEprtr = options.indexOf('NONEPRTR') !== -1;
if (isEprtr && isNonEprtr) return null;
if (isEprtr)
return `((facilityTypes LIKE 'EPRTR%') OR (facilityTypes LIKE '% EPRTR'))`;
return `((facilityTypes LIKE 'NONEPRTR%') OR (facilityTypes LIKE '% NONEPRTR'))`;
},
type: 'multiple',
},
// Plant type
Expand Down Expand Up @@ -565,7 +572,9 @@ const OpenlayersMapView = (props) => {
if (where.type === 'multiple') {
options = isArray(options) ? options?.filter((option) => option) : [];
const conditions = [];
if (options?.length) {
if (typeof where.sql === 'function' && options?.length) {
where.sql = where.sql(props.query[id]);
} else if (options?.length) {
options.forEach((option) => {
let baseSql = where.sql;
option && conditions.push(baseSql.replace(/:options/g, option));
Expand Down
93 changes: 55 additions & 38 deletions src/components/manage/Blocks/FiltersBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
import React, { useState, useEffect, useRef } from 'react';
import { compose } from 'redux';
import { connect } from 'react-redux';
import { Header, Modal, Select, Input, List } from 'semantic-ui-react';
import {
Header,
Modal,
Select,
Input,
List,
Checkbox,
} from 'semantic-ui-react';
import { Portal } from 'react-portal';
import _uniqueId from 'lodash/uniqueId';
import axios from 'axios';
Expand Down Expand Up @@ -48,7 +55,6 @@ const View = ({ content, ...props }) => {
'pollutant_groups',
'pollutants',
'reporting_years',
'facility_types',
'plant_types',
'bat_conclusions',
'permit_types',
Expand Down Expand Up @@ -452,42 +458,6 @@ const View = ({ content, ...props }) => {
delete filtersMeta[key];
}
});
filtersMeta['facility_types'] = {
filteringInputs: [
{
id: _uniqueId('select_'),
type: 'select',
position: 0,
},
],
placeholder: 'Select facility type',
queryToSet: 'facilityTypes',
title: 'Facility type',
static: true,
options: [
{ key: null, value: null, text: 'No value' },
{
key: 'EPRTR',
value: 'EPRTR',
text: 'EPRTR',
},
{
key: 'NONEPRTR',
value: 'NONEPRTR',
text: 'NONEPRTR',
},
{
key: 'EPRTR, NONEPRTR',
value: 'EPRTR, NONEPRTR',
text: 'EPRTR, NONEPRTR',
},
{
key: 'NONEPRTR, EPRTR',
value: 'NONEPRTR, EPRTR',
text: 'NONEPRTR, EPRTR',
},
],
};
response.forEach((res, index) => {
const results = JSON.parse(res.request.response).results;
let filteringInputs = [];
Expand Down Expand Up @@ -1224,6 +1194,34 @@ const View = ({ content, ...props }) => {
</div>
);

const setCheckboxValue = (_, data) => {
let values = props.discodata_query.search[data.name] || [];
const checked = data.checked;
const index = values.indexOf(data.label);
if (checked && index === -1) {
values.push(data.label);
}
if (!checked && index !== -1) {
values.splice(index, 1);
}
props.setQueryParam({
queryParam: {
[data.name]: values,
locationTerm: null,
siteTerm: null,
advancedFiltering: true,
filtersCounter: props.discodata_query.search['filtersCounter']
? props.discodata_query.search['filtersCounter'] + 1
: 1,
},
});
setSearchTerm('');
};

const isChecked = (name, label) => {
return (props.discodata_query.search[name] || []).indexOf(label) !== -1;
};

if (!__CLIENT__) return '';
return (
<div className="filters-container">
Expand Down Expand Up @@ -1566,6 +1564,25 @@ const View = ({ content, ...props }) => {
/>
</form>
</div>

<Header as="h3">Facility type</Header>
<div className="input-container">
<form autoComplete="facilityTypes">
<Checkbox
name="facilityTypes"
label="EPRTR"
style={{ marginRight: '1rem' }}
checked={isChecked('facilityTypes', 'EPRTR')}
onChange={setCheckboxValue}
/>
<Checkbox
name="facilityTypes"
label="NONEPRTR"
checked={isChecked('facilityTypes', 'NONEPRTR')}
onChange={setCheckboxValue}
/>
</form>
</div>
</div>
<div className="dynamic-filter-actions">
<button
Expand Down
Loading

0 comments on commit 2f597a3

Please sign in to comment.