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