feat: added controller, views, tests for reports#264
Conversation
There was a problem hiding this comment.
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#indexandreports#destroyroutes and controller actions. - Add
app/views/reports/index.html.erbusingShared::IndexTableComponentwith 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 %> |
There was a problem hiding this comment.
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.
| <%= 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 %> |
| <% 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) %> |
There was a problem hiding this comment.
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.
| <%= 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) %> |
| <% table.column :start_date, header: t(".columns.start_date") %> | ||
| <% table.column :end_date, header: t(".columns.end_date") %> |
There was a problem hiding this comment.
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.
| <% 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 %> |
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?
ReportIndex Page #113How did you achieve it?
Checklist