Verify land use group/s

This commit is contained in:
Tom Russell 2020-08-04 17:16:57 +01:00
parent 8f56f96779
commit 77a916134c
2 changed files with 12 additions and 3 deletions

View File

@ -217,8 +217,8 @@ async function verifyBuildingAttributes(buildingId: number, userId: string, patc
for (let [key, value] of Object.entries(patch)) { for (let [key, value] of Object.entries(patch)) {
// check key in whitelist // check key in whitelist
if(BUILDING_FIELD_WHITELIST.has(key)) { if(BUILDING_FIELD_WHITELIST.has(key)) {
// check value against current from database // check value against current from database - JSON.stringify as hack for "any" data type
if (value == building[key]) { if (JSON.stringify(value) == JSON.stringify(building[key])) {
try { try {
await verifyDataAccess.updateBuildingUserVerifiedAttribute(buildingId, userId, key, building[key]); await verifyDataAccess.updateBuildingUserVerifiedAttribute(buildingId, userId, key, building[key]);
verified[key] = building[key]; verified[key] = building[key];
@ -260,7 +260,7 @@ async function getBuildingVerifications(building) {
} }
for (const item of verifications) { for (const item of verifications) {
if (building[item.attribute] == item.verified_value) { if (JSON.stringify(building[item.attribute]) == JSON.stringify(item.verified_value)) {
verified[item.attribute] += 1 verified[item.attribute] += 1
} }
} }

View File

@ -7,6 +7,7 @@ import MultiDataEntry from '../data-components/multi-data-entry/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';
import Verification from '../data-components/verification';
/** /**
* Use view/edit section * Use view/edit section
@ -29,6 +30,14 @@ const UseView: React.FunctionComponent<CategoryViewProps> = (props) => (
showAllOptionsOnEmpty={true} showAllOptionsOnEmpty={true}
addOnAutofillSelect={true} addOnAutofillSelect={true}
/> />
<Verification
slug="current_landuse_group"
allow_verify={props.user !== undefined && props.building.current_landuse_group !== null}
onVerify={props.onVerify}
user_verified={props.user_verified.hasOwnProperty("current_landuse_group")}
user_verified_as={props.user_verified.current_landuse_group && props.user_verified.current_landuse_group.join(", ")}
verified_count={props.building.verified.current_landuse_group}
/>
{ {
props.mode != 'view' && props.mode != 'view' &&
<InfoBox msg="Land use order, shown below, is automatically derived from the land use groups"></InfoBox> <InfoBox msg="Land use order, shown below, is automatically derived from the land use groups"></InfoBox>