summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2022-04-01 15:09:28 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2022-04-01 15:09:28 +0000
commitc431606e3ee5e471a0c4703ca0fb6678f7ceeb30 (patch)
treec0a58a4a674a4e62b7d272ba696aee58ceed828a /app
parent83ed32e8d71fdb8c6a7492a4d82db2d52889534d (diff)
downloadredmine-c431606e3ee5e471a0c4703ca0fb6678f7ceeb30.tar.gz
redmine-c431606e3ee5e471a0c4703ca0fb6678f7ceeb30.zip
Adds context menu to admin projects list (#33422).
Patch by Jens Krämer. git-svn-id: https://svn.redmine.org/redmine/trunk@21520 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/context_menus_controller.rb13
-rw-r--r--app/views/projects/_list.html.erb32
2 files changed, 33 insertions, 12 deletions
diff --git a/app/controllers/context_menus_controller.rb b/app/controllers/context_menus_controller.rb
index 1fd34aabd..f4ecb9547 100644
--- a/app/controllers/context_menus_controller.rb
+++ b/app/controllers/context_menus_controller.rb
@@ -95,4 +95,17 @@ class ContextMenusController < ApplicationController
render :layout => false
end
+
+ def projects
+ @projects = Project.where(id: params[:ids]).to_a
+ if @projects.empty?
+ render_404
+ return
+ end
+
+ if @projects.size == 1
+ @project = @projects.first
+ end
+ render layout: false
+ end
end
diff --git a/app/views/projects/_list.html.erb b/app/views/projects/_list.html.erb
index ba26e9d61..39978ee64 100644
--- a/app/views/projects/_list.html.erb
+++ b/app/views/projects/_list.html.erb
@@ -1,13 +1,21 @@
+<% @admin_list = User.current.admin? && controller_name == 'admin' && action_name == 'projects' %>
<%= render_query_totals(@query) %>
+<%= form_tag({}, data: {cm_url: projects_context_menu_path}) do -%>
+<%= hidden_field_tag 'back_url', url_for(params: request.query_parameters), id: nil %>
<div class="autoscroll">
<table class="list projects odd-even <%= @query.css_classes %>">
<thead>
<tr>
+ <% if @admin_list %>
+ <th class="checkbox hide-when-print">
+ <input type="checkbox" name="check_all" id="check_all" value="" class="toggle-selection" title="Check all/Uncheck all">
+ </th>
+ <% end %>
<% @query.inline_columns.each do |column| %>
<%= column_header(@query, column) %>
<% end %>
- <% if controller_name == 'admin' && action_name == 'projects' %>
- <th></th>
+ <% if @admin_list %>
+ <th></th>
<% end %>
</tr>
</thead>
@@ -26,28 +34,27 @@
<%= link_to_function("#{l(:button_collapse_all)}/#{l(:button_expand_all)}",
"toggleAllRowGroups(this)", :class => 'toggle-all') %>
</td>
- <% if controller_name == 'admin' && action_name == 'projects' %>
- <td></td>
+ <% if @admin_list %>
+ <td></td>
<% end %>
</tr>
<% end %>
- <tr id="project-<%= entry.id %>" class="<%= cycle('odd', 'even') %> <%= entry.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
+ <tr id="project-<%= entry.id %>" class="<%= cycle('odd', 'even') %> hascontextmenu <%= entry.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
+ <% if @admin_list %>
+ <td class="checkbox hide-when-print"><%= check_box_tag("ids[]", entry.id, false, :id => nil) %></td>
+ <% end %>
<% @query.inline_columns.each do |column| %>
<%= content_tag('td', column_content(column, entry), :class => column.css_classes) %>
<% end %>
- <% if controller_name == 'admin' && action_name == 'projects' %>
- <td class="buttons">
- <%= link_to(l(:button_archive), archive_project_path(entry, :status => params[:status]), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless entry.archived? %>
- <%= link_to(l(:button_unarchive), unarchive_project_path(entry, :status => params[:status]), :method => :post, :class => 'icon icon-unlock') if entry.archived? %>
- <%= link_to(l(:button_copy), copy_project_path(entry), :class => 'icon icon-copy') %>
- <%= link_to(l(:button_delete), project_path(entry), :method => :delete, :class => 'icon icon-del') %>
- </td>
+ <% if @admin_list %>
+ <td class="buttons"><%= link_to_context_menu %></td>
<% end %>
</tr>
<% end -%>
</tbody>
</table>
</div>
+<% end -%>
<span class="pagination"><%= pagination_links_full @entry_pages, @entry_count %></span>
<div id="csv-export-options" style="display:none;">
@@ -65,3 +72,4 @@
</p>
<% end %>
</div>
+<%= context_menu if @admin_list %>