diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt index f56200c11f..6db54eef82 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -930,7 +930,7 @@ [% IF ( template_id ) %] [% END %] - + [% END # / IF ( auth_val_error ) %] @@ -2005,6 +2005,18 @@ } } + const toggleReportRunButton = (element => { + if ($(element).attr('disabled') === undefined) { + $(element).attr('disabled', 'disabled'); + $(element).addClass('disabled'); + $(element).find('i.fa-play').first().replaceWith(''); + } else { + $(element).removeAttr('disabled'); + $(element).removeClass('disabled'); + $(element).find('i.fa-spinner').first().replaceWith(''); + } + }); + $(document).ready(function(){ var activeTab = localStorage.getItem("sql_reports_activetab"); @@ -2480,6 +2492,41 @@ selectField.style.minWidth = '320px'; $(selectField).select2(); }); + + $('a[href*="/cgi-bin/koha/reports/guided_reports.pl"]').each((idx, element) => { + const params = new URLSearchParams($(element).attr('href')); + const op = params.get('op'); + + if (op !== 'run') { + return; + } + + $(element).on('click', event => { + event.preventDefault(); + const href = $(element).attr('href'); + + toggleReportRunButton(element); + setTimeout(() => { + toggleReportRunButton(element); + }, 120000); + + window.location.href = href; + return false; + }); + }); + + $('#report_param_form').on('submit', event => { + const button = $('button[type="submit"]'); + + if (button.length < 1) { + return; + } + + toggleReportRunButton(button); + setTimeout(() => { + toggleReportRunButton(button); + }, 120000); + }); }); $("#toggle_auto_links").on("click", function(e){