diff --git a/crm/api/contact.py b/crm/api/contact.py
index 8ef93e43..5484bb9b 100644
--- a/crm/api/contact.py
+++ b/crm/api/contact.py
@@ -132,3 +132,36 @@ def set_as_primary(contact, field, value):
contact.save()
return True
+
+
+@frappe.whitelist()
+def search_emails(txt: str):
+ doctype = "Contact"
+ meta = frappe.get_meta(doctype)
+ filters = [["Contact", "email_id", "is", "set"]]
+
+ if meta.get("fields", {"fieldname": "enabled", "fieldtype": "Check"}):
+ filters.append([doctype, "enabled", "=", 1])
+ if meta.get("fields", {"fieldname": "disabled", "fieldtype": "Check"}):
+ filters.append([doctype, "disabled", "!=", 1])
+
+ or_filters = []
+ search_fields = ["full_name", "email_id", "name"]
+ if txt:
+ for f in search_fields:
+ or_filters.append([doctype, f.strip(), "like", f"%{txt}%"])
+
+ results = frappe.get_list(
+ doctype,
+ filters=filters,
+ fields=search_fields,
+ or_filters=or_filters,
+ limit_start=0,
+ limit_page_length=20,
+ order_by='email_id, full_name, name',
+ ignore_permissions=False,
+ as_list=True,
+ strict=False,
+ )
+
+ return results
\ No newline at end of file
diff --git a/frontend/src/components/CommunicationArea.vue b/frontend/src/components/CommunicationArea.vue
index c8fb92a7..eb2f8470 100644
--- a/frontend/src/components/CommunicationArea.vue
+++ b/frontend/src/components/CommunicationArea.vue
@@ -23,18 +23,6 @@
-
-
-
-
')
+ signature.data = signature.data?.replace(/\n/g, '
')
let emailContent = editor.getHTML()
emailContent = emailContent.startsWith('
')
? emailContent.slice(7)
@@ -236,22 +224,6 @@ async function submitComment() {
emit('scroll')
}
-function toggleCC() {
- newEmailEditor.value.cc = !newEmailEditor.value.cc
- newEmailEditor.value.cc &&
- nextTick(() => {
- newEmailEditor.value.ccInput.setFocus()
- })
-}
-
-function toggleBCC() {
- newEmailEditor.value.bcc = !newEmailEditor.value.bcc
- newEmailEditor.value.bcc &&
- nextTick(() => {
- newEmailEditor.value.bccInput.setFocus()
- })
-}
-
function toggleEmailBox() {
if (showCommentBox.value) {
showCommentBox.value = false
diff --git a/frontend/src/components/Controls/MultiselectInput.vue b/frontend/src/components/Controls/MultiselectInput.vue
index ed8b4102..a5cb6928 100644
--- a/frontend/src/components/Controls/MultiselectInput.vue
+++ b/frontend/src/components/Controls/MultiselectInput.vue
@@ -8,7 +8,7 @@
:label="value"
theme="gray"
variant="subtle"
- class="rounded-full"
+ class="rounded"
@keydown.delete.capture.stop="removeLastValue"
>
@@ -133,30 +133,26 @@ watchDebounced(
query,
(val) => {
val = val || ''
- if (text.value === val) return
+ if (text.value === val && options.value?.length) return
text.value = val
reload(val)
},
- { debounce: 300, immediate: true }
+ { debounce: 300, immediate: true },
)
const filterOptions = createResource({
- url: 'frappe.desk.search.search_link',
+ url: 'crm.api.contact.search_emails',
method: 'POST',
cache: [text.value, 'Contact'],
- params: {
- txt: text.value,
- doctype: 'Contact',
- },
+ params: { txt: text.value },
transform: (data) => {
let allData = data
- .filter((c) => {
- return c.description.split(', ')[1]
- })
.map((option) => {
- let email = option.description.split(', ')[1]
+ let fullName = option[0]
+ let email = option[1]
+ let name = option[2]
return {
- label: option.label || email,
+ label: fullName || name || email,
value: email,
}
})
@@ -177,10 +173,7 @@ const options = computed(() => {
function reload(val) {
filterOptions.update({
- params: {
- txt: val,
- doctype: 'Contact',
- },
+ params: { txt: val },
})
filterOptions.reload()
}
diff --git a/frontend/src/components/EmailEditor.vue b/frontend/src/components/EmailEditor.vue
index d60baaf1..db6ad0cf 100644
--- a/frontend/src/components/EmailEditor.vue
+++ b/frontend/src/components/EmailEditor.vue
@@ -9,60 +9,68 @@
:editable="editable"
>
-
- {{ __('SUBJECT') }}:
-
-
-
- {{ __('TO') }}:
-
-
-
- {{ __('CC') }}:
-
-
-
-
{{ __('BCC') }}:
-
+
+
+
{{ __('TO') }}:
+
+
+
+
+
+
+
+ {{ __('CC') }}:
+
+
+
+ {{ __('BCC') }}:
+
+
+
+ {{ __('SUBJECT') }}:
+
+
@@ -147,7 +155,7 @@ import EmailTemplateSelectorModal from '@/components/Modals/EmailTemplateSelecto
import { TextEditorFixedMenu, TextEditor, FileUploader, call } from 'frappe-ui'
import { validateEmail } from '@/utils'
import { EditorContent } from '@tiptap/vue-3'
-import { ref, computed, defineModel } from 'vue'
+import { ref, computed, defineModel, nextTick } from 'vue'
const props = defineProps({
placeholder: {
@@ -211,7 +219,7 @@ async function applyEmailTemplate(template) {
{
template_name: template.name,
doc: modelValue.value,
- }
+ },
)
if (template.subject) {
@@ -225,6 +233,16 @@ async function applyEmailTemplate(template) {
showEmailTemplateSelectorModal.value = false
}
+function toggleCC() {
+ cc.value = !cc.value
+ cc.value && nextTick(() => ccInput.value.setFocus())
+}
+
+function toggleBCC() {
+ bcc.value = !bcc.value
+ bcc.value && nextTick(() => bccInput.value.setFocus())
+}
+
defineExpose({
editor,
subject,
@@ -233,8 +251,6 @@ defineExpose({
toEmails,
ccEmails,
bccEmails,
- ccInput,
- bccInput,
})
const textEditorMenuButtons = [