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
|
class ProposalsDashboardController < Dashboard::BaseController
|
||||||
helper_method :proposal_dashboard_action, :active_resources
|
helper_method :proposal_dashboard_action, :active_resources, :course
|
||||||
|
|
||||||
def index
|
def index
|
||||||
authorize! :dashboard, proposal
|
authorize! :dashboard, proposal
|
||||||
@@ -69,6 +69,10 @@ class ProposalsDashboardController < Dashboard::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def active_resources
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -51,6 +51,13 @@ class ProposalDashboardAction < ActiveRecord::Base
|
|||||||
.where('day_offset <= ?', (Date.today - published_at).to_i)
|
.where('day_offset <= ?', (Date.today - published_at).to_i)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scope :course_for, lambda { |proposal|
|
||||||
|
active
|
||||||
|
.resources
|
||||||
|
.where('required_supports > ?', proposal.votes_for.size)
|
||||||
|
.order(required_supports: :asc)
|
||||||
|
}
|
||||||
|
|
||||||
def active_for?(proposal)
|
def active_for?(proposal)
|
||||||
published_at = proposal.published_at&.to_date || Date.today
|
published_at = proposal.published_at&.to_date || Date.today
|
||||||
|
|
||||||
@@ -58,10 +65,7 @@ class ProposalDashboardAction < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.next_goal_for(proposal)
|
def self.next_goal_for(proposal)
|
||||||
active
|
course_for(proposal).first
|
||||||
.where('required_supports > ?', proposal.votes_for.size)
|
|
||||||
.order(required_supports: :asc)
|
|
||||||
&.first
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_to_administrators?
|
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>
|
<h5><%= t('.title') %></h5>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
<div class="row next-goal">
|
|
||||||
<div class="column small-12">
|
<div id="next-goal" data-toggler=".hide">
|
||||||
<i class="fi-flag"></i>
|
<%= render 'goal', goal: next_goal %>
|
||||||
<strong>
|
|
||||||
<%= t('.target_supports', count: number_with_precision(next_goal.required_supports, delimiter: '.', precision: 0)) %>
|
|
||||||
</strong>
|
|
||||||
</div>
|
|
||||||
<div class="column small-12"> </div>
|
|
||||||
|
|
||||||
<div class="column small-12">
|
<div class="column small-12">
|
||||||
<i class="fi-unlock"></i>
|
<a data-toggle="complete-course next-goal"><%= t('.see_complete_course') %></a>
|
||||||
<strong><%= next_goal.title %></strong>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="column small-12 skip-icon">
|
|
||||||
<p class="help-text"><%= t('.unlocked_resource') %></p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if next_goal.day_offset.positive? %>
|
<% if course.count > 1 %>
|
||||||
|
<div class="hide" id="complete-course" data-toggler=".hide">
|
||||||
|
<%= render partial: 'goal', collection: course %>,
|
||||||
|
|
||||||
<div class="column small-12">
|
<div class="column small-12">
|
||||||
<strong><%= t('.days', count: next_goal.day_offset) %></strong>
|
<a data-toggle="complete-course next-goal"><%= t('.hide_course') %></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="column small-12">
|
|
||||||
<p class="help-text"><%= t('.ideal_time') %></p>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="column small-12">
|
|
||||||
<%= link_to t('.see_complete_course'), '#' %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -540,6 +540,9 @@ en:
|
|||||||
title: Recommended actions
|
title: Recommended actions
|
||||||
next_goal:
|
next_goal:
|
||||||
title: Goal
|
title: Goal
|
||||||
|
see_complete_course: Check out the complete course
|
||||||
|
hide_course: Hide course
|
||||||
|
goal:
|
||||||
target_supports:
|
target_supports:
|
||||||
one: Get %{count} support for your proposal
|
one: Get %{count} support for your proposal
|
||||||
other: Get %{count} supports for your proposal
|
other: Get %{count} supports for your proposal
|
||||||
@@ -548,7 +551,6 @@ en:
|
|||||||
other: "%{count} days"
|
other: "%{count} days"
|
||||||
unlocked_resource: Resource unlocked
|
unlocked_resource: Resource unlocked
|
||||||
ideal_time: Ideal time
|
ideal_time: Ideal time
|
||||||
see_complete_course: Check out the complete course
|
|
||||||
dashboard:
|
dashboard:
|
||||||
polls:
|
polls:
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -540,6 +540,9 @@ es:
|
|||||||
title: Acciones recomendadas
|
title: Acciones recomendadas
|
||||||
next_goal:
|
next_goal:
|
||||||
title: Meta
|
title: Meta
|
||||||
|
see_complete_course: Ver ruta completa
|
||||||
|
hide_course: Ocultar ruta
|
||||||
|
goal:
|
||||||
target_supports:
|
target_supports:
|
||||||
one: Consigue %{count} apoyo para tu propuesta
|
one: Consigue %{count} apoyo para tu propuesta
|
||||||
other: Consigue %{count} apoyos para tu propuesta
|
other: Consigue %{count} apoyos para tu propuesta
|
||||||
@@ -548,7 +551,6 @@ 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
|
||||||
see_complete_course: Ver ruta completa
|
|
||||||
dashboard:
|
dashboard:
|
||||||
polls:
|
polls:
|
||||||
index:
|
index:
|
||||||
|
|||||||
Reference in New Issue
Block a user