fix(plugin-workflow): fix endsOn field (#1144)

This commit is contained in:
Junyi 2022-11-24 08:06:48 -08:00 committed by GitHub
parent 945c64304a
commit 2c6b9babff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -32,6 +32,7 @@ export default {
'Based on date field of collection': '根据数据表时间字段',
'Starts on': '开始于',
'Ends on': '结束于',
'No end': '不结束',
'Exactly at': '当时',
'Repeat mode': '重复模式',
'Repeat limit': '重复次数',

View File

@ -10,23 +10,28 @@ import { OnField } from "./OnField";
export function EndsByField({ value, onChange }) {
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 (
<fieldset className={css`
display: flex;
gap: .5em;
`}>
<Select value={type} onChange={t => {
onChange(t === 'field' ? {} : null);
setType(t);
onChange(t ? t === 'field' ? {} : new Date() : null);
}}>
<Select.Option value={null}>{t('No end')}</Select.Option>
<Select.Option value={'field'}>{t('By field')}</Select.Option>
<Select.Option value={'date'}>{t('By custom date')}</Select.Option>
</Select>
{type === 'field'
? <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>
);