From f06c70150ba287b6dd649bbcbe6ff470a2a218f2 Mon Sep 17 00:00:00 2001 From: hirokiej <123009866+hirokiej@users.noreply.github.com> Date: Tue, 8 Jul 2025 20:35:51 +0900 Subject: [PATCH 1/8] =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3=E6=99=82=E3=80=81=E3=83=A6?= =?UTF-8?q?=E3=83=BC=E3=82=B6=E3=83=BC=E3=81=AE=E6=97=A5=E5=A0=B1=E6=AC=84?= =?UTF-8?q?=E3=81=A7=E5=85=A8=E3=81=A6=E3=81=A8=E6=9C=AA=E3=83=81=E3=82=A7?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=81=AE=E6=97=A5=E5=A0=B1=E3=82=BF=E3=83=96?= =?UTF-8?q?=E3=82=92=E8=A1=A8=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/reports/index.html.slim | 9 +++++++++ config/locales/ja.yml | 2 ++ 2 files changed, 11 insertions(+) diff --git a/app/views/users/reports/index.html.slim b/app/views/users/reports/index.html.slim index 3c7ba361aae..c4939831228 100644 --- a/app/views/users/reports/index.html.slim +++ b/app/views/users/reports/index.html.slim @@ -4,4 +4,13 @@ = render 'users/page_title', user: @user = user_page_tabs(@user, active_tab: '日報') +- if admin_or_mentor_login? + nav.tab-nav(class="#{mentor_login? ? 'is-only-mentor' : ''}") + .container + ul.tab-nav__items + - targets = %w[all_reports unchecked_reports] + - targets.each do |target| + li.tab-nav__item + = link_to t("target.#{target}"), user_reports_path(@user, target: target), class: (@target == target ? ['is-active'] : []) << 'tab-nav__item-link' + = react_component('Reports', userId: @user.id, practices: @current_user_practice.sorted_practices) diff --git a/config/locales/ja.yml b/config/locales/ja.yml index f4fd2bfcd32..8087352569b 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -467,6 +467,8 @@ ja: rails_course: Rails front_end_course: フロントエンド other_courses: その他 + all_reports: 全て + unchecked_reports: 未チェック invitation_role: adviser: アドバイザー trainee: 研修生(%{payment_method}) From 8a34a9a60db31d5d9ab83f2172253dec6bebfcf4 Mon Sep 17 00:00:00 2001 From: hirokiej <123009866+hirokiej@users.noreply.github.com> Date: Sat, 12 Jul 2025 18:11:56 +0900 Subject: [PATCH 2/8] =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E3=81=AE=E6=9C=AA=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E6=97=A5?= =?UTF-8?q?=E5=A0=B1=E3=82=92target=20=3D=3D=20unchecked=5Freports?= =?UTF-8?q?=E3=81=A7=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88=E3=81=A6=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/reports_controller.rb | 1 + app/controllers/users/reports_controller.rb | 12 +++++++++++- app/views/users/reports/index.html.slim | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/reports_controller.rb b/app/controllers/api/reports_controller.rb index 75b3fbed262..f42c596d1e6 100644 --- a/app/controllers/api/reports_controller.rb +++ b/app/controllers/api/reports_controller.rb @@ -8,5 +8,6 @@ def index @reports = @reports.where(user_id: params[:user_id]) if params[:user_id].present? @reports = @reports.limit(params[:limit].to_i) if params[:limit].present? @reports = @reports.joins(:user).where(users: { company_id: params[:company_id] }) if params[:company_id] + @reports = @reports.includes(:checks).unchecked.not_wip if params[:target] == 'unchecked_reports' end end diff --git a/app/controllers/users/reports_controller.rb b/app/controllers/users/reports_controller.rb index b74fd4aeb90..9f983e01f12 100644 --- a/app/controllers/users/reports_controller.rb +++ b/app/controllers/users/reports_controller.rb @@ -2,6 +2,7 @@ class Users::ReportsController < ApplicationController before_action :set_user + before_action :set_target before_action :set_reports before_action :set_report before_action :set_export @@ -30,13 +31,22 @@ def set_user end def set_reports - @reports = user.reports.list.page(params[:page]) + @reports = case @target + when 'unchecked_reports' + @user.reports.unchecked.not_wip.list.page(params[:page]) + else + @user.reports.list.page(params[:page]) + end end def set_report @report = @reports[0] end + def set_target + @target = params[:target] || 'all_reports' + end + def user @user ||= User.find(params[:user_id]) end diff --git a/app/views/users/reports/index.html.slim b/app/views/users/reports/index.html.slim index c4939831228..f80663e0794 100644 --- a/app/views/users/reports/index.html.slim +++ b/app/views/users/reports/index.html.slim @@ -11,6 +11,6 @@ - targets = %w[all_reports unchecked_reports] - targets.each do |target| li.tab-nav__item - = link_to t("target.#{target}"), user_reports_path(@user, target: target), class: (@target == target ? ['is-active'] : []) << 'tab-nav__item-link' + = link_to t("target.#{target}"), user_reports_path(@user, target:), class: (@target == target ? ['is-active'] : []) << 'tab-nav__item-link' -= react_component('Reports', userId: @user.id, practices: @current_user_practice.sorted_practices) += react_component('Reports', userId: @user.id, practices: @current_user_practice.sorted_practices, unchecked: (@target == 'unchecked_reports')) From a0e176da7bb90cd27a47b6e88807fda017a9fcec Mon Sep 17 00:00:00 2001 From: hirokiej <123009866+hirokiej@users.noreply.github.com> Date: Sat, 12 Jul 2025 18:21:47 +0900 Subject: [PATCH 3/8] =?UTF-8?q?=E3=83=AC=E3=83=9D=E3=83=BC=E3=83=88?= =?UTF-8?q?=E5=8F=96=E5=BE=97URL=E3=82=92=E5=A4=89=E6=9B=B4=E3=81=97?= =?UTF-8?q?=E3=80=81=E7=89=B9=E5=AE=9A=E3=81=AE=E3=83=A6=E3=83=BC=E3=82=B6?= =?UTF-8?q?=E3=83=BC=E3=81=AE=E6=9C=AA=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= =?UTF-8?q?=E6=97=A5=E5=A0=B1=E3=82=92=E5=8F=96=E5=BE=97=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/Reports.jsx | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/app/javascript/components/Reports.jsx b/app/javascript/components/Reports.jsx index 278a3b732d9..67ad26e1c1c 100644 --- a/app/javascript/components/Reports.jsx +++ b/app/javascript/components/Reports.jsx @@ -9,7 +9,6 @@ import UnconfirmedLink from './UnconfirmedLink' import usePage from './hooks/usePage' export default function Reports({ - all = false, userId = '', practices = false, unchecked = false, @@ -26,22 +25,14 @@ export default function Reports({ setUserPracticeId(userPracticeId) }, [userPracticeId]) - const { data, error } = useSWR( - practices - ? `/api/reports.json?user_id=${userId}&page=${page}&practice_id=${userPracticeId}` - : unchecked - ? `/api/reports/unchecked.json?page=${page}&user_id=${userId}` - : userId !== '' - ? `/api/reports.json?page=${page}&user_id=${userId}` - : practiceId !== '' - ? `/api/reports.json?page=${page}&practice_id=${practiceId}` - : companyId !== '' - ? `/api/reports.json?page=${page}&company_id=${companyId}` - : all === true - ? `/api/reports.json?page=${page}&practice_id=${userPracticeId}` - : console.log('data_fetched!'), - fetcher - ) + let reportsUrl = `/api/reports.json?page=${page}` + if (userId) reportsUrl += `&user_id=${userId}` + if (practiceId) reportsUrl += `&practice_id=${practiceId}` + if (companyId) reportsUrl += `&company_id=${companyId}` + if (userPracticeId) reportsUrl += `&practice_id=${userPracticeId}` + if (unchecked) reportsUrl += `&target=unchecked_reports` + + const { data, error } = useSWR(reportsUrl, fetcher) if (error) return <>エラーが発生しました。 if (!data) { From 1634dd4ca006b093869b0d0f4b5ce20b9a5822f5 Mon Sep 17 00:00:00 2001 From: hirokiej <123009866+hirokiej@users.noreply.github.com> Date: Mon, 4 Aug 2025 21:44:46 +0900 Subject: [PATCH 4/8] =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3=E6=99=82=E3=81=AE=E3=81=BF?= =?UTF-8?q?=E3=80=81=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=83=9A=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E3=82=BF=E3=83=96=E3=81=AE=E6=97=A5=E5=A0=B1?= =?UTF-8?q?=E9=83=A8=E5=88=86=E3=81=AB=E6=9C=AA=E3=83=81=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=82=AF=E6=95=B0=E3=81=AE=E3=83=90=E3=83=83=E3=82=B8=E3=82=92?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/page_tabs/users_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/helpers/page_tabs/users_helper.rb b/app/helpers/page_tabs/users_helper.rb index 3959c4eea04..95b85f151d5 100644 --- a/app/helpers/page_tabs/users_helper.rb +++ b/app/helpers/page_tabs/users_helper.rb @@ -4,10 +4,11 @@ module PageTabs module UsersHelper def user_page_tabs(user, active_tab:) comment_count = user.comments.without_private_comment.length + unchecked_report_badge = current_user.admin_or_mentor? ? Cache.user_unchecked_report_count(user) : nil tabs = [] tabs << { name: 'プロフィール', link: user_path(user) } tabs << { name: 'ポートフォリオ', link: user_portfolio_path(user) } - tabs << { name: '日報', link: user_reports_path(user), count: user.reports.length } + tabs << { name: '日報', link: user_reports_path(user), count: user.reports.length, badge: unchecked_report_badge } tabs << { name: 'コメント', link: user_comments_path(user), count: comment_count } tabs << { name: '提出物', link: user_products_path(user), count: user.products.length } tabs << { name: '質問', link: user_questions_path(user), count: user.questions.length } From 7885c689d3967be9b5d3dcfcd4b35cb4fb7fe5fd Mon Sep 17 00:00:00 2001 From: hirokiej <123009866+hirokiej@users.noreply.github.com> Date: Mon, 4 Aug 2025 21:50:32 +0900 Subject: [PATCH 5/8] =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E3=83=A2=E3=83=BC=E3=83=89=E6=99=82=E3=80=81=E3=83=A6=E3=83=BC?= =?UTF-8?q?=E3=82=B6=E3=83=BC=E6=97=A5=E5=A0=B1=E6=9C=AC=E6=96=87=E4=B8=8B?= =?UTF-8?q?=E3=81=AE=E3=80=8C=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=81=AE?= =?UTF-8?q?=E6=97=A5=E5=A0=B1=E4=B8=80=E8=A6=A7=E3=81=B8=E3=80=8D=E3=82=92?= =?UTF-8?q?=E3=82=AF=E3=83=AA=E3=83=83=E3=82=AF=E3=81=97=E3=81=9F=E9=9A=9B?= =?UTF-8?q?=E3=80=81=E3=80=8C=E6=9C=AA=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=80=8D=E3=81=AE=E6=97=A5=E5=A0=B1=E4=B8=80=E8=A6=A7=E3=81=AB?= =?UTF-8?q?=E9=81=B7=E7=A7=BB=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/reports/_report_body.html.slim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/reports/_report_body.html.slim b/app/views/reports/_report_body.html.slim index d0d0c54fc62..d14663a35d8 100644 --- a/app/views/reports/_report_body.html.slim +++ b/app/views/reports/_report_body.html.slim @@ -14,7 +14,7 @@ = report.user.unchecked_report_message(count, report.user) ul.card-body-main-actions__items li.card-body-main-actions__item - = link_to user_reports_path(report.user), class: "card-body-main-actions__action a-button is-sm #{report.user.user_report_count_class(count)} is-block", target: '_blank', rel: 'noopener' do + = link_to user_reports_path(report.user, target: 'unchecked_reports'), class: "card-body-main-actions__action a-button is-sm #{report.user.user_report_count_class(count)} is-block", target: '_blank', rel: 'noopener' do | #{report.user.login_name}さんの日報一覧へ - else .card-body-main-actions.p-0 From d0b7f280cf123050904b673ddbd66917e46fc574 Mon Sep 17 00:00:00 2001 From: hirokiej <123009866+hirokiej@users.noreply.github.com> Date: Sun, 17 Aug 2025 17:15:18 +0900 Subject: [PATCH 6/8] =?UTF-8?q?=E6=9C=AA=E3=83=81=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=81=AE=E4=B8=80=E8=A6=A7=E3=81=AEUI=E3=81=A8API?= =?UTF-8?q?=E3=81=AE=E3=82=A2=E3=82=AF=E3=82=BB=E3=82=B9=E6=A8=A9=E9=99=90?= =?UTF-8?q?=E3=82=92admin/mentor=E3=81=AB=E9=99=90=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit unchecked_reportsのアクセス制御をhead :forbiddenからrequire_admin_or_mentor_loginに変更 --- app/controllers/api/reports_controller.rb | 5 ++++- app/controllers/users/reports_controller.rb | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/reports_controller.rb b/app/controllers/api/reports_controller.rb index f42c596d1e6..e8908afdb38 100644 --- a/app/controllers/api/reports_controller.rb +++ b/app/controllers/api/reports_controller.rb @@ -8,6 +8,9 @@ def index @reports = @reports.where(user_id: params[:user_id]) if params[:user_id].present? @reports = @reports.limit(params[:limit].to_i) if params[:limit].present? @reports = @reports.joins(:user).where(users: { company_id: params[:company_id] }) if params[:company_id] - @reports = @reports.includes(:checks).unchecked.not_wip if params[:target] == 'unchecked_reports' + return unless params[:target] == 'unchecked_reports' + return head :forbidden unless current_user.admin_or_mentor? + + @reports = @reports.includes(:checks).unchecked.not_wip end end diff --git a/app/controllers/users/reports_controller.rb b/app/controllers/users/reports_controller.rb index 9f983e01f12..85b908e2f33 100644 --- a/app/controllers/users/reports_controller.rb +++ b/app/controllers/users/reports_controller.rb @@ -3,6 +3,7 @@ class Users::ReportsController < ApplicationController before_action :set_user before_action :set_target + before_action :require_admin_or_mentor_login, if: -> { params[:target] == 'unchecked_reports' } before_action :set_reports before_action :set_report before_action :set_export @@ -31,8 +32,7 @@ def set_user end def set_reports - @reports = case @target - when 'unchecked_reports' + @reports = if @target == 'unchecked_reports' @user.reports.unchecked.not_wip.list.page(params[:page]) else @user.reports.list.page(params[:page]) From 325744a8c9acc473087099489e78262d9dad59e3 Mon Sep 17 00:00:00 2001 From: hirokiej <123009866+hirokiej@users.noreply.github.com> Date: Sun, 17 Aug 2025 23:35:14 +0900 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84useEffect=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/Reports.jsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/javascript/components/Reports.jsx b/app/javascript/components/Reports.jsx index 67ad26e1c1c..28eca21eb56 100644 --- a/app/javascript/components/Reports.jsx +++ b/app/javascript/components/Reports.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react' +import React, { useState } from 'react' import useSWR from 'swr' import fetcher from '../fetcher' import LoadingListPlaceholder from './LoadingListPlaceholder' @@ -21,10 +21,6 @@ export default function Reports({ const { page, setPage } = usePage() const [userPracticeId, setUserPracticeId] = useState('') - useEffect(() => { - setUserPracticeId(userPracticeId) - }, [userPracticeId]) - let reportsUrl = `/api/reports.json?page=${page}` if (userId) reportsUrl += `&user_id=${userId}` if (practiceId) reportsUrl += `&practice_id=${practiceId}` From 4ead1d83ea09664bd33471496f28643af612ecbd Mon Sep 17 00:00:00 2001 From: hirokiej <123009866+hirokiej@users.noreply.github.com> Date: Sun, 17 Aug 2025 23:51:43 +0900 Subject: [PATCH 8/8] =?UTF-8?q?practice=5Fid=E3=81=8C=E4=BA=8C=E9=87=8D?= =?UTF-8?q?=E4=BB=98=E4=B8=8E=E3=81=95=E3=82=8C=E3=82=8B=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E6=80=A7=E3=82=92=E6=8E=92=E9=99=A4=E3=81=97=E3=80=81=E3=83=95?= =?UTF-8?q?=E3=82=A3=E3=83=AB=E3=82=BF=E5=85=A5=E5=8A=9B=E3=82=92=E5=84=AA?= =?UTF-8?q?=E5=85=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/components/Reports.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/components/Reports.jsx b/app/javascript/components/Reports.jsx index 28eca21eb56..afb77ea0c0f 100644 --- a/app/javascript/components/Reports.jsx +++ b/app/javascript/components/Reports.jsx @@ -23,9 +23,9 @@ export default function Reports({ let reportsUrl = `/api/reports.json?page=${page}` if (userId) reportsUrl += `&user_id=${userId}` - if (practiceId) reportsUrl += `&practice_id=${practiceId}` if (companyId) reportsUrl += `&company_id=${companyId}` - if (userPracticeId) reportsUrl += `&practice_id=${userPracticeId}` + const pid = userPracticeId || practiceId + if (pid) reportsUrl += `&practice_id=${pid}` if (unchecked) reportsUrl += `&target=unchecked_reports` const { data, error } = useSWR(reportsUrl, fetcher)