diff --git a/app/assets/javascripts/templates/admin/links_dropdown.html.haml b/app/assets/javascripts/templates/admin/links_dropdown.html.haml index 1f4f8e4f47..afcaa1e8da 100644 --- a/app/assets/javascripts/templates/admin/links_dropdown.html.haml +++ b/app/assets/javascripts/templates/admin/links_dropdown.html.haml @@ -4,7 +4,16 @@ {{ 'admin.actions' | t }} %i{ 'ng-class' => "expanded && 'icon-caret-up' || !expanded && 'icon-caret-down'" } %div.menu{ 'ng-show' => "expanded" } - %a.menu_item{ 'ng-repeat' => "link in links", href: '{{link.url}}', target: "{{link.target || '_self'}}", data: { method: "{{ link.method || 'get' }}", confirm: "{{link.confirm}}" } } - %span - %i{ ng: { class: "link.icon" } } - %span {{ link.name }} + %div{ 'ng-repeat' => "link in links" } + %a.menu_item{ 'ng-if': "link.method", href: '{{link.url}}', target: "{{link.target || '_self'}}", data: { method: "{{ link.method }}", "ujs-navigate": "false", confirm: "{{link.confirm}}" } } + %span + %i{ ng: { class: "link.icon" } } + %span {{ link.name }} + %a.menu_item{ 'ng-if': "link.confirm && !link.method", href: '{{link.url}}', target: "{{link.target || '_self'}}", "data-confirm": "{{link.confirm}}" } + %span + %i{ ng: { class: "link.icon" } } + %span {{ link.name }} + %a.menu_item{ 'ng-if': "!link.confirm && !link.method", href: '{{link.url}}', target: "{{link.target || '_self'}}" } + %span + %i{ ng: { class: "link.icon" } } + %span {{ link.name }} diff --git a/app/views/admin/enterprises/form/_stripe_connect.html.haml b/app/views/admin/enterprises/form/_stripe_connect.html.haml index 5c42499718..ec8e1e178b 100644 --- a/app/views/admin/enterprises/form/_stripe_connect.html.haml +++ b/app/views/admin/enterprises/form/_stripe_connect.html.haml @@ -4,7 +4,8 @@ .row = t('.stripe_account_connected') .row - =link_to t('.disconnect'), main_app.admin_stripe_account_path(@stripe_account), method: :delete, class: 'button' + + =link_to t('.disconnect'), main_app.admin_stripe_account_path(@stripe_account), data: { method: :delete, "ujs-navigate": "false"}, class: 'button' - else .row.stripe-info .six.columns.alpha diff --git a/app/views/admin/oidc_settings/index.html.haml b/app/views/admin/oidc_settings/index.html.haml index 4a6878eed6..eed72c78d2 100644 --- a/app/views/admin/oidc_settings/index.html.haml +++ b/app/views/admin/oidc_settings/index.html.haml @@ -22,4 +22,4 @@ %br = button_to t(".link_account_button"), Spree::Core::Engine.routes.url_helpers.spree_user_openid_connect_omniauth_authorize_path(auth_type: "login"), - method: :post + data: { method: :post, "ujs-navigate": "false" } diff --git a/app/views/admin/order_cycles/_row.html.haml b/app/views/admin/order_cycles/_row.html.haml index 5a2e06dbb6..4508858a1d 100644 --- a/app/views/admin/order_cycles/_row.html.haml +++ b/app/views/admin/order_cycles/_row.html.haml @@ -36,4 +36,4 @@ %td.actions{ ng: { if: 'orderCycle.viewing_as_coordinator' } } %a.clone-order-cycle.icon-copy.no-text{ ng: { href: '{{orderCycle.clone_path}}'}, 'ofn-with-tip' => t(:clone) } %td.actions{ ng: { if: 'orderCycle.deletable && orderCycle.viewing_as_coordinator' }} - %a.delete-order-cycle.icon-trash.no-text{ ng: { href: '{{orderCycle.delete_path}}'}, data: { method: 'delete', confirm: t(:are_you_sure) }, 'ofn-with-tip' => t(:remove) } + %a.delete-order-cycle.icon-trash.no-text{ ng: { href: '{{orderCycle.delete_path}}'}, data: { method: 'delete', confirm: t(:are_you_sure), "ujs-navigate": "false" }, 'ofn-with-tip' => t(:remove) } diff --git a/app/views/admin/order_cycles/edit.html.haml b/app/views/admin/order_cycles/edit.html.haml index 56151db299..3dcc757370 100644 --- a/app/views/admin/order_cycles/edit.html.haml +++ b/app/views/admin/order_cycles/edit.html.haml @@ -5,7 +5,8 @@ - mails_sent = @order_cycle.mails_sent? - url = main_app.notify_producers_admin_order_cycle_path - confirm_msg = "#{t('.notify_producers_tip')} #{t(:are_you_sure)}" - %a.button.icon-email.with-tip{ href: url, data: { method: 'post', confirm: confirm_msg }, 'data-powertip': t('.notify_producers_tip') } + + %a.button.icon-email.with-tip{ href: url, data: { method: :post, "ujs-navigate": "false", confirm: confirm_msg }, 'data-powertip': t('.notify_producers_tip') } = mails_sent ? t('.re_notify_producers') : t(:notify_producers) - if mails_sent .badge.icon-ok.success diff --git a/app/views/admin/subscriptions/_autocomplete.html.haml b/app/views/admin/subscriptions/_autocomplete.html.haml index 789f27104c..784c77009e 100644 --- a/app/views/admin/subscriptions/_autocomplete.html.haml +++ b/app/views/admin/subscriptions/_autocomplete.html.haml @@ -16,5 +16,5 @@ %input#add_quantity.fullwidth{ type: 'number', min: 1, ng: { model: 'newItem.quantity' } } %td .actions - %a.icon-plus.button.fullwidth{ href: 'javascript:void(0)', method: :post, ng: { click: 'addSubscriptionLineItem()' } } + %a.icon-plus.button.fullwidth{ href: 'javascript:void(0)', ng: { click: 'addSubscriptionLineItem()' } } = t('.add') diff --git a/app/views/admin/terms_of_service_files/show.html.haml b/app/views/admin/terms_of_service_files/show.html.haml index 68373724a0..2f3c5b387b 100644 --- a/app/views/admin/terms_of_service_files/show.html.haml +++ b/app/views/admin/terms_of_service_files/show.html.haml @@ -7,7 +7,7 @@ .admin-current-terms-of-service - if @current_file %p= t(".current_terms_html", tos_link: link_to(t(".terms_of_service"), @current_file.attachment), datetime: @current_file.updated_at) - %p= link_to t(".delete"), main_app.admin_terms_of_service_files_path, method: "delete", data: { confirm: t(".confirm_delete") } + %p= link_to t(".delete"), main_app.admin_terms_of_service_files_path, data: { method: :delete, "ujs-navigate": "false", confirm: t(".confirm_delete") } - else %p = t(".no_files") diff --git a/app/views/spree/admin/mail_methods/edit.html.haml b/app/views/spree/admin/mail_methods/edit.html.haml index 9e79403270..5a03702c21 100644 --- a/app/views/spree/admin/mail_methods/edit.html.haml +++ b/app/views/spree/admin/mail_methods/edit.html.haml @@ -5,7 +5,8 @@ - content_for :page_actions do %li - = link_to_with_icon 'icon-envelope-alt', t("spree.admin.mail_methods.send_testmail"), testmail_admin_mail_methods_path, method: :post, title: t("spree.admin.mail_methods.send_testmail"), class: 'send_mail button no-text' + = link_to_with_icon 'icon-envelope-alt', t("spree.admin.mail_methods.send_testmail"), testmail_admin_mail_methods_path, + data: { method: :post, "ujs-navigate": "false" }, title: t("spree.admin.mail_methods.send_testmail"), class: 'send_mail button no-text' = render partial: 'spree/shared/error_messages', locals: { target: @mail_method } diff --git a/app/views/spree/admin/payments/_list.html.haml b/app/views/spree/admin/payments/_list.html.haml index 6daa450eca..4e1a1ec066 100644 --- a/app/views/spree/admin/payments/_list.html.haml +++ b/app/views/spree/admin/payments/_list.html.haml @@ -16,4 +16,5 @@ %span{class: "state #{payment.state}"}= t(payment.state, scope: "spree.payment_states", default: payment.state.capitalize) %td.actions - payment.actions.each do |action| - = link_to_with_icon "icon-#{action}", Spree.t(action), fire_admin_order_payment_path(@order, payment, e: action), method: :put, no_text: true, data: {action: action, disable_with: ""} + = link_to_with_icon "icon-#{action}", Spree.t(action), fire_admin_order_payment_path(@order, payment, e: action), + no_text: true, data: { method: :put, "ujs-navigate": "false", action: action, disable_with: "" } diff --git a/app/views/spree/admin/return_authorizations/edit.html.haml b/app/views/spree/admin/return_authorizations/edit.html.haml index 71c32c0ab3..190e6e31c5 100644 --- a/app/views/spree/admin/return_authorizations/edit.html.haml +++ b/app/views/spree/admin/return_authorizations/edit.html.haml @@ -1,10 +1,12 @@ - content_for :page_actions do %li - if @return_authorization.can_receive? - = button_link_to t('.receive'), fire_admin_order_return_authorization_url(@order, @return_authorization, e: 'receive'), method: :put, data: { confirm: t('.are_you_sure') }, icon: 'icon-download-alt' + = button_link_to t('.receive'), fire_admin_order_return_authorization_url(@order, @return_authorization, e: 'receive'), + data: { method: :put, "ujs-navigate": "false", confirm: t('.are_you_sure') }, icon: 'icon-download-alt' %li - if @return_authorization.can_cancel? - = button_link_to t('actions.cancel'), fire_admin_order_return_authorization_url(@order, @return_authorization, e: 'cancel'), method: :put, data: { confirm: t('.are_you_sure') }, icon: 'icon-remove' + = button_link_to t('actions.cancel'), fire_admin_order_return_authorization_url(@order, @return_authorization, e: 'cancel'), + data: { method: :put, "ujs-navigate": "false", confirm: t('.are_you_sure') }, icon: 'icon-remove' = render partial: 'spree/admin/shared/order_page_title' = render partial: 'spree/admin/shared/order_tabs', locals: { current: 'Return Authorizations' } diff --git a/app/webpacker/js/mrujs.js b/app/webpacker/js/mrujs.js index c2702a9992..602fc56ca4 100644 --- a/app/webpacker/js/mrujs.js +++ b/app/webpacker/js/mrujs.js @@ -6,6 +6,17 @@ mrujs.start({ plugins: [new CableCar(CableReady, { mimeType: "text/vnd.cable-ready.json" })], }); +// Handle legacy jquery ujs buttons +document.addEventListener("ajax:beforeNavigation", (event) => { + if (event.detail.element.dataset.ujsNavigate !== "false") return; + + event.preventDefault(); + + if (event.detail.fetchResponse.response.redirected) { + document.location.href = event.detail.fetchResponse.response.url; + } +}); + document.addEventListener("ajax:beforeSend", (event) => { window.Turbo.navigator.adapter.progressBar.setValue(0); window.Turbo.navigator.adapter.progressBar.show();