Bug 40896: Disable run report buttons upon click
This patch will disable the run report button found on both the list page, and the individual operation pages (e.g. run, edit, saved successfully). This will stop librarians from unintentionally crashing their Koha system, by pressing the run report button repeatedly when there is no need to re-request it.
TO TEST:
a) go to /cgi-bin/koha/reports/guided_reports.pl?op=list
b) create three new sql test reports:
*) Name: Test report #1, SQL: SELECT count(*) FROM biblio
*) Name: Test report #2, SQL: SELECT count(*) FROM items
*) Name: Test report #3, SQL: SELECT * FROM items WHERE items.dateaccessioned = <<Date accessioned|date>>
c) run all of the above test reports, noticing how the run report button can be activated repeatedly
APPLY PATCH
d) redo step a
e) run test report #1 from the table, notice how now the button can only be activated once before it is greyed out and the play button is replaced with a spinner
f) return to the list, edit test report #2 from the table, click run report from the edit page, and notice how this run report button exhibits the same behaviour as the button in step e
g) return to the list, run test report #3, select a date, click run report from this page, and notice again how the run report button exhibits the same behaviour as the buttons in steps e and f
SIGN OFF
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 9067b2aafe)
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
parent
63bc6f9dd0
commit
7d71525ec5
|
|
@ -930,7 +930,7 @@
|
|||
[% IF ( template_id ) %]
|
||||
<input type="hidden" name="template" value="[% template_id | html %]" />
|
||||
[% END %]
|
||||
<button type="submit" class="btn btn-primary">Run the report</button>
|
||||
<button type="submit" class="btn btn-primary"><i class="fa fa-play"></i> Run the report</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
[% 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('<i class=\"fa fa-spinner fa-spin\" style=\"--fa-animation-duration: 2s;\"></i>');
|
||||
} else {
|
||||
$(element).removeAttr('disabled');
|
||||
$(element).removeClass('disabled');
|
||||
$(element).find('i.fa-spinner').first().replaceWith('<i class=\"fa fa-play\"></i>');
|
||||
}
|
||||
});
|
||||
|
||||
$(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){
|
||||
|
|
|
|||
Loading…
Reference in New Issue