Merge pull request #877 from colouring-cities/team-edits

Team section new fields and renaming some things
This commit is contained in:
Ed Chalstrey 2022-07-22 16:36:05 +01:00 committed by GitHub
commit 324370cf21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 105 additions and 4 deletions

View File

@ -351,6 +351,14 @@ export const buildingAttributesConfig = valueType<DataFieldConfig>()({ /* eslint
edit: true, edit: true,
verify: true verify: true
}, },
landowner: {
edit: true,
verify: true
},
landowner_source_link: {
edit: true,
verify: true
},
designers: { designers: {
edit: true, edit: true,
verify: true verify: true

View File

@ -107,3 +107,41 @@ export const LogicalDataEntry: React.FC<LogicalDataEntryProps> = (props) => {
</> </>
); );
}; };
export const LogicalDataEntryYesOnly: React.FC<LogicalDataEntryProps> = (props) => {
function handleValueChange(e: React.ChangeEvent<HTMLInputElement>) {
props.onChange?.(props.slug, e.target.value === 'true');
}
function handleClear(e: React.MouseEvent<HTMLButtonElement>) {
props.onChange?.(props.slug, null);
}
const isDisabled = props.mode === 'view' || props.disabled;
return (
<>
<DataTitleCopyable
slug={props.slug}
title={props.title}
tooltip={props.tooltip}
disabled={props.disabled || props.value == undefined}
copy={props.copy}
/>
<div className="btn-group btn-group-toggle">
<ToggleButton
value="true"
checked={props.value === true}
disabled={isDisabled || props.disallowTrue}
checkedClassName='btn-outline-dark active'
uncheckedClassName='btn-outline-dark'
onChange={handleValueChange}
>Yes</ToggleButton>
</div>
{
!isDisabled && props.value != null &&
<ClearButton onClick={handleClear} disabled={props.disallowNull}/>
}
</>
);
};

View File

@ -5,7 +5,7 @@ import SelectDataEntry from '../data-components/select-data-entry';
import NumericDataEntry from '../data-components/numeric-data-entry'; import NumericDataEntry from '../data-components/numeric-data-entry';
import Verification from '../data-components/verification'; import Verification from '../data-components/verification';
import { MultiDataEntry } from '../data-components/multi-data-entry/multi-data-entry'; import { MultiDataEntry } from '../data-components/multi-data-entry/multi-data-entry';
import { LogicalDataEntry } from '../data-components/logical-data-entry/logical-data-entry'; import { LogicalDataEntry, LogicalDataEntryYesOnly } from '../data-components/logical-data-entry/logical-data-entry';
import { DataEntryGroup } from '../data-components/data-entry-group'; import { DataEntryGroup } from '../data-components/data-entry-group';
import withCopyEdit from '../data-container'; import withCopyEdit from '../data-container';
@ -22,6 +22,45 @@ const TeamView: React.FunctionComponent<CategoryViewProps> = (props) => {
return ( return (
<form> <form>
<InfoBox msg="Can you help us capture information on who built the current building?"></InfoBox> <InfoBox msg="Can you help us capture information on who built the current building?"></InfoBox>
<MultiDataEntry
title={dataFields.landowner.title}
slug="landowner"
value={props.building.landowner}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
tooltip={dataFields.landowner.tooltip}
placeholder=""
editableEntries={true}
/>
<Verification
slug="landowner"
allow_verify={props.user !== undefined && props.building.landowner !== null && !props.edited}
onVerify={props.onVerify}
user_verified={props.user_verified.hasOwnProperty("landowner")}
user_verified_as={props.user_verified.landowner}
verified_count={props.building.verified.landowner}
/>
<MultiDataEntry
title={dataFields.landowner_source_link.title}
slug="landowner_source_link"
value={props.building.landowner_source_link}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
tooltip={dataFields.landowner_source_link.tooltip}
placeholder="https://..."
editableEntries={true}
isUrl={true}
/>
<Verification
slug="landowner_source_link"
allow_verify={props.user !== undefined && props.building.landowner_source_link !== null && !props.edited}
onVerify={props.onVerify}
user_verified={props.user_verified.hasOwnProperty("landowner_source_link")}
user_verified_as={props.user_verified.landowner_source_link}
verified_count={props.building.verified.landowner_source_link}
/>
<NumericDataEntry <NumericDataEntry
slug='date_year' slug='date_year'
title={dataFields.date_year.title} title={dataFields.date_year.title}
@ -187,7 +226,7 @@ const TeamView: React.FunctionComponent<CategoryViewProps> = (props) => {
user_verified_as={props.user_verified.lead_designer_type} user_verified_as={props.user_verified.lead_designer_type}
verified_count={props.building.verified.lead_designer_type} verified_count={props.building.verified.lead_designer_type}
/> />
<LogicalDataEntry <LogicalDataEntryYesOnly
slug='designer_awards' slug='designer_awards'
title={dataFields.designer_awards.title} title={dataFields.designer_awards.title}
tooltip={dataFields.designer_awards.tooltip} tooltip={dataFields.designer_awards.tooltip}

View File

@ -672,7 +672,7 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
"Community/Cooperative", "Community/Cooperative",
"Other non-profit body", "Other non-profit body",
"Private (individual)", "Private (individual)",
"Private (company/estate)", "Commercial (company/estate)",
"Religious body", "Religious body",
"Other" "Other"
] ]
@ -689,6 +689,18 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
tooltip: "URL for source for developer(s)", tooltip: "URL for source for developer(s)",
example: ["", "", ""], example: ["", "", ""],
}, },
landowner: {
category: Category.Team,
title: "Landowner(s) at time of construction",
tooltip: "Free text. First name, space, then Last name",
example: ["", "", ""],
},
landowner_source_link: {
category: Category.Team,
title: "Source links for landowner(s)",
tooltip: "URL for source for landowner(s)",
example: ["", "", ""],
},
designers: { designers: {
category: Category.Team, category: Category.Team,
title: "Who were the main designer(s)?", title: "Who were the main designer(s)?",
@ -710,7 +722,7 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
"Speculative builder", "Speculative builder",
"Government architecture department", "Government architecture department",
"Architect/ architectural firm", "Architect/ architectural firm",
"Engineering firm", "Engineer/ Engineering firm",
"Other" "Other"
] ]
}, },

View File

@ -0,0 +1,2 @@
ALTER TABLE buildings DROP COLUMN IF EXISTS landowner;
ALTER TABLE buildings DROP COLUMN IF EXISTS landowner_source_link;

View File

@ -0,0 +1,2 @@
ALTER TABLE buildings ADD COLUMN IF NOT EXISTS landowner text[];
ALTER TABLE buildings ADD COLUMN IF NOT EXISTS landowner_source_link text[];