Merge pull request #388 from shariquerik/redirect-fix
fix: redirect fixes
This commit is contained in:
commit
8170c83c68
@ -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
|
||||
@ -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) {
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user