Skip to content

Commit

Permalink
Merge pull request #7953 from fjordllc/feature/alert-dialog-on-unassi…
Browse files Browse the repository at this point in the history
…gned-products

担当が決まっていない提出物にメンターがコメントをした場合にアラートを出す
  • Loading branch information
komagata authored Jul 19, 2024
2 parents 2d068fe + f1d15f1 commit aba8ff5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 4 deletions.
12 changes: 11 additions & 1 deletion app/javascript/checkable.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ export default {
console.warn(error)
})
},
checkProduct(productId, currentUserId, url, method, token) {
checkProduct(
productId,
currentUserId,
url,
method,
token,
isChargeFromComment
) {
const params = {
product_id: productId,
current_user_id: currentUserId
Expand All @@ -81,6 +88,9 @@ export default {
this.id = json.checker_id
this.name = json.checker_name
if (this.id !== null) {
if (isChargeFromComment) {
alert('提出物の担当になりました。') // 担当が決まっていない提出物にメンターがコメントをした場合にアラートを出す
}
this.toast('担当になりました。')
} else {
this.toast('担当から外れました。')
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/comments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ export default {
this.currentUserId,
'/api/products/checker',
'PATCH',
CSRF.getToken()
CSRF.getToken(),
true
)
}
},
Expand Down
5 changes: 3 additions & 2 deletions app/javascript/product_checker.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template lang="pug">
button(
v-if='!checkerId || checkerId === currentUserId',
:class='["a-button", "is-block", id ? "is-warning" : "is-secondary", checkableType ? "is-sm" : "is-sm"]',
:class='["a-button", "is-block", productCheckerId ? "is-warning" : "is-secondary", checkableType ? "is-sm" : "is-sm"]',
@click='checkInCharge')
i(
v-if='!checkerId || checkerId === currentUserId',
Expand Down Expand Up @@ -64,7 +64,8 @@ export default {
this.currentUserId,
'/api/products/checker',
this.productCheckerId ? 'DELETE' : 'PATCH',
CSRF.getToken()
CSRF.getToken(),
false
)
}
}
Expand Down
1 change: 1 addition & 0 deletions test/system/comments_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class CommentsTest < ApplicationSystemTestCase
fill_in('new_comment[description]', with: 'test')
end
click_button 'コメントする'
accept_alert '提出物の担当になりました。'
assert_text 'test'
assert_text 'Watch中'
end
Expand Down
1 change: 1 addition & 0 deletions test/system/product/checker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def assigned_product_count
visit "/products/#{products(:product1).id}"

post_comment('担当者がいない提出物の場合、担当者になる')
accept_alert '提出物の担当になりました。'
assert_text '担当になりました。'
assert_text '担当から外れる'

Expand Down
1 change: 1 addition & 0 deletions test/system/product/unchecked_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class Product::UncheckedTest < ApplicationSystemTestCase
visit_with_auth "/products/#{product.id}", 'mentormentaro'
fill_in('new_comment[description]', with: 'test')
click_button 'コメントする'
accept_alert '提出物の担当になりました。'
within('.thread-comment.is-latest') do
assert_text 'mentormentaro'
assert_text 'test'
Expand Down
1 change: 1 addition & 0 deletions test/system/products_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ class ProductsTest < ApplicationSystemTestCase
visit_with_auth "/products/#{products(:product1).id}", 'komagata'
fill_in 'new_comment[description]', with: 'コメントしたら担当になるテスト'
click_button 'コメントする'
accept_alert '提出物の担当になりました。'
assert_text 'コメントしたら担当になるテスト'
visit current_path
assert_text '担当から外れる'
Expand Down

0 comments on commit aba8ff5

Please sign in to comment.