From 37053c3c4e17f4e340fcb7a104266a69e617ced7 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 26 Aug 2023 16:52:45 +0530 Subject: [PATCH] fix: create new note --- frontend/src/pages/Notes.vue | 39 +++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/frontend/src/pages/Notes.vue b/frontend/src/pages/Notes.vue index cdf21142..86a9c107 100644 --- a/frontend/src/pages/Notes.vue +++ b/frontend/src/pages/Notes.vue @@ -4,7 +4,7 @@ @@ -47,9 +47,11 @@ class="flex flex-col gap-2 px-20 mt-5 mb-10 min-h-[400px] max-h-[500px] overflow-auto" > { oldNote.value = note currentNote.value = noteCopy showNoteModal.value = true + + nextTick(() => title.value.el.focus()) } async function updateNote() { @@ -116,13 +121,27 @@ async function updateNote() { return } currentNote.value.content = content.value?.editor.getHTML() - let d = await call('frappe.client.set_value', { - doctype: 'CRM Note', - name: currentNote.value.name, - fieldname: currentNote.value, - }) - if (d.name) { - notes.reload() + + if (currentNote.value.name) { + let d = await call('frappe.client.set_value', { + doctype: 'CRM Note', + name: currentNote.value.name, + fieldname: currentNote.value, + }) + if (d.name) { + notes.reload() + } + } else { + let d = await call('frappe.client.insert', { + doc: { + doctype: 'CRM Note', + title: currentNote.value.title, + content: currentNote.value.content, + }, + }) + if (d.name) { + notes.reload() + } } }