fix: permission issues on badges

This commit is contained in:
Jannat Patel
2026-02-19 15:59:03 +05:30
parent 08373dc2ab
commit c88d36df1e
6 changed files with 47 additions and 113 deletions

View File

@@ -1,82 +0,0 @@
<template>
<div v-if="badge.data">
<div class="p-5 flex flex-col items-center mt-40">
<div class="text-3xl font-semibold">
{{ badge.data.badge }}
</div>
<img
:src="badge.data.badge_image"
:alt="badge.data.badge"
class="h-60 mt-2"
/>
<div class="">
{{
__('This badge has been awarded to {0} on {1}.').format(
badge.data.member_name,
dayjs(badge.data.issued_on).format('DD MMM YYYY')
)
}}
</div>
<div class="mt-2">
{{ badge.data.badge_description }}
</div>
</div>
</div>
</template>
<script setup>
import { createResource, usePageMeta } from 'frappe-ui'
import { computed, inject } from 'vue'
import { sessionStore } from '../stores/session'
const dayjs = inject('$dayjs')
const { brand } = sessionStore()
const props = defineProps({
badgeName: {
type: String,
required: true,
},
email: {
type: String,
required: true,
},
})
const badge = createResource({
url: 'frappe.client.get',
makeParams(values) {
return {
doctype: 'LMS Badge Assignment',
filters: {
badge: props.badgeName,
member: props.email,
},
}
},
auto: true,
})
const breadcrumbs = computed(() => {
return [
{
label: __('Badges'),
},
{
label: badge.data.badge,
route: {
name: 'Badge',
params: {
badge: badge.data.badge,
},
},
},
]
})
usePageMeta(() => {
return {
title: badge.data.badge,
icon: brand.favicon,
}
})
</script>

View File

@@ -70,13 +70,16 @@
<div class="leading-5 mb-4">
{{ badge.badge_description }}
</div>
<div class="flex flex-col mb-4">
<div class="flex flex-col">
<span class="text-xs text-ink-gray-7 font-medium mb-1">
{{ __('Issued on') }}:
</span>
{{ dayjs(badge.issued_on).format('DD MMM YYYY') }}
</div>
<div class="flex flex-col">
<div
v-if="user.data?.name == profile.data?.name"
class="flex flex-col mt-4"
>
<span class="text-xs text-ink-gray-7 font-medium mb-1">
{{ __('Share on') }}:
</span>
@@ -125,6 +128,7 @@ import DOMPurify from 'dompurify'
import { getLmsRoute } from '@/utils/basePath'
const dayjs = inject('$dayjs')
const user = inject('$user')
const { branding } = sessionStore()
const props = defineProps({
@@ -135,13 +139,9 @@ const props = defineProps({
})
const badges = createResource({
url: 'frappe.client.get_list',
url: 'lms.lms.api.get_badges',
params: {
doctype: 'LMS Badge Assignment',
fields: ['name', 'badge', 'badge_image', 'badge_description', 'issued_on'],
filters: {
member: props.profile.data.name,
},
member: props.profile.data.name,
},
auto: true,
transform(data) {
@@ -160,14 +160,16 @@ const shareOnSocial = (badge, medium) => {
let shareUrl
const url = encodeURIComponent(
`${window.location.origin}${getLmsRoute(
`badges/${badge.badge}/${props.profile.data?.email}`
`user/${props.profile.data?.username}`
)}`
)
const summary = `I am happy to announce that I earned the ${
badge.badge
} badge on ${dayjs(badge.issued_on).format('DD MMM YYYY')} at ${
const summary = __(
'I am happy to announce that I earned the {0} badge on {1} at {2}'
).format(
badge.badge,
dayjs(badge.issued_on).format('DD MMM YYYY'),
branding.data?.app_name
}.`
)
if (medium == 'LinkedIn')
shareUrl = `https://www.linkedin.com/shareArticle?mini=true&url=${url}&text=${summary}`