Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def share
@plan = Plan.find(params[:id])
if @plan.present?
authorize @plan
@plan_roles = @plan.roles
@plan_roles = @plan.roles.where(active: true)
else
redirect_to(plans_path)
end
Expand All @@ -315,7 +315,7 @@ def request_feedback
@plan = Plan.find(params[:id])
if @plan.present?
authorize @plan
@plan_roles = @plan.roles
@plan_roles = @plan.roles.where(active: true)
else
redirect_to(plans_path)
end
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/roles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def create
# rubocop:enable Layout/LineLength
else
user = User.where_case_insensitive("email", role_params[:user][:email]).first
if Role.find_by(plan: @role.plan, user: user) # role already exists
if user.present? &&
Role.where(plan: @role.plan, user: user, active: true)
.count
.positive? # role already exists

flash[:notice] = _("Plan is already shared with %{email}.") % {
email: role_params[:user][:email]
}
Expand Down
2 changes: 1 addition & 1 deletion app/views/plans/_share_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<h2><%= _('Manage collaborators')%></h2>
<p><%= _('Invite specific people to read, edit, or administer your plan. Invitees will receive an email notification that they have access to this plan.') %></p>
<% if @plan.roles.any? then %>
<% if @plan_roles.any? then %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch!

<table class="table table-hover table-bordered" id="collaborator-table">
<thead>
<tr>
Expand Down