1
0
forked from test/crm

Merge pull request #388 from shariquerik/redirect-fix

fix: redirect fixes
This commit is contained in:
Shariq Ansari 2024-09-30 13:35:00 +05:30 committed by GitHub
commit 8170c83c68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 36 additions and 3 deletions

View File

@ -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

View File

@ -720,6 +720,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) {

View File

@ -5,6 +5,7 @@
:task="task"
:doctype="doctype"
:doc="doc.data?.name"
@after="redirect('tasks')"
/>
<NoteModal
v-model="showNoteModal"
@ -12,6 +13,7 @@
:note="note"
:doctype="doctype"
:doc="doc.data?.name"
@after="redirect('notes')"
/>
</template>
<script setup>
@ -19,6 +21,7 @@ import TaskModal from '@/components/Modals/TaskModal.vue'
import NoteModal from '@/components/Modals/NoteModal.vue'
import { call } from 'frappe-ui'
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const props = defineProps({
doctype: String,
@ -74,6 +77,19 @@ function showNote(n) {
showNoteModal.value = true
}
// common
const route = useRoute()
const router = useRouter()
function redirect(tabName) {
if (route.name == 'Lead' || route.name == 'Deal') {
let hash = '#' + tabName
if (route.hash != hash) {
router.push({ ...route, hash })
}
}
}
defineExpose({
showTask,
deleteTask,

View File

@ -141,7 +141,7 @@ const props = defineProps({
const show = defineModel()
const tasks = defineModel('reloadTasks')
const emit = defineEmits(['updateTask'])
const emit = defineEmits(['updateTask', 'after'])
const router = useRouter()
const { getUser } = usersStore()
@ -202,6 +202,7 @@ async function updateTask() {
if (d.name) {
capture('task_created')
tasks.value.reload()
emit('after')
}
}
show.value = false

View File

@ -147,10 +147,11 @@ function getRoute(notification) {
dealId: notification.reference_name,
}
}
return {
name: notification.route_name,
params: params,
hash: '#' + notification.comment || notification.notification_type_doc,
hash: notification.hash,
}
}