Merge pull request #3323 from aignatov-bio/ai-sci-5722-fix-docx-generate-button

Add action to generate docx button [SCI-5722]
This commit is contained in:
Alex Kriuchykhin 2021-05-18 14:40:22 +02:00 committed by GitHub
commit 5315bf2888
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,8 +89,7 @@
${I18n.t('projects.reports.index.docx')}
</a>`;
}
return `<a href="#" class="generate-docx">${I18n.t('projects.reports.index.generate')}</a>`;
return `<a href="#" class="generate-docx docx">${I18n.t('projects.reports.index.generate')}</a>`;
}
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();