Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/assets/images/icons/reports-fill.svg
Copy link
Contributor

Choose a reason for hiding this comment

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

This icon is not used throughout this PR.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion app/components/sidebar_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def build_admin_section
SIDEBAR_ITEM.new(name: t("users", scope: "components.sidebar_component.build_admin_section"),
path: helpers.users_path, icon: "person-gear"),
SIDEBAR_ITEM.new(name: t("regions", scope: "components.sidebar_component.build_admin_section"),
path: helpers.regions_path, icon: "compass")
path: helpers.regions_path, icon: "compass"),
SIDEBAR_ITEM.new(name: t("reports", scope: "components.sidebar_component.build_admin_section"),
path: helpers.reports_path, icon: "reports-fill")
Copy link
Contributor

Choose a reason for hiding this comment

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

Make this a seperate pr.

]
)
end
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
class ReportsController < ApplicationController
before_action :set_report, only: %i[show edit update destroy]

Check failure on line 2 in app/controllers/reports_controller.rb

View workflow job for this annotation

GitHub Actions / lint_ruby

Rails/LexicallyScopedActionFilter: `update`, `destroy` are not explicitly defined on the class.

def index
@reports = Report.all
end

def show
@report = Report.find(params[:id])
end
Expand Down
28 changes: 28 additions & 0 deletions app/views/reports/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<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 %>
<%= t(".actions.create") %>
<% end %>
</div>
<%= render ContentCardComponent.new do %>
<%= render Shared::IndexTableComponent.new(records: @reports) do |table| %>
<% table.column :start_date, header: t(".columns.start_date") do |report| %>
<%= l(report.start_date) if report.start_date %>
<% end %>
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need the header here. The table component derives it.

<% table.column :end_date, header: t(".columns.end_date") do |report| %>
<%= l(report.end_date) if report.end_date %>
<% end %>
<% table.column :created_at, header: t(".columns.created_at") do |report| %>
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

The table headers use t(".columns.start_date") / end_date / created_at, but there are no corresponding reports.index.columns.* keys in the locale files (they were not added in this PR). This will display "translation missing" in the UI. Either add those locale keys or omit the explicit header: and let IndexTableComponent fall back to Report.human_attribute_name.

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

Copilot uses AI. Check for mistakes.
<%= l(report.created_at) %>
<% end %>
<% table.column :actions, header: t("shared.index_table_component.actions"), col_size: "90px" do |report| %>
<div class="flex flex-row gap-2 items-center">
<%= render ActionButtonComponent.new(to: report_path(report), icon: "view", turbo_stream: true) %>
<%= render ActionButtonComponent.new(to: edit_report_path(report), icon: "edit", turbo_stream: true, colour: :info) %>
<%= render ActionButtonComponent.new(to: report_path(report), method: :delete, icon: "delete", colour: :error, confirm: t("reports.destroy.confirm")) %>
</div>
<% end %>
<% end %>
<% end %>
</div>
4 changes: 4 additions & 0 deletions config/locales/en/reports.en.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
en:
components:
sidebar_component:
build_admin_section:
reports: Reports
reports:
create:
invalid: Please provide valid dates and select at least one subproject.
Expand Down
4 changes: 4 additions & 0 deletions config/locales/es/reports.es.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
es:
components:
sidebar_component:
build_admin_section:
reports: Informes
reports:
create:
invalid: Por favor proporcione fechas válidas y seleccione al menos un subproyecto.
Expand Down
Loading