fix: moved evaluation cancel button in a menu

This commit is contained in:
Jannat Patel
2025-03-13 22:00:39 +05:30
parent e23f6ae0fa
commit f29c2da9ce
5 changed files with 166 additions and 120 deletions

View File

@@ -18,8 +18,45 @@
<div class="grid grid-cols-3 gap-4"> <div class="grid grid-cols-3 gap-4">
<div v-for="evl in upcoming_evals.data"> <div v-for="evl in upcoming_evals.data">
<div class="border rounded-md p-3"> <div class="border rounded-md p-3">
<div class="font-semibold mb-3"> <div class="flex justify-between mb-3">
{{ evl.course_title }} <span class="font-semibold leading-5">
{{ evl.course_title }}
</span>
<Menu v-if="evl.date > dayjs().format()" as="div" class="relative inline-block text-left">
<div>
<MenuButton
class="inline-flex w-full justify-center"
>
<EllipsisVertical class="w-4 h-4 stroke-1.5" />
</MenuButton>
</div>
<transition
enter-active-class="transition duration-100 ease-out"
enter-from-class="transform scale-95 opacity-0"
enter-to-class="transform scale-100 opacity-100"
leave-active-class="transition duration-75 ease-in"
leave-from-class="transform scale-100 opacity-100"
leave-to-class="transform scale-95 opacity-0"
>
<MenuItems
class="absolute mt-2 w-32 rounded-md bg-white shadow-lg p-1.5"
>
<MenuItem v-slot="{ active }">
<Button variant="ghost" class="w-full" @click="cancelEvaluation(evl)">
<template #prefix>
<Ban
:active="active"
class="size-4 stroke-1.5"
aria-hidden="true"
/>
</template>
{{ __("Cancel") }}
</Button>
</MenuItem>
</MenuItems>
</transition>
</Menu>
</div> </div>
<div class="flex items-center mb-2"> <div class="flex items-center mb-2">
<Calendar class="w-4 h-4 stroke-1.5" /> <Calendar class="w-4 h-4 stroke-1.5" />
@@ -50,16 +87,6 @@
</template> </template>
{{ __('Join Call') }} {{ __('Join Call') }}
</Button> </Button>
<Button
v-if="evl.date > dayjs().format()"
@click="cancelEvaluation(evl)"
class="w-full"
>
<template #prefix>
<Ban class="w-4 h-4 stroke-1.5" />
</template>
{{ __('Cancel') }}
</Button>
</div> </div>
</div> </div>
</div> </div>
@@ -84,11 +111,13 @@ import {
Clock, Clock,
GraduationCap, GraduationCap,
HeadsetIcon, HeadsetIcon,
EllipsisVertical
} from 'lucide-vue-next' } from 'lucide-vue-next'
import { inject, ref, getCurrentInstance } from 'vue' import { inject, ref, getCurrentInstance } from 'vue'
import { formatTime } from '../utils' import { formatTime } from '../utils'
import { Button, createResource, call } from 'frappe-ui' import { Button, createResource, call } from 'frappe-ui'
import EvaluationModal from '@/components/Modals/EvaluationModal.vue' import EvaluationModal from '@/components/Modals/EvaluationModal.vue'
import { Menu, MenuButton, MenuItems, MenuItem } from '@headlessui/vue'
const dayjs = inject('$dayjs') const dayjs = inject('$dayjs')
const user = inject('$user') const user = inject('$user')

View File

@@ -82,6 +82,7 @@ import {
User, User,
Settings, Settings,
Sun, Sun,
Zap,
} from 'lucide-vue-next' } from 'lucide-vue-next'
const router = useRouter() const router = useRouter()
@@ -125,90 +126,107 @@ const toggleTheme = () => {
const userDropdownOptions = computed(() => { const userDropdownOptions = computed(() => {
return [ return [
{ {
icon: User, group: "",
label: 'My Profile', items: [
onClick: () => { {
router.push(`/user/${userResource.data?.username}`) icon: User,
}, label: 'My Profile',
condition: () => { onClick: () => {
return isLoggedIn router.push(`/user/${userResource.data?.username}`)
}, },
condition: () => {
return isLoggedIn
},
},
{
icon: theme.value === 'light' ? Moon : Sun,
label: 'Toggle Theme',
onClick: () => {
toggleTheme()
},
},
{
component: markRaw(Apps),
condition: () => {
let cookies = new URLSearchParams(document.cookie.split('; ').join('&'))
let system_user = cookies.get('system_user')
if (system_user === 'yes') return true
else return false
},
},
{
icon: Settings,
label: 'Settings',
onClick: () => {
settingsStore.isSettingsOpen = true
},
condition: () => {
return userResource.data?.is_moderator
},
},
{
icon: FrappeCloudIcon,
label: 'Login to Frappe Cloud',
onClick: () => {
$dialog({
title: __('Login to Frappe Cloud?'),
message: __(
'Are you sure you want to login to your Frappe Cloud dashboard?'
),
actions: [
{
label: __('Confirm'),
variant: 'solid',
onClick(close) {
loginToFrappeCloud()
close()
},
},
],
})
},
condition: () => {
return (
userResource.data?.is_system_manager && userResource.data?.is_fc_site
)
},
},
]
}, },
{ {
icon: theme.value === 'light' ? Moon : Sun, group: "",
label: 'Toggle Theme', items: [
onClick: () => { {
toggleTheme() icon: Zap,
}, label: "Powered by Learning",
}, onClick: () => {
{ window.open('https://frappe.io/learning', '_blank')
component: markRaw(Apps), },
condition: () => { },
let cookies = new URLSearchParams(document.cookie.split('; ').join('&')) {
let system_user = cookies.get('system_user') icon: LogOut,
if (system_user === 'yes') return true label: 'Log out',
else return false onClick: () => {
}, logout.submit().then(() => {
}, isLoggedIn = false
{ })
icon: Settings, },
label: 'Settings', condition: () => {
onClick: () => { return isLoggedIn
settingsStore.isSettingsOpen = true },
}, },
condition: () => { {
return userResource.data?.is_moderator icon: LogIn,
}, label: 'Log in',
}, onClick: () => {
{ window.location.href = '/login'
icon: FrappeCloudIcon, },
label: 'Login to Frappe Cloud', condition: () => {
onClick: () => { return !isLoggedIn
$dialog({ },
title: __('Login to Frappe Cloud?'), },
message: __( ]
'Are you sure you want to login to your Frappe Cloud dashboard?' }
),
actions: [
{
label: __('Confirm'),
variant: 'solid',
onClick(close) {
loginToFrappeCloud()
close()
},
},
],
})
},
condition: () => {
return (
userResource.data?.is_system_manager && userResource.data?.is_fc_site
)
},
},
{
icon: LogOut,
label: 'Log out',
onClick: () => {
logout.submit().then(() => {
isLoggedIn = false
})
},
condition: () => {
return isLoggedIn
},
},
{
icon: LogIn,
label: 'Log in',
onClick: () => {
window.location.href = '/login'
},
condition: () => {
return !isLoggedIn
},
},
] ]
}) })

View File

@@ -277,28 +277,20 @@
"is_published_field": "published", "is_published_field": "published",
"links": [ "links": [
{ {
"group": "Chapters", "link_doctype": "LMS Enrollment",
"link_fieldname": "course"
},
{
"link_doctype": "Course Chapter", "link_doctype": "Course Chapter",
"link_fieldname": "course" "link_fieldname": "course"
}, },
{ {
"group": "Batches", "link_doctype": "Course Lesson",
"link_doctype": "LMS Batch Old",
"link_fieldname": "course"
},
{
"group": "Mentors",
"link_doctype": "LMS Course Mentor Mapping",
"link_fieldname": "course"
},
{
"group": "Interests",
"link_doctype": "LMS Course Interest",
"link_fieldname": "course" "link_fieldname": "course"
} }
], ],
"make_attachments_public": 1, "make_attachments_public": 1,
"modified": "2025-03-04 15:43:25.151554", "modified": "2025-03-13 16:01:19.105212",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS Course", "name": "LMS Course",

View File

@@ -44,13 +44,15 @@
"fieldtype": "Currency", "fieldtype": "Currency",
"in_list_view": 1, "in_list_view": 1,
"label": "Amount", "label": "Amount",
"options": "currency" "options": "currency",
"reqd": 1
}, },
{ {
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Currency", "label": "Currency",
"options": "Currency" "options": "Currency",
"reqd": 1
}, },
{ {
"fieldname": "column_break_rqkd", "fieldname": "column_break_rqkd",
@@ -70,7 +72,8 @@
"fieldname": "address", "fieldname": "address",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Address", "label": "Address",
"options": "Address" "options": "Address",
"reqd": 1
}, },
{ {
"default": "0", "default": "0",
@@ -124,13 +127,15 @@
"fieldname": "payment_for_document_type", "fieldname": "payment_for_document_type",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Payment for Document Type", "label": "Payment for Document Type",
"options": "\nLMS Course\nLMS Batch" "options": "\nLMS Course\nLMS Batch",
"reqd": 1
}, },
{ {
"fieldname": "payment_for_document", "fieldname": "payment_for_document",
"fieldtype": "Dynamic Link", "fieldtype": "Dynamic Link",
"label": "Payment for Document", "label": "Payment for Document",
"options": "payment_for_document_type" "options": "payment_for_document_type",
"reqd": 1
}, },
{ {
"fieldname": "source", "fieldname": "source",
@@ -156,7 +161,7 @@
"link_fieldname": "payment" "link_fieldname": "payment"
} }
], ],
"modified": "2025-02-21 18:29:55.436611", "modified": "2025-03-13 15:31:38.019002",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS Payment", "name": "LMS Payment",

View File

@@ -1889,16 +1889,16 @@ def update_payment_record(doctype, docname):
try: try:
if payment_for_certificate: if payment_for_certificate:
update_certificate_purchase(docname) update_certificate_purchase(docname, data.payment)
elif doctype == "LMS Course": elif doctype == "LMS Course":
enroll_in_course(data.payment, docname) enroll_in_course(docname, data.payment)
else: else:
enroll_in_batch(docname, data.payment) enroll_in_batch(docname, data.payment)
except Exception as e: except Exception as e:
frappe.log_error(frappe.get_traceback(), _("Enrollment Failed")) frappe.log_error(frappe.get_traceback(), _("Enrollment Failed"))
def enroll_in_course(payment_name, course): def enroll_in_course(course, payment_name):
if not frappe.db.exists( if not frappe.db.exists(
"LMS Enrollment", {"member": frappe.session.user, "course": course} "LMS Enrollment", {"member": frappe.session.user, "course": course}
): ):
@@ -1950,12 +1950,14 @@ def enroll_in_batch(batch, payment_name=None):
new_student.save() new_student.save()
def update_certificate_purchase(course): def update_certificate_purchase(course, payment_name):
frappe.db.set_value( frappe.db.set_value(
"LMS Enrollment", "LMS Enrollment",
{"member": frappe.session.user, "course": course}, {"member": frappe.session.user, "course": course},
"purchased_certificate", {
1, "purchased_certificate": 1,
"payment": payment_name,
}
) )