fix: dynamically generating timeline content instead of duplicate code
This commit is contained in:
parent
cd118cf08c
commit
39ffe88549
@ -16,7 +16,7 @@
|
|||||||
class="flex items-center justify-center rounded-full outline outline-4 outline-white w-6 h-6 bg-gray-200 z-10"
|
class="flex items-center justify-center rounded-full outline outline-4 outline-white w-6 h-6 bg-gray-200 z-10"
|
||||||
>
|
>
|
||||||
<FeatherIcon
|
<FeatherIcon
|
||||||
:name="timelineIcon(activity.activity_type)"
|
:name="activity.icon"
|
||||||
class="w-3.5 h-3.5 text-gray-600"
|
class="w-3.5 h-3.5 text-gray-600"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -25,63 +25,31 @@
|
|||||||
<div
|
<div
|
||||||
class="flex items-start justify-stretch gap-2 text-base leading-6"
|
class="flex items-start justify-stretch gap-2 text-base leading-6"
|
||||||
>
|
>
|
||||||
<Avatar
|
<UserAvatar :user="activity.owner" size="md" />
|
||||||
:image="getUser(activity.owner).user_image"
|
|
||||||
:label="getUser(activity.owner).full_name"
|
|
||||||
size="md"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div class="flex items-center gap-1">
|
<div class="inline-flex flex-wrap gap-1 text-gray-600">
|
||||||
<div>{{ getUser(activity.owner).full_name }}</div>
|
<span class="text-gray-900">{{ activity.owner_name }}</span>
|
||||||
<div
|
<span v-if="activity.type">{{ activity.type }}</span>
|
||||||
v-if="activity.activity_type == 'creation'"
|
<span
|
||||||
class="text-gray-600"
|
v-if="activity.data.field"
|
||||||
|
class="text-gray-900 truncate max-w-xs"
|
||||||
>
|
>
|
||||||
{{ activity.data }}
|
{{ activity.data.field }}
|
||||||
</div>
|
</span>
|
||||||
<div
|
<span v-if="activity.value">{{ activity.value }}</span>
|
||||||
v-else-if="activity.activity_type == 'added'"
|
<span
|
||||||
class="inline-flex gap-1 text-gray-600"
|
v-if="activity.data.old_value"
|
||||||
|
class="text-gray-900 truncate max-w-xs"
|
||||||
>
|
>
|
||||||
<span>added</span>
|
{{ activity.data.old_value }}
|
||||||
<span class="text-gray-900 truncate max-w-xs">
|
</span>
|
||||||
{{ activity.data.field }}
|
<span v-if="activity.to">to</span>
|
||||||
</span>
|
<span
|
||||||
<span>value as</span>
|
v-if="activity.data.value"
|
||||||
<span class="text-gray-900 truncate max-w-xs">
|
class="text-gray-900 truncate max-w-xs"
|
||||||
{{ activity.data.value }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-else-if="activity.activity_type == 'removed'"
|
|
||||||
class="inline-flex gap-1 text-gray-600"
|
|
||||||
>
|
>
|
||||||
<span>removed</span>
|
{{ activity.data.value }}
|
||||||
<span class="text-gray-900 truncate max-w-xs">
|
</span>
|
||||||
{{ activity.data.field }}
|
|
||||||
</span>
|
|
||||||
<span>value</span>
|
|
||||||
<span class="text-gray-900 truncate max-w-xs">
|
|
||||||
{{ activity.data.value }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-else-if="activity.activity_type == 'changed'"
|
|
||||||
class="inline-flex gap-1 text-gray-600"
|
|
||||||
>
|
|
||||||
<span>changed</span>
|
|
||||||
<span class="text-gray-900 truncate max-w-xs">
|
|
||||||
{{ activity.data.field }}
|
|
||||||
</span>
|
|
||||||
<span>value from</span>
|
|
||||||
<span class="text-gray-900 truncate max-w-xs">
|
|
||||||
{{ activity.data.old_value }}
|
|
||||||
</span>
|
|
||||||
<span>to</span>
|
|
||||||
<span class="text-gray-900 truncate max-w-xs">
|
|
||||||
{{ activity.data.value }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ml-auto whitespace-nowrap">
|
<div class="ml-auto whitespace-nowrap">
|
||||||
@ -99,9 +67,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Avatar, FeatherIcon, Tooltip, Button } from 'frappe-ui'
|
import { FeatherIcon, Tooltip } from 'frappe-ui'
|
||||||
import { timeAgo, dateFormat, dateTooltipFormat } from '@/utils'
|
import { timeAgo, dateFormat, dateTooltipFormat } from '@/utils'
|
||||||
import { usersStore } from '@/stores/users'
|
import { usersStore } from '@/stores/users'
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import UserAvatar from './UserAvatar.vue'
|
||||||
|
|
||||||
const { getUser } = usersStore()
|
const { getUser } = usersStore()
|
||||||
|
|
||||||
@ -116,6 +86,27 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const activities = computed(() => {
|
||||||
|
props.activities.forEach((activity) => {
|
||||||
|
activity.owner_name = getUser(activity.owner).full_name
|
||||||
|
activity.icon = timelineIcon(activity.activity_type)
|
||||||
|
if (activity.activity_type == 'creation') {
|
||||||
|
activity.type = activity.data
|
||||||
|
} else if (activity.activity_type == 'added') {
|
||||||
|
activity.type = 'added'
|
||||||
|
activity.value = 'value as'
|
||||||
|
} else if (activity.activity_type == 'removed') {
|
||||||
|
activity.type = 'removed'
|
||||||
|
activity.value = 'value'
|
||||||
|
} else {
|
||||||
|
activity.type = 'changed'
|
||||||
|
activity.value = 'value from'
|
||||||
|
activity.to = 'to'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return props.activities
|
||||||
|
})
|
||||||
|
|
||||||
function timelineIcon(activity_type) {
|
function timelineIcon(activity_type) {
|
||||||
if (activity_type == 'creation') {
|
if (activity_type == 'creation') {
|
||||||
return 'plus'
|
return 'plus'
|
||||||
|
|||||||
@ -249,9 +249,6 @@ const lead = createResource({
|
|||||||
url: 'crm.crm.doctype.crm_lead.api.get_lead',
|
url: 'crm.crm.doctype.crm_lead.api.get_lead',
|
||||||
params: { name: props.leadId },
|
params: { name: props.leadId },
|
||||||
auto: true,
|
auto: true,
|
||||||
onSuccess: (response) => {
|
|
||||||
console.log(response)
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const breadcrumbs = computed(() => {
|
const breadcrumbs = computed(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user