Current goal indicator

Indicator with current goal and the supports required to achieve it has
been added
This commit is contained in:
Juan Salvador Pérez García
2018-06-28 10:44:58 +02:00
parent a22027a343
commit 50d4523ded
6 changed files with 40 additions and 5 deletions

View File

@@ -126,14 +126,10 @@
padding-right: 10pt;
.counter-value {
font-size: 1.2rem;
font-weight: bold;
text-align: center;
}
.counter-label {
color: #c5c5c5;
font-weight: bold;
text-align: center;
}
}
@@ -154,6 +150,16 @@
border-right: 1px solid lightgray;
}
.counter-value {
font-size: 1.2rem;
font-weight: bold;
}
.counter-label {
color: #c5c5c5;
font-weight: bold;
}
.proposal-link {
flex-grow: 1;
.button {

View File

@@ -1,5 +1,5 @@
class ProposalsDashboardController < Dashboard::BaseController
helper_method :proposal_dashboard_action
helper_method :proposal_dashboard_action, :next_goal_supports
def index
authorize! :dashboard, proposal
@@ -61,4 +61,8 @@ class ProposalsDashboardController < Dashboard::BaseController
def proposal_dashboard_action
@proposal_dashboard_action ||= ProposalDashboardAction.find(params[:id])
end
def next_goal_supports
ProposalDashboardAction.next_goal_for(proposal)&.required_supports || Setting["votes_for_proposal_success"]
end
end

View File

@@ -52,6 +52,18 @@ class ProposalDashboardAction < ActiveRecord::Base
.where('day_offset <= ?', (Date.today - published_at).to_i)
end
def self.next_goal_for(proposal)
published_at = proposal.published_at&.to_date || Date.today
active
.where(
'(required_supports > ? or day_offset > ?)',
proposal.votes_for.size,
(Date.today - published_at).to_i)
.order(required_supports: :asc)
&.first
end
default_scope { order(order: :asc, title: :asc) }
def request_to_administrators?

View File

@@ -22,6 +22,11 @@
</div>
<div class="column large-8">
<div class="current-goal">
<div class="counter-value">
<%= t('.support_count', count: next_goal_supports) %>
</div>
<div class="counter-label"><%= t('.current_goal') %></div>
</div>
<div class="support-indicator">

View File

@@ -212,6 +212,10 @@ en:
active_resources: Active resources
community: Community
show_proposal: Show proposal
current_goal: Current goal
support_count:
one: "%{count} support"
other: "%{count} supports"
footer:
accessibility: Accessibility
conditions: Terms and conditions of use

View File

@@ -212,6 +212,10 @@ es:
active_resources: Recursos activos
community: Comunidad
show_proposal: Ver propuesta
current_goal: Meta actual
support_count:
one: "%{count} apoyo"
other: "%{count} apoyos"
footer:
accessibility: Accesibilidad
conditions: Condiciones de uso