fix-context-menu-on-issue.patch

Mizuki ISHIKAWA, 2018-08-07 02:30

Download (6.25 KB)

View differences:

app/views/context_menus/issues.html.erb
2 2
  <%= call_hook(:view_issues_context_menu_start, {:issues => @issues, :can => @can, :back => @back }) %>
3 3

  
4 4
  <% if @issue -%>
5
    <li><%= context_menu_link l(:button_edit), edit_issue_path(@issue),
5
    <% if @back != issue_url(@issue.id, :only_path => false) -%>
6
      <li><%= context_menu_link l(:button_edit), edit_issue_path(@issue),
6 7
            :class => 'icon icon-edit', :disabled => !@can[:edit] %></li>
8
    <% end %>
7 9
  <% else %>
8 10
    <li><%= context_menu_link l(:button_edit), bulk_edit_issues_path(:ids => @issue_ids),
9 11
            :class => 'icon icon-edit', :disabled => !@can[:edit] %></li>
......
129 131
  </li>
130 132
<% end %>
131 133

  
132
<% if User.current.logged? %>
134
<% if User.current.logged? && (@issue.nil? || @back != issue_url(@issue.id, :only_path => false)) -%>
133 135
  <li><%= watcher_link(@issues, User.current) %></li>
134 136
<% end %>
135 137

  
......
139 141
<% end %>
140 142

  
141 143
<% if @issue.present? %>
142
  <% if @can[:log_time] -%>
143
  <li><%= context_menu_link l(:button_log_time), new_issue_time_entry_path(@issue),
144
          :class => 'icon icon-time-add' %></li>
144
  <% if @back != issue_url(@issue.id, :only_path => false) -%>
145
    <% if @can[:log_time] -%>
146
    <li><%= context_menu_link l(:button_log_time), new_issue_time_entry_path(@issue),
147
            :class => 'icon icon-time-add' %></li>
148
    <% end %>
149
    <li><%= context_menu_link l(:button_copy), project_copy_issue_path(@project, @issue),
150
            :class => 'icon icon-copy', :disabled => !@can[:copy] %></li>
145 151
  <% end %>
146
  <li><%= context_menu_link l(:button_copy), project_copy_issue_path(@project, @issue),
147
          :class => 'icon icon-copy', :disabled => !@can[:copy] %></li>
148 152
<% else %>
149 153
  <li><%= context_menu_link l(:button_copy), bulk_edit_issues_path(:ids => @issue_ids, :copy => '1'),
150 154
                          :class => 'icon icon-copy', :disabled => !@can[:copy] %></li>
151 155
<% end %>
156
<% if @issue.nil? || @back != issue_url(@issue.id, :only_path => false) -%>
152 157
  <li><%= context_menu_link l(:button_delete), issues_path(:ids => @issue_ids, :back_url => @back),
153 158
                            :method => :delete, :data => {:confirm => issues_destroy_confirmation_message(@issues)}, :class => 'icon icon-del', :disabled => !@can[:delete] %></li>
154

  
159
<% end %>
155 160
  <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
156 161
</ul>
app/views/issues/_action_menu.html.erb
4 4
<%= watcher_link(@issue, User.current) %>
5 5
<%= link_to l(:button_copy), project_copy_issue_path(@project, @issue), :class => 'icon icon-copy' if User.current.allowed_to?(:copy_issues, @project) && Issue.allowed_target_projects.any? %>
6 6
<%= link_to l(:button_delete), issue_path(@issue), :data => {:confirm => issues_destroy_confirmation_message(@issue)}, :method => :delete, :class => 'icon icon-del' if @issue.deletable? %>
7
<%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do %>
8
  <span class="hascontextmenu">
9
    <%= check_box_tag("ids[]", @issue.id, false, :style => 'display:none;', :id => nil) %>
10
    <%= link_to_context_menu %>
11
  </span>
7
<% if @issue.new_statuses_allowed_to.present? %>
8
  <%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do %>
9
    <span class="hascontextmenu">
10
      <%= check_box_tag("ids[]", @issue.id, false, :style => 'display:none;', :id => nil) %>
11
      <%= link_to_context_menu %>
12
    </span>
13
  <% end %>
12 14
<% end %>
13 15
</div>
public/stylesheets/responsive.css
625 625
  }
626 626

  
627 627
  .contextual span.hascontextmenu a.js-contextmenu {
628
      width: initial !important;
629
      height: initial !important;
630
      margin-top: 3px !important;
628
      width: auto;
629
      height: auto;
630
      margin-top: 2px !important;
631 631
      padding-left: 25px !important;
632
      font-size: 100%;
632 633
  }
633 634
  .contextual span.hascontextmenu a.js-contextmenu::after { content: ''; }
634 635

  
test/functional/context_menus_controller_test.rb
66 66
      assert_select 'a.icon-del.disabled[href="#"]', :text => 'Delete'
67 67
    end
68 68
  end
69
  def test_context_menu_one_issue_if_the_back_url_is_issue_path
70
    @request.session[:user_id] = 2
71
    @request.env['HTTP_REFERER'] = issue_url(1, :only_path => false)
72
    get :issues, :params => {
73
        :ids => [1]
74
      }
75
    assert_response :success
76
    assert_select 'a.icon-edit[href=?]', '/issues/1/edit', { :text => 'Edit', :count => 0 }
77
    assert_select 'a.icon-time-add[href=?]', '/issues/1/time_entries/new', { :text => 'Log time', :count => 0 }
78
    assert_select 'a.icon-fav-off[href=?]', '/watchers/watch?object_id=1&object_type=issue', { :text => 'Watch', :count => 0 }
79
    assert_select 'a.icon-copy[href=?]', '/projects/ecookbook/issues/1/copy', { :text => 'Copy', :count => 0 }
80
    assert_select 'a.icon-del[href=?]', '/issues?ids%5B%5D=1', { :text => 'Delete', :count => 0 }
81
  end
69 82

  
70 83
  def test_context_menu_multiple_issues_of_same_project
71 84
    @request.session[:user_id] = 2
test/functional/issues_controller_test.rb
1577 1577
    # action_menu for anonymous role
1578 1578
    assert_select 'div.contextual' do
1579 1579
      assert_select 'a[href=?]', '/issues/1/edit'
1580
      assert_select "form[data-cm-url=?]", '/issues/context_menu' do
1581
        assert_select 'span[class=?]', 'hascontextmenu'
1582
      end
1583 1580
    end
1584 1581
  end
1585 1582