-
Notifications
You must be signed in to change notification settings - Fork 75
ユーザー個人ページに定期イベント一覧を実装 #9714
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
Merged
Merged
ユーザー個人ページに定期イベント一覧を実装 #9714
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
325a63e
ユーザー個人ページに定期イベント一覧を実装
y-kawahara-gs 1a29f1d
ユーザー個人ページから遷移する特別イベントのテスト修正・定期イベントのテスト実装
y-kawahara-gs c9a50fa
N+1問題対策の実装、整合性を保った処理に修正
y-kawahara-gs 7536793
N+1問題対策としてuser/regular_eventのincludeにregular_event_repeat_rulesを追加
y-kawahara-gs 903444c
event.usersの数をsizeで数える処理に修正
y-kawahara-gs 352e6a3
終了イベントが下にかつ新しく作成されたイベントが上にくるように並び替え
y-kawahara-gs c6250fc
navsのhelper化
y-kawahara-gs 0df91a3
is-activeの判定処理のリファクタリング
y-kawahara-gs ad63632
_nav.html.slimを共通化
y-kawahara-gs 9ab0b32
開催日時の表示にi18nを適用
y-kawahara-gs 478414e
events_testの堅牢化
y-kawahara-gs 5911967
event_navのクラス指定を配列から文字列に修正
y-kawahara-gs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class Users::RegularEventsController < ApplicationController | ||
| def index | ||
| @user = User.find(params[:user_id]) | ||
| @regular_events = @user.participate_regular_events | ||
| .includes(:comments, :regular_event_repeat_rules, :user, | ||
| { users: { avatar_attachment: :blob } }) | ||
| .order(:finished, created_at: :desc, id: :desc) | ||
| .page(params[:page]) | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| nav.tab-nav | ||
| .container | ||
| ul.tab-nav__items | ||
| - event_navs(@user).each do |nav| | ||
| li.tab-nav__item | ||
| - nav_class = 'tab-nav__item-link ' | ||
| - nav_class << 'is-active' if current_page?(nav[:path]) | ||
| = link_to "#{nav[:name]}(#{nav[:count]})", nav[:path], class: nav_class |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| - title "#{@user.login_name}のイベント一覧" | ||
| - set_meta_tags description: "#{@user.login_name}さんのイベントページです。" | ||
|
|
||
| = render 'users/page_title', user: @user | ||
| = user_page_tabs(@user, active_tab: 'イベント') | ||
|
|
||
| = render 'users/event_nav' | ||
|
|
||
| .page-main | ||
| .page-body | ||
| .page-body__inner.has-side-nav | ||
| .container.is-md | ||
| - if @regular_events.present? | ||
| .pagination | ||
| = paginate @regular_events | ||
| .card-list.a-card | ||
| - @regular_events.each do |event| | ||
| .card-list-item.is-event | ||
| .card-list-item__inner | ||
| .card-list-item__label(class="is-#{event.category}") | ||
| = t("activerecord.enums.regular_event.category.#{event.category}") | ||
| .card-list-item__rows | ||
| .card-list-item__row | ||
| .card-list-item-title | ||
| .card-list-item-title__start | ||
| - if event.wip | ||
| .a-list-item-badge.is-wip | ||
| <span>WIP</span> | ||
| - elsif event.finished? | ||
| .a-list-item-badge.is-ended | ||
| <span>終了</span> | ||
| h2.card-list-item-title__title | ||
| = link_to event.title, event, class: 'card-list-item-title__link a-text-link' | ||
| .card-list-item__row | ||
| .card-list-item-meta | ||
| .card-list-item-meta__items | ||
| .card-list-item-meta__item | ||
| .a-meta | ||
| = link_to event.user, class: 'a-user-name' do | ||
| = event.user.long_name | ||
| .card-list-item__row | ||
| .card-list-item-meta | ||
| .card-list-item-meta__items | ||
| - if event.users.size.positive? | ||
| .card-list-item-meta__item | ||
| .a-meta | ||
| .a-meta__label | ||
| = '主催' | ||
| .card-list-item__user-icons | ||
| - event.users.each do |organizer_user| | ||
| = render 'users/icon', | ||
| user: organizer_user, | ||
| link_class: 'card-list-item__user-link', | ||
| image_class: 'card-list-item__user-icon' | ||
|
y-kawahara-gs marked this conversation as resolved.
|
||
| .card-list-item-meta__item | ||
| time.a-meta(datetime="#{event.start_at}") | ||
| | 開催日時: | ||
| | #{event.holding_cycles} #{l event.start_at, format: :time_only} ~ #{l event.end_at, format: :time_only} | ||
| - if event.comments.size.positive? | ||
| .card-list-item-meta__item | ||
| .a-meta | ||
| = event_comment_count(event, styled: false) | ||
| .pagination | ||
| = paginate @regular_events | ||
| - else | ||
| .o-empty-message | ||
| .o-empty-message__icon | ||
| i.fa-regular.fa-sad-tear | ||
| p.o-empty-message__text | ||
| | イベントはまだありません。 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'application_system_test_case' | ||
|
|
||
| class User::RegularEventsTest < ApplicationSystemTestCase | ||
| test 'shows the regular event listing for a user ' do | ||
| visit_with_auth "/users/#{users(:komagata).id}/regular_events", 'komagata' | ||
| assert_equal 'komagataのイベント一覧 | FBC', title | ||
| nav = find('a.tab-nav__item-link', text: /定期イベント\(\d+\)/) | ||
| assert nav.matches_css?('.is-active') | ||
| end | ||
|
|
||
| test 'shows correct count of user participating regular events' do | ||
| visit_with_auth "/users/#{users(:kimura).id}/regular_events", 'kimura' | ||
| assert_text "定期イベント(#{users(:kimura).participate_regular_events.count})" | ||
| end | ||
|
|
||
| test 'does not show regular events the user is not participating in' do | ||
| visit_with_auth "/users/#{users(:kimura).id}/regular_events", 'kimura' | ||
| assert_text '独習Git輪読会' | ||
| assert_no_text '開発MTG' | ||
| end | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
controller側で
avatar_attachment: :blobまで含めてincludesする書き方を知らなかったので、勉強になりました!🙌