diff --git a/crm/api/comment.py b/crm/api/comment.py index 7aa2fee5..7d78f0d4 100644 --- a/crm/api/comment.py +++ b/crm/api/comment.py @@ -18,16 +18,18 @@ def notify_mentions(doc): if not content: return mentions = extract_mentions(content) + reference_doc = frappe.get_doc(doc.reference_doctype, doc.reference_name) for mention in mentions: owner = frappe.get_cached_value("User", doc.owner, "full_name") doctype = doc.reference_doctype if doctype.startswith("CRM "): doctype = doctype[4:].lower() + name = reference_doc.lead_name or name if doctype == "lead" else reference_doc.organization or reference_doc.lead_name or name notification_text = f"""
{ owner } { _('mentioned you in {0}').format(doctype) } - { doc.reference_name } + { name }
""" notify_user({ diff --git a/crm/api/doc.py b/crm/api/doc.py index 218abe98..576127a1 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -617,6 +617,7 @@ def get_field_obj(field): obj["placeholder"] = field.get("placeholder") or "Select " + field.label + "..." obj["doctype"] = field.options elif field.fieldtype == "Select" and field.options: + obj["placeholder"] = field.get("placeholder") or "Select " + field.label + "..." obj["options"] = [{"label": option, "value": option} for option in field.options.split("\n")] if field.read_only: diff --git a/crm/api/notifications.py b/crm/api/notifications.py index 2067b8f0..afe495db 100644 --- a/crm/api/notifications.py +++ b/crm/api/notifications.py @@ -27,7 +27,7 @@ def get_notifications(): "type": notification.type, "to_user": notification.to_user, "read": notification.read, - "comment": notification.comment, + "hash": get_hash(notification), "notification_text": notification.notification_text, "notification_type_doctype": notification.notification_type_doctype, "notification_type_doc": notification.notification_type_doc, @@ -58,3 +58,17 @@ def mark_as_read(user=None, doc=None): d = frappe.get_doc("CRM Notification", n.name) d.read = True d.save() + +def get_hash(notification): + _hash = "" + if notification.type == "Mention" and notification.notification_type_doc: + _hash = "#" + notification.notification_type_doc + + if notification.type == "WhatsApp": + _hash = "#whatsapp" + + if notification.type == "Assignment" and notification.notification_type_doctype == "CRM Task": + _hash = "#tasks" + if "has been removed by" in notification.message: + _hash = "" + return _hash \ No newline at end of file diff --git a/crm/api/todo.py b/crm/api/todo.py index e4bb50b5..f30e19f4 100644 --- a/crm/api/todo.py +++ b/crm/api/todo.py @@ -52,8 +52,8 @@ def get_notification_text(owner, doc, reference_doc, is_cancelled=False): if doctype.startswith("CRM "): doctype = doctype[4:].lower() - if doctype in ["CRM Lead", "CRM Deal"]: - name = reference_doc.lead_name or name if doctype == "CRM Lead" else reference_doc.organization or reference_doc.lead_name or name + if doctype in ["lead", "deal"]: + name = reference_doc.lead_name or name if doctype == "lead" else reference_doc.organization or reference_doc.lead_name or name if is_cancelled: return f""" @@ -76,7 +76,7 @@ def get_notification_text(owner, doc, reference_doc, is_cancelled=False): """ - if doc.reference_type == "CRM Task": + if doctype == "task": if is_cancelled: return f"""
diff --git a/frappe-ui b/frappe-ui index cf4e7d34..427b7618 160000 --- a/frappe-ui +++ b/frappe-ui @@ -1 +1 @@ -Subproject commit cf4e7d347237c23ebde5f5c890abdf7e81284961 +Subproject commit 427b76188fe8b20e683bccf9bb4003821253259f diff --git a/frontend/package.json b/frontend/package.json index a5060017..18861947 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -14,7 +14,7 @@ "@vueuse/core": "^10.3.0", "@vueuse/integrations": "^10.3.0", "feather-icons": "^4.28.0", - "frappe-ui": "^0.1.66", + "frappe-ui": "^0.1.70", "gemoji": "^8.1.0", "lodash": "^4.17.21", "mime": "^4.0.1", diff --git a/frontend/src/components/Activities/Activities.vue b/frontend/src/components/Activities/Activities.vue index 58a67cae..55e6fae5 100644 --- a/frontend/src/components/Activities/Activities.vue +++ b/frontend/src/components/Activities/Activities.vue @@ -457,10 +457,6 @@ const { getUser } = usersStore() const { getContact, getLeadContact } = contactsStore() const props = defineProps({ - title: { - type: String, - default: 'Activity', - }, doctype: { type: String, default: 'CRM Lead', @@ -471,6 +467,8 @@ const props = defineProps({ }, }) +const route = useRoute() + const doc = defineModel() const reload = defineModel('reload') const tabIndex = defineModel('tabIndex') @@ -478,6 +476,8 @@ const tabIndex = defineModel('tabIndex') const reload_email = ref(false) const modalRef = ref(null) +const title = computed(() => props.tabs?.[tabIndex.value]?.name || 'Activity') + const all_activities = createResource({ url: 'crm.api.activities.get_activities', params: { name: doc.value.data.name }, @@ -549,6 +549,14 @@ onMounted(() => { whatsappMessages.reload() } }) + + nextTick(() => { + const hash = route.hash.slice(1) || null + let tabNames = props.tabs?.map((tab) => tab.name) + if (!tabNames?.includes(hash)) { + scroll(hash) + } + }) }) function sendTemplate(template) { @@ -577,25 +585,25 @@ function get_activities() { const activities = computed(() => { let activities = [] - if (props.title == 'Activity') { + if (title.value == 'Activity') { activities = get_activities() - } else if (props.title == 'Emails') { + } else if (title.value == 'Emails') { if (!all_activities.data?.versions) return [] activities = all_activities.data.versions.filter( (activity) => activity.activity_type === 'communication', ) - } else if (props.title == 'Comments') { + } else if (title.value == 'Comments') { if (!all_activities.data?.versions) return [] activities = all_activities.data.versions.filter( (activity) => activity.activity_type === 'comment', ) - } else if (props.title == 'Calls') { + } else if (title.value == 'Calls') { if (!all_activities.data?.calls) return [] return sortByCreation(all_activities.data.calls) - } else if (props.title == 'Tasks') { + } else if (title.value == 'Tasks') { if (!all_activities.data?.tasks) return [] return sortByCreation(all_activities.data.tasks) - } else if (props.title == 'Notes') { + } else if (title.value == 'Notes') { if (!all_activities.data?.notes) return [] return sortByCreation(all_activities.data.notes) } @@ -649,17 +657,17 @@ function update_activities_details(activity) { const emptyText = computed(() => { let text = 'No Activities' - if (props.title == 'Emails') { + if (title.value == 'Emails') { text = 'No Email Communications' - } else if (props.title == 'Comments') { + } else if (title.value == 'Comments') { text = 'No Comments' - } else if (props.title == 'Calls') { + } else if (title.value == 'Calls') { text = 'No Call Logs' - } else if (props.title == 'Notes') { + } else if (title.value == 'Notes') { text = 'No Notes' - } else if (props.title == 'Tasks') { + } else if (title.value == 'Tasks') { text = 'No Tasks' - } else if (props.title == 'WhatsApp') { + } else if (title.value == 'WhatsApp') { text = 'No WhatsApp Messages' } return text @@ -667,17 +675,17 @@ const emptyText = computed(() => { const emptyTextIcon = computed(() => { let icon = ActivityIcon - if (props.title == 'Emails') { + if (title.value == 'Emails') { icon = Email2Icon - } else if (props.title == 'Comments') { + } else if (title.value == 'Comments') { icon = CommentIcon - } else if (props.title == 'Calls') { + } else if (title.value == 'Calls') { icon = PhoneIcon - } else if (props.title == 'Notes') { + } else if (title.value == 'Notes') { icon = NoteIcon - } else if (props.title == 'Tasks') { + } else if (title.value == 'Tasks') { icon = TaskIcon - } else if (props.title == 'WhatsApp') { + } else if (title.value == 'WhatsApp') { icon = WhatsAppIcon } return h(icon, { class: 'text-gray-500' }) @@ -720,6 +728,7 @@ watch([reload, reload_email], ([reload_value, reload_email_value]) => { }) function scroll(hash) { + if (['tasks', 'notes'].includes(route.hash?.slice(1))) return setTimeout(() => { let el if (!hash) { @@ -736,11 +745,4 @@ function scroll(hash) { } defineExpose({ emailBox }) - -const route = useRoute() - -nextTick(() => { - const hash = route.hash.slice(1) || null - scroll(hash) -}) diff --git a/frontend/src/components/Activities/AllModals.vue b/frontend/src/components/Activities/AllModals.vue index b8b4a2c4..1217b039 100644 --- a/frontend/src/components/Activities/AllModals.vue +++ b/frontend/src/components/Activities/AllModals.vue @@ -5,6 +5,7 @@ :task="task" :doctype="doctype" :doc="doc.data?.name" + @after="redirect('tasks')" />