Skip to content

Commit

Permalink
allow unselect parameter key
Browse files Browse the repository at this point in the history
Signed-off-by: andy.lee <andy.lee@suse.com>
  • Loading branch information
a110605 authored and derekbit committed Jul 5, 2024
1 parent 3d065c2 commit 4f4bb38
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/routes/recurringJob/CreateRecurringJob.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ const modal = ({
data.parameters = {}
data.parameters[data.parametersKey] = data.parametersValue.toString()
}

delete data.parametersKey
delete data.parametersValue
onOk(data)
Expand Down Expand Up @@ -154,6 +153,16 @@ const modal = ({
})
}
}

const handleParameterChange = (value) => {
// clear parametersValue if parametersKey is cleared
if (value === undefined) {
setFieldsValue({
parametersValue: '',
})
}
}

const onCronOk = () => {
// CronProps.cron changed by the parent component and passed on to the current component.
setFieldsValue({
Expand Down Expand Up @@ -349,20 +358,14 @@ const modal = ({
<div style={{ display: 'flex' }}>
<FormItem label="Parameters" style={{ flex: '1 50%' }} labelCol={{ span: 8 }} wrapperCol={{ span: 14 }}>
{getFieldDecorator('parametersKey', {
initialValue: isEdit ? Object.keys(item?.parameters)[0] : '',
})(<Select style={{ width: '100%' }}>
initialValue: isEdit && item?.parameters && Object.keys(item.parameters)[0] ? Object.keys(item.parameters)[0] : '',
})(<Select style={{ width: '100%' }} allowClear onChange={handleParameterChange}>
<Option value="full-backup-interval">full-backup-interval</Option>
</Select>)}
</FormItem>
<FormItem style={{ flex: '1 50%' }} {...formItemLayout}>
{getFieldDecorator('parametersValue', {
initialValue: isEdit ? Object.values(item?.parameters)[0] : '',
rules: [
{
required: getFieldValue('parametersKey') !== '',
message: 'interval number is required',
},
],
initialValue: isEdit && item?.parameters && Object.keys(item.parameters)[0] ? Object.values(item.parameters)[0] : '',
})(<InputNumber min={0} style={{ width: '66%' }} />)}
</FormItem>
</div>
Expand Down

0 comments on commit 4f4bb38

Please sign in to comment.