feat: add Swal as a hyperscript behavior

This commit is contained in:
Herculino Trotta
2024-10-14 23:20:09 -03:00
parent aee9f39e20
commit b28e88b9cd
9 changed files with 74 additions and 125 deletions
+1
View File
@@ -9,6 +9,7 @@
{% include 'includes/scripts/hyperscript/tooltip.html' %}
{% include 'includes/scripts/hyperscript/htmx_error_handler.html' %}
{% include 'includes/scripts/hyperscript/sounds.html' %}
{% include 'includes/scripts/hyperscript/swal.html' %}
{% javascript_pack 'htmx' attrs="defer" %}
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
@@ -0,0 +1,22 @@
{% load i18n %}
<script type="text/hyperscript">
behavior prompt_swal
on click
if @data-bypass-on-ctrl === 'true' and event.ctrlKey then trigger confirmed
else
call Swal.fire({title: @data-title,
text: @data-text,
icon: @data-icon or 'warning',
showCancelButton: @data-cancel-button or 'true',
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
cancelButtonText: @data-cancel-text or '{% translate 'Cancel' %}',
confirmButtonText: @data-confirm-text or '{% translate 'Confirm' %}',
customClass: {
confirmButton: 'btn btn-primary me-3',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false})
if result.isConfirmed trigger confirmed
end
</script>