IO-1010 Fix note modal saving and reset issue.
This commit is contained in:
@@ -36,10 +36,12 @@ export function NoteUpsertModalContainer({
|
||||
|
||||
useEffect(() => {
|
||||
//Required to prevent infinite looping.
|
||||
if (existingNote) {
|
||||
if (existingNote && visible) {
|
||||
form.setFieldsValue(existingNote);
|
||||
} else if (!existingNote && visible) {
|
||||
form.resetFields();
|
||||
}
|
||||
}, [existingNote, form]);
|
||||
}, [existingNote, form, visible]);
|
||||
|
||||
const handleFinish = (values) => {
|
||||
if (existingNote) {
|
||||
@@ -90,12 +92,7 @@ export function NoteUpsertModalContainer({
|
||||
}}
|
||||
destroyOnClose
|
||||
>
|
||||
<Form
|
||||
form={form}
|
||||
onFinish={handleFinish}
|
||||
initialValues={existingNote}
|
||||
layout="vertical"
|
||||
>
|
||||
<Form form={form} onFinish={handleFinish} layout="vertical">
|
||||
<NoteUpsertModalComponent form={form} />
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
@@ -34,6 +34,15 @@ export const UPDATE_NOTE = gql`
|
||||
update_notes(where: { id: { _eq: $noteId } }, _set: $note) {
|
||||
returning {
|
||||
id
|
||||
created_at
|
||||
created_by
|
||||
critical
|
||||
id
|
||||
jobid
|
||||
private
|
||||
text
|
||||
updated_at
|
||||
audit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user