Add "Common Source Types" list

- This will be the default source type for all fields, unless they need custom data. Then we can manage and edit this list in multiple places
- Use in Location and Land Use pages
This commit is contained in:
Mike Simpson 2023-05-23 15:13:23 +01:00
parent 4e348e7b54
commit 4c32710358
3 changed files with 25 additions and 36 deletions

View File

@ -1,7 +1,7 @@
import React, { Fragment } from 'react';
import InfoBox from '../../components/info-box';
import { dataFields } from '../../config/data-fields-config';
import { commonSourceTypes, dataFields } from '../../config/data-fields-config';
import DataEntry from '../data-components/data-entry';
import { MultiDataEntry } from '../data-components/multi-data-entry/multi-data-entry';
import SelectDataEntry from '../data-components/select-data-entry';
@ -62,8 +62,8 @@ const UseView: React.FunctionComponent<CategoryViewProps> = (props) => {
onChange={props.onChange}
tooltip={dataFields.is_domestic_source.tooltip}
/>
{(props.building.is_domestic_source == "Expert knowledge" ||
props.building.is_domestic_source == "Observed from the street" ||
{(props.building.is_domestic_source == commonSourceTypes[0] ||
props.building.is_domestic_source == commonSourceTypes[1] ||
props.building.is_domestic_source == null) ? <></> :
<><MultiDataEntry
title={dataFields.is_domestic_links.title}

View File

@ -1,5 +1,5 @@
import React, { Fragment } from 'react';
import { dataFields } from '../../config/data-fields-config';
import { commonSourceTypes, dataFields } from '../../config/data-fields-config';
import DataEntry from '../data-components/data-entry';
import NumericDataEntry from '../data-components/numeric-data-entry';
import UPRNsDataEntry from '../data-components/uprns-data-entry';
@ -140,8 +140,8 @@ const LocationView: React.FunctionComponent<CategoryViewProps> = (props) => (
placeholder={dataFields.location_address_source.example}
options={dataFields.location_address_source.items}
/>
{(props.building.location_address_source == "Expert/personal knowledge of building" ||
props.building.location_address_source == "Online streetview image" ||
{(props.building.location_address_source == commonSourceTypes[0] ||
props.building.location_address_source == commonSourceTypes[1] ||
props.building.location_address_source == null) ? <></> :
<>
<MultiDataEntry
@ -248,8 +248,8 @@ const LocationView: React.FunctionComponent<CategoryViewProps> = (props) => (
placeholder={dataFields.location_coordinates_source.example}
options={dataFields.location_coordinates_source.items}
/>
{(props.building.location_coordinates_source == "Expert/personal knowledge of building" ||
props.building.location_coordinates_source == "Online streetview image" ||
{(props.building.location_coordinates_source == commonSourceTypes[0] ||
props.building.location_coordinates_source == commonSourceTypes[1] ||
props.building.location_coordinates_source == null) ? <></> :
<>
<MultiDataEntry

View File

@ -2,6 +2,18 @@ import { Category } from './categories-config';
import { CCConfig } from '../../cc-config';
let ccconfig: CCConfig = require('../../cc-config.json')
/*
* Common list of Source Types, used in multiple menus
*/
export const commonSourceTypes = [
"Expert knowledge",
"Observed from the street",
"Google or other photograph/satellite imagery",
"Government/public record/database",
"Independently managed record/database",
"Other type of record/database"
];
/**
* This interface is used only in code which uses dataFields, not in the dataFields definition itself
* Cannot make dataFields an indexed type ({[key: string]: DataFieldDefinition}),
@ -165,18 +177,10 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
},
location_address_source: {
category: Category.Location,
title: "Source",
title: "Source type",
example: "",
tooltip: "Source of address data.",
items: [
"Expert/personal knowledge of building",
"Online streetview image",
"Open planning authority dataset",
"Open property tax dataset",
"Open housing dataset",
"Open address dataset",
"Other"
]
items: commonSourceTypes
},
location_address_links: {
category: Category.Location,
@ -232,18 +236,10 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
},
location_coordinates_source: {
category: Category.Location,
title: "Source",
title: "Source type",
example: "",
tooltip: "Source of lcoordinate data.",
items: [
"Expert/personal knowledge of building",
"Online streetview image",
"Open planning authority dataset",
"Open property tax dataset",
"Open housing dataset",
"Open address dataset",
"Other"
]
items: commonSourceTypes
},
location_coordinates_links: {
category: Category.Location,
@ -656,14 +652,7 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
title: "Source type",
tooltip: "Source of domestic/non-domestic data",
example: "",
items: [
"Expert knowledge",
"Observed from the street",
"Google or other photograph/satellite imagery",
"Government/public record/database",
"Independently managed record/database",
"Other type of record/database"
]
items: commonSourceTypes
},
is_domestic_links: {
category: Category.Team,