Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: redirect fixes #388

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion crm/api/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions frontend/src/components/Activities/Activities.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/components/Activities/AllModals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@
:task="task"
:doctype="doctype"
:doc="doc.data?.name"
@after="redirect('tasks')"
/>
<NoteModal
v-model="showNoteModal"
v-model:reloadNotes="activities"
:note="note"
:doctype="doctype"
:doc="doc.data?.name"
@after="redirect('notes')"
/>
</template>
<script setup>
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,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/Modals/TaskModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -202,6 +202,7 @@ async function updateTask() {
if (d.name) {
capture('task_created')
tasks.value.reload()
emit('after')
}
}
show.value = false
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/Notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
Loading