5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 02:46:21 +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() { connect() {
} }
checkboxTargetConnected(checkboxTarget) {
if (checkboxTarget.checked) {
this.requiredTarget.required = false;
this.revalid();
}
}
/* /*
* El grupo deja de ser obligatorio cuando al menos uno está activo. * 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) { for (const checkbox of this.checkboxTargets) {
checkbox.required = true; 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 = render 'targets/array/item', value: @value, class: 'mb-2', id: item_id do
.d-flex.flex-row.flex-wrap .d-flex.flex-row.flex-wrap
.flex-grow-1 .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 %div
%button.btn.btn-sm.m-0{ data: { action: 'array#remove', 'remove-target-param': item_id } }= t('.remove') %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 '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' }