fix(LMS): program enrollment does not give any feedback (backport #29922) (#29924)

Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>
This commit is contained in:
mergify[bot]
2022-02-21 23:10:20 +05:30
committed by GitHub
parent 6b87d38a80
commit 233a75a438

View File

@@ -11,7 +11,7 @@
{% if frappe.session.user == 'Guest' %} {% if frappe.session.user == 'Guest' %}
<a id="signup" class="btn btn-primary btn-lg" href="/login#signup">{{_('Sign Up')}}</a> <a id="signup" class="btn btn-primary btn-lg" href="/login#signup">{{_('Sign Up')}}</a>
{% elif not has_access %} {% elif not has_access %}
<button id="enroll" class="btn btn-primary btn-lg" onclick="enroll()" disabled>{{_('Enroll')}}</button> <button id="enroll" class="btn btn-primary btn-lg" onclick="enroll()">{{_('Enroll')}}</button>
{% endif %} {% endif %}
</p> </p>
</div> </div>
@@ -20,34 +20,35 @@
<script type="text/javascript"> <script type="text/javascript">
frappe.ready(() => { frappe.ready(() => {
btn = document.getElementById('enroll'); btn = document.getElementById('enroll');
if (btn) btn.disabled = false;
}) })
function enroll() { function enroll() {
let params = frappe.utils.get_query_params() let params = frappe.utils.get_query_params()
let btn = document.getElementById('enroll'); let btn = document.getElementById('enroll');
btn.disbaled = true;
btn.innerText = __('Enrolling...')
let opts = { let opts = {
method: 'erpnext.education.utils.enroll_in_program', method: 'erpnext.education.utils.enroll_in_program',
args: { args: {
program_name: params.program program_name: params.program
} },
freeze: true,
freeze_message: __('Enrolling...')
} }
frappe.call(opts).then(res => { frappe.call(opts).then(res => {
let success_dialog = new frappe.ui.Dialog({ let success_dialog = new frappe.ui.Dialog({
title: __('Success'), title: __('Success'),
primary_action_label: __('View Program Content'),
primary_action: function() {
window.location.reload();
},
secondary_action: function() { secondary_action: function() {
window.location.reload() window.location.reload();
} }
}) })
success_dialog.set_message(__('You have successfully enrolled for the program '));
success_dialog.$message.show()
success_dialog.show(); success_dialog.show();
btn.disbaled = false; success_dialog.set_message(__('You have successfully enrolled for the program '));
}) })
} }
</script> </script>