-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1164 from frappe/develop
chore: merge 'develop' into 'main'
- Loading branch information
Showing
28 changed files
with
2,205 additions
and
6,693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<template> | ||
<Dialog | ||
v-model="show" | ||
:options="{ | ||
title: __('Generate Certificates'), | ||
size: 'lg', | ||
actions: [ | ||
{ | ||
label: 'Create', | ||
variant: 'solid', | ||
onClick: ({ close }) => { | ||
generateCertificates(close) | ||
}, | ||
}, | ||
], | ||
}" | ||
> | ||
<template #body-content> | ||
<div class="space-y-4"> | ||
<FormControl | ||
type="select" | ||
v-model="details.course" | ||
:label="__('Course')" | ||
:options="getCourses()" | ||
/> | ||
<Link | ||
v-model="details.evaluator" | ||
:label="__('Evaluator')" | ||
doctype="Course Evaluator" | ||
/> | ||
<FormControl | ||
type="date" | ||
v-model="details.issue_date" | ||
:label="__('Issue Date')" | ||
/> | ||
<FormControl | ||
type="date" | ||
v-model="details.expiry_date" | ||
:label="__('Expiry Date')" | ||
/> | ||
<Link | ||
v-model="details.template" | ||
:label="__('Template')" | ||
doctype="Print Format" | ||
:filters="{ | ||
doc_type: 'LMS Certificate', | ||
}" | ||
/> | ||
<Switch | ||
size="sm" | ||
:label="__('Published')" | ||
:description=" | ||
__( | ||
'Enabling this will publish the certificate on the certified participants page.' | ||
) | ||
" | ||
v-model="details.published" | ||
/> | ||
</div> | ||
</template> | ||
</Dialog> | ||
</template> | ||
<script setup> | ||
import { inject, reactive } from 'vue' | ||
import { createResource, Dialog, FormControl, Switch } from 'frappe-ui' | ||
import Link from '@/components/Controls/Link.vue' | ||
import { showToast } from '@/utils' | ||
const show = defineModel() | ||
const dayjs = inject('$dayjs') | ||
const details = reactive({ | ||
issue_date: dayjs().format('YYYY-MM-DD'), | ||
expiry_date: null, | ||
template: null, | ||
evaluator: null, | ||
published: true, | ||
}) | ||
const props = defineProps({ | ||
batch: { | ||
type: [Object, null], | ||
required: true, | ||
}, | ||
}) | ||
const createCertificate = createResource({ | ||
url: 'frappe.client.insert', | ||
makeParams(values) { | ||
return { | ||
doc: { | ||
doctype: 'LMS Certificate', | ||
issue_date: details.issue_date, | ||
expiry_date: details.expiry_date, | ||
template: details.template, | ||
published: details.published, | ||
course: values.course, | ||
batch: values.batch, | ||
member: values.member, | ||
evaluator: details.evaluator, | ||
}, | ||
} | ||
}, | ||
}) | ||
const generateCertificates = (close) => { | ||
props.batch?.students.forEach((student) => { | ||
createCertificate.submit( | ||
{ | ||
course: details.course, | ||
batch: props.batch.name, | ||
member: student, | ||
}, | ||
{ | ||
onError(err) { | ||
showToast(__('Error'), err.messages?.[0] || err, 'x') | ||
}, | ||
} | ||
) | ||
}) | ||
close() | ||
showToast(__('Success'), __('Certificates generated successfully'), 'check') | ||
} | ||
const getCourses = () => { | ||
return props.batch?.courses.map((course) => { | ||
return { | ||
label: course.course, | ||
value: course.course, | ||
} | ||
}) | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.