Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ユーザー登録画面でアンチハラスメントポリシーと利用規約のチェック状態をエラー時に残す #7440

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions app/javascript/agreements.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
})
4 changes: 2 additions & 2 deletions app/views/users/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down