Skip to content

Commit 2e57878

Browse files
authored
Merge pull request #725 from frappe/mergify/bp/main/pr-716
fix: Create & Make call (backport #716)
2 parents cc7f6fd + 7775117 commit 2e57878

File tree

7 files changed

+145
-16
lines changed

7 files changed

+145
-16
lines changed

Diff for: frontend/components.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ declare module 'vue' {
150150
MobileLayout: typeof import('./src/components/Layouts/MobileLayout.vue')['default']
151151
MobileSidebar: typeof import('./src/components/Mobile/MobileSidebar.vue')['default']
152152
MoneyIcon: typeof import('./src/components/Icons/MoneyIcon.vue')['default']
153+
MultiActionButton: typeof import('./src/components/MultiActionButton.vue')['default']
153154
MultipleAvatar: typeof import('./src/components/MultipleAvatar.vue')['default']
154155
MultiSelectEmailInput: typeof import('./src/components/Controls/MultiSelectEmailInput.vue')['default']
155156
MuteIcon: typeof import('./src/components/Icons/MuteIcon.vue')['default']

Diff for: frontend/src/components/Activities/Activities.vue

+21-6
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,7 @@
373373
>
374374
<component :is="emptyTextIcon" class="h-10 w-10" />
375375
<span>{{ __(emptyText) }}</span>
376-
<Button
377-
v-if="title == 'Calls'"
378-
:label="__('Make a Call')"
379-
@click="makeCall(doc.data.mobile_no)"
380-
/>
376+
<MultiActionButton v-if="title == 'Calls'" :options="callActions" />
381377
<Button
382378
v-else-if="title == 'Notes'"
383379
:label="__('Create Note')"
@@ -470,6 +466,7 @@ import WhatsAppIcon from '@/components/Icons/WhatsAppIcon.vue'
470466
import WhatsAppArea from '@/components/Activities/WhatsAppArea.vue'
471467
import WhatsAppBox from '@/components/Activities/WhatsAppBox.vue'
472468
import LoadingIndicator from '@/components/Icons/LoadingIndicator.vue'
469+
import MultiActionButton from '@/components/MultiActionButton.vue'
473470
import LeadsIcon from '@/components/Icons/LeadsIcon.vue'
474471
import DealsIcon from '@/components/Icons/DealsIcon.vue'
475472
import DotIcon from '@/components/Icons/DotIcon.vue'
@@ -487,7 +484,7 @@ import FilesUploader from '@/components/FilesUploader/FilesUploader.vue'
487484
import { timeAgo, formatDate, startCase } from '@/utils'
488485
import { globalStore } from '@/stores/global'
489486
import { usersStore } from '@/stores/users'
490-
import { whatsappEnabled } from '@/composables/settings'
487+
import { whatsappEnabled, callEnabled } from '@/composables/settings'
491488
import { capture } from '@/telemetry'
492489
import { Button, Tooltip, createResource } from 'frappe-ui'
493490
import { useElementVisibility } from '@vueuse/core'
@@ -785,5 +782,23 @@ function scroll(hash) {
785782
}, 500)
786783
}
787784
785+
const callActions = computed(() => {
786+
let actions = [
787+
{
788+
label: __('Create Call Log'),
789+
onClick: () => modalRef.value.createCallLog(),
790+
},
791+
{
792+
label: __('Make a Call'),
793+
onClick: () => makeCall(doc.data.mobile_no),
794+
condition: () => callEnabled.value,
795+
},
796+
]
797+
798+
return actions.filter((action) =>
799+
action.condition ? action.condition() : true,
800+
)
801+
})
802+
788803
defineExpose({ emailBox, all_activities })
789804
</script>

Diff for: frontend/src/components/Activities/ActivityHeader.vue

+29-8
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,11 @@
2626
</template>
2727
<span>{{ __('New Comment') }}</span>
2828
</Button>
29-
<Button
29+
<MultiActionButton
3030
v-else-if="title == 'Calls'"
3131
variant="solid"
32-
@click="makeCall(doc.data.mobile_no)"
33-
>
34-
<template #prefix>
35-
<PhoneIcon class="h-4 w-4" />
36-
</template>
37-
<span>{{ __('Make a Call') }}</span>
38-
</Button>
32+
:options="callActions"
33+
/>
3934
<Button
4035
v-else-if="title == 'Notes'"
4136
variant="solid"
@@ -97,6 +92,7 @@
9792
</div>
9893
</template>
9994
<script setup>
95+
import MultiActionButton from '@/components/MultiActionButton.vue'
10096
import Email2Icon from '@/components/Icons/Email2Icon.vue'
10197
import CommentIcon from '@/components/Icons/CommentIcon.vue'
10298
import PhoneIcon from '@/components/Icons/PhoneIcon.vue'
@@ -136,6 +132,11 @@ const defaultActions = computed(() => {
136132
label: __('New Comment'),
137133
onClick: () => (props.emailBox.showComment = true),
138134
},
135+
{
136+
icon: h(PhoneIcon, { class: 'h-4 w-4' }),
137+
label: __('Create Call Log'),
138+
onClick: () => props.modalRef.createCallLog(),
139+
},
139140
{
140141
icon: h(PhoneIcon, { class: 'h-4 w-4' }),
141142
label: __('Make a Call'),
@@ -172,4 +173,24 @@ const defaultActions = computed(() => {
172173
function getTabIndex(name) {
173174
return props.tabs.findIndex((tab) => tab.name === name)
174175
}
176+
177+
const callActions = computed(() => {
178+
let actions = [
179+
{
180+
label: __('Create Call Log'),
181+
icon: 'plus',
182+
onClick: () => props.modalRef.createCallLog(),
183+
},
184+
{
185+
label: __('Make a Call'),
186+
icon: h(PhoneIcon, { class: 'h-4 w-4' }),
187+
onClick: () => makeCall(doc.data.mobile_no),
188+
condition: () => callEnabled.value,
189+
},
190+
]
191+
192+
return actions.filter((action) =>
193+
action.condition ? action.condition() : true,
194+
)
195+
})
175196
</script>

Diff for: frontend/src/components/Activities/AllModals.vue

+23
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@
1515
:doc="doc.data?.name"
1616
@after="redirect('notes')"
1717
/>
18+
<CallLogModal
19+
v-model="showCallLogModal"
20+
v-model:callLog="callLog"
21+
:options="{ afterInsert: () => activities.reload() }"
22+
/>
1823
</template>
1924
<script setup>
2025
import TaskModal from '@/components/Modals/TaskModal.vue'
2126
import NoteModal from '@/components/Modals/NoteModal.vue'
27+
import CallLogModal from '@/components/Modals/CallLogModal.vue'
2228
import { call } from 'frappe-ui'
2329
import { ref } from 'vue'
2430
import { useRoute, useRouter } from 'vue-router'
@@ -77,6 +83,22 @@ function showNote(n) {
7783
showNoteModal.value = true
7884
}
7985
86+
// Call Logs
87+
const showCallLogModal = ref(false)
88+
const callLog = ref({})
89+
90+
function createCallLog() {
91+
let doctype = props.doctype
92+
let docname = props.doc.data?.name
93+
callLog.value = {
94+
data: {
95+
reference_doctype: doctype,
96+
reference_docname: docname,
97+
},
98+
}
99+
showCallLogModal.value = true
100+
}
101+
80102
// common
81103
const route = useRoute()
82104
const router = useRouter()
@@ -95,5 +117,6 @@ defineExpose({
95117
deleteTask,
96118
updateTaskStatus,
97119
showNote,
120+
createCallLog,
98121
})
99122
</script>

Diff for: frontend/src/components/MultiActionButton.vue

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<template>
2+
<div class="flex items-center">
3+
<Button
4+
:variant="$attrs.variant"
5+
class="border-0"
6+
:label="activeButton.label"
7+
:size="$attrs.size"
8+
:class="[
9+
$attrs.class,
10+
showDropdown ? 'rounded-br-none rounded-tr-none' : '',
11+
]"
12+
@click="() => activeButton.onClick()"
13+
>
14+
<template #prefix>
15+
<FeatherIcon
16+
v-if="activeButton.icon && typeof activeButton.icon === 'string'"
17+
:name="activeButton.icon"
18+
class="h-4 w-4"
19+
/>
20+
<component
21+
v-else-if="activeButton.icon"
22+
:is="activeButton.icon"
23+
class="h-4 w-4"
24+
/>
25+
</template>
26+
</Button>
27+
<Dropdown
28+
v-show="showDropdown"
29+
:options="parsedOptions"
30+
size="sm"
31+
class="flex-1 [&>div>div>div]:w-full"
32+
placement="right"
33+
>
34+
<template v-slot="{ togglePopover }">
35+
<Button
36+
:variant="$attrs.variant"
37+
@click="togglePopover"
38+
icon="chevron-down"
39+
class="!w-6 justify-start rounded-bl-none rounded-tl-none border-0 pr-0 text-xs"
40+
/>
41+
</template>
42+
</Dropdown>
43+
</div>
44+
</template>
45+
<script setup>
46+
import { Dropdown } from 'frappe-ui'
47+
import { computed, ref } from 'vue'
48+
49+
const props = defineProps({
50+
options: {
51+
type: Array,
52+
default: () => [],
53+
},
54+
})
55+
56+
const showDropdown = ref(props.options?.length > 1)
57+
const activeButton = ref(props.options?.[0] || {})
58+
59+
const parsedOptions = computed(() => {
60+
return (
61+
props.options?.map((option) => {
62+
return {
63+
label: option.label,
64+
onClick: () => {
65+
activeButton.value = option
66+
},
67+
}
68+
}) || []
69+
)
70+
})
71+
</script>

Diff for: frontend/src/pages/Deal.vue

-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,6 @@ const tabs = computed(() => {
545545
name: 'Calls',
546546
label: __('Calls'),
547547
icon: PhoneIcon,
548-
condition: () => callEnabled.value,
549548
},
550549
{
551550
name: 'Tasks',

Diff for: frontend/src/pages/Lead.vue

-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ const tabs = computed(() => {
532532
name: 'Calls',
533533
label: __('Calls'),
534534
icon: PhoneIcon,
535-
condition: () => callEnabled.value,
536535
},
537536
{
538537
name: 'Tasks',

0 commit comments

Comments
 (0)