Feature #40901
closedDisable custom query links while loading to prevent multiple requests
0%
Description
In scenarios where custom queries involve complex conditions, accessing the destination via the query link might take some time. During this waiting period, users might click the link multiple times, causing unnecessary server load. To prevent this, we propose adding the :disable_with option to the link.
This feature will disable the link once it is clicked and preventing multiple submissions. This approach not only enhances the user experience by reducing confusion but also helps maintain optimal server performance.
For more information on the :disable_with option, you can refer to the official Rails documentation https://api.rubyonrails.org/v5.0/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
The following code can be used to add disable_with:
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index 453149436..47f7db0f2 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -507,7 +507,8 @@ module QueriesHelper
link_to(query.name,
url_params.merge(:query_id => query),
:class => css,
- :title => query.description) +
+ :title => query.description,
+ :data => { :disable_with => query.name }) +
clear_link.html_safe)
end.join("\n").html_safe,
:class => 'queries'