Process input value inside CheckboxDataEntry

This commit is contained in:
Maciej Ziarkowski 2019-10-17 14:38:52 +01:00
parent ca4750b0be
commit 7c042dd58e
2 changed files with 18 additions and 14 deletions

View File

@ -2,8 +2,14 @@ import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { DataTitleCopyable } from './data-title';
import { BaseDataEntryProps } from './data-entry';
const DataEntry: React.FunctionComponent<any> = (props) => { // TODO: remove any
interface CheckboxDataEntryProps extends BaseDataEntryProps {
value: boolean;
}
const CheckboxDataEntry: React.FunctionComponent<CheckboxDataEntryProps> = (props) => {
return (
<Fragment>
<DataTitleCopyable
@ -19,7 +25,7 @@ const DataEntry: React.FunctionComponent<any> = (props) => { // TODO: remove any
name={props.slug}
checked={!!props.value}
disabled={props.mode === 'view' || props.disabled}
onChange={props.onChange}
onChange={e => props.onChange(props.slug, e.target.checked)}
/>
<label
htmlFor={props.slug}
@ -31,14 +37,12 @@ const DataEntry: React.FunctionComponent<any> = (props) => { // TODO: remove any
);
}
DataEntry.propTypes = {
CheckboxDataEntry.propTypes = {
title: PropTypes.string,
slug: PropTypes.string,
tooltip: PropTypes.string,
disabled: PropTypes.bool,
value: PropTypes.any,
placeholder: PropTypes.string,
maxLength: PropTypes.number,
onChange: PropTypes.func,
copy: PropTypes.shape({
copying: PropTypes.bool,
@ -47,4 +51,4 @@ DataEntry.propTypes = {
})
}
export default DataEntry;
export default CheckboxDataEntry;

View File

@ -26,7 +26,7 @@ const PlanningView = (props) => (
value={props.building.planning_in_conservation_area}
mode={props.mode}
copy={props.copy}
onChange={props.onCheck}
onChange={props.onUpdate}
/>
<DataEntry
title="Conservation area name"
@ -42,7 +42,7 @@ const PlanningView = (props) => (
value={props.building.planning_in_list}
mode={props.mode}
copy={props.copy}
onChange={props.onCheck}
onChange={props.onUpdate}
/>
<DataEntry
title="National Heritage List for England list id"
@ -103,7 +103,7 @@ const PlanningView = (props) => (
value={props.building.planning_in_glher}
mode={props.mode}
copy={props.copy}
onChange={props.onCheck}
onChange={props.onUpdate}
/>
<DataEntry
title="Greater London Historic Environment Record link"
@ -119,7 +119,7 @@ const PlanningView = (props) => (
value={props.building.planning_in_apa}
mode={props.mode}
copy={props.copy}
onChange={props.onCheck}
onChange={props.onUpdate}
/>
<DataEntry
title="Architectural Priority Area name"
@ -143,7 +143,7 @@ const PlanningView = (props) => (
value={props.building.planning_in_local_list}
mode={props.mode}
copy={props.copy}
onChange={props.onCheck}
onChange={props.onUpdate}
/>
<DataEntry
title="Local list link"
@ -159,7 +159,7 @@ const PlanningView = (props) => (
value={props.building.planning_in_historic_area_assessment}
mode={props.mode}
copy={props.copy}
onChange={props.onCheck}
onChange={props.onUpdate}
/>
<DataEntry
title="Historic area assessment link"
@ -177,7 +177,7 @@ const PlanningView = (props) => (
value={props.building.planning_demolition_proposed}
mode={props.mode}
copy={props.copy}
onChange={props.onCheck}
onChange={props.onUpdate}
disabled={true}
/>
<CheckboxDataEntry
@ -186,7 +186,7 @@ const PlanningView = (props) => (
value={props.building.planning_demolition_complete}
mode={props.mode}
copy={props.copy}
onChange={props.onCheck}
onChange={props.onUpdate}
disabled={true}
/>
<DataEntry