Skip to content

Commit

Permalink
提出物詳細ページのメンター用サイドカラムに提出物タブを追加した
Browse files Browse the repository at this point in the history
  • Loading branch information
keiz1213 committed Aug 9, 2022
1 parent de2cabb commit 6fbb463
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#side-tabs-3:checked ~ .side-tabs-contents #side-tabs-content-3
display: block

#side-tabs-4:checked ~ .side-tabs-contents #side-tabs-content-4
display: block

.side-tabs-contents__item
display: none
.a-card
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

#side-tabs-1:checked ~ .side-tabs-nav #side-tabs-nav-1,
#side-tabs-2:checked ~ .side-tabs-nav #side-tabs-nav-2,
#side-tabs-3:checked ~ .side-tabs-nav #side-tabs-nav-3
#side-tabs-3:checked ~ .side-tabs-nav #side-tabs-nav-3,
#side-tabs-4:checked ~ .side-tabs-nav #side-tabs-nav-4
background-color: $base
color: $default-text

Expand Down
5 changes: 5 additions & 0 deletions app/controllers/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def show
.limit(10)
.includes(:comments, :checks)
.order(reported_on: :DESC)
@products = @product.user
.products
.limit(10)
.not_wip
.order(published_at: :DESC)
@practice = find_practice
@learning = @product.learning # decoratorメソッド用にcontrollerでインスタンス変数化
@footprints = find_footprints
Expand Down
17 changes: 17 additions & 0 deletions app/views/products/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ header.page-header
input.a-toggle-checkbox#side-tabs-1 type='radio' name='side-tabs-contents' checked='checked'
input.a-toggle-checkbox#side-tabs-2 type='radio' name='side-tabs-contents'
input.a-toggle-checkbox#side-tabs-3 type='radio' name='side-tabs-contents'
input.a-toggle-checkbox#side-tabs-4 type='radio' name='side-tabs-contents'
.side-tabs-nav
.side-tabs-nav__items
.side-tabs-nav__item
Expand All @@ -64,6 +65,9 @@ header.page-header
.side-tabs-nav__item
label.side-tabs-nav__item-link#side-tabs-nav-3 for='side-tabs-3'
| ユーザーメモ
.side-tabs-nav__item
label.side-tabs-nav__item-link#side-tabs-nav-4 for='side-tabs-4'
| 提出物
.side-tabs-contents
.side-tabs-contents__item#side-tabs-content-1
.card-list.a-card
Expand All @@ -85,6 +89,19 @@ header.page-header
= render 'users/user_secret_attributes', user: @product.user
= render 'users/metas', user: @product.user
#js-user-mentor-memo(data-user-id="#{@product.user.id}" data-products-mode="#{true}")
.side-tabs-contents__item#side-tabs-content-4
.card-list.a-card
- if @products.present?
- @products.each do |product|
= render partial: 'product', locals: { product: product }
- else
.card-list__message
.container
.o-empty-message
.o-empty-message__icon
i.fa-regular.fa-sad-tear
.o-empty-message__text
| 提出物はまだありません。

- if !current_user.adviser? && @product.practice.open_product?
.sticky-message
Expand Down
14 changes: 12 additions & 2 deletions test/system/products_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,15 @@ class ProductsTest < ApplicationSystemTestCase
assert_text '直近の日報'
assert_text 'プラクティスメモ'
assert_text 'ユーザーメモ'
assert_selector '.side-tabs-nav__item-link', text: '提出物'
assert_selector '#side-tabs-nav-4', text: '提出物'
end

test 'students can not see block for mentors' do
visit_with_auth "/products/#{products(:product2).id}", 'hatsuno'
assert_no_text '直近の日報'
assert_no_text 'プラクティスメモ'
assert_no_text 'ユーザーメモ'
assert_no_selector '.side-tabs-nav__item-link', text: '提出物'
assert_no_selector '#side-tabs-nav-4', text: '提出物'
end

test 'display the user memos after click on user-memos tab' do
Expand Down Expand Up @@ -465,6 +465,16 @@ class ProductsTest < ApplicationSystemTestCase
click_button '保存する'
end

test 'display a list of the 10 most recent products' do
user = users(:kimura)
visit_with_auth "/products/#{products(:product2).id}", 'mentormentaro'
page.find('#side-tabs-nav-4').click
products = user.products.not_wip.first(10)
products.each do |product|
assert_text "#{product.practice.title}の提出物"
end
end

test 'can see unassigned-tab' do
visit_with_auth products_path, 'komagata'
assert find('.page-tabs__item-link', text: '未アサイン')
Expand Down

0 comments on commit 6fbb463

Please sign in to comment.