From 7a71b728c5e8999c6f9d0e11a2da4c0537605501 Mon Sep 17 00:00:00 2001 From: Miu Razvan Date: Sun, 11 Oct 2020 23:35:46 +0300 Subject: [PATCH] Update --- .../Blocks/DiscodataComponentsBlock/View.jsx | 4 +- .../manage/Blocks/PollutantIndex/View.jsx | 52 +++++++++---------- src/components/theme/View/DefaultView.jsx | 11 ++++ .../volto/components/theme/Search/Search.jsx | 8 +-- 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/components/manage/Blocks/DiscodataComponentsBlock/View.jsx b/src/components/manage/Blocks/DiscodataComponentsBlock/View.jsx index f18839f6..cd19967c 100644 --- a/src/components/manage/Blocks/DiscodataComponentsBlock/View.jsx +++ b/src/components/manage/Blocks/DiscodataComponentsBlock/View.jsx @@ -68,8 +68,8 @@ const renderComponents = { }, header: (props) => { let value = props.item?.[props.component?.value]; - if (value && !isNaN(Date.parse(value)) && value.length >= 10) { - value = moment(props.item[value]).format('DD MMM YYYY'); + if (value && value && moment(value, 'DD-MM-YYYY', true).isValid()) { + value = moment(value).format('DD MMM YYYY'); } const text = props.component?.static ? props.component?.staticValue diff --git a/src/components/manage/Blocks/PollutantIndex/View.jsx b/src/components/manage/Blocks/PollutantIndex/View.jsx index e8addd0f..5ad4d919 100644 --- a/src/components/manage/Blocks/PollutantIndex/View.jsx +++ b/src/components/manage/Blocks/PollutantIndex/View.jsx @@ -636,7 +636,7 @@ const View = (props) => { }, }); } - }, [indexPollutantId]); + }, [indexPollutantId, JSON.stringify(indexPollutants)]); useEffect(() => { const newPollutantGroup = indexPollutantGroups.filter( @@ -648,32 +648,32 @@ const View = (props) => { ? newPollutantGroup : undefined, ); - }, [indexPollutantGroupId]); + }, [indexPollutantGroupId, JSON.stringify(indexPollutantGroups)]); - useEffect(() => { - if ( - mounted.current && - !initialized && - !indexPollutantGroupId && - indexPollutantGroups.length > 0 && - indexPollutants.length > 0 - ) { - props.setQueryParam({ - queryParam: { - index_pollutant_group_id: parseInt(indexPollutants[0].parentId), - index_pollutant_id: parseInt(indexPollutants[0].pollutantId), - }, - }); - setCurrentPollutantGroup( - indexPollutantGroups.filter( - (group) => - parseInt(group.pollutantId) === - parseInt(indexPollutants[0].parentId), - )[0], - ); - setInitialized(true); - } - }, [indexPollutantGroups?.length, indexPollutants?.length]); + // useEffect(() => { + // if ( + // mounted.current && + // !initialized && + // !indexPollutantGroupId && + // indexPollutantGroups.length > 0 && + // indexPollutants.length > 0 + // ) { + // props.setQueryParam({ + // queryParam: { + // index_pollutant_group_id: parseInt(indexPollutants[0].parentId), + // index_pollutant_id: parseInt(indexPollutants[0].pollutantId), + // }, + // }); + // setCurrentPollutantGroup( + // indexPollutantGroups.filter( + // (group) => + // parseInt(group.pollutantId) === + // parseInt(indexPollutants[0].parentId), + // )[0], + // ); + // setInitialized(true); + // } + // }, [indexPollutantGroups?.length, indexPollutants?.length]); useEffect(() => { mounted.current = true; diff --git a/src/components/theme/View/DefaultView.jsx b/src/components/theme/View/DefaultView.jsx index de0172a2..3e761841 100644 --- a/src/components/theme/View/DefaultView.jsx +++ b/src/components/theme/View/DefaultView.jsx @@ -37,6 +37,17 @@ const DefaultView = ({ content, intl, location }) => { const blocksLayoutFieldname = getBlocksLayoutFieldname(content); const contentTypeBlocks = content['@components']?.layout?.[blocksFieldname]; + useEffect(() => { + if (content['@type' === 'site_template']) { + const hashElement = document.getElementById( + location.hash.replace('#', ''), + ); + if (hashElement) { + hashElement.scrollIntoView(); + } + } + }, []); + useEffect(() => { if (content['@type' === 'site_template']) { const hashElement = document.getElementById( diff --git a/src/customizations/volto/components/theme/Search/Search.jsx b/src/customizations/volto/components/theme/Search/Search.jsx index 26ac1a0e..4e39c730 100644 --- a/src/customizations/volto/components/theme/Search/Search.jsx +++ b/src/customizations/volto/components/theme/Search/Search.jsx @@ -392,16 +392,18 @@ class Search extends Component { .filter( (pollutant) => pollutant.pollutantId && - pollutant.name.includes(this.props.searchableText), + pollutant.name + .toLowerCase() + .includes(this.props.searchableText.toLowerCase()), ) .map((pollutant) => ( { - setQueryParam({ + this.props.setQueryParam({ queryParam: { index_pollutant_group_id: parseInt( pollutant.parentId,