Add new section on sidebar menu for recommended proposals
- Display recommended_proposals on new section as goals with toogle. - Divide recommended actions into actions done and actions pending to clarify the information to the user as summary_recomended_actions.
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -21,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
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -1,17 +1,36 @@
|
|||||||
<h2 class="title"><%= t("dashboard.recommended_actions.#{status}_title") %></h2>
|
<h2 class="title"><%= t("dashboard.recommended_actions.#{status}_title") %></h2>
|
||||||
<% if actions.any? %>
|
<% if actions.any? %>
|
||||||
<div id="proposed_actions" data-toggler=".hide">
|
<div id="proposed_actions_<%= status %>" data-toggler=".hide">
|
||||||
<% actions.first(4).each do |proposed_action| %>
|
<% actions.first(4).each do |proposed_action| %>
|
||||||
<%= render 'proposed_action', proposed_action: proposed_action %>
|
<%= render 'proposed_action', proposed_action: proposed_action %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if actions.count > 4 %>
|
<% if actions.count > 4 %>
|
||||||
<div class="margin small">
|
<div class="margin small">
|
||||||
|
<% if toggle == true %>
|
||||||
|
<a id="see_proposed_actions_link_<%= status %>" data-toggle="last_proposed_actions_<%= status %> proposed_actions_<%= status %>">
|
||||||
|
<%= t("dashboard.recommended_actions.see_proposed_actions") %>
|
||||||
|
</a>
|
||||||
|
<% else %>
|
||||||
<%= link_to recommended_actions_proposal_dashboard_path(proposal.to_param) do %>
|
<%= link_to recommended_actions_proposal_dashboard_path(proposal.to_param) do %>
|
||||||
<strong><%= t("dashboard.recommended_actions.see_proposed_actions") %></strong>
|
<strong><%= t("dashboard.recommended_actions.see_proposed_actions") %></strong>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</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 %>
|
||||||
|
|
||||||
|
<div class="margin small">
|
||||||
|
<a data-toggle="last_proposed_actions_<%= status %> proposed_actions_<%= status %>">
|
||||||
|
<%= t("dashboard.recommended_actions.hide_proposed_actions") %>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= t("dashboard.recommended_actions.without_#{status}_actions") %>
|
<%= t("dashboard.recommended_actions.without_#{status}_actions") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
4
app/views/dashboard/recommended_actions.html.erb
Normal file
4
app/views/dashboard/recommended_actions.html.erb
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<h3 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 %>
|
||||||
@@ -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:
|
||||||
@@ -518,7 +519,9 @@ en:
|
|||||||
see_proposed_actions: Check out recommended actions
|
see_proposed_actions: Check out recommended actions
|
||||||
hide_proposed_actions: Hide recommended actions
|
hide_proposed_actions: Hide recommended actions
|
||||||
pending_title: Recommended actions pending
|
pending_title: Recommended actions pending
|
||||||
|
without_pending_actions: No recommended actions pending
|
||||||
done_title: Recommended actions done
|
done_title: Recommended actions 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:
|
||||||
@@ -518,7 +519,9 @@ es:
|
|||||||
see_proposed_actions: Ver todas las acciones recomendadas
|
see_proposed_actions: Ver todas las acciones recomendadas
|
||||||
hide_proposed_actions: Ocultar acciones recomendadas
|
hide_proposed_actions: Ocultar acciones recomendadas
|
||||||
pending_title: Acciones recomendadas pendientes
|
pending_title: Acciones recomendadas pendientes
|
||||||
|
without_pending_actions: No hay acciones recomendadas pendientes
|
||||||
done_title: Acciones recomendadas realizadas
|
done_title: Acciones recomendadas 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'
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ feature "Proposal's dashboard" do
|
|||||||
expect(page).not_to have_content(action_5.title)
|
expect(page).not_to have_content(action_5.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Dashboard progress display link to new page for proposed actions when there are more than four proposed actions", js: true do
|
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)
|
create_list(:dashboard_action, 4, :proposed_action, :active)
|
||||||
action_5 = create(:dashboard_action, :proposed_action, :active)
|
action_5 = create(:dashboard_action, :proposed_action, :active)
|
||||||
|
|
||||||
@@ -72,7 +73,8 @@ feature "Proposal's dashboard" do
|
|||||||
expect(page).to have_link("Check out recommended actions")
|
expect(page).to have_link("Check out recommended actions")
|
||||||
end
|
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
|
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)
|
create_list(:dashboard_action, 4, :proposed_action, :active)
|
||||||
|
|
||||||
visit progress_proposal_dashboard_path(proposal)
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
@@ -90,7 +92,8 @@ feature "Proposal's dashboard" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Dashboard progress display no results text when there are not proposed_actions pending" do
|
scenario "Dashboard progress display contains no results text when there are not
|
||||||
|
proposed_actions pending" do
|
||||||
visit progress_proposal_dashboard_path(proposal)
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
|
|
||||||
expect(page).to have_content("No recommended actions pending")
|
expect(page).to have_content("No recommended actions pending")
|
||||||
@@ -107,7 +110,8 @@ feature "Proposal's dashboard" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Dashboard progress display no results text when there are not proposed_actions pending" do
|
scenario "Dashboard progress display contains no results text when there are not
|
||||||
|
proposed_actions pending" do
|
||||||
visit progress_proposal_dashboard_path(proposal)
|
visit progress_proposal_dashboard_path(proposal)
|
||||||
|
|
||||||
expect(page).to have_content("No recommended actions done")
|
expect(page).to have_content("No recommended actions done")
|
||||||
@@ -223,4 +227,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("Recommended actions pending")
|
||||||
|
expect(page).to have_content("Recommended actions 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