Merge pull request #3263 from Platoniq/dashboard-recommended-actions-page
Dashboard recommended actions page
This commit is contained in:
@@ -99,6 +99,7 @@
|
|||||||
.action-content {
|
.action-content {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-left: $line-height / 4;
|
margin-left: $line-height / 4;
|
||||||
|
max-width: 90%;
|
||||||
|
|
||||||
h4,
|
h4,
|
||||||
p {
|
p {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class Dashboard::ActionsController < Dashboard::BaseController
|
|||||||
authorize! :dashboard, proposal
|
authorize! :dashboard, proposal
|
||||||
|
|
||||||
Dashboard::ExecutedAction.create(proposal: proposal, action: dashboard_action, executed_at: Time.now)
|
Dashboard::ExecutedAction.create(proposal: proposal, action: dashboard_action, executed_at: Time.now)
|
||||||
redirect_to progress_proposal_dashboard_path(proposal.to_param)
|
redirect_to request.referer
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -39,4 +39,3 @@ class Dashboard::ActionsController < Dashboard::BaseController
|
|||||||
@dashboard_action ||= Dashboard::Action.find(params[:id])
|
@dashboard_action ||= Dashboard::Action.find(params[:id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class DashboardController < Dashboard::BaseController
|
class DashboardController < Dashboard::BaseController
|
||||||
helper_method :dashboard_action, :active_resources, :course
|
helper_method :dashboard_action, :active_resources, :course
|
||||||
|
before_action :set_done_and_pending_actions, only: [:recommended_actions, :progress]
|
||||||
|
|
||||||
def show
|
def show
|
||||||
authorize! :dashboard, proposal
|
authorize! :dashboard, proposal
|
||||||
@@ -20,6 +21,10 @@ class DashboardController < Dashboard::BaseController
|
|||||||
authorize! :dashboard, proposal
|
authorize! :dashboard, proposal
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def recommended_actions
|
||||||
|
authorize! :dashboard, proposal
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def active_resources
|
def active_resources
|
||||||
@@ -32,4 +37,9 @@ class DashboardController < Dashboard::BaseController
|
|||||||
def course
|
def course
|
||||||
@course ||= Dashboard::Action.course_for(proposal)
|
@course ||= Dashboard::Action.course_for(proposal)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_done_and_pending_actions
|
||||||
|
@done_actions = proposed_actions.joins(:proposals).where("proposals.id = ?", proposal.id)
|
||||||
|
@pending_actions = proposed_actions - @done_actions
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ module ProposalsDashboardHelper
|
|||||||
is_proposed_action_request? || (controller_name == 'dashboard' && action_name == 'progress')
|
is_proposed_action_request? || (controller_name == 'dashboard' && action_name == 'progress')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def recommended_actions_menu_active?
|
||||||
|
controller_name == "dashboard" && action_name == "recommended_actions"
|
||||||
|
end
|
||||||
|
|
||||||
def resources_menu_visible?(proposal, resources)
|
def resources_menu_visible?(proposal, resources)
|
||||||
can?(:manage_polls, proposal) || resources.any?
|
can?(:manage_polls, proposal) || resources.any?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,6 +13,13 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li class="section-title <%= 'is-active' if recommended_actions_menu_active? %>">
|
||||||
|
<span class="icon-checkmark-circle"></span>
|
||||||
|
<%= link_to recommended_actions_proposal_dashboard_path(proposal.to_param) do %>
|
||||||
|
<strong><%= t("dashboard.menu.recommended_actions") %></strong>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
|
||||||
<% if resources_menu_visible?(proposal, resources) %>
|
<% if resources_menu_visible?(proposal, resources) %>
|
||||||
<li class="section-title <%= 'is-active' if resources_menu_active? %>">
|
<li class="section-title <%= 'is-active' if resources_menu_active? %>">
|
||||||
<span class="icon-zip"></span>
|
<span class="icon-zip"></span>
|
||||||
|
|||||||
@@ -10,21 +10,32 @@
|
|||||||
<span class="unchecked"></span>
|
<span class="unchecked"></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="action-content">
|
<div class="action-content">
|
||||||
<h4><%= proposed_action.title %></h4>
|
<h4><%= proposed_action.title %></h4>
|
||||||
|
|
||||||
<% if proposed_action.proposals.where(id: proposal.id).any? %>
|
<% if proposed_action.proposals.where(id: proposal.id).any? %>
|
||||||
<p><%= l(proposed_action.executed_actions.find_by(proposal: proposal).executed_at.to_date) %></p>
|
<p class="inline">
|
||||||
<% else %>
|
<%= l(proposed_action.executed_actions.find_by(proposal: proposal).executed_at.to_date) %>
|
||||||
<% if proposed_action.short_description.present? %>
|
</p>
|
||||||
<p><%= proposed_action.short_description %></p>
|
<% if proposed_action.description.present? %>
|
||||||
|
<a data-toggle="proposed_action_description_<%= dom_id(proposed_action) %>">
|
||||||
|
<small><%= t("dashboard.recommended_actions.show_description") %></small>
|
||||||
|
</a>
|
||||||
|
<div id="proposed_action_description_<%= dom_id(proposed_action) %>" class="hide" data-toggler=".hide">
|
||||||
|
<%= proposed_action.description.html_safe %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<% if proposed_action.description.present? %>
|
||||||
|
<a data-toggle="proposed_action_description_<%= dom_id(proposed_action) %>">
|
||||||
|
<small><%= t("dashboard.recommended_actions.show_description") %></small>
|
||||||
|
</a>
|
||||||
|
<div id="proposed_action_description_<%= dom_id(proposed_action) %>" class="hide" data-toggler=".hide">
|
||||||
|
<%= proposed_action.description.html_safe %>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% proposed_action.links.each do |link| %>
|
<% proposed_action.links.each do |link| %>
|
||||||
<p><%= link_to link.label, link.url, target: "_blank" %></p>
|
<p><%= link_to link.label, link.url, target: "_blank" %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render partial: 'document', collection: proposed_action.documents %>
|
<%= render partial: 'document', collection: proposed_action.documents %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
<% if proposed_actions.any? %>
|
|
||||||
<h3 class="title"><%= t("dashboard.recommended_actions.title") %></h3>
|
|
||||||
|
|
||||||
<%= render partial: 'proposed_action', collection: proposed_actions %>
|
|
||||||
<% end %>
|
|
||||||
35
app/views/dashboard/_recommended_actions_by_status.html.erb
Normal file
35
app/views/dashboard/_recommended_actions_by_status.html.erb
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<h3 class="title"><%= t("dashboard.recommended_actions.#{status}_title") %></h3>
|
||||||
|
<% if actions.any? %>
|
||||||
|
<div id="proposed_actions_<%= status %>">
|
||||||
|
<% actions.first(4).each do |proposed_action| %>
|
||||||
|
<%= render 'proposed_action', proposed_action: proposed_action %>
|
||||||
|
<% end %>
|
||||||
|
<% if actions.count > 4 %>
|
||||||
|
<div class="margin small" id="proposed_actions_<%= status %>_link" data-toggler=".hide">
|
||||||
|
<% if toggle == true %>
|
||||||
|
<a id="see_proposed_actions_link_<%= status %>" data-toggle="last_proposed_actions_<%= status %> proposed_actions_<%= status %>_link">
|
||||||
|
<strong><%= t("dashboard.recommended_actions.see_proposed_actions") %></strong>
|
||||||
|
</a>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to recommended_actions_proposal_dashboard_path(proposal.to_param) do %>
|
||||||
|
<strong><%= t("dashboard.recommended_actions.goto_proposed_actions") %></strong>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% if toggle == true %>
|
||||||
|
<% if actions.count > 4 %>
|
||||||
|
<div id="last_proposed_actions_<%= status %>" class="hide" data-toggler=".hide">
|
||||||
|
<%= render partial: 'proposed_action', collection: actions - actions.first(4) %>
|
||||||
|
<div class="margin small">
|
||||||
|
<a data-toggle="last_proposed_actions_<%= status %> proposed_actions_<%= status %>_link">
|
||||||
|
<strong><%= t("dashboard.recommended_actions.hide_proposed_actions") %></strong>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<%= t("dashboard.recommended_actions.without_#{status}_actions") %>
|
||||||
|
<% end %>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<h2 class="title"><%= t("dashboard.recommended_actions.title") %></h2>
|
||||||
|
|
||||||
|
<%= render 'recommended_actions_by_status', status: 'pending', actions: @pending_actions, toggle: false %>
|
||||||
|
<%= render 'recommended_actions_by_status', status: 'done', actions: @done_actions, toggle: false %>
|
||||||
@@ -33,5 +33,5 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render 'next_goal' %>
|
<%= render 'next_goal' %>
|
||||||
<%= render 'recommended_actions' %>
|
<%= render 'summary_recommended_actions' %>
|
||||||
<%= render 'resources' %>
|
<%= render 'resources' %>
|
||||||
|
|||||||
4
app/views/dashboard/recommended_actions.html.erb
Normal file
4
app/views/dashboard/recommended_actions.html.erb
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<h2 class="title"><%= t("dashboard.recommended_actions.title") %></h3>
|
||||||
|
|
||||||
|
<%= render 'recommended_actions_by_status', status: 'pending', actions: @pending_actions, toggle: true %>
|
||||||
|
<%= render 'recommended_actions_by_status', status: 'done', actions: @done_actions, toggle: true %>
|
||||||
@@ -167,6 +167,7 @@ ignore_unused:
|
|||||||
- 'polls.index.filters.*'
|
- 'polls.index.filters.*'
|
||||||
- 'polls.index.section_header.*'
|
- 'polls.index.section_header.*'
|
||||||
- 'polls.index.orders.*'
|
- 'polls.index.orders.*'
|
||||||
|
- 'dashboard.recommended_actions.*'
|
||||||
- 'debates.index.select_order'
|
- 'debates.index.select_order'
|
||||||
- 'debates.index.orders.*'
|
- 'debates.index.orders.*'
|
||||||
- 'debates.index.section_header.*'
|
- 'debates.index.section_header.*'
|
||||||
|
|||||||
@@ -484,6 +484,7 @@ en:
|
|||||||
polls: Polls
|
polls: Polls
|
||||||
mailing: E-mail
|
mailing: E-mail
|
||||||
poster: Poster
|
poster: Poster
|
||||||
|
recommended_actions: Recommended actions
|
||||||
form:
|
form:
|
||||||
request: Request
|
request: Request
|
||||||
create_request:
|
create_request:
|
||||||
@@ -515,6 +516,14 @@ en:
|
|||||||
resource_locked: Resource locked
|
resource_locked: Resource locked
|
||||||
recommended_actions:
|
recommended_actions:
|
||||||
title: Recommended actions
|
title: Recommended actions
|
||||||
|
goto_proposed_actions: Go to recommended actions
|
||||||
|
see_proposed_actions: Check out recommended actions
|
||||||
|
hide_proposed_actions: Hide recommended actions
|
||||||
|
pending_title: Pending
|
||||||
|
show_description: Show description
|
||||||
|
without_pending_actions: No recommended actions pending
|
||||||
|
done_title: Done
|
||||||
|
without_done_actions: No recommended actions done
|
||||||
next_goal:
|
next_goal:
|
||||||
title: Goal
|
title: Goal
|
||||||
see_complete_course: Check out the complete course
|
see_complete_course: Check out the complete course
|
||||||
|
|||||||
@@ -484,6 +484,7 @@ es:
|
|||||||
polls: Encuestas
|
polls: Encuestas
|
||||||
mailing: Correo electrónico
|
mailing: Correo electrónico
|
||||||
poster: Póster
|
poster: Póster
|
||||||
|
recommended_actions: Acciones recomendadas
|
||||||
form:
|
form:
|
||||||
request: Solicitar
|
request: Solicitar
|
||||||
create_request:
|
create_request:
|
||||||
@@ -515,6 +516,14 @@ es:
|
|||||||
resource_locked: Recurso bloqueado
|
resource_locked: Recurso bloqueado
|
||||||
recommended_actions:
|
recommended_actions:
|
||||||
title: Acciones recomendadas
|
title: Acciones recomendadas
|
||||||
|
goto_proposed_actions: Ir a las acciones recomendadas
|
||||||
|
see_proposed_actions: Ver todas las acciones recomendadas
|
||||||
|
hide_proposed_actions: Ocultar acciones recomendadas
|
||||||
|
pending_title: Pendientes
|
||||||
|
show_description: Mostrar descripción
|
||||||
|
without_pending_actions: No hay acciones recomendadas pendientes
|
||||||
|
done_title: Realizadas
|
||||||
|
without_done_actions: No hay acciones recomendadas realizadas
|
||||||
next_goal:
|
next_goal:
|
||||||
title: Meta
|
title: Meta
|
||||||
see_complete_course: Ver ruta completa
|
see_complete_course: Ver ruta completa
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ resources :proposals do
|
|||||||
patch :publish
|
patch :publish
|
||||||
get :progress
|
get :progress
|
||||||
get :community
|
get :community
|
||||||
|
get :recommended_actions
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :resources, only: [:index], controller: 'dashboard/resources'
|
resources :resources, only: [:index], controller: 'dashboard/resources'
|
||||||
|
|||||||
@@ -49,6 +49,77 @@ feature "Proposal's dashboard" do
|
|||||||
scenario 'Dashboard progress show proposed actions' do
|
scenario 'Dashboard progress show proposed actions' do
|
||||||
action = create(:dashboard_action, :proposed_action, :active)
|
action = create(:dashboard_action, :proposed_action, :active)
|
||||||
|
|
||||||
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
|
|
||||||
|
expect(page).to have_content(action.title)
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Dashboard progress do not display from the fourth proposed actions", js: true do
|
||||||
|
create_list(:dashboard_action, 4, :proposed_action, :active)
|
||||||
|
action_5 = create(:dashboard_action, :proposed_action, :active)
|
||||||
|
|
||||||
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
|
|
||||||
|
expect(page).not_to have_content(action_5.title)
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Dashboard progress display link to new page for proposed actions when
|
||||||
|
there are more than four proposed actions", js: true do
|
||||||
|
create_list(:dashboard_action, 4, :proposed_action, :active)
|
||||||
|
action_5 = create(:dashboard_action, :proposed_action, :active)
|
||||||
|
|
||||||
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
|
|
||||||
|
expect(page).to have_link("Go to recommended actions")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Dashboard progress do not display link to new page for proposed actions
|
||||||
|
when there are less than five proposed actions", js: true do
|
||||||
|
create_list(:dashboard_action, 4, :proposed_action, :active)
|
||||||
|
|
||||||
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
|
|
||||||
|
expect(page).not_to have_link("Check out recommended actions")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Dashboard progress display proposed_action pending on his section" do
|
||||||
|
action = create(:dashboard_action, :proposed_action, :active)
|
||||||
|
|
||||||
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
|
|
||||||
|
within "#proposed_actions_pending" do
|
||||||
|
expect(page).to have_content(action.title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Dashboard progress display contains no results text when there are not
|
||||||
|
proposed_actions pending" do
|
||||||
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
|
|
||||||
|
expect(page).to have_content("No recommended actions pending")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Dashboard progress display proposed_action done on his section" do
|
||||||
|
action = create(:dashboard_action, :proposed_action, :active)
|
||||||
|
|
||||||
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
|
find(:css, "#dashboard_action_#{action.id}_execute").click
|
||||||
|
|
||||||
|
within "#proposed_actions_done" do
|
||||||
|
expect(page).to have_content(action.title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Dashboard progress display contains no results text when there are not
|
||||||
|
proposed_actions pending" do
|
||||||
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
|
|
||||||
|
expect(page).to have_content("No recommended actions done")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Dashboard progress can execute proposed action" do
|
||||||
|
action = create(:dashboard_action, :proposed_action, :active)
|
||||||
|
|
||||||
visit progress_proposal_dashboard_path(proposal)
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
expect(page).to have_content(action.title)
|
expect(page).to have_content(action.title)
|
||||||
|
|
||||||
@@ -229,4 +300,88 @@ feature "Proposal's dashboard" do
|
|||||||
expect(page).to have_content('Comments')
|
expect(page).to have_content('Comments')
|
||||||
expect(page).to have_link('Access the community')
|
expect(page).to have_link('Access the community')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Dashboard has a link to recommended_actions", js: true do
|
||||||
|
expect(page).to have_link("Recommended actions")
|
||||||
|
click_link "Recommended actions"
|
||||||
|
|
||||||
|
expect(page).to have_content("Recommended actions")
|
||||||
|
expect(page).to have_content("Pending")
|
||||||
|
expect(page).to have_content("Done")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "On recommended actions section display from the fourth proposed actions
|
||||||
|
when click see_proposed_actions_link", js: true do
|
||||||
|
create_list(:dashboard_action, 4, :proposed_action, :active)
|
||||||
|
action_5 = create(:dashboard_action, :proposed_action, :active)
|
||||||
|
|
||||||
|
visit recommended_actions_proposal_dashboard_path(proposal.to_param)
|
||||||
|
find(:css, "#see_proposed_actions_link_pending").click
|
||||||
|
|
||||||
|
expect(page).to have_content(action_5.title)
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "On recommended actions section do not display from the fourth proposed actions", js: true do
|
||||||
|
create_list(:dashboard_action, 4, :proposed_action, :active)
|
||||||
|
action_5 = create(:dashboard_action, :proposed_action, :active)
|
||||||
|
|
||||||
|
visit recommended_actions_proposal_dashboard_path(proposal.to_param)
|
||||||
|
|
||||||
|
expect(page).not_to have_content(action_5.title)
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "On recommended actions section display link for toggle when there are
|
||||||
|
more than four proposed actions", js: true do
|
||||||
|
create_list(:dashboard_action, 4, :proposed_action, :active)
|
||||||
|
action_5 = create(:dashboard_action, :proposed_action, :active)
|
||||||
|
|
||||||
|
visit recommended_actions_proposal_dashboard_path(proposal.to_param)
|
||||||
|
|
||||||
|
expect(page).to have_content("Check out recommended actions")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "On recommended actions section do not display link for toggle when
|
||||||
|
there are less than five proposed actions", js: true do
|
||||||
|
create_list(:dashboard_action, 4, :proposed_action, :active)
|
||||||
|
|
||||||
|
visit recommended_actions_proposal_dashboard_path(proposal.to_param)
|
||||||
|
|
||||||
|
expect(page).not_to have_link("Check out recommended actions")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "On recommended actions section display proposed_action pending on his section" do
|
||||||
|
action = create(:dashboard_action, :proposed_action, :active)
|
||||||
|
|
||||||
|
visit recommended_actions_proposal_dashboard_path(proposal.to_param)
|
||||||
|
|
||||||
|
within "#proposed_actions_pending" do
|
||||||
|
expect(page).to have_content(action.title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "On recommended actions section contains no_results_text when there are
|
||||||
|
not proposed_actions pending" do
|
||||||
|
visit recommended_actions_proposal_dashboard_path(proposal.to_param)
|
||||||
|
|
||||||
|
expect(page).to have_content("No recommended actions pending")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "On recommended actions section display proposed_action done on his section" do
|
||||||
|
action = create(:dashboard_action, :proposed_action, :active)
|
||||||
|
|
||||||
|
visit recommended_actions_proposal_dashboard_path(proposal.to_param)
|
||||||
|
find(:css, "#dashboard_action_#{action.id}_execute").click
|
||||||
|
|
||||||
|
within "#proposed_actions_done" do
|
||||||
|
expect(page).to have_content(action.title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "On recommended actions section contains no_results_text when there are
|
||||||
|
not proposed_actions pending" do
|
||||||
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
|
|
||||||
|
expect(page).to have_content("No recommended actions done")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user