Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix manually the custom validation for the calendar when the date is in the future #26

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion imports/ui/components/Task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ export const Task = ({ _id }: { _id: string }) => {
if (!task.customHeaders.formIO) {
return (<div>Task exists but is not well formed (has no formIO field). Check with your administrator that the BPMN file is well formatted</div>)
} else {
const parsedFormIO = JSON.parse(task.customHeaders.formIO)

const newValidate = 'let m = moment();' +
'let p = moment(input, "DD.MM.YYYY");' +
'let p2 = moment(input, "YYYY-MM-DD");' +
'valid = ((m>p) || (m>p2)) ? true : "date must not be in the future"'

if (parsedFormIO?.components[0]?.components[1]?.validate?.custom) parsedFormIO.components[0].components[1].validate.custom = newValidate

return (
<>{
taskLoading ? (<>
Expand All @@ -44,7 +53,7 @@ export const Task = ({ _id }: { _id: string }) => {
(<>
<h1 className={'h2'}>{task.customHeaders.title || `Task ${task._id}`}</h1>
<Errors/>
<Form form={ JSON.parse(task.customHeaders.formIO) }
<Form form={ parsedFormIO }
submission={ {data: task.variables} }
onCustomEvent={ (event: customEvent) => event.type == 'cancelClicked' && navigate('/') }
options={ { hooks: { beforeSubmit: beforeSubmitHook,} } }
Expand Down