fix(dossier): désactiver la checkbox select_all quand action en cours

This commit is contained in:
Paul Chavard 2023-04-14 17:41:22 +02:00
parent bf8c218d3a
commit cb6875352e
3 changed files with 2 additions and 20 deletions

View file

@ -89,6 +89,7 @@ module Instructeurs
.per(ITEMS_PER_PAGE)
@projected_dossiers = DossierProjectionService.project(@filtered_sorted_paginated_ids, procedure_presentation.displayed_fields)
@disable_checkbox_all = @projected_dossiers.all? { _1.batch_operation_id.present? }
assign_exports
@batch_operations = BatchOperation.joins(:groupe_instructeurs)

View file

@ -149,22 +149,3 @@ function emptyCheckboxes() {
);
inputs.forEach((e) => (e.checked = false));
}
// Disable select_all checkbox if all checkboxes are disabled
addEventListener('DOMContentLoaded', () => {
const checkbox_all = document.querySelector<HTMLInputElement>(
'#checkbox_all_batch_operation'
);
const inputs = document.querySelectorAll<HTMLInputElement>(
'div[data-controller="batch-operation"] input[data-batch-operation-target="input"]'
);
if (checkbox_all) {
const disabled_inputs = Array.from(inputs).filter(
(input) => input.disabled == true
);
if (disabled_inputs.length == inputs.length) {
checkbox_all.checked = true;
checkbox_all.disabled = true;
}
}
});

View file

@ -109,7 +109,7 @@
%tr
- if batch_operation_component.render?
%th.text-center
%input{ type: "checkbox", data: { action: "batch-operation#onCheckAll" }, id: dom_id(BatchOperation.new, :checkbox_all), aria: { label: t('views.instructeurs.dossiers.select_all') } }
%input{ type: "checkbox", disabled: @disable_checkbox_all, checked: @disable_checkbox_all, data: { action: "batch-operation#onCheckAll" }, id: dom_id(BatchOperation.new, :checkbox_all), aria: { label: t('views.instructeurs.dossiers.select_all') } }
- else
- if @statut.in? %w(suivis traites tous)
= render partial: "header_field", locals: { field: { "label" => "●", "table" => "notifications", "column" => "notifications" }, classname: "notification-col text-center" }