fix: added translation in Activity Component

This commit is contained in:
Shariq Ansari 2024-04-15 19:21:44 +05:30
parent d53271d002
commit d0ec9bb5b4

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="flex items-center justify-between px-10 py-5 text-lg font-medium"> <div class="flex items-center justify-between px-10 py-5 text-lg font-medium">
<div class="flex h-7 items-center text-xl font-semibold text-gray-800"> <div class="flex h-7 items-center text-xl font-semibold text-gray-800">
{{ title }} {{ __(title) }}
</div> </div>
<Button <Button
v-if="title == 'Emails'" v-if="title == 'Emails'"
@ -11,7 +11,7 @@
<template #prefix> <template #prefix>
<FeatherIcon name="plus" class="h-4 w-4" /> <FeatherIcon name="plus" class="h-4 w-4" />
</template> </template>
<span>New Email</span> <span>{{ __('New Email') }}</span>
</Button> </Button>
<Button <Button
v-else-if="title == 'Calls'" v-else-if="title == 'Calls'"
@ -21,41 +21,41 @@
<template #prefix> <template #prefix>
<PhoneIcon class="h-4 w-4" /> <PhoneIcon class="h-4 w-4" />
</template> </template>
<span>Make a Call</span> <span>{{ __('Make a Call') }}</span>
</Button> </Button>
<Button v-else-if="title == 'Notes'" variant="solid" @click="showNote()"> <Button v-else-if="title == 'Notes'" variant="solid" @click="showNote()">
<template #prefix> <template #prefix>
<FeatherIcon name="plus" class="h-4 w-4" /> <FeatherIcon name="plus" class="h-4 w-4" />
</template> </template>
<span>New Note</span> <span>{{ __('New Note') }}</span>
</Button> </Button>
<Button v-else-if="title == 'Tasks'" variant="solid" @click="showTask()"> <Button v-else-if="title == 'Tasks'" variant="solid" @click="showTask()">
<template #prefix> <template #prefix>
<FeatherIcon name="plus" class="h-4 w-4" /> <FeatherIcon name="plus" class="h-4 w-4" />
</template> </template>
<span>New Task</span> <span>{{ __('New Task') }}</span>
</Button> </Button>
<Dropdown <Dropdown
v-else v-else
:options="[ :options="[
{ {
icon: h(EmailIcon, { class: 'h-4 w-4' }), icon: h(EmailIcon, { class: 'h-4 w-4' }),
label: 'New Email', label: __('New Email'),
onClick: () => ($refs.emailBox.show = true), onClick: () => ($refs.emailBox.show = true),
}, },
{ {
icon: h(PhoneIcon, { class: 'h-4 w-4' }), icon: h(PhoneIcon, { class: 'h-4 w-4' }),
label: 'Make a Call', label: __('Make a Call'),
onClick: () => makeCall(doc.data.mobile_no), onClick: () => makeCall(doc.data.mobile_no),
}, },
{ {
icon: h(NoteIcon, { class: 'h-4 w-4' }), icon: h(NoteIcon, { class: 'h-4 w-4' }),
label: 'New Note', label: __('New Note'),
onClick: () => showNote(), onClick: () => showNote(),
}, },
{ {
icon: h(TaskIcon, { class: 'h-4 w-4' }), icon: h(TaskIcon, { class: 'h-4 w-4' }),
label: 'New Task', label: __('New Task'),
onClick: () => showTask(), onClick: () => showTask(),
}, },
]" ]"
@ -66,7 +66,7 @@
<template #prefix> <template #prefix>
<FeatherIcon name="plus" class="h-4 w-4" /> <FeatherIcon name="plus" class="h-4 w-4" />
</template> </template>
<span>New</span> <span>{{ __('New') }}</span>
<template #suffix> <template #suffix>
<FeatherIcon <FeatherIcon
:name="open ? 'chevron-up' : 'chevron-down'" :name="open ? 'chevron-up' : 'chevron-down'"
@ -82,7 +82,7 @@
class="flex flex-1 flex-col items-center justify-center gap-3 text-xl font-medium text-gray-500" class="flex flex-1 flex-col items-center justify-center gap-3 text-xl font-medium text-gray-500"
> >
<LoadingIndicator class="h-6 w-6" /> <LoadingIndicator class="h-6 w-6" />
<span>Loading...</span> <span>{{ __('Loading...') }}</span>
</div> </div>
<div v-else-if="activities?.length" class="activities flex-1 overflow-y-auto"> <div v-else-if="activities?.length" class="activities flex-1 overflow-y-auto">
<div <div
@ -101,8 +101,8 @@
<Dropdown <Dropdown
:options="[ :options="[
{ {
label: __('Delete'),
icon: 'trash-2', icon: 'trash-2',
label: 'Delete',
onClick: () => deleteNote(note.name), onClick: () => deleteNote(note.name),
}, },
]" ]"
@ -135,7 +135,7 @@
</div> </div>
<Tooltip :text="dateFormat(note.modified, dateTooltipFormat)"> <Tooltip :text="dateFormat(note.modified, dateTooltipFormat)">
<div class="truncate text-sm text-gray-700"> <div class="truncate text-sm text-gray-700">
{{ timeAgo(note.modified) }} {{ __(timeAgo(note.modified)) }}
</div> </div>
</Tooltip> </Tooltip>
</div> </div>
@ -188,7 +188,7 @@
:options="taskStatusOptions(updateTaskStatus, task)" :options="taskStatusOptions(updateTaskStatus, task)"
@click.stop @click.stop
> >
<Tooltip text="Change Status"> <Tooltip :text="__('Change Status')">
<Button variant="ghosted" class="hover:bg-gray-300"> <Button variant="ghosted" class="hover:bg-gray-300">
<TaskStatusIcon :status="task.status" /> <TaskStatusIcon :status="task.status" />
</Button> </Button>
@ -197,15 +197,15 @@
<Dropdown <Dropdown
:options="[ :options="[
{ {
label: __('Delete'),
icon: 'trash-2', icon: 'trash-2',
label: 'Delete',
onClick: () => { onClick: () => {
$dialog({ $dialog({
title: 'Delete Task', title: __('Delete Task'),
message: 'Are you sure you want to delete this task?', message: __('Are you sure you want to delete this task?'),
actions: [ actions: [
{ {
label: 'Delete', label: __('Delete'),
theme: 'red', theme: 'red',
variant: 'solid', variant: 'solid',
onClick(close) { onClick(close) {
@ -257,12 +257,16 @@
> >
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
{{ call.type == 'Incoming' ? 'Inbound' : 'Outbound' }} Call {{
call.type == 'Incoming'
? __('Inbound Call')
: __('Outbound Call')
}}
</div> </div>
<div> <div>
<Tooltip :text="dateFormat(call.creation, dateTooltipFormat)"> <Tooltip :text="dateFormat(call.creation, dateTooltipFormat)">
<div class="text-sm text-gray-600"> <div class="text-sm text-gray-600">
{{ timeAgo(call.creation) }} {{ __(timeAgo(call.creation)) }}
</div> </div>
</Tooltip> </Tooltip>
</div> </div>
@ -270,25 +274,28 @@
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div class="flex items-center gap-1"> <div class="flex items-center gap-1">
<DurationIcon class="h-4 w-4 text-gray-600" /> <DurationIcon class="h-4 w-4 text-gray-600" />
<div class="text-sm text-gray-600">Duration</div> <div class="text-sm text-gray-600">{{ __('Duration') }}</div>
<div class="text-sm"> <div class="text-sm">
{{ call.duration }} {{ call.duration }}
</div> </div>
</div> </div>
<div <div
v-if="call.recording_url"
class="flex cursor-pointer select-none items-center gap-1" class="flex cursor-pointer select-none items-center gap-1"
@click="call.show_recording = !call.show_recording" @click="call.show_recording = !call.show_recording"
> >
<PlayIcon class="h-4 w-4 text-gray-600" /> <PlayIcon class="h-4 w-4 text-gray-600" />
<div class="text-sm text-gray-600"> <div class="text-sm text-gray-600">
{{ {{
call.show_recording ? 'Hide Recording' : 'Listen to Call' call.show_recording
? __('Hide Recording')
: __('Listen to Call')
}} }}
</div> </div>
</div> </div>
</div> </div>
<div <div
v-if="call.show_recording" v-if="call.show_recording && call.recording_url"
class="flex items-center justify-between rounded border" class="flex items-center justify-between rounded border"
> >
<audio class="audio-control" controls :src="call.recording_url" /> <audio class="audio-control" controls :src="call.recording_url" />
@ -302,7 +309,7 @@
/> />
<div class="ml-1 flex flex-col gap-1"> <div class="ml-1 flex flex-col gap-1">
<div class="text-base font-medium"> <div class="text-base font-medium">
{{ call.caller.label }} {{ __(call.caller.label) }}
</div> </div>
<div class="text-xs text-gray-600"> <div class="text-xs text-gray-600">
{{ call.from }} {{ call.from }}
@ -319,7 +326,7 @@
/> />
<div class="ml-1 flex flex-col gap-1"> <div class="ml-1 flex flex-col gap-1">
<div class="text-base font-medium"> <div class="text-base font-medium">
{{ call.receiver.label }} {{ __(call.receiver.label) }}
</div> </div>
<div class="text-xs text-gray-600"> <div class="text-xs text-gray-600">
{{ call.to }} {{ call.to }}
@ -378,12 +385,12 @@
:text="dateFormat(activity.creation, dateTooltipFormat)" :text="dateFormat(activity.creation, dateTooltipFormat)"
> >
<div class="text-sm text-gray-600"> <div class="text-sm text-gray-600">
{{ timeAgo(activity.creation) }} {{ __(timeAgo(activity.creation)) }}
</div> </div>
</Tooltip> </Tooltip>
</div> </div>
<div class="flex gap-0.5"> <div class="flex gap-0.5">
<Tooltip text="Reply"> <Tooltip :text="__('Reply')">
<Button <Button
variant="ghost" variant="ghost"
class="text-gray-700" class="text-gray-700"
@ -392,7 +399,7 @@
<ReplyIcon class="h-4 w-4" /> <ReplyIcon class="h-4 w-4" />
</Button> </Button>
</Tooltip> </Tooltip>
<Tooltip text="Reply All"> <Tooltip :text="__('Reply All')">
<Button <Button
variant="ghost" variant="ghost"
class="text-gray-700" class="text-gray-700"
@ -407,14 +414,16 @@
{{ activity.data.subject }} {{ activity.data.subject }}
</div> </div>
<div class="mb-3 text-sm leading-5 text-gray-600"> <div class="mb-3 text-sm leading-5 text-gray-600">
<span class="mr-1 text-2xs font-bold text-gray-500">TO:</span> <span class="mr-1 text-2xs font-bold text-gray-500">
{{ __('TO') }}:
</span>
<span>{{ activity.data.recipients }}</span> <span>{{ activity.data.recipients }}</span>
<span v-if="activity.data.cc">, </span> <span v-if="activity.data.cc">, </span>
<span <span
v-if="activity.data.cc" v-if="activity.data.cc"
class="mr-1 text-2xs font-bold text-gray-500" class="mr-1 text-2xs font-bold text-gray-500"
> >
CC: {{ __('CC') }}:
</span> </span>
<span v-if="activity.data.cc">{{ activity.data.cc }}</span> <span v-if="activity.data.cc">{{ activity.data.cc }}</span>
<span v-if="activity.data.bcc">, </span> <span v-if="activity.data.bcc">, </span>
@ -422,7 +431,7 @@
v-if="activity.data.bcc" v-if="activity.data.bcc"
class="mr-1 text-2xs font-bold text-gray-500" class="mr-1 text-2xs font-bold text-gray-500"
> >
BCC: {{ __('BCC') }}:
</span> </span>
<span v-if="activity.data.bcc">{{ activity.data.bcc }}</span> <span v-if="activity.data.bcc">{{ activity.data.bcc }}</span>
</div> </div>
@ -452,15 +461,15 @@
<span class="font-medium text-gray-800"> <span class="font-medium text-gray-800">
{{ activity.owner_name }} {{ activity.owner_name }}
</span> </span>
<span>added a</span> <span>{{ __('added a') }}</span>
<span class="max-w-xs truncate font-medium text-gray-800"> <span class="max-w-xs truncate font-medium text-gray-800">
comment {{ __('comment') }}
</span> </span>
</div> </div>
<div class="ml-auto whitespace-nowrap"> <div class="ml-auto whitespace-nowrap">
<Tooltip :text="dateFormat(activity.creation, dateTooltipFormat)"> <Tooltip :text="dateFormat(activity.creation, dateTooltipFormat)">
<div class="text-gray-600"> <div class="text-gray-600">
{{ timeAgo(activity.creation) }} {{ __(timeAgo(activity.creation)) }}
</div> </div>
</Tooltip> </Tooltip>
</div> </div>
@ -479,12 +488,16 @@
> >
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div> <div>
{{ activity.type == 'Incoming' ? 'Inbound' : 'Outbound' }} Call {{
activity.type == 'Incoming'
? __('Inbound Call')
: __('Outbound Call')
}}
</div> </div>
<div> <div>
<Tooltip :text="dateFormat(activity.creation, dateTooltipFormat)"> <Tooltip :text="dateFormat(activity.creation, dateTooltipFormat)">
<div class="text-sm text-gray-600"> <div class="text-sm text-gray-600">
{{ timeAgo(activity.creation) }} {{ __(timeAgo(activity.creation)) }}
</div> </div>
</Tooltip> </Tooltip>
</div> </div>
@ -492,25 +505,28 @@
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div class="flex items-center gap-1"> <div class="flex items-center gap-1">
<DurationIcon class="h-4 w-4 text-gray-600" /> <DurationIcon class="h-4 w-4 text-gray-600" />
<div class="text-sm text-gray-600">Duration</div> <div class="text-sm text-gray-600">{{ __('Duration') }}</div>
<div class="text-sm"> <div class="text-sm">
{{ activity.duration }} {{ activity.duration }}
</div> </div>
</div> </div>
<div <div
v-if="activity.recording_url"
class="flex cursor-pointer select-none items-center gap-1" class="flex cursor-pointer select-none items-center gap-1"
@click="activity.show_recording = !activity.show_recording" @click="activity.show_recording = !activity.show_recording"
> >
<PlayIcon class="h-4 w-4 text-gray-600" /> <PlayIcon class="h-4 w-4 text-gray-600" />
<div class="text-sm text-gray-600"> <div class="text-sm text-gray-600">
{{ {{
activity.show_recording ? 'Hide Recording' : 'Listen to Call' activity.show_recording
? __('Hide Recording')
: __('Listen to Call')
}} }}
</div> </div>
</div> </div>
</div> </div>
<div <div
v-if="activity.show_recording" v-if="activity.show_recording && activity.recording_url"
class="flex items-center justify-between rounded border" class="flex items-center justify-between rounded border"
> >
<audio <audio
@ -528,7 +544,7 @@
/> />
<div class="ml-1 flex flex-col gap-1"> <div class="ml-1 flex flex-col gap-1">
<div class="text-base font-medium"> <div class="text-base font-medium">
{{ activity.caller.label }} {{ __(activity.caller.label) }}
</div> </div>
<div class="text-xs text-gray-600"> <div class="text-xs text-gray-600">
{{ activity.from }} {{ activity.from }}
@ -545,7 +561,7 @@
/> />
<div class="ml-1 flex flex-col gap-1"> <div class="ml-1 flex flex-col gap-1">
<div class="text-base font-medium"> <div class="text-base font-medium">
{{ activity.receiver.label }} {{ __(activity.receiver.label) }}
</div> </div>
<div class="text-xs text-gray-600"> <div class="text-xs text-gray-600">
{{ activity.to }} {{ activity.to }}
@ -557,17 +573,17 @@
<div v-else class="mb-4 flex flex-col gap-5 py-1.5"> <div v-else class="mb-4 flex flex-col gap-5 py-1.5">
<div class="flex items-start justify-stretch gap-2 text-base"> <div class="flex items-start justify-stretch gap-2 text-base">
<div class="inline-flex flex-wrap gap-1 text-gray-600"> <div class="inline-flex flex-wrap gap-1 text-gray-600">
<span class="font-medium text-gray-800">{{ <span class="font-medium text-gray-800">
activity.owner_name {{ activity.owner_name }}
}}</span> </span>
<span v-if="activity.type">{{ activity.type }}</span> <span v-if="activity.type">{{ __(activity.type) }}</span>
<span <span
v-if="activity.data.field_label" v-if="activity.data.field_label"
class="max-w-xs truncate font-medium text-gray-800" class="max-w-xs truncate font-medium text-gray-800"
> >
{{ activity.data.field_label }} {{ __(activity.data.field_label) }}
</span> </span>
<span v-if="activity.value">{{ activity.value }}</span> <span v-if="activity.value">{{ __(activity.value) }}</span>
<span <span
v-if="activity.data.old_value" v-if="activity.data.old_value"
class="max-w-xs font-medium text-gray-800" class="max-w-xs font-medium text-gray-800"
@ -583,7 +599,7 @@
{{ activity.data.old_value }} {{ activity.data.old_value }}
</div> </div>
</span> </span>
<span v-if="activity.to">to</span> <span v-if="activity.to">{{ __('to') }}</span>
<span <span
v-if="activity.data.value" v-if="activity.data.value"
class="max-w-xs font-medium text-gray-800" class="max-w-xs font-medium text-gray-800"
@ -604,7 +620,7 @@
<div class="ml-auto whitespace-nowrap"> <div class="ml-auto whitespace-nowrap">
<Tooltip :text="dateFormat(activity.creation, dateTooltipFormat)"> <Tooltip :text="dateFormat(activity.creation, dateTooltipFormat)">
<div class="text-gray-600"> <div class="text-gray-600">
{{ timeAgo(activity.creation) }} {{ __(timeAgo(activity.creation)) }}
</div> </div>
</Tooltip> </Tooltip>
</div> </div>
@ -620,7 +636,7 @@
v-if="activity.data.field_label" v-if="activity.data.field_label"
class="max-w-xs truncate text-gray-600" class="max-w-xs truncate text-gray-600"
> >
{{ activity.data.field_label }} {{ __(activity.data.field_label) }}
</span> </span>
<FeatherIcon <FeatherIcon
name="arrow-right" name="arrow-right"
@ -628,7 +644,9 @@
/> />
</div> </div>
<div class="flex flex-wrap items-center gap-1"> <div class="flex flex-wrap items-center gap-1">
<span v-if="activity.type">{{ startCase(activity.type) }}</span> <span v-if="activity.type">{{
startCase(__(activity.type))
}}</span>
<span <span
v-if="activity.data.old_value" v-if="activity.data.old_value"
class="max-w-xs font-medium text-gray-800" class="max-w-xs font-medium text-gray-800"
@ -644,7 +662,7 @@
{{ activity.data.old_value }} {{ activity.data.old_value }}
</div> </div>
</span> </span>
<span v-if="activity.to">to</span> <span v-if="activity.to">{{ __('to') }}</span>
<span <span
v-if="activity.data.value" v-if="activity.data.value"
class="max-w-xs font-medium text-gray-800" class="max-w-xs font-medium text-gray-800"
@ -666,7 +684,7 @@
<div class="ml-auto whitespace-nowrap"> <div class="ml-auto whitespace-nowrap">
<Tooltip :text="dateFormat(activity.creation, dateTooltipFormat)"> <Tooltip :text="dateFormat(activity.creation, dateTooltipFormat)">
<div class="text-gray-600"> <div class="text-gray-600">
{{ timeAgo(activity.creation) }} {{ __(timeAgo(activity.creation)) }}
</div> </div>
</Tooltip> </Tooltip>
</div> </div>
@ -674,7 +692,9 @@
<div v-if="activity.other_versions"> <div v-if="activity.other_versions">
<Button <Button
:label=" :label="
activity.show_others ? 'Hide all Changes' : 'Show all Changes' activity.show_others
? __('Hide all Changes')
: __('Show all Changes')
" "
variant="outline" variant="outline"
@click="activity.show_others = !activity.show_others" @click="activity.show_others = !activity.show_others"
@ -696,25 +716,25 @@
class="flex flex-1 flex-col items-center justify-center gap-3 text-xl font-medium text-gray-500" class="flex flex-1 flex-col items-center justify-center gap-3 text-xl font-medium text-gray-500"
> >
<component :is="emptyTextIcon" class="h-10 w-10" /> <component :is="emptyTextIcon" class="h-10 w-10" />
<span>{{ emptyText }}</span> <span>{{ __(emptyText) }}</span>
<Button <Button
v-if="title == 'Calls'" v-if="title == 'Calls'"
label="Make a Call" :label="__('Make a Call')"
@click="makeCall(doc.data.mobile_no)" @click="makeCall(doc.data.mobile_no)"
/> />
<Button <Button
v-else-if="title == 'Notes'" v-else-if="title == 'Notes'"
label="Create Note" :label="__('Create Note')"
@click="showNote()" @click="showNote()"
/> />
<Button <Button
v-else-if="title == 'Emails'" v-else-if="title == 'Emails'"
label="New Email" :label="__('New Email')"
@click="$refs.emailBox.show = true" @click="$refs.emailBox.show = true"
/> />
<Button <Button
v-else-if="title == 'Tasks'" v-else-if="title == 'Tasks'"
label="Create Task" :label="__('Create Task')"
@click="showTask()" @click="showTask()"
/> />
</div> </div>
@ -785,11 +805,10 @@ import {
TextEditor, TextEditor,
Avatar, Avatar,
createResource, createResource,
createListResource,
call, call,
} from 'frappe-ui' } from 'frappe-ui'
import { useElementVisibility } from '@vueuse/core' import { useElementVisibility } from '@vueuse/core'
import { ref, computed, h, markRaw, watch, nextTick, onMounted } from 'vue' import { ref, computed, h, markRaw, watch, nextTick } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
const { makeCall } = globalStore() const { makeCall } = globalStore()