From c88e4bc29bbcad8db56c6009a76c14c76797ae8e Mon Sep 17 00:00:00 2001 From: Daniel Perrett Date: Thu, 24 Jul 2025 11:42:02 +0100 Subject: [PATCH] fix: prevent overzealous repeated downloads --- .../javascripts/cites_trade/application.js | 10 ++++++++ app/assets/stylesheets/cites_trade/common.css | 10 +++++++- app/views/cites_trade/home/download.html.erb | 23 +++++++++++++------ config/locales/en.yml | 1 + config/locales/es.yml | 1 + config/locales/fr.yml | 1 + 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/cites_trade/application.js b/app/assets/javascripts/cites_trade/application.js index 82752dd8b..bb9e49449 100644 --- a/app/assets/javascripts/cites_trade/application.js +++ b/app/assets/javascripts/cites_trade/application.js @@ -760,6 +760,16 @@ $(document).ready(function(){ href = '/' + locale + '/cites_trade/exports/download?' + q; $link.attr('href', href).click(); window.location.href = $link.attr("href"); + + const $button = $('#button_report').attr('disabled', 'disabled'); + const $message = $('#download_status_loading').show(); + + window.setTimeout( + function () { + $button.removeAttr('disabled'); + $message.hide(); + }, 10e3 + ) } function handleDownloadRequest (ignoreWarning) { diff --git a/app/assets/stylesheets/cites_trade/common.css b/app/assets/stylesheets/cites_trade/common.css index a807314b2..d5c9cde7a 100644 --- a/app/assets/stylesheets/cites_trade/common.css +++ b/app/assets/stylesheets/cites_trade/common.css @@ -217,7 +217,15 @@ font-style:italic; height:16px; } -/* STANDARD */button:hover, .buttons a:hover{ +/* STANDARD */ +button { + /** + * UA stylesheet sets this to 2, and we don't want the border width to change + * on hover + */ + border-width: 1px; +} +button:hover:not(:disabled), .buttons a:hover{ background-color:#dff4ff; border:1px solid #c2e1ef; color:#336699; diff --git a/app/views/cites_trade/home/download.html.erb b/app/views/cites_trade/home/download.html.erb index 3ecc410e0..5dff015ed 100644 --- a/app/views/cites_trade/home/download.html.erb +++ b/app/views/cites_trade/home/download.html.erb @@ -47,13 +47,22 @@ -
- - - +
+
+ + + +
+



diff --git a/config/locales/en.yml b/config/locales/en.yml index 057eef978..c791b4ed2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -60,6 +60,7 @@ en: comparative_tabulations: "Comparative Tabulations" trade_tabulations: "Gross/Net Trade Tabulations" get_report: "Get report" + downloading_report: "Your file is being prepared and will be downloaded shortly" new_search: "New Search" from: "From" diff --git a/config/locales/es.yml b/config/locales/es.yml index 64a40e7e5..365e6d9d1 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -57,6 +57,7 @@ es: comparative_tabulations: "Tabulaciónes Comparativas" trade_tabulations: " Tabulaciones del Comercio Bruto/Neto" get_report: "Obtener el informe" + downloading_report: "Your file is being prepared and will be downloaded shortly" # TODO: translate new_search: "Nueva Búsqueda" from: "De" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index f5b7a637f..42607aab6 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -57,6 +57,7 @@ fr: comparative_tabulations: "Tabulations Comparatives" trade_tabulations: "Tabulations du Commerce Brut/Net" get_report: "Obtenir le rapport" + downloading_report: "Your file is being prepared and will be downloaded shortly" # TODO: translate new_search: "Nouvelle Recherche" from: "De"