split old planning data into separate section
This commit is contained in:
parent
dc49ff5833
commit
66ee4f2235
@ -4,7 +4,7 @@ import InfoBox from '../../components/info-box';
|
|||||||
import CheckboxDataEntry from '../data-components/checkbox-data-entry';
|
import CheckboxDataEntry from '../data-components/checkbox-data-entry';
|
||||||
|
|
||||||
interface PlanningDataOfficialDataEntryProps {
|
interface PlanningDataOfficialDataEntryProps {
|
||||||
value: {
|
shownData: {
|
||||||
uprn: string;
|
uprn: string;
|
||||||
building_id: number;
|
building_id: number;
|
||||||
description?: string;
|
description?: string;
|
||||||
@ -15,6 +15,7 @@ interface PlanningDataOfficialDataEntryProps {
|
|||||||
data_source: string;
|
data_source: string;
|
||||||
data_source_link?: string;
|
data_source_link?: string;
|
||||||
}[];
|
}[];
|
||||||
|
allEntryCount: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
const {useState} = React;
|
const {useState} = React;
|
||||||
@ -60,8 +61,9 @@ const LinkIfAvailable = (link) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const PlanningDataOfficialDataEntry: React.FC<PlanningDataOfficialDataEntryProps> = (props) => {
|
const PlanningDataOfficialDataEntry: React.FC<PlanningDataOfficialDataEntryProps> = (props) => {
|
||||||
const data = props.value || [];
|
const data = props.shownData || [];
|
||||||
if(data.length == 0) {
|
if(data.length == 0) {
|
||||||
|
if (props.allEntryCount == 0) {
|
||||||
return (<Fragment>
|
return (<Fragment>
|
||||||
<InfoBox type='success'>
|
<InfoBox type='success'>
|
||||||
<i>No live planning data available currently for this building polygon via the Planning London DataHub.</i>
|
<i>No live planning data available currently for this building polygon via the Planning London DataHub.</i>
|
||||||
@ -69,8 +71,17 @@ const PlanningDataOfficialDataEntry: React.FC<PlanningDataOfficialDataEntryProps
|
|||||||
<Disclaimer />
|
<Disclaimer />
|
||||||
</InfoBox>
|
</InfoBox>
|
||||||
</Fragment>);
|
</Fragment>);
|
||||||
|
} else {
|
||||||
|
return (<Fragment>
|
||||||
|
<InfoBox type='success'>
|
||||||
|
<i>No live planning data for this date range, but this building has associated planning data now shown here.</i>
|
||||||
|
<br/>
|
||||||
|
<Disclaimer />
|
||||||
|
</InfoBox>
|
||||||
|
</Fragment>);
|
||||||
}
|
}
|
||||||
return <>{data.map((item) => (
|
}
|
||||||
|
return <>{data.map((item) => (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<InfoBox type='success'>
|
<InfoBox type='success'>
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
@ -20,6 +20,32 @@ import { CategoryViewProps } from './category-view-props';
|
|||||||
import { Category } from '../../config/categories-config';
|
import { Category } from '../../config/categories-config';
|
||||||
|
|
||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
|
const currentTimestamp = new Date().valueOf();
|
||||||
|
const milisecondsInYear = 1000 * 60 * 60 * 24 * 365;
|
||||||
|
|
||||||
|
// TODO: there is already "parseDate" in helpers
|
||||||
|
function parseDate(isoUtcDate: string): Date {
|
||||||
|
const [year, month, day] = isoUtcDate.match(/^(\d{4})-(\d\d)-(\d\d)$/)
|
||||||
|
.splice(1)
|
||||||
|
.map(x => parseInt(x, 10));
|
||||||
|
return new Date(Date.UTC(year, month-1, day));
|
||||||
|
}
|
||||||
|
|
||||||
|
function isArchived(item) {
|
||||||
|
const decisionDate = item.decision_date;
|
||||||
|
console.warn(decisionDate)
|
||||||
|
if(decisionDate != null) {
|
||||||
|
if ((currentTimestamp - parseDate(decisionDate).valueOf()) > milisecondsInYear) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(item.registered_with_local_authority_date != null) {
|
||||||
|
if ((currentTimestamp - parseDate(item.registered_with_local_authority_date).valueOf()) > milisecondsInYear) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const PlanningView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
const PlanningView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
||||||
const communityLinkUrl = `/${props.mode}/${Category.Community}/${props.building.building_id}`;
|
const communityLinkUrl = `/${props.mode}/${Category.Community}/${props.building.building_id}`;
|
||||||
@ -29,8 +55,15 @@ const PlanningView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
|||||||
<InfoBox type='warning'>
|
<InfoBox type='warning'>
|
||||||
This section is under development as part of the project CLPV Tool. For more details and progress <a href="https://github.com/colouring-cities/manual/wiki/G.-Data-capture-methods">read here</a>.
|
This section is under development as part of the project CLPV Tool. For more details and progress <a href="https://github.com/colouring-cities/manual/wiki/G.-Data-capture-methods">read here</a>.
|
||||||
</InfoBox>
|
</InfoBox>
|
||||||
<PlanningDataOfficialDataEntry
|
<PlanningDataOfficialDataEntry
|
||||||
value={props.building.planning_data}
|
shownData={props.building.planning_data ? props.building.planning_data.filter(item => isArchived(item) == false) : []}
|
||||||
|
allEntryCount={props.building.planning_data ? props.building.planning_data.length : 0}
|
||||||
|
/>
|
||||||
|
</DataEntryGroup>
|
||||||
|
<DataEntryGroup name="Older planning data" collapsed={true} >
|
||||||
|
<PlanningDataOfficialDataEntry
|
||||||
|
shownData={props.building.planning_data ? props.building.planning_data.filter(item => isArchived(item)) : []}
|
||||||
|
allEntryCount={props.building.planning_data ? props.building.planning_data.length : 0}
|
||||||
/>
|
/>
|
||||||
</DataEntryGroup>
|
</DataEntryGroup>
|
||||||
<DataEntryGroup name="Crowdsourced planning application data" collapsed={false} >
|
<DataEntryGroup name="Crowdsourced planning application data" collapsed={false} >
|
||||||
|
@ -137,7 +137,7 @@ const LAYER_QUERIES = {
|
|||||||
community_public_ownership IS NOT NULL
|
community_public_ownership IS NOT NULL
|
||||||
`,
|
`,
|
||||||
planning_applications_status: `SELECT
|
planning_applications_status: `SELECT
|
||||||
buildings.geometry_id, building_properties.uprn, building_properties.building_id, planning_data.status AS status, planning_data.uprn
|
buildings.geometry_id, building_properties.uprn, building_properties.building_id, planning_data.status AS status, planning_data.uprn, planning_data.decision_date, planning_data.registered_with_local_authority_date
|
||||||
FROM building_properties
|
FROM building_properties
|
||||||
INNER JOIN planning_data ON building_properties.uprn = planning_data.uprn
|
INNER JOIN planning_data ON building_properties.uprn = planning_data.uprn
|
||||||
INNER JOIN buildings ON building_properties.building_id = buildings.building_id`,
|
INNER JOIN buildings ON building_properties.building_id = buildings.building_id`,
|
||||||
|
Loading…
Reference in New Issue
Block a user