Adds community to proposals dashboard
This commit is contained in:
@@ -340,5 +340,16 @@
|
|||||||
a {
|
a {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.community-totals {
|
||||||
|
span {
|
||||||
|
color: #898989;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
color: #898989;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ class ProposalsDashboardController < Dashboard::BaseController
|
|||||||
authorize! :dashboard, proposal
|
authorize! :dashboard, proposal
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def community
|
||||||
|
authorize! :dashboard, proposal
|
||||||
|
end
|
||||||
|
|
||||||
def supports
|
def supports
|
||||||
authorize! :dashboard, proposal
|
authorize! :dashboard, proposal
|
||||||
render json: ProposalSupportsQuery.for(params)
|
render json: ProposalSupportsQuery.for(params)
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ module ProposalsDashboardHelper
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def community_menu_class
|
||||||
|
return 'is-active' if controller_name == 'proposals_dashboard' && action_name == 'community'
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
def progress_menu_active?
|
def progress_menu_active?
|
||||||
is_proposed_action_request? || (controller_name == 'proposals_dashboard' && action_name == 'progress')
|
is_proposed_action_request? || (controller_name == 'proposals_dashboard' && action_name == 'progress')
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,6 +15,30 @@ class Community < ActiveRecord::Base
|
|||||||
proposal.present?
|
proposal.present?
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
def users_who_commented
|
def users_who_commented
|
||||||
|
|||||||
@@ -42,4 +42,12 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% 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>
|
</ul>
|
||||||
|
|||||||
8
app/views/proposals_dashboard/_topic.html.erb
Normal file
8
app/views/proposals_dashboard/_topic.html.erb
Normal 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>
|
||||||
39
app/views/proposals_dashboard/community.html.erb
Normal file
39
app/views/proposals_dashboard/community.html.erb
Normal 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>
|
||||||
|
<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>
|
||||||
|
<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>
|
||||||
|
<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 %>
|
||||||
@@ -508,6 +508,7 @@ en:
|
|||||||
my_proposal: My proposal
|
my_proposal: My proposal
|
||||||
progress: Progress
|
progress: Progress
|
||||||
resources: Resources
|
resources: Resources
|
||||||
|
community: Community
|
||||||
polls: Polls
|
polls: Polls
|
||||||
form:
|
form:
|
||||||
request: Request
|
request: Request
|
||||||
@@ -550,6 +551,13 @@ en:
|
|||||||
other: "%{count} days"
|
other: "%{count} days"
|
||||||
unlocked_resource: Resource unlocked
|
unlocked_resource: Resource unlocked
|
||||||
ideal_time: Ideal time
|
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:
|
dashboard:
|
||||||
polls:
|
polls:
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -508,6 +508,7 @@ es:
|
|||||||
my_proposal: Mi propuesta
|
my_proposal: Mi propuesta
|
||||||
progress: Progreso
|
progress: Progreso
|
||||||
resources: Recursos
|
resources: Recursos
|
||||||
|
community: Comunidad
|
||||||
polls: Encuestas
|
polls: Encuestas
|
||||||
form:
|
form:
|
||||||
request: Solicitar
|
request: Solicitar
|
||||||
@@ -550,6 +551,13 @@ es:
|
|||||||
other: "%{count} días"
|
other: "%{count} días"
|
||||||
unlocked_resource: Recurso desbloqueado
|
unlocked_resource: Recurso desbloqueado
|
||||||
ideal_time: Tiempo ideal
|
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:
|
dashboard:
|
||||||
polls:
|
polls:
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ resources :proposals do
|
|||||||
get :supports
|
get :supports
|
||||||
get :successful_supports
|
get :successful_supports
|
||||||
get :progress
|
get :progress
|
||||||
|
get :community
|
||||||
get :achievements
|
get :achievements
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user