diff --git a/coreplugins/cesiumion/public/components/BootstrapField.jsx b/coreplugins/cesiumion/public/components/BootstrapField.jsx index 82889fc2..518a0e68 100644 --- a/coreplugins/cesiumion/public/components/BootstrapField.jsx +++ b/coreplugins/cesiumion/public/components/BootstrapField.jsx @@ -15,21 +15,24 @@ const BootstrapFieldComponent = ({ ...props }) => { const isError = error && touched; - const ControlComponent = type === "checkbox" ? "input" : type === "textarea" || type === "select" ? type : "input"; + const isCheckbox = type === "checkbox"; + const ControlComponent = isCheckbox ? "input" : (type === "textarea" || type === "select") ? type : "input"; return (
- {label && } + {label && !isCheckbox && } + {label && isCheckbox && } {isError && {error}} {help && !isError && {help}} {isError && showIcon && } @@ -54,15 +57,16 @@ class BootstrapField extends React.Component { constructor(props) { super(props); this.state = { - value: props.value || '', + value: props.type === "checkbox" ? props.checked : props.value || '', touched: false, error: '' }; } handleChange = (e) => { - const { value } = e.target; - this.setState({ value }, () => { + const { type, checked, value } = e.target; + const newValue = type === "checkbox" ? checked : value; + this.setState({ value: newValue }, () => { if (this.props.onChange) { this.props.onChange(e); } diff --git a/coreplugins/cesiumion/public/components/UploadDialog.jsx b/coreplugins/cesiumion/public/components/UploadDialog.jsx index 81747539..68189776 100644 --- a/coreplugins/cesiumion/public/components/UploadDialog.jsx +++ b/coreplugins/cesiumion/public/components/UploadDialog.jsx @@ -32,10 +32,53 @@ export default class UploadDialog extends Component { } }; + constructor(props) { + super(props); + + this.mergedInitialValues = { + ...UploadDialog.defaultProps.initialValues, + ...this.props.initialValues + }; + + this.state = { + ...this.mergedInitialValues + } + + // this.state = { + // show: this.props.show, + // asset: null, + // loading: this.props.loading, + // ...this.mergedInitialValues, + // hide: this.props.hide, + // title: this.props.title + // } + } + show(){ this.dialog.show(); } + handleChange = (e) => { + const { value, name } = e.target; + + if (name === "options.textureFormat") + { + let options = {...this.state.options}; + options["textureFormat"] = value === "Yes"; + this.setState({ options }); + } + else if (name === "options.baseTerrainId") + { + let options = {...this.state.options}; + options["baseTerrainId"] = value; + this.setState({ options }); + } + else + { + this.setState({ [name]: value }); + } + } + handleError = msg => error => { this.props.onError(msg); console.error(error); @@ -43,7 +86,7 @@ export default class UploadDialog extends Component { onSubmit = values => { const { asset, onSubmit } = this.props; - values = JSON.parse(JSON.stringify(values)); + values = JSON.parse(JSON.stringify(this.state)); const { options = {} } = values; switch (UploadDialog.AssetSourceType[asset]) { @@ -66,10 +109,10 @@ export default class UploadDialog extends Component { getSourceFields() { switch (UploadDialog.AssetSourceType[this.props.asset]) { case SourceType.RASTER_TERRAIN: - const loadOptions = ({ isLoading, isError, data }) => { + let loadOptions = ({ isLoading, isError, data }) => { if (isLoading || isError) return ; - const userItems = data.items + let userItems = data.items .filter(item => item.type === "TERRAIN") .map(item => (