From cc9ab70fbb0ef9422f38375b8840ac77bf7e2554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 20 Dec 2020 23:08:24 +0100 Subject: [PATCH] Add processes to goal view Note the link to see all processes does not filter by goal because the legislation section does not have any search filters. --- app/assets/stylesheets/sdg/goals/show.scss | 15 +++++++++++++++ app/components/sdg/goals/show_component.html.erb | 6 ++++++ app/components/sdg/goals/show_component.rb | 6 ++++++ app/components/widgets/feeds/feed_component.rb | 2 +- .../widgets/feeds/feed_component_spec.rb | 8 ++++++++ spec/system/sdg/goals_spec.rb | 7 +++++++ 6 files changed, 43 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/sdg/goals/show.scss b/app/assets/stylesheets/sdg/goals/show.scss index 5023e3743..13b384215 100644 --- a/app/assets/stylesheets/sdg/goals/show.scss +++ b/app/assets/stylesheets/sdg/goals/show.scss @@ -22,4 +22,19 @@ } } } + + .feed-processes { + + .feed-content { + @include breakpoint(medium) { + @include grid-row-nest; + display: flex; + + > * { + @include grid-column-gutter; + width: 50%; + } + } + } + } } diff --git a/app/components/sdg/goals/show_component.html.erb b/app/components/sdg/goals/show_component.html.erb index e316e2ddc..862bd0763 100644 --- a/app/components/sdg/goals/show_component.html.erb +++ b/app/components/sdg/goals/show_component.html.erb @@ -10,4 +10,10 @@ <%= render Widgets::Feeds::ParticipationComponent.new(feeds) %> + + <% if processes_feed %> +
+ <%= render Widgets::Feeds::FeedComponent.new(processes_feed) %> +
+ <% end %> diff --git a/app/components/sdg/goals/show_component.rb b/app/components/sdg/goals/show_component.rb index 07bdff277..531967906 100644 --- a/app/components/sdg/goals/show_component.rb +++ b/app/components/sdg/goals/show_component.rb @@ -9,4 +9,10 @@ class SDG::Goals::ShowComponent < ApplicationComponent def feeds SDG::Widget::Feed.for_goal(goal) end + + private + + def processes_feed + feeds.find { |feed| feed.kind == "processes" } + end end diff --git a/app/components/widgets/feeds/feed_component.rb b/app/components/widgets/feeds/feed_component.rb index 2b41f9495..cf476382a 100644 --- a/app/components/widgets/feeds/feed_component.rb +++ b/app/components/widgets/feeds/feed_component.rb @@ -24,7 +24,7 @@ class Widgets::Feeds::FeedComponent < ApplicationComponent end def filters - if feed.respond_to?(:goal) + if feed.respond_to?(:goal) && kind != "processes" { advanced_search: { goal: feed.goal.code }} else {} diff --git a/spec/components/widgets/feeds/feed_component_spec.rb b/spec/components/widgets/feeds/feed_component_spec.rb index 8d2cae566..09974de0b 100644 --- a/spec/components/widgets/feeds/feed_component_spec.rb +++ b/spec/components/widgets/feeds/feed_component_spec.rb @@ -52,6 +52,14 @@ describe Widgets::Feeds::FeedComponent, type: :component do expect(component.see_all_path).to eq "/legislation/processes" end + + it "points to the legislation processes path for goal processes feeds" do + component = Widgets::Feeds::FeedComponent.new(SDG::Widget::Feed.new(feed, SDG::Goal[6])) + + render_inline component + + expect(component.see_all_path).to eq "/legislation/processes" + end end end end diff --git a/spec/system/sdg/goals_spec.rb b/spec/system/sdg/goals_spec.rb index 808a9afbd..3231a6f80 100644 --- a/spec/system/sdg/goals_spec.rb +++ b/spec/system/sdg/goals_spec.rb @@ -40,6 +40,8 @@ describe "SDG Goals", :js do create(:debate, title: "Hunting ground", sdg_goals: [goal]) create(:proposal, title: "Animal farm", sdg_goals: [goal]) create(:proposal, title: "Sea farm", sdg_goals: [SDG::Goal[14]]) + create(:legislation_process, title: "Bullfighting regulations", sdg_goals: [goal]) + create(:legislation_process, title: "Tax regulations", sdg_goals: [SDG::Goal[10]]) end scenario "shows the SDG and its related content" do @@ -56,6 +58,11 @@ describe "SDG Goals", :js do expect(page).to have_content "Hunting ground" expect(page).not_to have_content "Solar panels" end + + within ".feed-processes" do + expect(page).to have_content "BULLFIGHTING REGULATIONS" + expect(page).not_to have_content "TAX REGULATIONS" + end end scenario "has links to debates and proposals filtered by goal" do