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()
+ }
}
}