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
|
|
@ -58,14 +58,24 @@
|
|||
// Open in new tab
|
||||
window.open(response.data.url, '_blank');
|
||||
}
|
||||
} else {
|
||||
// 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() {
|
||||
$button.prop('disabled', false).removeClass('hvac-loading');
|
||||
// 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,19 +136,34 @@
|
|||
$button.prop('disabled', false).removeClass('hvac-loading');
|
||||
|
||||
if (response.success) {
|
||||
// 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
|
||||
const $row = $button.closest('tr');
|
||||
$row.find('.hvac-certificate-emailed').text('Yes');
|
||||
} else {
|
||||
// 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() {
|
||||
$button.prop('disabled', false).removeClass('hvac-loading');
|
||||
// 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');
|
||||
|
||||
if (response.success) {
|
||||
// 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
|
||||
const $row = $button.closest('tr');
|
||||
|
|
@ -187,14 +217,24 @@
|
|||
// Hide revoke button, show unrevoke button if it exists
|
||||
$button.hide();
|
||||
$row.find('.hvac-unrevoke-certificate').show();
|
||||
} else {
|
||||
// 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() {
|
||||
$button.prop('disabled', false).removeClass('hvac-loading');
|
||||
// Use toast notification instead of alert
|
||||
if (window.HVACToast) {
|
||||
HVACToast.error('Failed to connect to server');
|
||||
} else {
|
||||
alert('Error: Failed to connect to server');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -253,12 +293,22 @@
|
|||
if (response.success) {
|
||||
GenerateCertificates.renderAttendees(response.data.attendees, response.data.event_title);
|
||||
$('#step-select-attendees').show();
|
||||
} else {
|
||||
// Use toast notification instead of alert
|
||||
if (window.HVACToast) {
|
||||
HVACToast.error(response.data.message);
|
||||
} else {
|
||||
alert('Error: ' + response.data.message);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
// 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() {
|
||||
$('#attendees-loading').hide();
|
||||
|
|
@ -444,7 +494,12 @@
|
|||
const attendeeName = $button.data('attendee');
|
||||
|
||||
if (!url) {
|
||||
// Use toast notification instead of alert
|
||||
if (window.HVACToast) {
|
||||
HVACToast.error('Preview URL not available');
|
||||
} else {
|
||||
alert('Preview URL not available');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -233,13 +233,28 @@ jQuery(document).ready(function($) {
|
|||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
// Use toast notification instead of alert
|
||||
if (window.HVACToast) {
|
||||
HVACToast.success('Settings saved successfully!');
|
||||
} else {
|
||||
alert('Settings saved successfully!');
|
||||
}
|
||||
} else {
|
||||
// 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() {
|
||||
// Use toast notification instead of alert
|
||||
if (window.HVACToast) {
|
||||
HVACToast.error('Error saving settings');
|
||||
} else {
|
||||
alert('Error saving settings');
|
||||
}
|
||||
},
|
||||
complete: function() {
|
||||
$button.prop('disabled', false).text('Save Settings');
|
||||
|
|
|
|||
Loading…
Reference in a new issue