summaryrefslogtreecommitdiffstats
path: root/app/views/context_menus/issues.html.erb
blob: 9b9c7f07af1af70b357f407caaded640be34ecf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<ul>
  <%= call_hook(:view_issues_context_menu_start, {:issues => @issues, :can => @can, :back => @back }) %>

  <% if @issue -%>
    <li><%= context_menu_link icon_with_label('edit', l(:button_edit)), edit_issue_path(@issue),
            :class => 'icon icon-edit', :disabled => !@can[:edit] %></li>
  <% else %>
    <li><%= context_menu_link icon_with_label('edit', l(:label_bulk_edit)), bulk_edit_issues_path(:ids => @issue_ids),
            :class => 'icon icon-edit', :disabled => !@can[:edit] %></li>
  <% end %>

  <% if @allowed_statuses.present? %>
  <li class="folder">
    <a href="#" class="submenu"><%= l(:field_status) %></a>
    <ul>
    <% @allowed_statuses.each do |s| -%>
        <li>
          <%= context_menu_link(
                s.name,
                _bulk_update_issues_path(
                  @issue,
                  :ids => @issue_ids, :issue => {:status_id => s}, :back_url => @back
                ),
                :method => :patch,
                :selected => (@issue && s == @issue.status), :disabled => !@can[:edit]
              ) %>
        </li>
    <% end -%>
    </ul>
  </li>
  <% end %>

  <% if @trackers.present? %>
  <li class="folder">
    <a href="#" class="submenu"><%= l(:field_tracker) %></a>
    <ul>
    <% @trackers.each do |t| -%>
        <li><%= context_menu_link t.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'tracker_id' => t}, :back_url => @back), :method => :patch,
                                  :selected => (@issue && t == @issue.tracker), :disabled => !@can[:edit] %></li>
    <% end -%>
    </ul>
  </li>
  <% end %>

  <% if @safe_attributes.include?('priority_id') && @priorities.present? -%>
  <li class="folder">
    <a href="#" class="submenu"><%= l(:field_priority) %></a>
    <ul>
    <% @priorities.each do |p| -%>
        <li><%= context_menu_link p.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'priority_id' => p}, :back_url => @back), :method => :patch,
                                  :selected => (@issue && p == @issue.priority), :disabled => (!@can[:edit] || @issues.any?(&:priority_derived?)) %></li>
    <% end -%>
    </ul>
  </li>
  <% end %>

  <% if @safe_attributes.include?('fixed_version_id') && @versions.present? -%>
  <li class="folder">
    <a href="#" class="submenu"><%= l(:field_fixed_version) %></a>
    <ul>
    <% @versions.sort.each do |v| -%>
        <li><%= context_menu_link format_version_name(v), _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'fixed_version_id' => v}, :back_url => @back), :method => :patch,
                                  :selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:edit] %></li>
    <% end -%>
        <li><%= context_menu_link l(:label_none), _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'fixed_version_id' => 'none'}, :back_url => @back), :method => :patch,
                                  :selected => (@issue && @issue.fixed_version.nil?), :disabled => !@can[:edit] %></li>
    </ul>
  </li>
  <% end %>

  <% if @safe_attributes.include?('assigned_to_id') && @assignables.present? -%>
  <li class="folder">
    <a href="#" class="submenu"><%= l(:field_assigned_to) %></a>
    <ul>
    <% if @assignables.include?(User.current) %>
        <li><%= context_menu_link "<< #{l(:label_me)} >>", _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'assigned_to_id' => User.current}, :back_url => @back), :method => :patch,
                                  :disabled => !@can[:edit] %></li>
    <% end %>
    <% @assignables.each do |u| -%>
        <li><%= context_menu_link u.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'assigned_to_id' => u}, :back_url => @back), :method => :patch,
                                  :selected => (@issue && u == @issue.assigned_to), :disabled => !@can[:edit] %></li>
    <% end -%>
        <li><%= context_menu_link l(:label_nobody), _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'assigned_to_id' => 'none'}, :back_url => @back), :method => :patch,
                                  :selected => (@issue && @issue.assigned_to.nil?), :disabled => !@can[:edit] %></li>
    </ul>
  </li>
  <% end %>

  <% if @safe_attributes.include?('category_id') && @project && @project.issue_categories.any? -%>
  <li class="folder">
    <a href="#" class="submenu"><%= l(:field_category) %></a>
    <ul>
    <% @project.issue_categories.each do |u| -%>
        <li><%= context_menu_link u.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'category_id' => u}, :back_url => @back), :method => :patch,
                                  :selected => (@issue && u == @issue.category), :disabled => !@can[:edit] %></li>
    <% end -%>
        <li><%= context_menu_link l(:label_none), _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'category_id' => 'none'}, :back_url => @back), :method => :patch,
                                  :selected => (@issue && @issue.category.nil?), :disabled => !@can[:edit] %></li>
    </ul>
  </li>
  <% end -%>

  <% if @safe_attributes.include?('done_ratio') && Issue.use_field_for_done_ratio? %>
  <li class="folder">
    <a href="#" class="submenu"><%= l(:field_done_ratio) %></a>
    <ul>
    <% (0..10).map{|x|x*10}.each do |p| -%>
        <li><%= context_menu_link "#{p}%", _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'done_ratio' => p}, :back_url => @back), :method => :patch,
                                      :selected => (@issue && p == @issue.done_ratio), :disabled => (!@can[:edit] || @issues.any?(&:done_ratio_derived?)) %></li>
    <% end -%>
    </ul>
  </li>
  <% end %>

  <% @options_by_custom_field.each do |field, options| %>
    <li class="folder <%= field.css_classes %>">
      <a href="#" class="submenu"><%= field.name %></a>
      <ul>
      <% options.each do |text, value| %>
        <li><%= bulk_update_custom_field_context_menu_link(field, text, value || text) %></li>
      <% end %>
      <% unless field.is_required? %>
        <li><%= bulk_update_custom_field_context_menu_link(field, l(:label_none), '__none__') %></li>
      <% end %>
      </ul>
    </li>
  <% end %>

<% if @can[:add_watchers] %>
  <li class="folder">
    <a href="#" class="submenu"><%= l(:label_issue_watchers) %></a>
    <ul>
      <li><%= context_menu_link icon_with_label('add', l(:button_add)),
                new_watchers_path(:object_type => 'issue', :object_id => @issue_ids),
                :remote => true,
                :class => 'icon icon-add' %></li>
    </ul>
  </li>
<% end %>

<% if User.current.logged? %>
  <li><%= watcher_link(@issues, User.current) %></li>
<% end %>

<% unless @issue %>
  <li><%= context_menu_link icon_with_label('list', l(:button_filter)), _project_issues_path(@project, :set_filter => 1, :status_id => "*", :issue_id => @issue_ids.join(","), :c => @columns),
          :class => 'icon icon-list' %></li>
<% end %>

<% if @issue.present? %>
  <% if @can[:log_time] -%>
  <li><%= context_menu_link icon_with_label('time', l(:button_log_time)), new_issue_time_entry_path(@issue),
          :class => 'icon icon-time-add' %></li>
  <% end %>
  <% if @can[:add_subtask] -%>
  <li><%= context_menu_link icon_with_label('add', l(:button_add_subtask)), url_for_new_subtask(@issue),
          :class => 'icon icon-add' %></li>
  <% end %>
  <li><%= copy_object_url_link(issue_url(@issue)) %></li>
  <li><%= context_menu_link icon_with_label('copy', l(:button_copy)), project_copy_issue_path(@project, @issue),
          :class => 'icon icon-copy', :disabled => !@can[:copy] %></li>
<% else %>
  <li><%= copy_object_url_link(_project_issues_url(@project, set_filter: 1, status_id: '*', issue_id: @issue_ids.join(','))) %></li>
  <li><%= context_menu_link icon_with_label('copy', l(:button_copy)), bulk_edit_issues_path(:ids => @issue_ids, :copy => '1'),
                          :class => 'icon icon-copy', :disabled => !@can[:copy] %></li>
<% end %>
  <li><%= context_menu_link icon_with_label('del', l(:button_delete_object, object_name: (@issue_ids.size > 1 ? l(:label_issue_plural) : l(:label_issue)).downcase)), issues_path(:ids => @issue_ids, :back_url => @back),
                            :method => :delete, :data => {:confirm => issues_destroy_confirmation_message(@issues)}, :class => 'icon icon-del', :disabled => !@can[:delete] %></li>

  <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
</ul>