Skip to content

feat: added controller, views, tests for reports#264

Open
AliK070 wants to merge 1 commit intomainfrom
report-index-page-new
Open

feat: added controller, views, tests for reports#264
AliK070 wants to merge 1 commit intomainfrom
report-index-page-new

Conversation

@AliK070
Copy link
Contributor

@AliK070 AliK070 commented Mar 24, 2026

TL;DR

Adds reports index support with matching index-page styling: routes, controller/view, and tests for listing reports with view, edit, and delete actions.


What is this PR trying to achieve?


How did you achieve it?

  • Updated routes to include index and destroy.
  • Added reports index view using IndexTableComponent and the ActionButtonComponent
  • Added/updated controller tests for index and destroy behavior.
  • Updated locale keys in English and Spanish for the index page.

Checklist

  • Changes have been top-hatted locally
  • Tests have been added or updated
  • Documentation has been updated (if applicable)
  • Linked related issues

Copilot AI review requested due to automatic review settings March 24, 2026 16:28
@AliK070 AliK070 self-assigned this Mar 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a Report index page (and delete support) consistent with other admin index screens, using Shared::IndexTableComponent + ActionButtonComponent, along with routes, locales, and controller tests to support the new functionality.

Changes:

  • Add reports#index and reports#destroy routes and controller actions.
  • Add app/views/reports/index.html.erb using Shared::IndexTableComponent with view/edit/delete actions.
  • Extend locales (EN/ES) and controller tests to cover listing and deletion.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
app/controllers/reports_controller.rb Adds index for listing reports and destroy for deleting reports.
app/views/reports/index.html.erb New index UI with table columns and action buttons.
config/routes.rb Exposes index and destroy for reports resources.
config/locales/en/reports.en.yml Adds index/destroy strings and report attribute labels.
config/locales/es/reports.es.yml Adds index/destroy strings and report attribute labels.
test/controllers/reports_controller_test.rb Adds coverage for index listing and admin deletion; includes auth checks for new routes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<div class="mx-8 my-10">
<div class="flex items-center justify-between mb-4">
<h1 class="text-4xl font-bold"><%= t(".title") %></h1>
<%= render ActionButtonComponent.new(to: new_report_path, icon: "add", colour: :primary, size: :large, turbo_stream: true) do %>
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

ActionButtonComponent is being rendered with turbo_stream: true for the “Create Report” link, but ReportsController#new does not respond to the turbo_stream format and there is no new.turbo_stream.erb template. Clicking this will request Turbo Stream and can raise ActionView::MissingTemplate. Remove turbo_stream: true here, or add a respond_to block + Turbo Stream template for new.

Suggested change
<%= render ActionButtonComponent.new(to: new_report_path, icon: "add", colour: :primary, size: :large, turbo_stream: true) do %>
<%= render ActionButtonComponent.new(to: new_report_path, icon: "add", colour: :primary, size: :large) do %>

Copilot uses AI. Check for mistakes.
<% table.column :actions, header: t("shared.index_table_component.actions"), col_size: "90px" do |report| %>
<div class="flex items-center gap-2">
<%= render ActionButtonComponent.new(to: report_path(report), icon: "view") %>
<%= render ActionButtonComponent.new(to: edit_report_path(report), icon: "edit", colour: :info, turbo_stream: true) %>
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

turbo_stream: true on the “Edit” action will request the Turbo Stream format, but ReportsController#edit does not handle turbo_stream and there is no edit.turbo_stream.erb template. This can cause MissingTemplate errors when the button is clicked. Either remove turbo_stream: true or implement Turbo Stream responses for edit.

Suggested change
<%= render ActionButtonComponent.new(to: edit_report_path(report), icon: "edit", colour: :info, turbo_stream: true) %>
<%= render ActionButtonComponent.new(to: edit_report_path(report), icon: "edit", colour: :info) %>

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +12
<% table.column :start_date, header: t(".columns.start_date") %>
<% table.column :end_date, header: t(".columns.end_date") %>
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The start_date/end_date cells are rendered via record.send(...), which will output raw Date#to_s (ISO) and won’t respect locale formatting. Other tables in the app localize dates with l(...); consider rendering these cells with l(report.start_date) / l(report.end_date) for consistent, localized display.

Suggested change
<% table.column :start_date, header: t(".columns.start_date") %>
<% table.column :end_date, header: t(".columns.end_date") %>
<% table.column :start_date, header: t(".columns.start_date") do |report| %>
<%= l(report.start_date) %>
<% end %>
<% table.column :end_date, header: t(".columns.end_date") do |report| %>
<%= l(report.end_date) %>
<% end %>

Copilot uses AI. Check for mistakes.
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.

Report Index Page

2 participants