Merge pull request #1380 from pateljannat/issues-84

fix: moved evaluation cancel button in a menu
This commit is contained in:
Jannat Patel
2025-03-13 22:17:39 +05:30
committed by GitHub
5 changed files with 174 additions and 119 deletions

View File

@@ -18,8 +18,51 @@
<div class="grid grid-cols-3 gap-4">
<div v-for="evl in upcoming_evals.data">
<div class="border rounded-md p-3">
<div class="font-semibold mb-3">
{{ evl.course_title }}
<div class="flex justify-between mb-3">
<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 class="flex items-center mb-2">
<Calendar class="w-4 h-4 stroke-1.5" />
@@ -50,16 +93,6 @@
</template>
{{ __('Join Call') }}
</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>
@@ -84,11 +117,13 @@ import {
Clock,
GraduationCap,
HeadsetIcon,
EllipsisVertical,
} from 'lucide-vue-next'
import { inject, ref, getCurrentInstance } from 'vue'
import { formatTime } from '../utils'
import { Button, createResource, call } from 'frappe-ui'
import EvaluationModal from '@/components/Modals/EvaluationModal.vue'
import { Menu, MenuButton, MenuItems, MenuItem } from '@headlessui/vue'
const dayjs = inject('$dayjs')
const user = inject('$user')

View File

@@ -82,6 +82,7 @@ import {
User,
Settings,
Sun,
Zap,
} from 'lucide-vue-next'
const router = useRouter()
@@ -125,89 +126,109 @@ const toggleTheme = () => {
const userDropdownOptions = computed(() => {
return [
{
icon: User,
label: 'My Profile',
onClick: () => {
router.push(`/user/${userResource.data?.username}`)
},
condition: () => {
return isLoggedIn
},
group: '',
items: [
{
icon: User,
label: 'My Profile',
onClick: () => {
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,
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: 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
},
group: '',
items: [
{
icon: Zap,
label: 'Powered by Learning',
onClick: () => {
window.open('https://frappe.io/learning', '_blank')
},
},
{
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",
"links": [
{
"group": "Chapters",
"link_doctype": "LMS Enrollment",
"link_fieldname": "course"
},
{
"link_doctype": "Course Chapter",
"link_fieldname": "course"
},
{
"group": "Batches",
"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_doctype": "Course Lesson",
"link_fieldname": "course"
}
],
"make_attachments_public": 1,
"modified": "2025-03-04 15:43:25.151554",
"modified": "2025-03-13 16:01:19.105212",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Course",

View File

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

View File

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