Skip to content

Commit

Permalink
Pollutant index block
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Oct 6, 2020
1 parent 8d68491 commit 18b1b4e
Show file tree
Hide file tree
Showing 9 changed files with 340 additions and 275 deletions.
6 changes: 0 additions & 6 deletions jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
],
"@eeacms/volto-tabs-block": [
"develop/volto-tabs-block/src"
],
"@eeacms/volto-slate-metadata-mentions": [
"develop/volto-slate-metadata-mentions/src"
],
"volto-slate": [
"develop/volto-slate/src"
]
},
"baseUrl": "src"
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"workspaces": [
"src/develop/volto-grid-block",
"src/develop/volto-addons",
"src/develop/volto-datablocks",
"src/develop/volto-slate-metadata-mentions",
"src/develop/volto-slate"
"src/develop/volto-datablocks"
],
"addons": [
"volto-slate:asDefault",
Expand Down Expand Up @@ -115,8 +113,10 @@
"@eeacms/volto-object-widget": "github:eea/volto-object-widget#0.2.1",
"@eeacms/volto-widget-toggle": "github:eea/volto-widget-toggle#0.1.0",
"@eeacms/volto-widgets-view": "github:eea/volto-widgets-view#1.0.1",
"@eeacms/volto-slate-metadata-mentions": "github:eea/volto-slate-metadata-mentions#0.4.1",
"@material/react-linear-progress": "^0.15.0",
"@plone/volto": "github:eea/volto#8.0.0-beta.11",
"volto-slate": "github:eea/volto-slate#0.8.1",
"axios": "^0.20.0",
"jsonp": "^0.2.1",
"ol": "^6.4.3",
Expand Down
2 changes: 1 addition & 1 deletion src/components/manage/Blocks/DetailedLink/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.detailed-link-container .detailed-link-title {
color: #4296B3;
font-weight: 600;
font-size: 18px;
font-size: 1.3em;
line-height: 23px;
margin-bottom: 1em;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,15 @@ a.small h1 {
background-color: transparent;
}

.custom-selector.blue h1.ui.header,
.custom-selector.blue .ui.selection.dropdown,
.custom-selector.blue .ui.selection.dropdown > .default.text,
.custom-selector.blue .ui.selection.dropdown > .text,
.custom-selector.blue .ui.selection.visible.dropdown > .text:not(.default) {
color: #4296B3;
background-color: transparent;
}

.custom-selector.white h1.ui.header,
.custom-selector.white .ui.selection.dropdown,
.custom-selector.white .ui.selection.dropdown > .default.text,
Expand Down
29 changes: 29 additions & 0 deletions src/components/manage/Blocks/PollutantIndex/Edit.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux';
import { compose } from 'redux';
import _uniqueId from 'lodash/uniqueId';
import View from './View';
import { settings } from '~/config';
import './style.css';

const getSchema = (props) => {
return {};
};

const Edit = (props) => {
const [state, setState] = useState({
schema: getSchema({ ...props, providerUrl: settings.providerUrl }),
id: _uniqueId('block_'),
});
return (
<div>
<View {...props} id={state.id} mode="edit" />
</div>
);
};

export default compose(
connect((state, props) => ({
pathname: state.router.location.pathname,
})),
)(Edit);
187 changes: 187 additions & 0 deletions src/components/manage/Blocks/PollutantIndex/View.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/* REACT */
import React, { useState, useEffect } from 'react';
import { compose } from 'redux';
import { connect } from 'react-redux';
import { Tab, Dropdown, Table } from 'semantic-ui-react';
import qs from 'query-string';
import cx from 'classnames';
import './style.css';

const panes = [
{
menuItem: 'General information',
render: (props) => {
return (
<Tab.Pane>
<RenderTable
className="description-table"
celled={false}
headless={true}
headers={[
{ key: 'label', value: 'Label' },
{ key: 'value', value: 'Value' },
]}
rows={[
{ label: 'E-PRTR Pollutant No', value: '9' },
{ label: 'IUPAC Name', value: 'Methane' },
{ label: 'IUPAC Name', value: 'Methane' },
]}
/>
<h3>Description</h3>
<h3>Main Uses</h3>
<h3>Where do the releases originate?</h3>
<h3>How do the releases affect you and your environment?</h3>
</Tab.Pane>
);
},
},
{
menuItem: 'Pollutant Group',
render: () => (
<Tab.Pane>
<h3>Pollutant Group - Greenhouse Gases</h3>
<p className="bold">Group members</p>
</Tab.Pane>
),
},
{
menuItem: 'Pollutant thresholds',
render: () => (
<Tab.Pane>
<h3>Pollutant Group - Greenhouse Gases</h3>
<p className="bold">Threshold for releases</p>
<RenderTable
celled={false}
headless={false}
headers={[
{ key: 'to_air', value: 'to air kg/year' },
{ key: 'to_water', value: 'to water kg/year' },
{ key: 'to_land', value: 'to land kg/year' },
]}
rows={[
{ to_air: '100 000', to_water: '*', to_land: '*' },
{ to_air: '100 000', to_water: '*', to_land: '*' },
{ to_air: '100 000', to_water: '*', to_land: '*' },
]}
/>
</Tab.Pane>
),
},
{
menuItem: 'Measurements and calculations methods',
render: () => (
<Tab.Pane>
<h3>Methods and uncertainty</h3>
<RenderTable
className="description-table"
celled={false}
headless={false}
headers={[
{ key: 'to_air', value: 'to air kg/year' },
{ key: 'to_water', value: 'to water kg/year' },
{ key: 'to_land', value: 'to land kg/year' },
]}
rows={[
{ to_air: '100 000', to_water: '*', to_land: '*' },
{ to_air: '100 000', to_water: '*', to_land: '*' },
{ to_air: '100 000', to_water: '*', to_land: '*' },
]}
/>
</Tab.Pane>
),
},
{
menuItem: 'Synonyms or other commercial names',
render: () => <Tab.Pane>Tab 2 Content</Tab.Pane>,
},
{
menuItem: 'Other relevant reporting requirements',
render: () => <Tab.Pane>Tab 2 Content</Tab.Pane>,
},
];

const RenderTable = (props) => {
const { headless = false, headers = [], rows = [] } = props;
return (
<Table
celled={props.celled}
className={cx(props.className, headless ? 'headless' : '')}
columns={headers.length}
>
{!headless && headers.length > 0 && (
<Table.Header>
<Table.Row>
{headers.map((header, headerIndex) => (
<Table.HeaderCell key={`${headerIndex}_header`}>
{header.value}
</Table.HeaderCell>
))}
</Table.Row>
</Table.Header>
)}
<Table.Body>
{rows.length > 0 &&
headers.length > 0 &&
rows.map((row, rowIndex) => (
<Table.Row key={`${rowIndex}_row`}>
{headers.map((header, headerIndex) => (
<Table.Cell key={`${headerIndex}_cell`}>
{row[header.key]}
</Table.Cell>
))}
</Table.Row>
))}
</Table.Body>
</Table>
);
};

const View = ({ content, ...props }) => {
const [activeTab, setActiveTab] = useState(0);
const pollutionType = [
{
key: 'airPollutionPerCapita',
value: 'airPollutionPerCapita',
text: 'Air',
labelText: 'air pollution per capita',
},
{
key: 'waterPollutionPerCapita',
value: 'waterPollutionPerCapita',
text: 'Water',
labelText: 'water pollution per capita',
},
];
return (
<div className="pollutant-index-container">
<div className="custom-selector big blue display-flex">
<Dropdown
selection
onChange={(event, data) => {}}
placeholder={'Pollutant Group'}
options={pollutionType}
/>
<Dropdown
selection
onChange={(event, data) => {}}
placeholder={'Pollutant'}
options={pollutionType}
/>
</div>
<Tab
activeIndex={activeTab}
panes={panes}
onTabChange={(event, data) => {
setActiveTab(data.activeIndex);
}}
/>
</div>
);
};

export default compose(
connect((state, props) => ({
query: state.router.location.search,
search: state.discodata_query.search,
})),
)(View);
66 changes: 66 additions & 0 deletions src/components/manage/Blocks/PollutantIndex/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.pollutant-index-container .ui.attached.tabular.menu {
flex-wrap: wrap;
border-bottom: 0;
margin-left: -0.5rem;
}

.pollutant-index-container .ui.attached.tabular.menu .item {
padding: 0;
padding-top: 1rem;
padding-bottom: 0.6rem;
margin: 0 0.5rem;
}

.pollutant-index-container .ui.attached.tabular.menu .item:hover {

}

.pollutant-index-container .ui.attached.tabular.menu .active.item {
background-color: transparent !important;
color: #4296B3 !important;
font-weight: bold !important;
border-bottom: 2px solid #4296B3 !important;
border-radius: 0;
}

.pollutant-index-container .ui.attached.tabular.menu .active.item:hover {
background: transparent !important;
color: #3b849e !important;
}

.pollutant-index-container .ui.bottom.attached.segment.active.tab {
padding-left: 0;
padding-right: 0;
}

.pollutant-index-container h3 {
font-size: 1.3em;
}

.pollutant-index-container h3.blue {
color: #4296B3;
}

.pollutant-index-container .ui.table thead th {
text-transform: unset;
}

.pollutant-index-container .ui.table.description-table thead tr th {
background-color: unset;
}

.pollutant-index-container .ui.table.description-table thead tr,
.pollutant-index-container .ui.table.description-table:not(.headless) tbody tr:nth-child(even),
.pollutant-index-container .ui.table.description-table.headless tbody tr:nth-child(odd) {
background-color: #FAF8F8;
}

.pollutant-index-container .ui.table.description-table thead tr:hover,
.pollutant-index-container .ui.table.description-table tbody tr:hover {
background-color: #F4F4F4 !important;
}

.pollutant-index-container .ui.table.description-table tbody tr td:nth-child(1) {
color: #EC776A;
font-weight: bold;
}
12 changes: 12 additions & 0 deletions src/localconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ import QueryParamButtonView from '~/components/manage/Blocks/QueryParamButton/Vi
import IframeEdit from '~/components/manage/Blocks/Iframe/Edit';
import IframeView from '~/components/manage/Blocks/Iframe/View';

import PollutantIndexEdit from '~/components/manage/Blocks/PollutantIndex/Edit';
import PollutantIndexView from '~/components/manage/Blocks/PollutantIndex/View';

import DummyBlockEdit from '~/components/manage/Blocks/DummyBlock/Edit';
import DummyBlockView from '~/components/manage/Blocks/DummyBlock/View';

Expand Down Expand Up @@ -207,6 +210,15 @@ export function applyConfig(voltoConfig) {
icon: packSVG,
};

config.blocks.blocksConfig.eprtr_pollutant_index = {
id: 'eprtr_pollutant_index',
title: 'Eprtr pollutant index',
group: 'eprtr_blocks',
view: PollutantIndexView,
edit: PollutantIndexEdit,
icon: packSVG,
};

config.blocks.blocksConfig.eprtr_dummy_block = {
id: 'eprtr_dummy_block',
title: 'Eprtr dummy block',
Expand Down
Loading

0 comments on commit 18b1b4e

Please sign in to comment.