diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2017-03-05 07:58:07 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2017-03-05 07:58:07 +0000 |
commit | 91d10c63f02c6116c6215d66fa8ff7b17cddf527 (patch) | |
tree | bb4e7a6d49af67ea985a9fca25b890f1bef5931e /app | |
parent | 06c6de06e4d47531ebc6afef63b925ca80552339 (diff) | |
download | redmine-91d10c63f02c6116c6215d66fa8ff7b17cddf527.tar.gz redmine-91d10c63f02c6116c6215d66fa8ff7b17cddf527.zip |
Show Last Comment in Issue list (#1474).
Patch by Marius BALTEANU.
git-svn-id: http://svn.redmine.org/redmine/trunk@16367 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/queries_helper.rb | 2 | ||||
-rw-r--r-- | app/models/issue.rb | 26 | ||||
-rw-r--r-- | app/models/issue_query.rb | 6 | ||||
-rw-r--r-- | app/views/issues/_list.html.erb | 7 | ||||
-rw-r--r-- | app/views/issues/index.html.erb | 1 | ||||
-rw-r--r-- | app/views/timelog/_list.html.erb | 7 |
6 files changed, 46 insertions, 3 deletions
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 458fb70fd..c356ca0d4 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -185,6 +185,8 @@ module QueriesHelper value ? (value.visible? ? link_to_issue(value, :subject => false) : "##{value.id}") : '' when :description item.description? ? content_tag('div', textilizable(item, :description), :class => "wiki") : '' + when :last_notes + item.last_notes.present? ? content_tag('div', textilizable(item, :last_notes), :class => "wiki") : '' when :done_ratio progress_bar(value) when :relations diff --git a/app/models/issue.rb b/app/models/issue.rb index 19fef95b5..c80920ca5 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -246,6 +246,7 @@ class Issue < ActiveRecord::Base @total_spent_hours = nil @total_estimated_hours = nil @last_updated_by = nil + @last_notes = nil base_reload(*args) end @@ -1078,6 +1079,15 @@ class Issue < ActiveRecord::Base end end + def last_notes + if @last_notes + @last_notes + else + notes = self.journals.visible.where.not(notes: '').to_a + notes.last.notes unless notes.empty? + end + end + # Preloads relations for a collection of issues def self.load_relations(issues) if issues.any? @@ -1158,6 +1168,22 @@ class Issue < ActiveRecord::Base end end + # Preloads visible last notes for a collection of issues + def self.load_visible_last_notes(issues, user=User.current) + if issues.any? + issue_ids = issues.map(&:id) + + notes = Journal.joins(issue: :project).where.not(notes: ''). + where(Journal.visible_notes_condition(User.current, :skip_pre_condition => true)). + where(:issues => {:id => issue_ids}).order("#{Journal.table_name}.id ASC").to_a + + issues.each do |issue| + note = notes.select{|note| note.journalized_id == issue.id} + issue.instance_variable_set "@last_notes", (note.empty? ? '' : note.last.notes) + end + end + end + # Finds an issue relation given its id. def find_relation(relation_id) IssueRelation.where("issue_to_id = ? OR issue_from_id = ?", id, id).find(relation_id) diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 88b51f593..7f399f469 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -45,7 +45,8 @@ class IssueQuery < Query QueryColumn.new(:closed_on, :sortable => "#{Issue.table_name}.closed_on", :default_order => 'desc'), QueryColumn.new(:last_updated_by, :sortable => lambda {User.fields_for_order_statement("last_journal_user")}), QueryColumn.new(:relations, :caption => :label_related_issues), - QueryColumn.new(:description, :inline => false) + QueryColumn.new(:description, :inline => false), + QueryColumn.new(:last_notes, :caption => :label_last_notes, :inline => false) ] def initialize(attributes=nil, *args) @@ -305,6 +306,9 @@ class IssueQuery < Query if has_column?(:relations) Issue.load_visible_relations(issues) end + if has_column?(:last_notes) + Issue.load_visible_last_notes(issues) + end issues rescue ::ActiveRecord::StatementInvalid => e raise StatementInvalid.new(e.message) diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index 7e34fca24..3ae5e7023 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -33,7 +33,12 @@ <% @query.block_columns.each do |column| if (text = column_content(column, issue)) && text.present? -%> <tr class="<%= current_cycle %>"> - <td colspan="<%= @query.inline_columns.size + 1 %>" class="<%= column.css_classes %>"><%= text %></td> + <td colspan="<%= @query.inline_columns.size + 1 %>" class="<%= column.css_classes %>"> + <% if query.block_columns.count > 1 %> + <span><%= column.caption %></span> + <% end %> + <%= text %> + </td> </tr> <% end -%> <% end -%> diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 3d456aad1..80210814e 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -37,6 +37,7 @@ </p> <p> <label><%= check_box_tag 'c[]', 'description', @query.has_column?(:description) %> <%= l(:field_description) %></label> + <label><%= check_box_tag 'c[]', 'last_notes', @query.has_column?(:last_notes) %> <%= l(:label_last_notes) %></label> </p> <% if @issue_count > Setting.issues_export_limit.to_i %> <p class="icon icon-warning"> diff --git a/app/views/timelog/_list.html.erb b/app/views/timelog/_list.html.erb index 0fb72aeb4..b39eb5cc3 100644 --- a/app/views/timelog/_list.html.erb +++ b/app/views/timelog/_list.html.erb @@ -50,7 +50,12 @@ <% @query.block_columns.each do |column| if (text = column_content(column, issue)) && text.present? -%> <tr class="<%= current_cycle %>"> - <td colspan="<%= @query.inline_columns.size + 1 %>" class="<%= column.css_classes %>"><%= text %></td> + <td colspan="<%= @query.inline_columns.size + 1 %>" class="<%= column.css_classes %>"> + <% if query.block_columns.count > 1 %> + <span><%= column.caption %></span> + <% end %> + <%= text %> + </td> </tr> <% end -%> <% end -%> |