Adds community to proposals dashboard

This commit is contained in:
Juan Salvador Pérez García
2018-07-11 12:39:18 +02:00
parent 26d2a500ef
commit e8cd54d621
10 changed files with 116 additions and 0 deletions

View File

@@ -340,5 +340,16 @@
a {
font-size: 16px;
}
}
.community-totals {
span {
color: #898989;
}
p {
color: #898989;
}
}
}

View File

@@ -47,6 +47,10 @@ class ProposalsDashboardController < Dashboard::BaseController
authorize! :dashboard, proposal
end
def community
authorize! :dashboard, proposal
end
def supports
authorize! :dashboard, proposal
render json: ProposalSupportsQuery.for(params)

View File

@@ -9,6 +9,11 @@ module ProposalsDashboardHelper
nil
end
def community_menu_class
return 'is-active' if controller_name == 'proposals_dashboard' && action_name == 'community'
nil
end
def progress_menu_active?
is_proposed_action_request? || (controller_name == 'proposals_dashboard' && action_name == 'progress')
end

View File

@@ -15,6 +15,30 @@ class Community < ActiveRecord::Base
proposal.present?
end
def latest_activity
activity = []
most_recent_comment = Comment.where(commentable: topics).order(updated_at: :desc).take(1).first
activity << most_recent_comment.updated_at unless most_recent_comment.nil?
most_recent_topic = topics.order(updated_at: :desc).take(1).first
activity << most_recent_topic.updated_at unless most_recent_topic.nil?
activity.max
end
def comments_count
Comment.where(commentable: topics).count
end
def debates_count
topics.count
end
def participants_count
participants.count
end
private
def users_who_commented

View File

@@ -42,4 +42,12 @@
<% end %>
</li>
<% end %>
<li class="section-title">
<%= link_to community_proposal_dashboard_index_path(proposal.to_param),
class: community_menu_class do %>
<span class="fi-torsos-all"></span>
<strong><%= t('.community') %></strong>
<% end %>
</li>
</ul>

View File

@@ -0,0 +1,8 @@
<li>
<strong><%= topic.title %></strong>
<p class="help-text">
<%= l(topic.updated_at.to_date) %>
-
<%= topic.author.name %>
</p>
</li>

View File

@@ -0,0 +1,39 @@
<% content_for :action_title, t('proposals_dashboard.menu.community') %>
<div class="row">
<div class="small-12 large-9 column">
<%= link_to t('.access_community'), community_path(proposal.community), class: 'button hollow' %>
<% unless proposal.community.latest_activity.nil? %>
<p class="help-text"><%= t('.latest_activity', at: l(proposal.community.latest_activity.to_date)) %></p>
<% end %>
</div>
<div class="small-12 large-1 column community-totals">
<span class="fi-torsos-all"></span>
&nbsp;<strong><%= number_with_delimiter(proposal.community.participants_count, delimiter: '.') %></strong>
<p><%= t('.participants') %></p>
</div>
<div class="small-12 large-1 column community-totals">
<span class="fi-comment-quotes"></span>
&nbsp;<strong><%= number_with_delimiter(proposal.community.debates_count, delimiter: '.') %></strong>
<p><%= t('.debates') %></p>
</div>
<div class="small-12 large-1 column community-totals">
<span class="fi-comments"></span>
&nbsp;<strong><%= number_with_delimiter(proposal.community.comments_count, delimiter: '.') %></strong>
<p><%= t('.comments') %></p>
</div>
</div>
<% if proposal.community.topics.any? %>
<div class="action-title">
<h5><%= t('.latest_topics') %></h5>
<hr>
</div>
<ul>
<%= render partial: 'topic', collection: proposal.community.topics %>
</ul>
<% end %>

View File

@@ -508,6 +508,7 @@ en:
my_proposal: My proposal
progress: Progress
resources: Resources
community: Community
polls: Polls
form:
request: Request
@@ -550,6 +551,13 @@ en:
other: "%{count} days"
unlocked_resource: Resource unlocked
ideal_time: Ideal time
community:
access_community: Access the community
latest_activity: "Latest activity of the community: %{at}"
participants: Participants
debates: Debates
comments: Comments
latest_topics: Latest topics
dashboard:
polls:
index:

View File

@@ -508,6 +508,7 @@ es:
my_proposal: Mi propuesta
progress: Progreso
resources: Recursos
community: Comunidad
polls: Encuestas
form:
request: Solicitar
@@ -550,6 +551,13 @@ es:
other: "%{count} días"
unlocked_resource: Recurso desbloqueado
ideal_time: Tiempo ideal
community:
access_community: Acceder a la comunidad
latest_activity: "Última actividad de la comunidad: %{at}"
participants: Participantes
debates: Debates
comments: Comentarios
latest_topics: Últimos debates
dashboard:
polls:
index:

View File

@@ -9,6 +9,7 @@ resources :proposals do
get :supports
get :successful_supports
get :progress
get :community
get :achievements
end