Implements #202
The link 'Checkout the complete course' in progress view shows not only the next goal but all the upcoming goals.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class ProposalsDashboardController < Dashboard::BaseController
|
||||
helper_method :proposal_dashboard_action, :active_resources
|
||||
helper_method :proposal_dashboard_action, :active_resources, :course
|
||||
|
||||
def index
|
||||
authorize! :dashboard, proposal
|
||||
@@ -69,6 +69,10 @@ class ProposalsDashboardController < Dashboard::BaseController
|
||||
end
|
||||
|
||||
def active_resources
|
||||
ProposalDashboardAction.active.resources.order(required_supports: :asc, day_offset: :asc)
|
||||
@active_resources ||= ProposalDashboardAction.active.resources.order(required_supports: :asc, day_offset: :asc)
|
||||
end
|
||||
|
||||
def course
|
||||
@course ||= ProposalDashboardAction.course_for(proposal)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,6 +51,13 @@ class ProposalDashboardAction < ActiveRecord::Base
|
||||
.where('day_offset <= ?', (Date.today - published_at).to_i)
|
||||
end
|
||||
|
||||
scope :course_for, lambda { |proposal|
|
||||
active
|
||||
.resources
|
||||
.where('required_supports > ?', proposal.votes_for.size)
|
||||
.order(required_supports: :asc)
|
||||
}
|
||||
|
||||
def active_for?(proposal)
|
||||
published_at = proposal.published_at&.to_date || Date.today
|
||||
|
||||
@@ -58,10 +65,7 @@ class ProposalDashboardAction < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.next_goal_for(proposal)
|
||||
active
|
||||
.where('required_supports > ?', proposal.votes_for.size)
|
||||
.order(required_supports: :asc)
|
||||
&.first
|
||||
course_for(proposal).first
|
||||
end
|
||||
|
||||
def request_to_administrators?
|
||||
|
||||
27
app/views/proposals_dashboard/_goal.html.erb
Normal file
27
app/views/proposals_dashboard/_goal.html.erb
Normal file
@@ -0,0 +1,27 @@
|
||||
<div class="next-goal row">
|
||||
<div class="column small-12">
|
||||
<i class="fi-flag"></i>
|
||||
<strong>
|
||||
<%= t('.target_supports', count: number_with_precision(goal.required_supports, delimiter: '.', precision: 0)) %>
|
||||
</strong>
|
||||
</div>
|
||||
<div class="column small-12"> </div>
|
||||
|
||||
<div class="column small-12">
|
||||
<i class="fi-unlock"></i>
|
||||
<strong><%= goal.title %></strong>
|
||||
</div>
|
||||
<div class="column small-12 skip-icon">
|
||||
<p class="help-text"><%= t('.unlocked_resource') %></p>
|
||||
</div>
|
||||
|
||||
<% if goal.day_offset.positive? %>
|
||||
<div class="column small-12">
|
||||
<strong><%= t('.days', count: goal.day_offset) %></strong>
|
||||
</div>
|
||||
<div class="column small-12">
|
||||
<p class="help-text"><%= t('.ideal_time') %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -4,34 +4,22 @@
|
||||
<h5><%= t('.title') %></h5>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="row next-goal">
|
||||
<div class="column small-12">
|
||||
<i class="fi-flag"></i>
|
||||
<strong>
|
||||
<%= t('.target_supports', count: number_with_precision(next_goal.required_supports, delimiter: '.', precision: 0)) %>
|
||||
</strong>
|
||||
</div>
|
||||
<div class="column small-12"> </div>
|
||||
|
||||
<div id="next-goal" data-toggler=".hide">
|
||||
<%= render 'goal', goal: next_goal %>
|
||||
|
||||
<div class="column small-12">
|
||||
<i class="fi-unlock"></i>
|
||||
<strong><%= next_goal.title %></strong>
|
||||
</div>
|
||||
<div class="column small-12 skip-icon">
|
||||
<p class="help-text"><%= t('.unlocked_resource') %></p>
|
||||
</div>
|
||||
|
||||
<% if next_goal.day_offset.positive? %>
|
||||
<div class="column small-12">
|
||||
<strong><%= t('.days', count: next_goal.day_offset) %></strong>
|
||||
</div>
|
||||
<div class="column small-12">
|
||||
<p class="help-text"><%= t('.ideal_time') %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="column small-12">
|
||||
<%= link_to t('.see_complete_course'), '#' %>
|
||||
<a data-toggle="complete-course next-goal"><%= t('.see_complete_course') %></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if course.count > 1 %>
|
||||
<div class="hide" id="complete-course" data-toggler=".hide">
|
||||
<%= render partial: 'goal', collection: course %>,
|
||||
|
||||
<div class="column small-12">
|
||||
<a data-toggle="complete-course next-goal"><%= t('.hide_course') %></a>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -540,6 +540,9 @@ en:
|
||||
title: Recommended actions
|
||||
next_goal:
|
||||
title: Goal
|
||||
see_complete_course: Check out the complete course
|
||||
hide_course: Hide course
|
||||
goal:
|
||||
target_supports:
|
||||
one: Get %{count} support for your proposal
|
||||
other: Get %{count} supports for your proposal
|
||||
@@ -548,7 +551,6 @@ en:
|
||||
other: "%{count} days"
|
||||
unlocked_resource: Resource unlocked
|
||||
ideal_time: Ideal time
|
||||
see_complete_course: Check out the complete course
|
||||
dashboard:
|
||||
polls:
|
||||
index:
|
||||
|
||||
@@ -540,6 +540,9 @@ es:
|
||||
title: Acciones recomendadas
|
||||
next_goal:
|
||||
title: Meta
|
||||
see_complete_course: Ver ruta completa
|
||||
hide_course: Ocultar ruta
|
||||
goal:
|
||||
target_supports:
|
||||
one: Consigue %{count} apoyo para tu propuesta
|
||||
other: Consigue %{count} apoyos para tu propuesta
|
||||
@@ -548,7 +551,6 @@ es:
|
||||
other: "%{count} días"
|
||||
unlocked_resource: Recurso desbloqueado
|
||||
ideal_time: Tiempo ideal
|
||||
see_complete_course: Ver ruta completa
|
||||
dashboard:
|
||||
polls:
|
||||
index:
|
||||
|
||||
Reference in New Issue
Block a user