Rename Widgets components to Widget
So naming is consistent with the way Admin::Widget controllers are named.
This commit is contained in:
3
app/components/widget/feeds/debate_component.html.erb
Normal file
3
app/components/widget/feeds/debate_component.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="debate">
|
||||
<strong><%= link_to debate.title, url_for(debate) %></strong>
|
||||
</div>
|
||||
7
app/components/widget/feeds/debate_component.rb
Normal file
7
app/components/widget/feeds/debate_component.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Widget::Feeds::DebateComponent < ApplicationComponent
|
||||
attr_reader :debate
|
||||
|
||||
def initialize(debate)
|
||||
@debate = debate
|
||||
end
|
||||
end
|
||||
17
app/components/widget/feeds/feed_component.html.erb
Normal file
17
app/components/widget/feeds/feed_component.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<section id="feed_<%= kind %>" class="widget-feed feed-<%= kind %>">
|
||||
<header>
|
||||
<h2 class="title"><%= t("welcome.feed.most_active.#{kind}") %></h2>
|
||||
</header>
|
||||
|
||||
<% if feed.items.any? %>
|
||||
<div class="feed-content">
|
||||
<% feed.items.each do |item| %>
|
||||
<%= render item_component_class.new(item) %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= link_to t("welcome.feed.see_all.#{kind}"), see_all_path, class: "see-all" %>
|
||||
<% else %>
|
||||
<div class="no-items callout primary"><%= t("welcome.feed.no_items.#{kind}") %></div>
|
||||
<% end %>
|
||||
</section>
|
||||
33
app/components/widget/feeds/feed_component.rb
Normal file
33
app/components/widget/feeds/feed_component.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
class Widget::Feeds::FeedComponent < ApplicationComponent
|
||||
attr_reader :feed
|
||||
delegate :kind, to: :feed
|
||||
|
||||
def initialize(feed)
|
||||
@feed = feed
|
||||
end
|
||||
|
||||
def see_all_path
|
||||
polymorphic_path(feed.items.model, filters)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def item_component_class
|
||||
case kind
|
||||
when "proposals"
|
||||
Widget::Feeds::ProposalComponent
|
||||
when "debates"
|
||||
Widget::Feeds::DebateComponent
|
||||
when "processes"
|
||||
Widget::Feeds::ProcessComponent
|
||||
end
|
||||
end
|
||||
|
||||
def filters
|
||||
if feed.respond_to?(:goal) && kind != "processes"
|
||||
{ advanced_search: { goal: feed.goal.code }}
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
<div class="row margin-bottom feeds-list feeds-participation">
|
||||
<% feeds.each do |feed| %>
|
||||
<% if feed_proposals?(feed) || feed_debates?(feed) %>
|
||||
<%= render Widget::Feeds::FeedComponent.new(feed) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
17
app/components/widget/feeds/participation_component.rb
Normal file
17
app/components/widget/feeds/participation_component.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class Widget::Feeds::ParticipationComponent < ApplicationComponent
|
||||
attr_reader :feeds
|
||||
|
||||
def initialize(feeds)
|
||||
@feeds = feeds
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def feed_debates?(feed)
|
||||
feed.kind == "debates"
|
||||
end
|
||||
|
||||
def feed_proposals?(feed)
|
||||
feed.kind == "proposals"
|
||||
end
|
||||
end
|
||||
13
app/components/widget/feeds/process_component.html.erb
Normal file
13
app/components/widget/feeds/process_component.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<div class="legislation-process card">
|
||||
<%= link_to url_for(process) do %>
|
||||
<figure class="figure-card">
|
||||
<%= image_tag("welcome_process.png", alt: "") %>
|
||||
<figcaption>
|
||||
<span><%= t("welcome.feed.process_label") %></span><br>
|
||||
<h3><%= process.title %></h3>
|
||||
</figcaption>
|
||||
</figure>
|
||||
<p class="description small"><%= process.summary %></p>
|
||||
<p class="small"><%= t("welcome.feed.see_process") %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
7
app/components/widget/feeds/process_component.rb
Normal file
7
app/components/widget/feeds/process_component.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Widget::Feeds::ProcessComponent < ApplicationComponent
|
||||
attr_reader :process
|
||||
|
||||
def initialize(process)
|
||||
@process = process
|
||||
end
|
||||
end
|
||||
16
app/components/widget/feeds/proposal_component.html.erb
Normal file
16
app/components/widget/feeds/proposal_component.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
<div class="proposal">
|
||||
<div class="feed-description small-12 column
|
||||
<%= "medium-6 large-9" if proposal.image.present? %>">
|
||||
<strong><%= link_to proposal.title, url_for(proposal) %></strong><br>
|
||||
<p><%= proposal.summary %></p>
|
||||
</div>
|
||||
|
||||
<% if proposal.image.present? %>
|
||||
<div class="small-12 medium-6 large-3 column">
|
||||
<div class="feed-image">
|
||||
<%= image_tag proposal.image_url(:thumb),
|
||||
alt: proposal.image.title.unicode_normalize %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
7
app/components/widget/feeds/proposal_component.rb
Normal file
7
app/components/widget/feeds/proposal_component.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Widget::Feeds::ProposalComponent < ApplicationComponent
|
||||
attr_reader :proposal
|
||||
|
||||
def initialize(proposal)
|
||||
@proposal = proposal
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user