Disable edit button for reports of archived projects [SCI-5755]

This commit is contained in:
Oleksii Kriuchykhin 2021-05-28 16:17:20 +02:00
parent 27cefe7cbd
commit 2bad60d48c
2 changed files with 6 additions and 2 deletions

View file

@ -132,6 +132,9 @@
.attr('data-retry-count', 0)
.attr('data-save-to-inventory-path', data.save_to_inventory)
.attr('data-id', data['0']);
if (data.archived) {
$(row).addClass('archived');
}
if (data['3'].processing || data['4'].processing) {
$(row).addClass('processing');
}
@ -161,6 +164,7 @@
$('.single-object-action, .multiple-object-action').removeClass('disabled hidden');
let $row = $(`.report-row[data-id=${CHECKED_REPORTS[0]}]`);
let archived = $row.hasClass('archived');
let pdfProcessing = $row.has('.processing.pdf').length > 0;
let docxProcessing = $row.has('.processing.docx').length > 0;
let docxGenerate = $row.has('.generate-docx').length > 0;
@ -185,12 +189,11 @@
}
}
if (pdfProcessing || docxProcessing) {
if (archived || pdfProcessing || docxProcessing) {
$('#edit-report-btn').addClass('disabled');
} else {
$('#edit-report-btn').removeClass('disabled');
}
} else {
$('.single-object-action').removeClass('hidden').addClass('disabled');
$('.multiple-object-action').removeClass('disabled hidden');

View file

@ -60,6 +60,7 @@ class ReportDatatable < CustomDatatable
'6' => sanitize_input(record.modified_by),
'7' => I18n.l(record.created_at, format: :full),
'8' => I18n.l(record.updated_at, format: :full),
'archived' => record.project.archived?,
'edit' => edit_project_report_path(record.project_id, record.id),
'status' => status_project_report_path(record.project_id, record.id),
'generate_pdf' => generate_pdf_project_report_path(record.project_id, record.id),