Create new messages section for proposal's dashboard
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
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]
|
before_action :set_done_and_pending_actions, only: [:recommended_actions, :progress]
|
||||||
|
before_action :authorize_dashboard, only: [:show, :progress, :community, :recommended_actions, :messages]
|
||||||
|
|
||||||
def show
|
def show
|
||||||
authorize! :dashboard, proposal
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def publish
|
def publish
|
||||||
@@ -14,15 +14,15 @@ class DashboardController < Dashboard::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def progress
|
def progress
|
||||||
authorize! :dashboard, proposal
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def community
|
def community
|
||||||
authorize! :dashboard, proposal
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def recommended_actions
|
def recommended_actions
|
||||||
authorize! :dashboard, proposal
|
end
|
||||||
|
|
||||||
|
def messages
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -42,4 +42,8 @@ class DashboardController < Dashboard::BaseController
|
|||||||
@done_actions = proposed_actions.joins(:proposals).where("proposals.id = ?", proposal.id)
|
@done_actions = proposed_actions.joins(:proposals).where("proposals.id = ?", proposal.id)
|
||||||
@pending_actions = proposed_actions - @done_actions
|
@pending_actions = proposed_actions - @done_actions
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def authorize_dashboard
|
||||||
|
authorize! :dashboard, proposal
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ module ProposalsDashboardHelper
|
|||||||
controller_name == "dashboard" && action_name == "community"
|
controller_name == "dashboard" && action_name == "community"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def messages_menu_active?
|
||||||
|
controller_name == "dashboard" && action_name == "messages"
|
||||||
|
end
|
||||||
|
|
||||||
def progress_menu_active?
|
def progress_menu_active?
|
||||||
is_proposed_action_request? || (controller_name == "dashboard" && action_name == "progress")
|
is_proposed_action_request? || (controller_name == "dashboard" && action_name == "progress")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -35,9 +35,9 @@
|
|||||||
<ul class="no-bullet resources">
|
<ul class="no-bullet resources">
|
||||||
<% if can?(:manage_polls, proposal) %>
|
<% if can?(:manage_polls, proposal) %>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to proposal_dashboard_polls_path(proposal.to_param),
|
<%= link_to proposal_dashboard_polls_path(proposal),
|
||||||
class: "#{'submenu-active' if polls_menu_active?}" do %>
|
class: "#{"submenu-active" if polls_menu_active?}" do %>
|
||||||
<span data-tooltip title="<%= Setting['proposals.poll_short_title'] ||
|
<span data-tooltip title="<%= Setting["proposals.poll_short_title"] ||
|
||||||
t("dashboard.menu.polls") %>">
|
t("dashboard.menu.polls") %>">
|
||||||
<%= t("dashboard.menu.polls") %>
|
<%= t("dashboard.menu.polls") %>
|
||||||
</span>
|
</span>
|
||||||
@@ -47,9 +47,9 @@
|
|||||||
|
|
||||||
<% if can?(:manage_mailing, proposal) %>
|
<% if can?(:manage_mailing, proposal) %>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to new_proposal_dashboard_mailing_path(proposal.to_param),
|
<%= link_to new_proposal_dashboard_mailing_path(proposal),
|
||||||
class: "#{'submenu-active' if mailing_menu_active?}" do %>
|
class: "#{"submenu-active" if mailing_menu_active?}" do %>
|
||||||
<span data-tooltip title="<%= Setting['proposals.email_short_title'] ||
|
<span data-tooltip title="<%= Setting["proposals.email_short_title"] ||
|
||||||
t("dashboard.menu.mailing") %>">
|
t("dashboard.menu.mailing") %>">
|
||||||
<%= t("dashboard.menu.mailing") %>
|
<%= t("dashboard.menu.mailing") %>
|
||||||
</span>
|
</span>
|
||||||
@@ -59,9 +59,9 @@
|
|||||||
|
|
||||||
<% if can?(:manage_poster, proposal) %>
|
<% if can?(:manage_poster, proposal) %>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to new_proposal_dashboard_poster_path(proposal.to_param),
|
<%= link_to new_proposal_dashboard_poster_path(proposal),
|
||||||
class: "#{'submenu-active' if poster_menu_active?}" do %>
|
class: "#{"submenu-active" if poster_menu_active?}" do %>
|
||||||
<span data-tooltip title="<%= Setting['proposals.poster_short_title'] ||
|
<span data-tooltip title="<%= Setting["proposals.poster_short_title"] ||
|
||||||
t("dashboard.menu.poster") %>">
|
t("dashboard.menu.poster") %>">
|
||||||
<%= t("dashboard.menu.poster") %>
|
<%= t("dashboard.menu.poster") %>
|
||||||
</span>
|
</span>
|
||||||
@@ -85,8 +85,15 @@
|
|||||||
|
|
||||||
<li class="section-title <%= 'is-active' if community_menu_active? %>">
|
<li class="section-title <%= 'is-active' if community_menu_active? %>">
|
||||||
<span class="icon-organizations"></span>
|
<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>
|
<strong><%= t("dashboard.menu.community") %></strong>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</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>
|
</ul>
|
||||||
|
|||||||
7
app/views/dashboard/messages.html.erb
Normal file
7
app/views/dashboard/messages.html.erb
Normal 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" %>
|
||||||
@@ -483,6 +483,7 @@ en:
|
|||||||
mailing: E-mail
|
mailing: E-mail
|
||||||
poster: Poster
|
poster: Poster
|
||||||
recommended_actions: Recommended actions
|
recommended_actions: Recommended actions
|
||||||
|
messages: Message to users
|
||||||
form:
|
form:
|
||||||
request: Request
|
request: Request
|
||||||
create_request:
|
create_request:
|
||||||
@@ -544,6 +545,9 @@ en:
|
|||||||
debates: Debates
|
debates: Debates
|
||||||
comments: Comments
|
comments: Comments
|
||||||
latest_comments: Latest messages
|
latest_comments: Latest messages
|
||||||
|
messages:
|
||||||
|
send_notification: Send message to proposal supporters
|
||||||
|
previous_notifications: See previous notifications
|
||||||
polls:
|
polls:
|
||||||
index:
|
index:
|
||||||
title: Polls
|
title: Polls
|
||||||
|
|||||||
@@ -483,6 +483,7 @@ es:
|
|||||||
mailing: Correo electrónico
|
mailing: Correo electrónico
|
||||||
poster: Póster
|
poster: Póster
|
||||||
recommended_actions: Acciones recomendadas
|
recommended_actions: Acciones recomendadas
|
||||||
|
messages: Mensajes a usuarios
|
||||||
form:
|
form:
|
||||||
request: Solicitar
|
request: Solicitar
|
||||||
create_request:
|
create_request:
|
||||||
@@ -544,6 +545,9 @@ es:
|
|||||||
debates: Debates
|
debates: Debates
|
||||||
comments: Comentarios
|
comments: Comentarios
|
||||||
latest_comments: Últimos mensajes
|
latest_comments: Últimos mensajes
|
||||||
|
messages:
|
||||||
|
send_notification: Enviar mensaje a los que han apoyado la propuesta
|
||||||
|
previous_notifications: Ver notificaciones anteriores
|
||||||
polls:
|
polls:
|
||||||
index:
|
index:
|
||||||
title: Encuestas
|
title: Encuestas
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ resources :proposals do
|
|||||||
get :progress
|
get :progress
|
||||||
get :community
|
get :community
|
||||||
get :recommended_actions
|
get :recommended_actions
|
||||||
|
get :messages
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :resources, only: [:index], controller: "dashboard/resources"
|
resources :resources, only: [:index], controller: "dashboard/resources"
|
||||||
|
|||||||
@@ -358,6 +358,37 @@ describe "Proposal's dashboard" do
|
|||||||
expect(page).to have_content("Done")
|
expect(page).to have_content("Done")
|
||||||
end
|
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
|
scenario "On recommended actions section display from the fourth proposed actions
|
||||||
when click see_proposed_actions_link", js: true do
|
when click see_proposed_actions_link", js: true do
|
||||||
create_list(:dashboard_action, 4, :proposed_action, :active)
|
create_list(:dashboard_action, 4, :proposed_action, :active)
|
||||||
|
|||||||
@@ -4,15 +4,19 @@ describe "Proposal Notifications" do
|
|||||||
|
|
||||||
scenario "Send a notification" do
|
scenario "Send a notification" do
|
||||||
author = create(:user)
|
author = create(:user)
|
||||||
proposal = create(:proposal, author: author)
|
create(:proposal, author: author)
|
||||||
|
|
||||||
login_as(author)
|
login_as(author)
|
||||||
visit root_path
|
visit root_path
|
||||||
|
|
||||||
click_link "My content"
|
click_link "My content"
|
||||||
click_link proposal.title
|
click_link "Dashboard"
|
||||||
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: "Thank you for supporting my proposal"
|
fill_in "proposal_notification_title", with: "Thank you for supporting my proposal"
|
||||||
fill_in "proposal_notification_body", with: "Please share it with "\
|
fill_in "proposal_notification_body", with: "Please share it with "\
|
||||||
@@ -178,9 +182,19 @@ describe "Proposal Notifications" do
|
|||||||
proposal = create(:proposal, author: author)
|
proposal = create(:proposal, author: author)
|
||||||
|
|
||||||
login_as(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
|
end
|
||||||
|
|
||||||
scenario "Accessing form directly" do
|
scenario "Accessing form directly" do
|
||||||
|
|||||||
@@ -20,11 +20,14 @@ module Notifications
|
|||||||
click_link "My content"
|
click_link "My content"
|
||||||
|
|
||||||
within("#proposal_#{proposal.id}") do
|
within("#proposal_#{proposal.id}") do
|
||||||
click_link proposal.title
|
click_link "Dashboard"
|
||||||
end
|
end
|
||||||
|
|
||||||
click_link "Access the community"
|
within("#side_menu") do
|
||||||
click_link "Send message to the community"
|
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_title", with: "Thanks for supporting proposal: #{proposal.title}"
|
||||||
fill_in "proposal_notification_body", with: "Please share it with others! #{proposal.summary}"
|
fill_in "proposal_notification_body", with: "Please share it with others! #{proposal.summary}"
|
||||||
|
|||||||
Reference in New Issue
Block a user