From e316df0d99c4d4ea5621a5608b5b006ec9398aeb Mon Sep 17 00:00:00 2001 From: naokinaokiboo Date: Mon, 26 Feb 2024 21:23:18 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=82=A2=E3=83=B3=E3=83=81=E3=83=8F?= =?UTF-8?q?=E3=83=A9=E3=82=B9=E3=83=A1=E3=83=B3=E3=83=88=E3=83=9D=E3=83=AA?= =?UTF-8?q?=E3=82=B7=E3=83=BC=E3=81=A8=E5=88=A9=E7=94=A8=E8=A6=8F=E7=B4=84?= =?UTF-8?q?=E3=81=AEcheckbox=E3=81=AE=E5=80=A4=E3=82=92params=E3=81=8B?= =?UTF-8?q?=E3=82=89=E5=8F=96=E5=BE=97=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_form.html.slim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/_form.html.slim b/app/views/users/_form.html.slim index e43b183f0fc..ae85da3fc5b 100644 --- a/app/views/users/_form.html.slim +++ b/app/views/users/_form.html.slim @@ -140,7 +140,7 @@ ul.block-checks.is-1-item li.block-checks__item .a-block-check.is-checkbox - = check_box_tag :coc, 1, false, class: 'a-toggle-checkbox js-agreements-checkbox' + = check_box_tag :coc, 1, params[:coc], class: 'a-toggle-checkbox js-agreements-checkbox' label.a-block-check__label.is-ta-left(for='coc') | アンチハラスメントポリシーに同意 .a-form-help @@ -149,7 +149,7 @@ ul.block-checks.is-1-item li.block-checks__item .a-block-check.is-checkbox - = check_box_tag :tos, 2, false, class: 'a-toggle-checkbox js-agreements-checkbox' + = check_box_tag :tos, 2, params[:tos], class: 'a-toggle-checkbox js-agreements-checkbox' label.a-block-check__label.is-ta-left(for='tos') | 利用規約に同意 .a-form-help From 18f39b3ae6b13de78abacb3501803345444686ac Mon Sep 17 00:00:00 2001 From: naokinaokiboo Date: Tue, 27 Feb 2024 19:12:12 +0900 Subject: [PATCH 2/2] =?UTF-8?q?DOM=E3=83=84=E3=83=AA=E3=83=BC=E8=AA=AD?= =?UTF-8?q?=E3=81=BF=E8=BE=BC=E3=81=BF=E5=AE=8C=E4=BA=86=E6=99=82=E3=81=AB?= =?UTF-8?q?=E3=82=82=E3=80=81submit=E3=83=9C=E3=82=BF=E3=83=B3=E3=81=AE?= =?UTF-8?q?=E6=9C=89=E5=8A=B9=E7=84=A1=E5=8A=B9=E3=82=92=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/agreements.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/javascript/agreements.js b/app/javascript/agreements.js index 7b465e116c3..ae92d93eb31 100644 --- a/app/javascript/agreements.js +++ b/app/javascript/agreements.js @@ -4,15 +4,20 @@ document.addEventListener('DOMContentLoaded', () => { ) const submit = document.querySelector('.js-agreements-submit') - checkboxes.forEach((element) => { - element.addEventListener('click', () => { - const isSubmit = checkboxes.every((element) => element.checked) + const updateSubmitButtonStateFromCheckbox = () => { + const isSubmit = checkboxes.every((element) => element.checked) + if (isSubmit) { + submit.classList.remove('is-disabled') + } else { + submit.classList.add('is-disabled') + } + } - if (isSubmit) { - submit.classList.remove('is-disabled') - } else { - submit.classList.add('is-disabled') - } + if (checkboxes.length) { + checkboxes.forEach((element) => { + element.addEventListener('click', updateSubmitButtonStateFromCheckbox) }) - }) + + updateSubmitButtonStateFromCheckbox() + } })