diff --git a/app/javascript/etc/htmx_abort.js b/app/javascript/etc/htmx_abort.js new file mode 100644 index 00000000..308d0315 --- /dev/null +++ b/app/javascript/etc/htmx_abort.js @@ -0,0 +1,7 @@ +// Cancela las peticiones pendientes de htmx para todos los elementos al +// cambiar de página. +document.addEventListener("turbolinks:click", () => { + for (const hx of document.querySelectorAll("[hx-get]")) { + window.htmx.trigger(hx, "htmx:abort"); + } +}); diff --git a/app/javascript/etc/index.js b/app/javascript/etc/index.js index e19246af..3a1ef75c 100644 --- a/app/javascript/etc/index.js +++ b/app/javascript/etc/index.js @@ -6,3 +6,4 @@ import './timezone' import './turbolinks-anchors' import './validation' import './new_editor' +import './htmx_abort' diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index db44d43c..9041eab7 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -10,7 +10,6 @@ .mb-3 = render 'sites/header', site: @site = render 'sites/status', site: @site - = render 'sites/build', site: @site, class: 'btn-block' = render 'sites/moderation_queue', site: @site, class: 'btn-block' %h3= t('posts.new') diff --git a/app/views/sites/_status.haml b/app/views/sites/_status.haml index 47bed657..d3da5c73 100644 --- a/app/views/sites/_status.haml +++ b/app/views/sites/_status.haml @@ -22,3 +22,5 @@ %div{ 'hx-get': site_status_path(site), 'hx-trigger': 'every 10s', 'hx-swap': 'outerHTML' } = render 'bootstrap/alert' do = link_to_if link, message.html_safe, site_build_stats_path(site), class: 'alert-link' + + = render 'sites/build', site: site, class: 'btn-block'