1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-03 23:53:23 +00:00

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
This commit is contained in:
Marius Balteanu 2022-04-01 15:09:28 +00:00
parent 83ed32e8d7
commit c431606e3e
3 changed files with 35 additions and 12 deletions

View File

@ -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

View File

@ -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 %>

View File

@ -363,6 +363,8 @@ Rails.application.routes.draw do
post 'admin/test_email', :to => 'admin#test_email', :as => 'test_email'
post 'admin/default_configuration', :to => 'admin#default_configuration'
match '/admin/projects_context_menu', :to => 'context_menus#projects', :as => 'projects_context_menu', :via => [:get, :post]
resources :auth_sources do
member do
get 'test_connection', :as => 'try_connection'