Commit 83af326b authored by Aron Fiechter's avatar Aron Fiechter
Browse files

Add methods to determine whether an entity is inside the year range

parent df8b62df
......@@ -51,6 +51,7 @@ class Voronoi extends React.Component {
this.goDownAll = this.goDownAll.bind(this);
this.goUp = this.goUp.bind(this);
this.findChildrenOf = this.findChildrenOf.bind(this);
this.isEntityInYearRange = this.isEntityInYearRange.bind(this);
}
/**
......@@ -432,6 +433,21 @@ class Voronoi extends React.Component {
});
}
/**
* Whether an entity is in the selected year range.
* At least one of the entity years must fall in the year range.
* @returns {boolean}
*/
isEntityInYearRange(e) {
const { start, end } = this.props.yearRange;
const entityYears = this.props.resultsById[e.name]?.years;
// If entity does not have years, it's not a document/dossier
if (entityYears?.length) {
return entityYears.some((y) => y >= start && y <= end);
}
return true;
}
render() {
const { width, height } = this.props;
return (
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment