Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Oct 11, 2020
1 parent 8672665 commit 7a71b72
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 26 additions & 26 deletions src/components/manage/Blocks/PollutantIndex/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ const View = (props) => {
},
});
}
}, [indexPollutantId]);
}, [indexPollutantId, JSON.stringify(indexPollutants)]);

useEffect(() => {
const newPollutantGroup = indexPollutantGroups.filter(
Expand All @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions src/components/theme/View/DefaultView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 5 additions & 3 deletions src/customizations/volto/components/theme/Search/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => (
<Link
key={`item-${pollutant.pollutantId}`}
className="outline dark-blue"
as="a"
to="/glossary/pollutants/pollutant-index"
to="/test"
onClick={() => {
setQueryParam({
this.props.setQueryParam({
queryParam: {
index_pollutant_group_id: parseInt(
pollutant.parentId,
Expand Down

0 comments on commit 7a71b72

Please sign in to comment.