Add cards to SDG homepage

This commit is contained in:
Javi Martín
2021-01-13 14:44:55 +01:00
parent 5907ddf884
commit c3e60ff514
7 changed files with 37 additions and 4 deletions

View File

@@ -2748,7 +2748,8 @@ table {
.home-page,
.custom-page,
.sdg-goal-show {
.sdg-goal-show,
.sdg-goals-index {
a {

View File

@@ -22,4 +22,13 @@
}
}
}
.sdg-phase {
@include grid-row;
@include grid-column-gutter;
.cards-container {
@include grid-row-nest;
}
}
}

View File

@@ -1,3 +1,13 @@
<div class="sdg-goals-index">
<%= link_list(*goal_links, class: "sdg-goal-list") %>
<% phases.each do |phase| %>
<section class="sdg-phase" id="sdg_phase_<%= phase.kind %>">
<header>
<h2 class="title"><%= phase.title %></h2>
</header>
<%= render "shared/cards", cards: phase.cards %>
</section>
<% end %>
</div>

View File

@@ -1,9 +1,10 @@
class SDG::Goals::IndexComponent < ApplicationComponent
attr_reader :goals
attr_reader :goals, :phases
delegate :link_list, to: :helpers
def initialize(goals)
def initialize(goals, phases)
@goals = goals
@phases = phases
end
private

View File

@@ -5,6 +5,7 @@ class SDG::GoalsController < ApplicationController
def index
@goals = @goals.order(:code)
@phases = SDG::Phase.accessible_by(current_ability).order(:kind)
end
def show

View File

@@ -1 +1 @@
<%= render SDG::Goals::IndexComponent.new(@goals) %>
<%= render SDG::Goals::IndexComponent.new(@goals, @phases) %>

View File

@@ -32,6 +32,17 @@ describe "SDG Goals", :js do
expect(page).to have_current_path sdg_goal_path(7)
end
scenario "has cards for phases" do
create(:widget_card, cardable: SDG::Phase["planning"], title: "Planning card")
visit sdg_goals_path
within "#sdg_phase_planning" do
expect(page).to have_css "header", exact_text: "Planning"
expect(page).to have_content "PLANNING CARD"
end
end
end
describe "Show" do