Files
WYGIWYH/app/templates/includes/scripts/hyperscript/htmx_error_handler.html
Herculino Trotta 8ba89434f8 feat: automatically dismiss htmx error popups after 1 minute
this is mostly to avoid being greeted by a popup when you leave the app open and it is unable to auto-update every few minutes
2025-07-27 01:39:02 -03:00

33 lines
1.1 KiB
HTML

{% load i18n %}
<script type="text/hyperscript">
behavior htmx_error_handler
on htmx:responseError or htmx:afterRequest[detail.failed] or htmx:sendError queue none
-- Check if the event detail contains the xhr object and the status is 403
if event.detail.xhr.status == 403 then
call Swal.fire({
title: '{% trans "Access Denied" %}',
text: '{% trans "You do not have permission to perform this action or access this resource." %}',
icon: 'warning',
timer: 60000,
customClass: {
confirmButton: 'btn btn-warning' -- Optional: different button style
},
buttonsStyling: true
})
else
call Swal.fire({
title: '{% trans "Something went wrong loading your data" %}',
text: '{% trans "Try reloading the page or check the console for more information." %}',
icon: 'error',
timer: 60000,
customClass: {
confirmButton: 'btn btn-primary'
},
buttonsStyling: true
})
end
then log event
then halt the event
end
</script>