From 7697ce2c4d6a51405605ade27c013a25c76360af Mon Sep 17 00:00:00 2001 From: razvanMiu Date: Mon, 24 May 2021 13:26:54 +0300 Subject: [PATCH] Update --- .../manage/Blocks/FiltersBlock/View.jsx | 29 +- .../manage/Blocks/PollutantIndex/View.jsx | 506 +----------------- 2 files changed, 37 insertions(+), 498 deletions(-) diff --git a/src/components/manage/Blocks/FiltersBlock/View.jsx b/src/components/manage/Blocks/FiltersBlock/View.jsx index 1c367f1e..1adc99c6 100644 --- a/src/components/manage/Blocks/FiltersBlock/View.jsx +++ b/src/components/manage/Blocks/FiltersBlock/View.jsx @@ -423,9 +423,10 @@ const View = ({ content, ...props }) => { metadata.push(dynamicRequests.meta[index]); } }); - setLoadingData(true); } + if (!promises?.length) return; + setLoadingData(true); Promise.all(promises) .then((response) => { if (mounted.current) { @@ -760,13 +761,35 @@ const View = ({ content, ...props }) => { const clearFilters = () => { const newFilters = { ...state.filters }; - Object.keys(newFilters).forEach((filter) => { - newFilters[filter] = newFilters[filter].map((value) => null); + const newFiltersMeta = { ...state.filtersMeta }; + + Object.keys(state.filters).forEach((key) => { + newFilters[key] = [null]; + }); + + Object.keys(state.filtersMeta).forEach((key) => { + if ( + ['regions', 'river_basins', 'provinces', 'pollutants'].includes(key) + ) { + delete newFiltersMeta[key]; + } else { + newFiltersMeta[key].filteringInputs = [ + { + id: _uniqueId('select_'), + type: 'select', + position: 0, + }, + ]; + } }); + + setState({ ...state, filters: newFilters, + filtersMeta: newFiltersMeta, }); + setSitesResults([]); setLocationResults([]); setSearchTerm(''); diff --git a/src/components/manage/Blocks/PollutantIndex/View.jsx b/src/components/manage/Blocks/PollutantIndex/View.jsx index 5a01523d..f45635dd 100644 --- a/src/components/manage/Blocks/PollutantIndex/View.jsx +++ b/src/components/manage/Blocks/PollutantIndex/View.jsx @@ -65,14 +65,14 @@ const panes = [ }, { label: 'IUPAC Name', value: pollutant.IUPAC_Name || '-' }, { label: 'CAS Number', value: pollutant.cas_no || '-' }, - { label: 'EC Number ', value: pollutant.ec_no || '-' }, - { label: 'SMILES tooltip', value: pollutant.smiles_code || '-' }, - { label: 'Chemspider id', value: pollutant.chemspider_id || '-' }, + // { label: 'EC Number ', value: pollutant.ec_no || '-' }, + // { label: 'SMILES tooltip', value: pollutant.smiles_code || '-' }, + // { label: 'Chemspider id', value: pollutant.chemspider_id || '-' }, { label: 'Formula', value: molecular_formula || '-' }, - { - label: 'Classification', - value: classification || '-', - }, + // { + // label: 'Classification', + // value: classification || '-', + // }, ]} /> {pollutant.description ? ( @@ -125,61 +125,6 @@ const panes = [ ); }, }, - { - menuItem: 'Pollutant Group', - render: (props) => { - const { pollutants = [], pollutant_group = {} } = props.data; - const sub = pollutant_group.sub - ?.split('|') - ?.map((sub) => sub.replace(/['"]+/g, '')); - const description = pollutant_group.description - ?.replace(/['"]+/g, '') - .split('\n') - .map( - (element, index) => - element + (sub?.[index] ? `${sub[index]}` : ''), - ) - .join(''); - - if (!pollutants?.length) return ''; - return ( - - {pollutant_group.name ? ( -
-

{`Pollutant Group - ${pollutant_group.name}`}

-
- ) : ( - '' - )} - {description ? ( -
-

-

- ) : ( - '' - )} - {pollutants?.length > 0 ? ( -
-

Group members

-
    - {pollutants.map((pollutant, index) => ( -
  • - {pollutant.name} -
  • - ))} -
-
- ) : ( - '' - )} -
- ); - }, - }, { menuItem: 'Pollutant thresholds', render: (props) => { @@ -218,438 +163,6 @@ const panes = [ ); }, }, - { - menuItem: 'Measurements and calculations methods', - render: (props) => { - const { pollutant_iso = [] } = props.data; - - return ( - -

Methods and uncertainty

- {pollutant_iso?.length > 0 ? ( - { - const uncertainty_sup = iso.uncertainty_sup - ?.split('|') - ?.map((sub) => sub.replace(/['"]+/g, '')); - const uncertainty_text = iso.uncertainty_text - ?.replace(/['"]+/g, '') - .split('\n') - .map( - (element, index) => - element + - (uncertainty_sup?.[index] - ? `${uncertainty_sup[index]}` - : ''), - ) - .join(''); - return { - standard: iso.standard, - title: iso.title, - target: iso.target, - uncertainty: uncertainty_text, - }; - })} - /> - ) : ( - '' - )} - -
-

Footnotes

-

- (*) indicates that performance information is included in the - standard but not in a suitable form for inclusion. -

-

(-) Indicates that no information is available.

-

- Notes:This table is based on the following published information: - the 2003 General Principles of Monitoring BREF{' '} - - http://eippcb.jrc.es/reference/ - - ; CEN and ISO websites and those of their relevant Technical - Committees (TCs) for details and publication dates ( i.e. CEN - TC230 – water analysis and CEN TC 264 – air quality, ISO TC 147 – - water quality and ISO TC 146 – air quality); and current UK - guidance on monitoring for air and water for IPPC Directive - installations (Environment Agency documents M2 Version 6 - January - 2010and M18 Version 2 - April 2009 covering air and water - respectively) available on{' '} - - http://www.environment-agency.gov.uk/business/regulation/31831.aspx - - ).Standard numbers have been checked against CEN and ISO websites - and, to best of our knowledge, are both available and consistent - with EN or ISO publication dates. -

-

- Information related to uncertainty is included where it is - available, in a suitable form, in the standard.The information - given for Stationary source emissions generally refers to sampling - and analysis, that for Water quality data refers to the - coefficient of variation of reproducibility - CVR - of the - analysis alone.CVR is the reproducibility standard deviation/mean - concentration, expressed as a %, this has been expressed to one - significant decimal place %. Wherever possible we have taken the - sample matrix most similar to the industrial discharges to be - reported under the EPRTR Regulation.Where the Standard allows a - choice of technique we have taken the 'worst' case - on - the basis that if an operator reports a discharge as having been - measured in accordance with the Standard and not necessarily a - particular variation of it. -

-
-
- ); - }, - }, - { - menuItem: 'Synonyms or other commercial names', - render: (props) => { - const { pollutant = {} } = props.data; - const synonyms = []; - pollutant.synonyms && - pollutant.synonyms.split('|').forEach((synonym) => { - synonyms.push(synonym.replace(/['"]+/g, '')); - }); - return ( - -

Synonyms or other commercial names

- -
- ); - }, - }, - { - menuItem: 'Other relevant reporting requirements', - render: (props) => { - const { other_provisions = [] } = props.data; - const provisionsOrder = []; - const provisions = {}; - other_provisions.forEach((provision) => { - if (!provisions[provision.other_provision_id]) { - provisions[provision.other_provision_id] = {}; - provisionsOrder.push(provision.other_provision_id); - } - provisions[provision.other_provision_id][ - provision.other_provision_type - ] = provision; - }); - - const getProvisionText = (sub, text) => { - const parsed_sub = sub - ?.split('|') - ?.map((sub) => sub.replace(/['"]+/g, '')); - return text - ?.replace(/['"]+/g, '') - .split('\n') - .map( - (element, index) => - element + - (parsed_sub?.[index] ? `${parsed_sub[index]}` : ''), - ) - .join(''); - }; - - return ( - -
-

- Overview of relevant reporting requirements for the selected - pollutant or compound set by European Regulations or Multilateral - Environmental Agreements (MEAs). -

- {provisionsOrder.map((provision, index) => ( -
- {provisions[provision].other_provision_instrument - ?.other_provision_text ? ( -

- -

- ) : ( - '' - )} - {provisions[provision].other_provision_overview - ?.other_provision_text ? ( -
-

Overview

-

-

- ) : ( - '' - )} - {provisions[provision].other_provision_reporting - ?.other_provision_text ? ( -
-

General Reporting

-

-

- ) : ( - '' - )} - {provisions[provision].other_provision_specific - ?.other_provision_text ? ( -
-

Specific Reporting

-

-

- ) : ( - '' - )} -
- ))} -
-
- ); - }, - }, - { - menuItem: 'Hazards and other technical characteristics', - render: (props) => { - const { pollutant = {}, phrases = [] } = props.data; - const phrasesTypes = { - clp_phrase: 'clp_phrase', - ghs_phrase: 'ghs_phrase', - r_phrase: 'r_s_phrase', - s_phrase: 'r_s_phrase', - }; - const phrasesByType = {}; - phrases.forEach((phrase) => { - if (!phrasesByType[phrasesTypes[phrase.phrase_type]]) { - phrasesByType[phrasesTypes[phrase.phrase_type]] = [phrase]; - } else { - phrasesByType[phrasesTypes[phrase.phrase_type]].push(phrase); - } - }); - - return ( - -

Risk and Safety Phrases (R&S)

-

- Risk and Safety phrases describe the risks of a substance and safety - measures that should be taken. -

- - -

Classification & Labelling

-

- The Regulation (EC) No 1272/2008 establishes a standard - classification and labelling system for substances distinguishing a) - Hazard Class and b) Hazard Statements -

- - Regulation (EC) No 1272/2008, OJ L 353 - -

Hazard Class

- -

Hazard Statements

- -

Physical Properties

- row.value)} - /> -

Human Health & Environmental Hazard Assessment

- row.value)} - /> -
- ); - }, - }, ]; const RenderTable = (props) => { @@ -697,12 +210,14 @@ const View = (props) => { const [activeTab, setActiveTab] = useState(0); const [currentPollutant, setCurrentPollutant] = useState(undefined); const [currentPollutantGroup, setCurrentPollutantGroup] = useState(undefined); - const [dataReady, setDataReady] = useState(false); const mounted = useRef(false); const indexPollutantId = props.discodata_query.search.index_pollutant_id || null; const indexPollutantGroupId = props.discodata_query.search.index_pollutant_group_id || null; + const [dataReady, setDataReady] = useState( + indexPollutantId && indexPollutantGroupId, + ); const indexPollutantGroups = props.discodata_resources.data.index_pollutant_groups || []; const indexPollutants = props.discodata_resources.data.index_pollutants || []; @@ -730,6 +245,7 @@ const View = (props) => { }); setDataReady(true); } + /* eslint-disable-next-line */ }, [indexPollutants, indexPollutantGroups]); useEffect(() => {