5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 05:16:23 +00:00

fix: los elementos nuevos revalidan las opciones obligatorias

This commit is contained in:
f 2024-07-20 15:21:36 -03:00
parent b63b0786fd
commit 8ec30d09e9
No known key found for this signature in database
3 changed files with 18 additions and 4 deletions

View file

@ -11,6 +11,13 @@ export default class extends Controller {
connect() {
}
checkboxTargetConnected(checkboxTarget) {
if (checkboxTarget.checked) {
this.requiredTarget.required = false;
this.revalid();
}
}
/*
* El grupo deja de ser obligatorio cuando al menos uno está activo.
*/
@ -29,11 +36,18 @@ export default class extends Controller {
}
/*
* Si el checkbox es considerado
* Si el checkbox es considerado inválido, transmitir todos los
* estados a los checkboxes.
*/
invalid(event) {
invalid(event = undefined) {
for (const checkbox of this.checkboxTargets) {
checkbox.required = true;
}
}
revalid(event = undefined) {
for (const checkbox of this.checkboxTargets) {
checkbox.required = false;
}
}
}

View file

@ -3,6 +3,6 @@
= render 'targets/array/item', value: @value, class: 'mb-2', id: item_id do
.d-flex.flex-row.flex-wrap
.flex-grow-1
= render 'bootstrap/custom_checkbox', name: @name, id: random_id, value: @value, checked: true, content: @value
= render 'bootstrap/custom_checkbox', name: @name, id: random_id, value: @value, checked: true, content: @value, data: { action: 'required-checkbox#change', 'required-checkbox-target': 'checkbox' }
%div
%button.btn.btn-sm.m-0{ data: { action: 'array#remove', 'remove-target-param': item_id } }= t('.remove')

View file

@ -1,2 +1,2 @@
= render 'targets/array/item', value: @uuid, 'send-value': @uuid, 'human-value': @value, class: 'mb-2' do
= render 'bootstrap/custom_checkbox', name: @name, id: random_id, value: @uuid, checked: true, content: @value
= render 'bootstrap/custom_checkbox', name: @name, id: random_id, value: @uuid, checked: true, content: @value, data: { action: 'required-checkbox#change', 'required-checkbox-target': 'checkbox' }