diff --git a/app/assets/javascripts/reports/reports_datatable.js b/app/assets/javascripts/reports/reports_datatable.js
index 4bdbda04a..3ca2e4214 100644
--- a/app/assets/javascripts/reports/reports_datatable.js
+++ b/app/assets/javascripts/reports/reports_datatable.js
@@ -89,8 +89,7 @@
${I18n.t('projects.reports.index.docx')}
`;
}
-
- return `${I18n.t('projects.reports.index.generate')}`;
+ return `${I18n.t('projects.reports.index.generate')}`;
}
function renderPdfFile(data) {
@@ -193,7 +192,6 @@
function checkProcessingStatus(reportId) {
let $row = $('#reports-table').find(`tr[data-id="${reportId}"]`);
-
if ($row.length === 0) return;
$.getJSON($row.data('status-path'), (statusData) => {
@@ -268,9 +266,9 @@
updateButtons();
}
- function generateReportRequest(pathAttrName) {
- if (CHECKED_REPORTS.length === 1) {
- let row = $(".report-row[data-id='" + CHECKED_REPORTS[0] + "']");
+ function generateReportRequest(pathAttrName, id) {
+ if (CHECKED_REPORTS.length === 1 || id) {
+ let row = $(".report-row[data-id='" + (id || CHECKED_REPORTS[0]) + "']");
animateSpinner();
$.post(row.data(pathAttrName), function(response) {
animateSpinner(null, false);
@@ -374,10 +372,18 @@
});
}
+
$('.reports-index').on('change', '.report-search', function() {
REPORTS_TABLE.search($(this).val()).draw();
});
+ $('.reports-index').on('click', '.generate-docx', function(e) {
+ var reportId = $(this).closest('.report-row').attr('data-id');
+ e.preventDefault();
+ e.stopPropagation();
+ generateReportRequest('generate-docx-path', reportId);
+ });
+
$('#show_report_preview').click();
initDatatable();