From 77a916134c35eb3479cad7911cdcda2a890dcc5a Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Tue, 4 Aug 2020 17:16:57 +0100 Subject: [PATCH] Verify land use group/s --- app/src/api/services/building.ts | 6 +++--- app/src/frontend/building/data-containers/use.tsx | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/api/services/building.ts b/app/src/api/services/building.ts index 3bb4bd55..c3c2c955 100644 --- a/app/src/api/services/building.ts +++ b/app/src/api/services/building.ts @@ -217,8 +217,8 @@ async function verifyBuildingAttributes(buildingId: number, userId: string, patc for (let [key, value] of Object.entries(patch)) { // check key in whitelist if(BUILDING_FIELD_WHITELIST.has(key)) { - // check value against current from database - if (value == building[key]) { + // check value against current from database - JSON.stringify as hack for "any" data type + if (JSON.stringify(value) == JSON.stringify(building[key])) { try { await verifyDataAccess.updateBuildingUserVerifiedAttribute(buildingId, userId, key, building[key]); verified[key] = building[key]; @@ -260,7 +260,7 @@ async function getBuildingVerifications(building) { } 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 } } diff --git a/app/src/frontend/building/data-containers/use.tsx b/app/src/frontend/building/data-containers/use.tsx index 976e3e58..a85f22e5 100644 --- a/app/src/frontend/building/data-containers/use.tsx +++ b/app/src/frontend/building/data-containers/use.tsx @@ -7,6 +7,7 @@ import MultiDataEntry from '../data-components/multi-data-entry/multi-data-entry import withCopyEdit from '../data-container'; import { CategoryViewProps } from './category-view-props'; +import Verification from '../data-components/verification'; /** * Use view/edit section @@ -29,6 +30,14 @@ const UseView: React.FunctionComponent = (props) => ( showAllOptionsOnEmpty={true} addOnAutofillSelect={true} /> + { props.mode != 'view' &&