Project

General

Profile

Feature #37973 » enable_to_display_watches_count_on_issues_list.patch

Takenori TAKAKI, 2022-11-28 15:22

View differences:

app/models/issue.rb
1176 1176
    end
1177 1177
  end
1178 1178

  
1179
  def watches
1180
    @watches ||= self.watchers.count(:id)
1181
  end
1182

  
1179 1183
  # Preloads relations for a collection of issues
1180 1184
  def self.load_relations(issues)
1181 1185
    if issues.any?
app/models/issue_query.rb
45 45
    QueryColumn.new(:category, :sortable => "#{IssueCategory.table_name}.name", :groupable => true),
46 46
    QueryColumn.new(:fixed_version, :sortable => lambda {Version.fields_for_order_statement},
47 47
                    :groupable => true),
48
    QueryColumn.new(
49
      :watches,
50
      :sortable =>
51
        lambda do
52
          "COALESCE((SELECT COUNT(user_id) FROM #{Watcher.table_name}" \
53
          " WHERE #{Watcher.table_name}.watchable_id = #{Issue.table_name}.id), 0)"
54
        end,
55
      :default_order => 'desc'),
48 56
    QueryColumn.new(:start_date, :sortable => "#{Issue.table_name}.start_date", :groupable => true),
49 57
    QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date", :groupable => true),
50 58
    QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours",
app/views/watchers/_set_watcher.js.erb
1
<% selector = ".#{watcher_css(watched)}" %>
2
$("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link(watched, user) %>")});
3
$('#watchers').html('<%= escape_javascript(render(:partial => 'watchers/watchers', :locals => {:watched => watched.first})) %>');
1
var back_url = $('input[name="back_url"]').val() || '';
2
if (back_url.length > 0) {
3
  window.location.href = back_url;
4
} else {
5
  <% selector = ".#{watcher_css(watched)}" %>
6
  $("<%= selector %>").each(function(){$(this).replaceWith("<%= escape_javascript watcher_link(watched, user) %>")});
7
  $('#watchers').html('<%= escape_javascript(render(:partial => 'watchers/watchers', :locals => {:watched => watched.first})) %>');
8
}
app/views/watchers/create.js.erb
3 3
         render(:partial => 'watchers/new',
4 4
                :locals => {:watchables => @watchables, :users => @users})) %>');
5 5

  
6
<% if @watchables.size == 1 %>
7
  <%= render(:partial => 'watchers/set_watcher',
8
             :locals => {:watched => @watchables, :user => User.current}) %>
9
<% end %>
6
<%= render(:partial => 'watchers/set_watcher',
7
           :locals => {:watched => @watchables, :user => User.current}) %>
config/locales/en.yml
370 370
  field_parent_title: Parent page
371 371
  field_editable: Editable
372 372
  field_watcher: Watcher
373
  field_watches: Watches
373 374
  field_content: Content
374 375
  field_group_by: Group results by
375 376
  field_sharing: Sharing
config/locales/ja.yml
329 329
  field_parent_title: 親ページ
330 330
  field_editable: 編集可能
331 331
  field_watcher: ウォッチャー
332
  field_watches: ウォッチ数
332 333
  field_content: 内容
333 334
  field_group_by: グループ条件
334 335
  field_sharing: 共有
(2-2/4)