Skip to content

日報のテンプレートが画面遷移するときに自動で挿入されてしまうバグを解消#9269

Merged
komagata merged 1 commit intomainfrom
bug/automatically-insert-report-temlate-anytime
Oct 18, 2025
Merged

日報のテンプレートが画面遷移するときに自動で挿入されてしまうバグを解消#9269
komagata merged 1 commit intomainfrom
bug/automatically-insert-report-temlate-anytime

Conversation

@hirokiej
Copy link
Copy Markdown
Contributor

@hirokiej hirokiej commented Oct 17, 2025

Issue

概要

テンプレートを登録しているユーザーが日報を提出してできずにエラーが起きた時や、編集しようとした時(提出済みも含む)、自動でテンプレートが挿入されてしまい、元々の本文が消えてしまうバグを解消しました。
@yokomaru さんに画面共有で確認してもらいました。

変更確認方法

  1. bug/automatically-insert-report-temlate-anytimeをローカルに取り込む
  2. machidaでログイン
    ID: machida
    PASS: testtest
  3. http://localhost:3000/reports/430404470 にアクセスする。
  4. 内容を修正するをクリック。
  5. 内容が変更されていないことを確認する。
  6. テンプレートを反映するをクリックし、テンプレートが反映されることを確認する。
    (もし、テンプレートが作成されていなかったら任意の文字列を登録する。)

Summary by CodeRabbit

Bug Fixes

  • フォーム説明欄の自動入力動作を改善しました。登録済みテンプレートは、ユーザーによる説明入力がない場合にのみ適用されるようになります。

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 17, 2025

Walkthrough

レポート作成フォーム内の説明フィールドの事前入力ロジックが変更されました。登録済みテンプレートが存在する場合に自動的に適用されていた処理から、ユーザーが説明を入力していない場合のみテンプレートを使用するように制限されました。

Changes

Cohort / File(s) Change Summary
フォーム入力ロジック修正
app/views/reports/_form.html.slim
description text_area の value_option 計算条件を変更。registered_template のみの判定から「現在のレポート説明が空白かつ registered_template が存在」の複合条件に修正し、テンプレート値の事前入力を制限

Sequence Diagram

sequenceDiagram
    participant User
    participant Form as フォーム
    participant Template as テンプレート

    rect rgb(200, 220, 255)
    Note over User,Template: 変更前: registered_template が存在すれば常に適用
    User->>Form: フォーム表示要求
    alt registered_template 存在
        Form->>Template: テンプレート取得
        Template-->>Form: テンプレート値
        Form-->>User: 説明欄にテンプレート値を事前入力
    end
    end

    rect rgb(220, 255, 220)
    Note over User,Template: 変更後: 説明が空白かつテンプレート存在で適用
    User->>Form: フォーム表示要求
    alt 説明が空白 AND registered_template 存在
        Form->>Template: テンプレート取得
        Template-->>Form: テンプレート値
        Form-->>User: 説明欄にテンプレート値を事前入力
    else 説明が入力済み
        Form-->>User: ユーザー入力値を保持
    end
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

変更範囲が単一ファイルの条件判定修正であり、ロジックの複雑性も低いため、影響範囲の確認と入力条件の妥当性検証を中心に審査できます。

Possibly related PRs

Suggested reviewers

  • komagata

Poem

🐰✨ テンプレートの魔法、今はもっと賢く
ユーザーの手書きを大事にして
空白の時だけ、そっと導く
フォームの思いやり、ここに光る

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed プルリクエストのタイトル「日報のテンプレートが画面遷移するときに自動で挿入されてしまうバグを解消」は、RAW要約で説明されている変更内容(テンプレート値の入力前埋込動作を修正)と PR objectives で説明されているバグ(ユーザーが編集時にテンプレートが自動的に挿入されて本文が消える問題)に完全に関連しており、修正内容を簡潔かつ明確に表現しています。タイトルは単一文で、ノイズがなく、歴史を確認するチームメイトが主な変更を理解するのに十分な具体性があります。
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed PR説明は、テンプレートで指定された主要なセクションのほぼすべてを網羅しています。Issue番号(#9270)、概要(バグの詳細な説明)、変更確認方法(具体的なステップと認証情報を含む詳細な手順)が完全に記載されており、バグ修正の内容と確認方法が明確です。ただし、テンプレートで指定されているScreenshotセクション(変更前後のスクリーンショット)が完全に欠けています。一方で、提供されている変更確認方法が十分に詳細であり、実際の確認手順が明確に記載されているため、スクリーンショットなしでも検証可能な状態となっています。
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug/automatically-insert-report-temlate-anytime

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hirokiej hirokiej requested a review from yokomaru October 17, 2025 13:23
@hirokiej hirokiej self-assigned this Oct 17, 2025
@hirokiej hirokiej requested a review from komagata October 17, 2025 13:23
Copy link
Copy Markdown
Contributor

@yokomaru yokomaru left a comment

Choose a reason for hiding this comment

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

@hirokiej
お疲れ様です!
確認しました!問題なさそうなのでApproveします!

  • 確認した動線
    • テンプレート登録済みで日報新規作成 → テンプレートが表示されていること
    • テンプレート登録済みで日報新規作成→ 内容を修正してWIPで保存 → 保存した内容が編集画面に表示されること
    • ↑の日報のタイトルを空欄にしてWIPで保存 → エラー時にも保存した内容が置き換わらないこと
    • WIPの日報を編集 → 提出 → 編集した内容で表示(保存)されること
    • 提出済みの日報を編集 → テンプレートに置き換わらずに保存した内容が表示されていること
    • 日報をコピーで新規作成 → テンプレートに置き換わらずに保存した内容が表示されていること
    • テンプレートなしで新規作成 → 内容欄が空欄になっていること
    • ↑の状態でWIP で保存 → 空欄のためエラーになること

@hirokiej
Copy link
Copy Markdown
Contributor Author

@komagata さん
お疲れ様です。
メンバーのレビューが終わったのでご確認よろしくお願いいたします🙇

@hirokiej hirokiej removed the request for review from okuramasafumi October 17, 2025 15:45
Copy link
Copy Markdown
Member

@komagata komagata left a comment

Choose a reason for hiding this comment

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

確認させて頂きました。OKです〜🙆‍♂️

@komagata komagata merged commit a47b3ef into main Oct 18, 2025
12 checks passed
@komagata komagata deleted the bug/automatically-insert-report-temlate-anytime branch October 18, 2025 07:41
@github-actions github-actions bot mentioned this pull request Oct 18, 2025
1 task
@hirokiej
Copy link
Copy Markdown
Contributor Author

@komagata さん
ご確認とリリースありがとうございます🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants