Merge pull request #840 from colouring-cities/copy-tool-enable
Enable copy tool for all fields
This commit is contained in:
commit
8fad7cead9
@ -16,7 +16,7 @@ interface MultiDataEntryProps extends BaseDataEntryProps, TextDataEntryInputProp
|
|||||||
|
|
||||||
export const MultiDataEntry: React.FC<MultiDataEntryProps> = ({
|
export const MultiDataEntry: React.FC<MultiDataEntryProps> = ({
|
||||||
editableEntries = false,
|
editableEntries = false,
|
||||||
copyable = false,
|
copyable = true,
|
||||||
confirmOnEnter = true,
|
confirmOnEnter = true,
|
||||||
...props
|
...props
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -17,6 +17,7 @@ import { CopyControl } from './header-buttons/copy-control';
|
|||||||
import { ViewEditControl } from './header-buttons/view-edit-control';
|
import { ViewEditControl } from './header-buttons/view-edit-control';
|
||||||
|
|
||||||
import './data-container.css';
|
import './data-container.css';
|
||||||
|
import { dataFields } from '../config/data-fields-config'
|
||||||
|
|
||||||
interface DataContainerProps {
|
interface DataContainerProps {
|
||||||
title: string;
|
title: string;
|
||||||
@ -80,11 +81,31 @@ const withCopyEdit: (wc: React.ComponentType<CategoryViewProps>) => DataContaine
|
|||||||
static getDerivedStateFromProps(props, state): DataContainerState {
|
static getDerivedStateFromProps(props, state): DataContainerState {
|
||||||
const newBuildingId = props.building == undefined ? undefined : props.building.building_id;
|
const newBuildingId = props.building == undefined ? undefined : props.building.building_id;
|
||||||
const newBuildingRevisionId = props.building == undefined ? undefined : props.building.revision_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) {
|
if(newBuildingId !== state.currentBuildingId || newBuildingRevisionId > state.currentBuildingRevisionId) {
|
||||||
return {
|
return {
|
||||||
error: undefined,
|
error: undefined,
|
||||||
copying: false,
|
copying: false,
|
||||||
keys_to_copy: {},
|
keys_to_copy: categoryKeys,
|
||||||
buildingEdits: {},
|
buildingEdits: {},
|
||||||
currentBuildingId: newBuildingId,
|
currentBuildingId: newBuildingId,
|
||||||
currentBuildingRevisionId: newBuildingRevisionId
|
currentBuildingRevisionId: newBuildingRevisionId
|
||||||
|
@ -7,12 +7,26 @@ interface CopyProps {
|
|||||||
copyingKey: (key: string) => boolean;
|
copyingKey: (key: string) => boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initCopyProps(options?: Partial<CopyProps>): CopyProps {
|
||||||
|
const defaults = {
|
||||||
|
copying: true,
|
||||||
|
toggleCopying: undefined
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...defaults,
|
||||||
|
...options,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultCopyProps: CopyProps = initCopyProps();
|
||||||
|
|
||||||
interface CategoryViewProps {
|
interface CategoryViewProps {
|
||||||
intro: string;
|
intro: string;
|
||||||
building: Building;
|
building: Building;
|
||||||
mode: 'view' | 'edit' | 'multi-edit';
|
mode: 'view' | 'edit' | 'multi-edit';
|
||||||
edited: boolean;
|
edited: boolean;
|
||||||
copy: CopyProps;
|
copy: defaultCopyProps;
|
||||||
onChange: (key: string, value: any) => void;
|
onChange: (key: string, value: any) => void;
|
||||||
onVerify: (slug: string, verify: boolean, x: number, y: number) => void;
|
onVerify: (slug: string, verify: boolean, x: number, y: number) => void;
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ const CommunityView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
|||||||
onChange={props.onSaveChange}
|
onChange={props.onSaveChange}
|
||||||
mode={props.mode}
|
mode={props.mode}
|
||||||
copy={props.copy}
|
copy={props.copy}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
<LogicalDataEntry
|
<LogicalDataEntry
|
||||||
slug='community_type_worth_keeping'
|
slug='community_type_worth_keeping'
|
||||||
@ -47,7 +48,7 @@ const CommunityView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
|||||||
|
|
||||||
onChange={props.onSaveChange}
|
onChange={props.onSaveChange}
|
||||||
mode={props.mode}
|
mode={props.mode}
|
||||||
copy={props.copy}
|
|
||||||
/>
|
/>
|
||||||
{
|
{
|
||||||
props.building.community_type_worth_keeping !== false &&
|
props.building.community_type_worth_keeping !== false &&
|
||||||
@ -64,6 +65,7 @@ const CommunityView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
|||||||
label: definition.title
|
label: definition.title
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
mode={props.mode}
|
mode={props.mode}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@ -87,7 +89,7 @@ const CommunityView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
|||||||
title={dataFields.community_activities_current.title}
|
title={dataFields.community_activities_current.title}
|
||||||
tooltip={dataFields.community_activities_current.tooltip}
|
tooltip={dataFields.community_activities_current.tooltip}
|
||||||
value={props.building.community_activities_current}
|
value={props.building.community_activities_current}
|
||||||
|
copy={props.copy}
|
||||||
onChange={props.onChange}
|
onChange={props.onChange}
|
||||||
mode={props.mode}
|
mode={props.mode}
|
||||||
/>
|
/>
|
||||||
@ -96,7 +98,7 @@ const CommunityView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
|||||||
title={dataFields.community_activities.title}
|
title={dataFields.community_activities.title}
|
||||||
tooltip={dataFields.community_activities.tooltip}
|
tooltip={dataFields.community_activities.tooltip}
|
||||||
value={props.building.community_activities}
|
value={props.building.community_activities}
|
||||||
|
copy={props.copy}
|
||||||
onChange={props.onChange}
|
onChange={props.onChange}
|
||||||
mode={props.mode}
|
mode={props.mode}
|
||||||
/>
|
/>
|
||||||
@ -105,7 +107,7 @@ const CommunityView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
|||||||
title={dataFields.community_activities_always.title}
|
title={dataFields.community_activities_always.title}
|
||||||
tooltip={dataFields.community_activities_always.tooltip}
|
tooltip={dataFields.community_activities_always.tooltip}
|
||||||
value={props.building.community_activities_always}
|
value={props.building.community_activities_always}
|
||||||
|
copy={props.copy}
|
||||||
onChange={props.onChange}
|
onChange={props.onChange}
|
||||||
mode={props.mode}
|
mode={props.mode}
|
||||||
/>
|
/>
|
||||||
@ -150,10 +152,10 @@ const CommunityView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
|||||||
isUrl={true}
|
isUrl={true}
|
||||||
placeholder={'https://...'}
|
placeholder={'https://...'}
|
||||||
editableEntries={true}
|
editableEntries={true}
|
||||||
|
|
||||||
value={props.building.community_public_ownership_sources}
|
value={props.building.community_public_ownership_sources}
|
||||||
onChange={props.onChange}
|
onChange={props.onChange}
|
||||||
mode={props.mode}
|
mode={props.mode}
|
||||||
|
copy={props.copy}
|
||||||
/>
|
/>
|
||||||
<Verification
|
<Verification
|
||||||
slug="community_public_ownership_sources"
|
slug="community_public_ownership_sources"
|
||||||
|
@ -47,6 +47,7 @@ const TeamView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
|||||||
slug="has_extension"
|
slug="has_extension"
|
||||||
value={props.building.has_extension}
|
value={props.building.has_extension}
|
||||||
mode={props.mode}
|
mode={props.mode}
|
||||||
|
copy={props.copy}
|
||||||
onChange={props.onChange}
|
onChange={props.onChange}
|
||||||
tooltip={dataFields.has_extension.tooltip}
|
tooltip={dataFields.has_extension.tooltip}
|
||||||
/>
|
/>
|
||||||
@ -189,7 +190,7 @@ const TeamView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
|||||||
title={dataFields.designer_awards.title}
|
title={dataFields.designer_awards.title}
|
||||||
tooltip={dataFields.designer_awards.tooltip}
|
tooltip={dataFields.designer_awards.tooltip}
|
||||||
value={props.building.designer_awards}
|
value={props.building.designer_awards}
|
||||||
|
copy={props.copy}
|
||||||
onChange={props.onChange}
|
onChange={props.onChange}
|
||||||
mode={props.mode}
|
mode={props.mode}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user