feat: Allow to skip submitting empty values in form data (#5830)
This commit is contained in:
@@ -1,24 +1,19 @@
|
||||
import React from "react"
|
||||
import cx from "classnames"
|
||||
import PropTypes from "prop-types"
|
||||
import ImPropTypes from "react-immutable-proptypes"
|
||||
|
||||
export const ParameterIncludeEmpty = ({ param, isIncluded, onChange, isDisabled }) => {
|
||||
export const ParameterIncludeEmpty = ({ isIncluded, onChange, isDisabled }) => {
|
||||
const onCheckboxChange = e => {
|
||||
onChange(e.target.checked)
|
||||
}
|
||||
if(!param.get("allowEmptyValue")) {
|
||||
return null
|
||||
}
|
||||
return <div className={cx("parameter__empty_value_toggle", {
|
||||
return <label className={cx("parameter__empty_value_toggle", {
|
||||
"disabled": isDisabled
|
||||
})}>
|
||||
<input type="checkbox" disabled={isDisabled} checked={!isDisabled && isIncluded} onChange={onCheckboxChange} />
|
||||
Send empty value
|
||||
</div>
|
||||
</label>
|
||||
}
|
||||
ParameterIncludeEmpty.propTypes = {
|
||||
param: ImPropTypes.map.isRequired,
|
||||
isIncluded: PropTypes.bool.isRequired,
|
||||
isDisabled: PropTypes.bool.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
|
||||
Reference in New Issue
Block a user