Replace alert() calls with HVACToast system in certificate and Zoho admin JavaScript
Updated hvac-certificate-actions.js and zoho-admin.js to use the modern toast notification system instead of browser alerts, with fallback to alert() if HVACToast is not available. This provides a better user experience with consistent styling and non-blocking notifications. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
67ffae0815
commit
2a75b6808d
2 changed files with 84 additions and 14 deletions
|
|
@ -59,12 +59,22 @@
|
||||||
window.open(response.data.url, '_blank');
|
window.open(response.data.url, '_blank');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
alert(response.data.message || 'Error: Failed to get certificate URL');
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.error(response.data.message || 'Failed to get certificate URL');
|
||||||
|
} else {
|
||||||
|
alert(response.data.message || 'Error: Failed to get certificate URL');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
$button.prop('disabled', false).removeClass('hvac-loading');
|
$button.prop('disabled', false).removeClass('hvac-loading');
|
||||||
alert('Error: Failed to connect to server');
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.error('Failed to connect to server');
|
||||||
|
} else {
|
||||||
|
alert('Error: Failed to connect to server');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -126,18 +136,33 @@
|
||||||
$button.prop('disabled', false).removeClass('hvac-loading');
|
$button.prop('disabled', false).removeClass('hvac-loading');
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
alert(response.data.message || 'Certificate sent successfully');
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.success(response.data.message || 'Certificate sent successfully');
|
||||||
|
} else {
|
||||||
|
alert(response.data.message || 'Certificate sent successfully');
|
||||||
|
}
|
||||||
|
|
||||||
// Update UI to indicate certificate has been emailed
|
// Update UI to indicate certificate has been emailed
|
||||||
const $row = $button.closest('tr');
|
const $row = $button.closest('tr');
|
||||||
$row.find('.hvac-certificate-emailed').text('Yes');
|
$row.find('.hvac-certificate-emailed').text('Yes');
|
||||||
} else {
|
} else {
|
||||||
alert(response.data.message || 'Error: Failed to send certificate');
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.error(response.data.message || 'Failed to send certificate');
|
||||||
|
} else {
|
||||||
|
alert(response.data.message || 'Error: Failed to send certificate');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
$button.prop('disabled', false).removeClass('hvac-loading');
|
$button.prop('disabled', false).removeClass('hvac-loading');
|
||||||
alert('Error: Failed to connect to server');
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.error('Failed to connect to server');
|
||||||
|
} else {
|
||||||
|
alert('Error: Failed to connect to server');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -176,7 +201,12 @@
|
||||||
$button.prop('disabled', false).removeClass('hvac-loading');
|
$button.prop('disabled', false).removeClass('hvac-loading');
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
alert(response.data.message || 'Certificate revoked successfully');
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.success(response.data.message || 'Certificate revoked successfully');
|
||||||
|
} else {
|
||||||
|
alert(response.data.message || 'Certificate revoked successfully');
|
||||||
|
}
|
||||||
|
|
||||||
// Update UI to indicate certificate has been revoked
|
// Update UI to indicate certificate has been revoked
|
||||||
const $row = $button.closest('tr');
|
const $row = $button.closest('tr');
|
||||||
|
|
@ -188,12 +218,22 @@
|
||||||
$button.hide();
|
$button.hide();
|
||||||
$row.find('.hvac-unrevoke-certificate').show();
|
$row.find('.hvac-unrevoke-certificate').show();
|
||||||
} else {
|
} else {
|
||||||
alert(response.data.message || 'Error: Failed to revoke certificate');
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.error(response.data.message || 'Failed to revoke certificate');
|
||||||
|
} else {
|
||||||
|
alert(response.data.message || 'Error: Failed to revoke certificate');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
$button.prop('disabled', false).removeClass('hvac-loading');
|
$button.prop('disabled', false).removeClass('hvac-loading');
|
||||||
alert('Error: Failed to connect to server');
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.error('Failed to connect to server');
|
||||||
|
} else {
|
||||||
|
alert('Error: Failed to connect to server');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -254,11 +294,21 @@
|
||||||
GenerateCertificates.renderAttendees(response.data.attendees, response.data.event_title);
|
GenerateCertificates.renderAttendees(response.data.attendees, response.data.event_title);
|
||||||
$('#step-select-attendees').show();
|
$('#step-select-attendees').show();
|
||||||
} else {
|
} else {
|
||||||
alert('Error: ' + response.data.message);
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.error(response.data.message);
|
||||||
|
} else {
|
||||||
|
alert('Error: ' + response.data.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
alert('Failed to load attendees. Please try again.');
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.error('Failed to load attendees. Please try again.');
|
||||||
|
} else {
|
||||||
|
alert('Failed to load attendees. Please try again.');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
$('#attendees-loading').hide();
|
$('#attendees-loading').hide();
|
||||||
|
|
@ -444,7 +494,12 @@
|
||||||
const attendeeName = $button.data('attendee');
|
const attendeeName = $button.data('attendee');
|
||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
alert('Preview URL not available');
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.error('Preview URL not available');
|
||||||
|
} else {
|
||||||
|
alert('Preview URL not available');
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -233,13 +233,28 @@ jQuery(document).ready(function($) {
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
alert('Settings saved successfully!');
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.success('Settings saved successfully!');
|
||||||
|
} else {
|
||||||
|
alert('Settings saved successfully!');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
alert('Error saving settings: ' + response.data.message);
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.error('Error saving settings: ' + response.data.message);
|
||||||
|
} else {
|
||||||
|
alert('Error saving settings: ' + response.data.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
alert('Error saving settings');
|
// Use toast notification instead of alert
|
||||||
|
if (window.HVACToast) {
|
||||||
|
HVACToast.error('Error saving settings');
|
||||||
|
} else {
|
||||||
|
alert('Error saving settings');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
$button.prop('disabled', false).text('Save Settings');
|
$button.prop('disabled', false).text('Save Settings');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue