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

「読みました」のチェックボックスを埋めたら「休会する」ボタンを押せるようにした #5461

Merged
merged 14 commits into from
Oct 17, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
max-width: 20rem
.block-checks.is-1-item &
max-width: 100%
.block-checks.is-1-item.is-centered &
width: 20rem
.block-checks.is-2-items &
flex: 0 0 calc((100% - .5rem) / 2)
max-width: calc((100% - .5rem) / 2)
Expand Down
14 changes: 14 additions & 0 deletions app/javascript/hibernation_agreements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
document.addEventListener('DOMContentLoaded', () => {
const checkbox = document.querySelector('.js-hibernation-agreements-checkbox')
const submit = document.querySelector('.js-hibernation-agreements-submit')

checkbox.addEventListener('change', () => {
if (checkbox.checked) {
submit.classList.remove('is-disabled')
submit.classList.add('is-danger')
} else {
submit.classList.add('is-disabled')
submit.classList.remove('is-danger')
}
})
})
1 change: 1 addition & 0 deletions app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import '../training-info-toggler.js'
import '../company-products.js'
import '../welcome_message_for_adviser.js'
import '../regular-events.js'
import '../hibernation_agreements.js'

import VueMounter from '../VueMounter.js'
import Hello from '../components/hello.vue'
Expand Down
23 changes: 11 additions & 12 deletions app/views/hibernation/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ header.page-header
html: { name: 'hibernation' },
class: 'form' do |f|
.form__items
//
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

休会についての注意を実装したら表示する
.form-item
label.a-form-label.is-required
| 休会についての注意を読みましたか?
.block-checks.is-2-items
.block-checks__item
.a-block-check.is-checkbox
input.a-toggle-checkbox#aaa(type='checkbox')
label.a-block-check__label(for='aaa')
| 読みました
.form-item
= f.label :scheduled_return_on,
class: 'a-form-label is-required'
Expand Down Expand Up @@ -79,12 +68,22 @@ header.page-header
| こちら
| のページの「分報 URL」欄に分報チャンネルの URL を登録してください。

.form-item
label.a-form-label.is-required
| 休会についての注意を読みましたか?
.block-checks.is-1-item.is-centered
.block-checks__item
.a-block-check.is-checkbox.check-box-to-read
input.a-toggle-checkbox.js-hibernation-agreements-checkbox#check-to-read(type='checkbox')
label.a-block-check__label(for='check-to-read')
| 読みました

.form-actions
ul.form-actions__items
li.form-actions__item.is-main
= link_to 'キャンセル', :back,
class: 'a-button is-md is-secondary is-block'
li.form-actions__item.is-main
= f.submit '休会する',
class: 'a-button is-md is-danger is-block',
class: 'a-button is-md is-block js-hibernation-agreements-submit is-disabled',
data: { confirm: '本当によろしいですか?' }
2 changes: 2 additions & 0 deletions test/system/hibernation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class HibernationTest < ApplicationSystemTestCase
end

VCR.use_cassette 'subscription/update', vcr_options do
find('.check-box-to-read').click
click_on '休会する'
page.driver.browser.switch_to.alert.accept
assert_text '休会処理が完了しました'
Expand All @@ -31,6 +32,7 @@ class HibernationTest < ApplicationSystemTestCase
fill_in('hibernation[reason]', with: 'test')
end

find('.check-box-to-read').click
click_on '休会する'
page.driver.browser.switch_to.alert.accept
assert_text '復帰予定日を入力してください'
Expand Down
3 changes: 3 additions & 0 deletions test/system/notification/hibernation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Notification::HibernationTest < ApplicationSystemTestCase
visit_with_auth new_hibernation_path, 'kimura'
fill_in 'hibernation[scheduled_return_on]', with: Time.current.next_month
fill_in 'hibernation[reason]', with: 'テストのため'
find('.check-box-to-read').click
accept_confirm do
click_button '休会する'
end
Expand All @@ -44,6 +45,7 @@ class Notification::HibernationTest < ApplicationSystemTestCase
visit_with_auth new_hibernation_path, 'kensyu'
fill_in 'hibernation[scheduled_return_on]', with: Time.current.next_month
fill_in 'hibernation[reason]', with: 'テストのため'
find('.check-box-to-read').click
accept_confirm do
click_button '休会する'
end
Expand All @@ -66,6 +68,7 @@ class Notification::HibernationTest < ApplicationSystemTestCase
visit_with_auth new_hibernation_path, 'senpai'
fill_in 'hibernation[scheduled_return_on]', with: Time.current.next_month
fill_in 'hibernation[reason]', with: 'テストのため'
find('.check-box-to-read').click
accept_confirm do
click_button '休会する'
end
Expand Down