fix linter js
This commit is contained in:
parent
8adb90b7e0
commit
3fdfc38faf
2 changed files with 44 additions and 19 deletions
|
@ -18,4 +18,4 @@
|
||||||
%a{ :href => "#", data: { action: "batch-operation#onDeleteSelection" } }
|
%a{ :href => "#", data: { action: "batch-operation#onDeleteSelection" } }
|
||||||
= t(".delete_selection")
|
= t(".delete_selection")
|
||||||
|
|
||||||
= hidden_field_tag :"batch_operation[dossier_ids][]", "", form: dom_id(BatchOperation.new), id: dom_id(BatchOperation.new, "checkbox_multiple")
|
= hidden_field_tag :"batch_operation[dossier_ids][]", "", form: dom_id(BatchOperation.new), id: dom_id(BatchOperation.new, "input_multiple_ids")
|
||||||
|
|
|
@ -20,24 +20,33 @@ export class BatchOperationController extends ApplicationController {
|
||||||
this.inputTargets.forEach((e) => (e.checked = target.checked));
|
this.inputTargets.forEach((e) => (e.checked = target.checked));
|
||||||
this.toggleSubmitButtonWhenNeeded();
|
this.toggleSubmitButtonWhenNeeded();
|
||||||
|
|
||||||
const pagination = document.querySelector('.pagination')
|
const pagination = document.querySelector('.pagination');
|
||||||
if (pagination) {
|
if (pagination) {
|
||||||
displayNotice(this.inputTargets);
|
displayNotice(this.inputTargets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectMore(event) {
|
onSelectMore(event: {
|
||||||
|
preventDefault: () => void;
|
||||||
|
target: HTMLInputElement;
|
||||||
|
}) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const target = event.target as HTMLInputElement;
|
const target = event.target as HTMLInputElement;
|
||||||
const dossierIds = target.getAttribute('data-dossiers');
|
const dossierIds = target.getAttribute('data-dossiers');
|
||||||
const hidden_checkbox_multiple_ids = document.querySelector('#checkbox_multiple_batch_operation');
|
|
||||||
hidden_checkbox_multiple_ids.value = dossierIds;
|
const hidden_input_multiple_ids = document.querySelector<HTMLInputElement>(
|
||||||
|
'#input_multiple_ids_batch_operation'
|
||||||
|
);
|
||||||
|
if (hidden_input_multiple_ids) {
|
||||||
|
hidden_input_multiple_ids.value = dossierIds || '';
|
||||||
|
}
|
||||||
|
|
||||||
hide(document.querySelector('#not_selected'));
|
hide(document.querySelector('#not_selected'));
|
||||||
show(document.querySelector('#selected'));
|
show(document.querySelector('#selected'));
|
||||||
}
|
}
|
||||||
|
|
||||||
onDeleteSelection(event) {
|
onDeleteSelection(event: { preventDefault: () => void }) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
emptyCheckboxes();
|
emptyCheckboxes();
|
||||||
deleteSelection();
|
deleteSelection();
|
||||||
|
@ -88,27 +97,43 @@ function switchButton(button: HTMLButtonElement, flag: boolean) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayNotice(inputs) {
|
function displayNotice(inputs: HTMLInputElement[]) {
|
||||||
if (document.querySelector('#checkbox_all_batch_operation').checked) {
|
const checkbox_all = document.querySelector<HTMLInputElement>(
|
||||||
show(document.querySelector('.fr-notice'));
|
'#checkbox_all_batch_operation'
|
||||||
hide(document.querySelector('#selected'));
|
);
|
||||||
show(document.querySelector('#not_selected'));
|
if (checkbox_all) {
|
||||||
} else {
|
if (checkbox_all.checked) {
|
||||||
hide(document.querySelector('.fr-notice'));
|
show(document.querySelector('.fr-notice'));
|
||||||
deleteSelection();
|
hide(document.querySelector('#selected'));
|
||||||
};
|
show(document.querySelector('#not_selected'));
|
||||||
|
} else {
|
||||||
|
hide(document.querySelector('.fr-notice'));
|
||||||
|
deleteSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.querySelector('#dynamic_number').textContent = (inputs.length);
|
const dynamic_number = document.querySelector('#dynamic_number');
|
||||||
|
|
||||||
|
if (dynamic_number) {
|
||||||
|
dynamic_number.textContent = inputs.length.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteSelection() {
|
function deleteSelection() {
|
||||||
const hidden_checkbox_multiple_ids = document.querySelector('#checkbox_multiple_batch_operation');
|
const hidden_input_multiple_ids = document.querySelector<HTMLInputElement>(
|
||||||
hidden_checkbox_multiple_ids.value = "";
|
'#input_multiple_ids_batch_operation'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hidden_input_multiple_ids) {
|
||||||
|
hidden_input_multiple_ids.value = '';
|
||||||
|
}
|
||||||
|
|
||||||
hide(document.querySelector('.fr-notice'));
|
hide(document.querySelector('.fr-notice'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function emptyCheckboxes() {
|
function emptyCheckboxes() {
|
||||||
const inputs = document.querySelectorAll('div[data-controller="batch-operation"] input[type=checkbox]')
|
const inputs = document.querySelectorAll<HTMLInputElement>(
|
||||||
|
'div[data-controller="batch-operation"] input[type=checkbox]'
|
||||||
|
);
|
||||||
inputs.forEach((e) => (e.checked = false));
|
inputs.forEach((e) => (e.checked = false));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue