mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 10:56:22 +00:00
fix: los elementos nuevos revalidan las opciones obligatorias
This commit is contained in:
parent
b63b0786fd
commit
8ec30d09e9
3 changed files with 18 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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' }
|
||||
|
|
Loading…
Reference in a new issue