diff --git a/app/src/frontend/building/data-components/multi-data-entry/multi-data-entry.tsx b/app/src/frontend/building/data-components/multi-data-entry/multi-data-entry.tsx index 50e38742..318debf1 100644 --- a/app/src/frontend/building/data-components/multi-data-entry/multi-data-entry.tsx +++ b/app/src/frontend/building/data-components/multi-data-entry/multi-data-entry.tsx @@ -16,7 +16,7 @@ interface MultiDataEntryProps extends BaseDataEntryProps, TextDataEntryInputProp export const MultiDataEntry: React.FC = ({ editableEntries = false, - copyable = false, + copyable = true, confirmOnEnter = true, ...props }) => { diff --git a/app/src/frontend/building/data-container.tsx b/app/src/frontend/building/data-container.tsx index 1d47c3bd..fb33e292 100644 --- a/app/src/frontend/building/data-container.tsx +++ b/app/src/frontend/building/data-container.tsx @@ -17,6 +17,7 @@ import { CopyControl } from './header-buttons/copy-control'; import { ViewEditControl } from './header-buttons/view-edit-control'; import './data-container.css'; +import { dataFields } from '../config/data-fields-config' interface DataContainerProps { title: string; @@ -80,11 +81,31 @@ const withCopyEdit: (wc: React.ComponentType) => DataContaine static getDerivedStateFromProps(props, state): DataContainerState { const newBuildingId = props.building == undefined ? undefined : props.building.building_id; const newBuildingRevisionId = props.building == undefined ? undefined : props.building.revision_id; + + const categoryKeys = {}; + const blackListedKeys = ['current_landuse_order', + 'current_landuse_verified', + 'planning_in_list', + 'planning_list_id', + 'planning_list_cat', + 'planning_list_grade', + 'likes_total', + 'community_local_significance_total' + ] + for (let key in dataFields) { + let fieldName = props.building == undefined ? undefined : props.building[key]; + if (dataFields[key].category == props.cat && fieldName != null && !blackListedKeys.includes(key)){ + categoryKeys[key] = true; + } + if (props.cat == 'team' && key == 'date_year' && fieldName != null && !blackListedKeys.includes(key)){ + categoryKeys[key] = true; + } + } if(newBuildingId !== state.currentBuildingId || newBuildingRevisionId > state.currentBuildingRevisionId) { return { error: undefined, copying: false, - keys_to_copy: {}, + keys_to_copy: categoryKeys, buildingEdits: {}, currentBuildingId: newBuildingId, currentBuildingRevisionId: newBuildingRevisionId diff --git a/app/src/frontend/building/data-containers/category-view-props.ts b/app/src/frontend/building/data-containers/category-view-props.ts index 27d510f6..c80504b3 100644 --- a/app/src/frontend/building/data-containers/category-view-props.ts +++ b/app/src/frontend/building/data-containers/category-view-props.ts @@ -7,12 +7,26 @@ interface CopyProps { copyingKey: (key: string) => boolean; } +function initCopyProps(options?: Partial): CopyProps { + const defaults = { + copying: true, + toggleCopying: undefined + }; + + return { + ...defaults, + ...options, + }; +} + +const defaultCopyProps: CopyProps = initCopyProps(); + interface CategoryViewProps { intro: string; building: Building; mode: 'view' | 'edit' | 'multi-edit'; edited: boolean; - copy: CopyProps; + copy: defaultCopyProps; onChange: (key: string, value: any) => void; onVerify: (slug: string, verify: boolean, x: number, y: number) => void; diff --git a/app/src/frontend/building/data-containers/community.tsx b/app/src/frontend/building/data-containers/community.tsx index d074da38..222d9ccc 100644 --- a/app/src/frontend/building/data-containers/community.tsx +++ b/app/src/frontend/building/data-containers/community.tsx @@ -36,6 +36,7 @@ const CommunityView: React.FunctionComponent = (props) => { onChange={props.onSaveChange} mode={props.mode} copy={props.copy} + /> = (props) => { onChange={props.onSaveChange} mode={props.mode} - copy={props.copy} + /> { props.building.community_type_worth_keeping !== false && @@ -64,6 +65,7 @@ const CommunityView: React.FunctionComponent = (props) => { label: definition.title })) } + mode={props.mode} /> } @@ -87,7 +89,7 @@ const CommunityView: React.FunctionComponent = (props) => { title={dataFields.community_activities_current.title} tooltip={dataFields.community_activities_current.tooltip} value={props.building.community_activities_current} - + copy={props.copy} onChange={props.onChange} mode={props.mode} /> @@ -96,7 +98,7 @@ const CommunityView: React.FunctionComponent = (props) => { title={dataFields.community_activities.title} tooltip={dataFields.community_activities.tooltip} value={props.building.community_activities} - + copy={props.copy} onChange={props.onChange} mode={props.mode} /> @@ -105,7 +107,7 @@ const CommunityView: React.FunctionComponent = (props) => { title={dataFields.community_activities_always.title} tooltip={dataFields.community_activities_always.tooltip} value={props.building.community_activities_always} - + copy={props.copy} onChange={props.onChange} mode={props.mode} /> @@ -150,10 +152,10 @@ const CommunityView: React.FunctionComponent = (props) => { isUrl={true} placeholder={'https://...'} editableEntries={true} - value={props.building.community_public_ownership_sources} onChange={props.onChange} mode={props.mode} + copy={props.copy} /> = (props) => { slug="has_extension" value={props.building.has_extension} mode={props.mode} + copy={props.copy} onChange={props.onChange} tooltip={dataFields.has_extension.tooltip} /> @@ -189,7 +190,7 @@ const TeamView: React.FunctionComponent = (props) => { title={dataFields.designer_awards.title} tooltip={dataFields.designer_awards.tooltip} value={props.building.designer_awards} - + copy={props.copy} onChange={props.onChange} mode={props.mode} />