Process input inside SelectDataEntry
This commit is contained in:
parent
7c042dd58e
commit
e1e1bc7aa5
@ -2,8 +2,16 @@ import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import { DataTitleCopyable } from './data-title';
|
||||
import { BaseDataEntryProps } from './data-entry';
|
||||
|
||||
const SelectDataEntry: React.FunctionComponent<any> = (props) => { // TODO: remove any
|
||||
interface SelectDataEntryProps extends BaseDataEntryProps {
|
||||
value: string;
|
||||
placeholder?: string;
|
||||
options: string[];
|
||||
}
|
||||
|
||||
|
||||
const SelectDataEntry: React.FunctionComponent<SelectDataEntryProps> = (props) => {
|
||||
return (
|
||||
<Fragment>
|
||||
<DataTitleCopyable
|
||||
@ -17,7 +25,14 @@ const SelectDataEntry: React.FunctionComponent<any> = (props) => { // TODO: remo
|
||||
id={props.slug} name={props.slug}
|
||||
value={props.value || ''}
|
||||
disabled={props.mode === 'view' || props.disabled}
|
||||
onChange={props.onChange}>
|
||||
onChange={e =>
|
||||
props.onChange(
|
||||
props.slug,
|
||||
e.target.value === '' ?
|
||||
null :
|
||||
e.target.value
|
||||
)}
|
||||
>
|
||||
<option value="">{props.placeholder}</option>
|
||||
{
|
||||
props.options.map(option => (
|
||||
|
@ -36,7 +36,7 @@ const AgeView = (props) => (
|
||||
value={props.building.date_source}
|
||||
mode={props.mode}
|
||||
copy={props.copy}
|
||||
onChange={props.onChange}
|
||||
onChange={props.onUpdate}
|
||||
tooltip="Source for the main start date"
|
||||
placeholder=""
|
||||
options={[
|
||||
|
@ -58,7 +58,7 @@ const PlanningView = (props) => (
|
||||
value={props.building.planning_list_cat}
|
||||
mode={props.mode}
|
||||
copy={props.copy}
|
||||
onChange={props.onChange}
|
||||
onChange={props.onUpdate}
|
||||
options={[
|
||||
"Listed Building",
|
||||
"Scheduled Monument",
|
||||
@ -73,7 +73,7 @@ const PlanningView = (props) => (
|
||||
value={props.building.planning_list_grade}
|
||||
mode={props.mode}
|
||||
copy={props.copy}
|
||||
onChange={props.onChange}
|
||||
onChange={props.onUpdate}
|
||||
options={[
|
||||
"I",
|
||||
"II*",
|
||||
|
@ -119,7 +119,7 @@ const SizeView = (props) => (
|
||||
value={props.building.size_configuration}
|
||||
mode={props.mode}
|
||||
copy={props.copy}
|
||||
onChange={props.onChange}
|
||||
onChange={props.onUpdate}
|
||||
disabled={true}
|
||||
options={[
|
||||
"Detached",
|
||||
@ -135,7 +135,7 @@ const SizeView = (props) => (
|
||||
value={props.building.size_roof_shape}
|
||||
mode={props.mode}
|
||||
copy={props.copy}
|
||||
onChange={props.onChange}
|
||||
onChange={props.onUpdate}
|
||||
disabled={true}
|
||||
options={[
|
||||
"Flat",
|
||||
|
@ -28,7 +28,7 @@ const SustainabilityView = (props) => {
|
||||
options={BreeamRatingOptions}
|
||||
mode={props.mode}
|
||||
copy={props.copy}
|
||||
onChange={props.onChange}
|
||||
onChange={props.onUpdate}
|
||||
/>
|
||||
<SelectDataEntry
|
||||
title="DEC Rating"
|
||||
@ -38,7 +38,7 @@ const SustainabilityView = (props) => {
|
||||
options={EnergyCategoryOptions}
|
||||
mode={props.mode}
|
||||
copy={props.copy}
|
||||
onChange={props.onChange}
|
||||
onChange={props.onUpdate}
|
||||
/>
|
||||
<SelectDataEntry
|
||||
title="EPC Rating"
|
||||
@ -49,7 +49,7 @@ const SustainabilityView = (props) => {
|
||||
disabled={true}
|
||||
mode={props.mode}
|
||||
copy={props.copy}
|
||||
onChange={props.onChange}
|
||||
onChange={props.onUpdate}
|
||||
/>
|
||||
<NumericDataEntry
|
||||
title="Last significant retrofit"
|
||||
|
@ -26,7 +26,7 @@ const TypeView = (props) => {
|
||||
options={AttachmentFormOptions}
|
||||
mode={props.mode}
|
||||
copy={props.copy}
|
||||
onChange={props.onChange}
|
||||
onChange={props.onUpdate}
|
||||
/>
|
||||
<NumericDataEntry
|
||||
title="When did use change?"
|
||||
|
Loading…
Reference in New Issue
Block a user