Current goal indicator
Indicator with current goal and the supports required to achieve it has been added
This commit is contained in:
@@ -126,14 +126,10 @@
|
|||||||
padding-right: 10pt;
|
padding-right: 10pt;
|
||||||
|
|
||||||
.counter-value {
|
.counter-value {
|
||||||
font-size: 1.2rem;
|
|
||||||
font-weight: bold;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.counter-label {
|
.counter-label {
|
||||||
color: #c5c5c5;
|
|
||||||
font-weight: bold;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,6 +150,16 @@
|
|||||||
border-right: 1px solid lightgray;
|
border-right: 1px solid lightgray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.counter-value {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.counter-label {
|
||||||
|
color: #c5c5c5;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
.proposal-link {
|
.proposal-link {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
.button {
|
.button {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class ProposalsDashboardController < Dashboard::BaseController
|
class ProposalsDashboardController < Dashboard::BaseController
|
||||||
helper_method :proposal_dashboard_action
|
helper_method :proposal_dashboard_action, :next_goal_supports
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize! :dashboard, proposal
|
authorize! :dashboard, proposal
|
||||||
@@ -61,4 +61,8 @@ class ProposalsDashboardController < Dashboard::BaseController
|
|||||||
def proposal_dashboard_action
|
def proposal_dashboard_action
|
||||||
@proposal_dashboard_action ||= ProposalDashboardAction.find(params[:id])
|
@proposal_dashboard_action ||= ProposalDashboardAction.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def next_goal_supports
|
||||||
|
ProposalDashboardAction.next_goal_for(proposal)&.required_supports || Setting["votes_for_proposal_success"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -52,6 +52,18 @@ class ProposalDashboardAction < ActiveRecord::Base
|
|||||||
.where('day_offset <= ?', (Date.today - published_at).to_i)
|
.where('day_offset <= ?', (Date.today - published_at).to_i)
|
||||||
end
|
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) }
|
default_scope { order(order: :asc, title: :asc) }
|
||||||
|
|
||||||
def request_to_administrators?
|
def request_to_administrators?
|
||||||
|
|||||||
@@ -22,6 +22,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="column large-8">
|
<div class="column large-8">
|
||||||
<div class="current-goal">
|
<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>
|
||||||
|
|
||||||
<div class="support-indicator">
|
<div class="support-indicator">
|
||||||
|
|||||||
@@ -212,6 +212,10 @@ en:
|
|||||||
active_resources: Active resources
|
active_resources: Active resources
|
||||||
community: Community
|
community: Community
|
||||||
show_proposal: Show proposal
|
show_proposal: Show proposal
|
||||||
|
current_goal: Current goal
|
||||||
|
support_count:
|
||||||
|
one: "%{count} support"
|
||||||
|
other: "%{count} supports"
|
||||||
footer:
|
footer:
|
||||||
accessibility: Accessibility
|
accessibility: Accessibility
|
||||||
conditions: Terms and conditions of use
|
conditions: Terms and conditions of use
|
||||||
|
|||||||
@@ -212,6 +212,10 @@ es:
|
|||||||
active_resources: Recursos activos
|
active_resources: Recursos activos
|
||||||
community: Comunidad
|
community: Comunidad
|
||||||
show_proposal: Ver propuesta
|
show_proposal: Ver propuesta
|
||||||
|
current_goal: Meta actual
|
||||||
|
support_count:
|
||||||
|
one: "%{count} apoyo"
|
||||||
|
other: "%{count} apoyos"
|
||||||
footer:
|
footer:
|
||||||
accessibility: Accesibilidad
|
accessibility: Accesibilidad
|
||||||
conditions: Condiciones de uso
|
conditions: Condiciones de uso
|
||||||
|
|||||||
Reference in New Issue
Block a user