Project

General

Profile

Feature #35616 » 0002-Show-the-Delete-item-in-the-context-menu-only-when-o.patch

Go MAEDA, 2025-08-27 08:21

View differences:

app/controllers/context_menus_controller.rb
46 46

  
47 47
    @priorities = IssuePriority.active.reverse
48 48
    @back = back_url
49
    begin
50
      # Recognize the controller and action from the back_url to determine
51
      # which view triggered the context menu.
52
      route = Rails.application.routes.recognize_path(@back)
53
      @include_delete =
54
        [
55
          {controller: 'issues', action: 'index'},
56
          {controller: 'gantts', action: 'show'},
57
          {controller: 'calendars', action: 'show'}
58
        ].any?(route.slice(:controller, :action))
59
    rescue ActionController::RoutingError
60
      @include_delete = false
61
    end
49 62

  
50 63
    @columns = params[:c]
51 64

  
app/views/context_menus/issues.html.erb
173 173
  <li><%= context_menu_link sprite_icon('copy', l(:button_copy)), bulk_edit_issues_path(:ids => @issue_ids, :copy => '1'),
174 174
                            :class => 'icon icon-copy', :disabled => !@can[:copy] %></li>
175 175
<% end %>
176
  <li><%= context_menu_link sprite_icon('del', l(:button_delete_object, object_name: (@issue_ids.size > 1 ? l(:label_issue_plural) : l(:label_issue))).capitalize), issues_path(:ids => @issue_ids, :back_url => @back),
177
                            :method => :delete, :data => {:confirm => issues_destroy_confirmation_message(@issues)}, :class => 'icon icon-del', :disabled => !@can[:delete] %></li>
176
  <% if @include_delete %>
177
    <li><%= context_menu_link sprite_icon('del', l(:button_delete_object, object_name: (@issue_ids.size > 1 ? l(:label_issue_plural) : l(:label_issue))).capitalize), issues_path(:ids => @issue_ids, :back_url => @back),
178
                              :method => :delete, :data => {:confirm => issues_destroy_confirmation_message(@issues)}, :class => 'icon icon-del', :disabled => !@can[:delete] %></li>
179
  <% end %>
178 180

  
179 181
  <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
180 182
</ul>
(4-4/5)