Fix project card menu visibility [SCI-5328]

This commit is contained in:
Oleksii Kriuchykhin 2020-12-30 22:17:04 +01:00
parent 67b3f853d7
commit 49dc56caf2

View file

@ -1,72 +1,70 @@
<% cache [current_user, project] do %>
<% active = !project.archived %>
<% if (active && (can_manage_project?(project) || can_archive_project?(project))) || (!active && can_restore_project?(project)) %>
<div class="dropdown project-actions-menu <%= 'new-comments' if has_unseen_comments?(project) %>">
<button class="btn btn-light dropdown-toggle icon-btn" type="button" id="projectActionsDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fas fa-ellipsis-h"></i>
</button>
<% project_form = nil %>
<%= form_for project, format: :json, method: :put, remote: true, html: {id: "edit-project-#{view}-form-#{project.id}" } do |f| %>
<% project_form = f %>
<%= f.hidden_field :archived, value: active %>
<div class="dropdown project-actions-menu <%= 'new-comments' if has_unseen_comments?(project) %>">
<button class="btn btn-light dropdown-toggle icon-btn" type="button" id="projectActionsDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fas fa-ellipsis-h"></i>
</button>
<% project_form = nil %>
<%= form_for project, format: :json, method: :put, remote: true, html: { id: "edit-project-#{view}-form-#{project.id}" } do |f| %>
<% project_form = f %>
<%= f.hidden_field :archived, value: !project.archived %>
<% end %>
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="projectActionsDropdown">
<!-- Edit project -->
<% if project.active? && can_manage_project?(project) %>
<li>
<a href="<%= edit_project_path(project, format: :json) %>"
class="edit-project-btn"
data-action="edit"
data-remote="true">
<i class="fas fa-pen"></i>
<span><%= t('projects.index.edit_option') %></span>
</a>
</li>
<% end %>
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="projectActionsDropdown">
<!-- Edit project -->
<% if active && can_manage_project?(project) %>
<li>
<a href="<%= edit_project_path(project, format: :json) %>"
class="edit-project-btn"
data-action="edit"
data-remote="true">
<i class="fas fa-pen"></i>
<span><%= t('projects.index.edit_option') %></span>
</a>
</li>
<% end %>
<!-- Archive/restore project -->
<% if active && can_archive_project?(project) %>
<li>
<a href="#"
class="form-submit-link"
data-turbolinks="false"
data-submit-form="<%= project_form.options[:html][:id] %>"
data-confirm-form="<%= t("projects.index.archive_confirm") %>">
<i class="fas fa-archive"></i>
<span><%= t ('projects.index.archive_option') %></span>
</a>
</li>
<% elsif !active %>
<li>
<a href="#"
class="form-submit-link"
data-turbolinks="false"
data-submit-form="<%= project_form.options[:html][:id] %>">
<i class="fas fa-undo"></i>
<span><%= t ('projects.index.restore_option') %></span>
</a>
</li>
<% end %>
<!-- Show comments -->
<!-- Archive/restore project -->
<% if project.active? && can_archive_project?(project) %>
<li>
<a href="#"
class="open-comments-sidebar"
class="form-submit-link"
data-turbolinks="false"
data-object-type="Project"
data-object-id="<%= project.id %>">
<i class="fas fa-comment"></i>
<span class="comment-count">
<%= t('projects.index.comments_option', comments_count: project.comment_count) %>
</span>
</a>
data-submit-form="<%= project_form.options[:html][:id] %>"
data-confirm-form="<%= t("projects.index.archive_confirm") %>">
<i class="fas fa-archive"></i>
<span><%= t ('projects.index.archive_option') %></span>
</a>
</li>
<!-- Open activities -->
<% elsif project.archived? && can_restore_project?(project) %>
<li>
<a href="/global_activities?<%= Activity.url_search_query({subjects: {Project: [project.id]}}) %>">
<i class="fas fa-list"></i>
<span><%= t('projects.index.activities_option') %></span>
<a href="#"
class="form-submit-link"
data-turbolinks="false"
data-submit-form="<%= project_form.options[:html][:id] %>">
<i class="fas fa-undo"></i>
<span><%= t ('projects.index.restore_option') %></span>
</a>
</li>
</ul>
</div>
<% end %>
<% end %>
<!-- Show comments -->
<li>
<a href="#"
class="open-comments-sidebar"
data-turbolinks="false"
data-object-type="Project"
data-object-id="<%= project.id %>">
<i class="fas fa-comment"></i>
<span class="comment-count">
<%= t('projects.index.comments_option', comments_count: project.comment_count) %>
</span>
</a>
</li>
<!-- Open activities -->
<li>
<a href="/global_activities?<%= Activity.url_search_query({ subjects: { Project: [project.id] } }) %>">
<i class="fas fa-list"></i>
<span><%= t('projects.index.activities_option') %></span>
</a>
</li>
</ul>
</div>
<% end %>