fix(plugin-workflow): fix endsOn field (#1144)
This commit is contained in:
parent
945c64304a
commit
2c6b9babff
@ -32,6 +32,7 @@ export default {
|
|||||||
'Based on date field of collection': '根据数据表时间字段',
|
'Based on date field of collection': '根据数据表时间字段',
|
||||||
'Starts on': '开始于',
|
'Starts on': '开始于',
|
||||||
'Ends on': '结束于',
|
'Ends on': '结束于',
|
||||||
|
'No end': '不结束',
|
||||||
'Exactly at': '当时',
|
'Exactly at': '当时',
|
||||||
'Repeat mode': '重复模式',
|
'Repeat mode': '重复模式',
|
||||||
'Repeat limit': '重复次数',
|
'Repeat limit': '重复次数',
|
||||||
|
@ -10,23 +10,28 @@ import { OnField } from "./OnField";
|
|||||||
|
|
||||||
export function EndsByField({ value, onChange }) {
|
export function EndsByField({ value, onChange }) {
|
||||||
const { t } = useWorkflowTranslation();
|
const { t } = useWorkflowTranslation();
|
||||||
const [type, setType] = useState(typeof value === 'object' && !(value instanceof Date) ? 'field' : 'date');
|
const type = value != null ? typeof value === 'object' && !(value instanceof Date) ? 'field' : 'date' : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<fieldset className={css`
|
<fieldset className={css`
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: .5em;
|
gap: .5em;
|
||||||
`}>
|
`}>
|
||||||
<Select value={type} onChange={t => {
|
<Select value={type} onChange={t => {
|
||||||
onChange(t === 'field' ? {} : null);
|
onChange(t ? t === 'field' ? {} : new Date() : null);
|
||||||
setType(t);
|
|
||||||
}}>
|
}}>
|
||||||
|
<Select.Option value={null}>{t('No end')}</Select.Option>
|
||||||
<Select.Option value={'field'}>{t('By field')}</Select.Option>
|
<Select.Option value={'field'}>{t('By field')}</Select.Option>
|
||||||
<Select.Option value={'date'}>{t('By custom date')}</Select.Option>
|
<Select.Option value={'date'}>{t('By custom date')}</Select.Option>
|
||||||
</Select>
|
</Select>
|
||||||
{type === 'field'
|
{type === 'field'
|
||||||
? <OnField value={value} onChange={onChange} />
|
? <OnField value={value} onChange={onChange} />
|
||||||
: <DatePicker showTime value={moment(value)} onChange={onChange} />
|
: null
|
||||||
|
}
|
||||||
|
{type === 'date'
|
||||||
|
? <DatePicker showTime value={moment(value)} onChange={(v) => {
|
||||||
|
onChange(v ? v.toDate() : null);
|
||||||
|
}} />
|
||||||
|
: null
|
||||||
}
|
}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user