Add current land use frontend (read-only)

This commit is contained in:
Maciej Ziarkowski 2019-12-03 18:17:04 +00:00
parent 5170dc7971
commit 529ce96e42
4 changed files with 50 additions and 23 deletions

View File

@ -43,7 +43,7 @@ const BuildingView: React.FunctionComponent<BuildingViewProps> = (props) => {
case 'use': case 'use':
return <UseContainer return <UseContainer
{...props} {...props}
inactive={true} inactive={false}
title="Land Use" title="Land Use"
intro="How are buildings used, and how does use change over time? Coming soon…" intro="How are buildings used, and how does use change over time? Coming soon…"
help="https://pages.colouring.london/use" help="https://pages.colouring.london/use"

View File

@ -1,5 +1,9 @@
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
import InfoBox from '../../components/info-box';
import { dataFields } from '../../data_fields';
import DataEntry from '../data-components/data-entry';
import MultiDataEntry from '../data-components/multi-data-entry';
import withCopyEdit from '../data-container'; import withCopyEdit from '../data-container';
import { CategoryViewProps } from './category-view-props'; import { CategoryViewProps } from './category-view-props';
@ -9,28 +13,35 @@ import { CategoryViewProps } from './category-view-props';
*/ */
const UseView: React.FunctionComponent<CategoryViewProps> = (props) => ( const UseView: React.FunctionComponent<CategoryViewProps> = (props) => (
<Fragment> <Fragment>
<p className="data-intro">{props.intro}</p> <InfoBox msg="This category is currently read-only. We are working on enabling its editing soon." />
<ul> <MultiDataEntry
<li>Single or multiple use?</li> title={dataFields.current_landuse_class.title}
{ slug="current_landuse_class"
// "disabled": true, value={props.building.current_landuse_class}
// "slug": "use_multi", mode="view"
// "type": "checkbox" copy={props.copy}
} onChange={props.onChange}
<li>Type of use/s</li> // tooltip={dataFields.current_landuse_class.tooltip}
{ placeholder="New land use class..."
// "disabled": true, />
// "slug": "use_type", <MultiDataEntry
// "type": "text_multi" title={dataFields.current_landuse_group.title}
} slug="current_landuse_group"
<li>Number of self-contained units</li> value={props.building.current_landuse_group}
{ mode="view"
// "disabled": true, copy={props.copy}
// "slug": "use_number_scu", onChange={props.onChange}
// "type": "number", // tooltip={dataFields.current_landuse_class.tooltip}
// "step": 1 placeholder="New land use group..."
} />
</ul> <DataEntry
title={dataFields.current_landuse_order.title}
slug="current_landuse_order"
value={props.building.current_landuse_order}
mode="view"
copy={props.copy}
onChange={props.onChange}
/>
</Fragment> </Fragment>
); );
const UseContainer = withCopyEdit(UseView); const UseContainer = withCopyEdit(UseView);

View File

@ -10,6 +10,9 @@ function formatValue(value: any) {
if(typeof value === 'boolean') { if(typeof value === 'boolean') {
return value ? 'Yes' : 'No'; return value ? 'Yes' : 'No';
} }
if(Array.isArray(value)) {
return value.map(v => `"${v}"`).join(', ');
}
return value; return value;
} }

View File

@ -153,6 +153,19 @@ export const dataFields = {
title: "Longitude", title: "Longitude",
}, },
current_landuse_class: {
category: Category.LandUse,
title: "Current Land Use Class"
},
current_landuse_group: {
category: Category.LandUse,
title: "Current Land Use Group"
},
current_landuse_order: {
category: Category.LandUse,
title: "Current Land Use Order"
},
building_attachment_form: { building_attachment_form: {
category: Category.Type, category: Category.Type,
title: "Building configuration (attachment)?", title: "Building configuration (attachment)?",