Add groups index page

When render the investment list component with the link "see all
investments", now we redirect to groups index page when a budget has
multiple headings.
This commit is contained in:
decabeza
2020-05-04 12:44:18 +02:00
committed by Javi Martín
parent 3cd2529791
commit 4a9aae9806
12 changed files with 58 additions and 10 deletions

View File

@@ -0,0 +1,8 @@
<% content_for :canonical do %>
<%= render "shared/canonical", href: budget_groups_url %>
<% end %>
<main class="budget-groups-index">
<%= header(before: back_link_to(budget_path(budget))) %>
<%= render Budgets::GroupsAndHeadingsComponent.new(budget) %>
</main>

View File

@@ -0,0 +1,12 @@
class Budgets::Groups::IndexComponent < ApplicationComponent
include Header
attr_reader :budget
def initialize(budget)
@budget = budget
end
def title
t("budgets.groups.show.title")
end
end

View File

@@ -14,7 +14,7 @@
<div class="row margin-top">
<div class="small-12 medium-6 large-4 small-centered column margin-top">
<%= link_to t("budgets.investments_list.see_all"),
budget_investments_path(budget),
see_all_path,
class: "button expanded" %>
</div>
</div>

View File

@@ -17,4 +17,12 @@ class Budgets::InvestmentsListComponent < ApplicationComponent
budget.investments.none
end
end
def see_all_path
if budget.single_heading?
budget_investments_path(budget)
else
budget_groups_path(budget)
end
end
end

View File

@@ -1,7 +1,7 @@
module Header
extend ActiveSupport::Concern
def header(&block)
def header(before: nil, &block)
provide(:title) do
[
t("#{namespace}.header.title", default: ""),
@@ -17,11 +17,7 @@ module Header
end
tag.header do
if block_given?
content_tag(heading_tag, title) + capture(&block)
else
content_tag(heading_tag, title)
end
safe_join([before, content_tag(heading_tag, title), (capture(&block) if block_given?)].compact)
end
end