Create new messages section for proposal's dashboard

This commit is contained in:
decabeza
2019-05-30 11:46:51 +02:00
parent c1d5c7b1b7
commit 4c5b2723f4
10 changed files with 102 additions and 23 deletions

View File

@@ -1,9 +1,9 @@
class DashboardController < Dashboard::BaseController
helper_method :dashboard_action, :active_resources, :course
before_action :set_done_and_pending_actions, only: [:recommended_actions, :progress]
before_action :authorize_dashboard, only: [:show, :progress, :community, :recommended_actions, :messages]
def show
authorize! :dashboard, proposal
end
def publish
@@ -14,15 +14,15 @@ class DashboardController < Dashboard::BaseController
end
def progress
authorize! :dashboard, proposal
end
def community
authorize! :dashboard, proposal
end
def recommended_actions
authorize! :dashboard, proposal
end
def messages
end
private
@@ -42,4 +42,8 @@ class DashboardController < Dashboard::BaseController
@done_actions = proposed_actions.joins(:proposals).where("proposals.id = ?", proposal.id)
@pending_actions = proposed_actions - @done_actions
end
def authorize_dashboard
authorize! :dashboard, proposal
end
end

View File

@@ -7,6 +7,10 @@ module ProposalsDashboardHelper
controller_name == "dashboard" && action_name == "community"
end
def messages_menu_active?
controller_name == "dashboard" && action_name == "messages"
end
def progress_menu_active?
is_proposed_action_request? || (controller_name == "dashboard" && action_name == "progress")
end

View File

@@ -35,9 +35,9 @@
<ul class="no-bullet resources">
<% if can?(:manage_polls, proposal) %>
<li>
<%= link_to proposal_dashboard_polls_path(proposal.to_param),
class: "#{'submenu-active' if polls_menu_active?}" do %>
<span data-tooltip title="<%= Setting['proposals.poll_short_title'] ||
<%= link_to proposal_dashboard_polls_path(proposal),
class: "#{"submenu-active" if polls_menu_active?}" do %>
<span data-tooltip title="<%= Setting["proposals.poll_short_title"] ||
t("dashboard.menu.polls") %>">
<%= t("dashboard.menu.polls") %>
</span>
@@ -47,9 +47,9 @@
<% if can?(:manage_mailing, proposal) %>
<li>
<%= link_to new_proposal_dashboard_mailing_path(proposal.to_param),
class: "#{'submenu-active' if mailing_menu_active?}" do %>
<span data-tooltip title="<%= Setting['proposals.email_short_title'] ||
<%= link_to new_proposal_dashboard_mailing_path(proposal),
class: "#{"submenu-active" if mailing_menu_active?}" do %>
<span data-tooltip title="<%= Setting["proposals.email_short_title"] ||
t("dashboard.menu.mailing") %>">
<%= t("dashboard.menu.mailing") %>
</span>
@@ -59,9 +59,9 @@
<% if can?(:manage_poster, proposal) %>
<li>
<%= link_to new_proposal_dashboard_poster_path(proposal.to_param),
class: "#{'submenu-active' if poster_menu_active?}" do %>
<span data-tooltip title="<%= Setting['proposals.poster_short_title'] ||
<%= link_to new_proposal_dashboard_poster_path(proposal),
class: "#{"submenu-active" if poster_menu_active?}" do %>
<span data-tooltip title="<%= Setting["proposals.poster_short_title"] ||
t("dashboard.menu.poster") %>">
<%= t("dashboard.menu.poster") %>
</span>
@@ -85,8 +85,15 @@
<li class="section-title <%= 'is-active' if community_menu_active? %>">
<span class="icon-organizations"></span>
<%= link_to community_proposal_dashboard_path(proposal.to_param) do %>
<%= link_to community_proposal_dashboard_path(proposal) do %>
<strong><%= t("dashboard.menu.community") %></strong>
<% end %>
</li>
<li class="section-title <%= "is-active" if messages_menu_active? %>">
<span class="icon-letter"></span>
<%= link_to messages_proposal_dashboard_path(proposal) do %>
<strong><%= t("dashboard.menu.messages") %></strong>
<% end %>
</li>
</ul>

View File

@@ -0,0 +1,7 @@
<% content_for :action_title, t("dashboard.menu.messages") %>
<%= link_to t("dashboard.messages.send_notification"),
new_proposal_notification_path(proposal_id: proposal.id), class: "button" %>
<%= link_to t("dashboard.messages.previous_notifications"),
proposal_path(proposal, anchor: "tab-notifications"), class: "button hollow" %>

View File

@@ -483,6 +483,7 @@ en:
mailing: E-mail
poster: Poster
recommended_actions: Recommended actions
messages: Message to users
form:
request: Request
create_request:
@@ -544,6 +545,9 @@ en:
debates: Debates
comments: Comments
latest_comments: Latest messages
messages:
send_notification: Send message to proposal supporters
previous_notifications: See previous notifications
polls:
index:
title: Polls

View File

@@ -483,6 +483,7 @@ es:
mailing: Correo electrónico
poster: Póster
recommended_actions: Acciones recomendadas
messages: Mensajes a usuarios
form:
request: Solicitar
create_request:
@@ -544,6 +545,9 @@ es:
debates: Debates
comments: Comentarios
latest_comments: Últimos mensajes
messages:
send_notification: Enviar mensaje a los que han apoyado la propuesta
previous_notifications: Ver notificaciones anteriores
polls:
index:
title: Encuestas

View File

@@ -5,6 +5,7 @@ resources :proposals do
get :progress
get :community
get :recommended_actions
get :messages
end
resources :resources, only: [:index], controller: "dashboard/resources"

View File

@@ -358,6 +358,37 @@ describe "Proposal's dashboard" do
expect(page).to have_content("Done")
end
scenario "Dashboard has a link to messages" do
expect(page).to have_link("Message to users")
within("#side_menu") do
click_link "Message to users"
end
expect(page).to have_link("Send message to proposal supporters")
expect(page).to have_link("See previous notifications")
end
scenario "Dashboard has a link to send message to proposal supporters" do
visit messages_proposal_dashboard_path(proposal)
click_link("Send message to proposal supporters")
fill_in "Title", with: "Thank you for supporting my proposal"
fill_in "Message", with: "Please share it with others!"
click_button "Send message"
expect(page).to have_content "Your message has been sent correctly."
expect(page).to have_content "Thank you for supporting my proposal"
expect(page).to have_content "Please share it with others!"
end
scenario "Dashboard has a link to see previous notifications" do
visit messages_proposal_dashboard_path(proposal)
expect(page).to have_link("See previous notifications", href: proposal_path(proposal,
anchor: "tab-notifications"))
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)

View File

@@ -4,15 +4,19 @@ describe "Proposal Notifications" do
scenario "Send a notification" do
author = create(:user)
proposal = create(:proposal, author: author)
create(:proposal, author: author)
login_as(author)
visit root_path
click_link "My content"
click_link proposal.title
click_link "Access the community"
click_link "Send message to the community"
click_link "Dashboard"
within("#side_menu") do
click_link "Message to users"
end
click_link "Send message to proposal supporters"
fill_in "proposal_notification_title", with: "Thank you for supporting my proposal"
fill_in "proposal_notification_body", with: "Please share it with "\
@@ -178,9 +182,19 @@ describe "Proposal Notifications" do
proposal = create(:proposal, author: author)
login_as(author)
visit community_path(proposal.community)
visit root_path
expect(page).to have_link "Send message to the community"
click_link "My content"
within("#proposal_#{proposal.id}") do
click_link "Dashboard"
end
within("#side_menu") do
click_link "Message to users"
end
expect(page).to have_link "Send message to proposal supporters"
end
scenario "Accessing form directly" do

View File

@@ -20,11 +20,14 @@ module Notifications
click_link "My content"
within("#proposal_#{proposal.id}") do
click_link proposal.title
click_link "Dashboard"
end
click_link "Access the community"
click_link "Send message to the community"
within("#side_menu") do
click_link "Message to users"
end
click_link "Send message to proposal supporters"
fill_in "proposal_notification_title", with: "Thanks for supporting proposal: #{proposal.title}"
fill_in "proposal_notification_body", with: "Please share it with others! #{proposal.summary}"