Project

General

Profile

Feature #10707 » redmine-last-note-patch.diff

Patch to add last issue comment to issues search. - Tom Bull, 2016-03-07 20:39

View differences:

app/helpers/queries_helper.rb
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require "htmlentities"
module QueriesHelper
include ApplicationHelper
......
content_tag('span',
value.to_s(issue) {|other| link_to_issue(other, :subject => false, :tracker => false)}.html_safe,
:class => value.css_classes_for(issue))
when :latest_journal_text
last_note_html = textilizable(value, :inline_attachments => false, :attachments => false)
last_note_html = last_note_html.gsub('>', '> ')
last_note_unformatted_text = strip_tags(last_note_html)
last_note_unformatted_text = last_note_unformatted_text.gsub('¶', '')
html_decoder = HTMLEntities.new
last_note_unformatted_text = html_decoder.decode(last_note_unformatted_text)
last_note_unformatted_text = last_note_unformatted_text.gsub(/\s+/, ' ')
truncated_text = truncate(last_note_unformatted_text, length: Setting.last_note_text_length.to_i, separator: ' ')
format_object(truncated_text)
else
format_object(value)
end
app/models/issue.rb
end
end
# Returns the notes from the latest journal where notes exist
def latest_journal_text
if new_record?
nil
else
last_note_object = journals.where.not(notes: '').order(created_on: :desc).first
last_note_object.nil? ? "" : last_note_object.notes
end
end
# Returns a scope for journals that have an id greater than journal_id
def journals_after(journal_id)
scope = journals.reorder("#{Journal.table_name}.id ASC")
app/models/issue_query.rb
QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
QueryColumn.new(:closed_on, :sortable => "#{Issue.table_name}.closed_on", :default_order => 'desc'),
QueryColumn.new(:relations, :caption => :label_related_issues),
QueryColumn.new(:latest_journal_text, :caption => :label_last_note),
QueryColumn.new(:description, :inline => false)
]
app/views/settings/_display.html.erb
<p><%= setting_check_box :thumbnails_enabled %></p>
<p><%= setting_text_field :thumbnails_size, :size => 6 %></p>
<p><%= setting_text_field :last_note_text_length, :size => 6 %></p>
</div>
<%= submit_tag l(:button_save) %>
config/locales/en.yml
setting_session_timeout: Session inactivity timeout
setting_thumbnails_enabled: Display attachment thumbnails
setting_thumbnails_size: Thumbnails size (in pixels)
setting_last_note_text_length: Length of text to display in 'Last Note' field (characters)
setting_non_working_week_days: Non-working days
setting_jsonp_enabled: Enable JSONP support
setting_default_projects_tracker_ids: Default trackers for new projects
......
label_permissions_report: Permissions report
label_watched_issues: Watched issues
label_related_issues: Related issues
label_last_note: Last note
label_applied_status: Applied status
label_loading: Loading...
label_relation_new: New relation
config/settings.yml
thumbnails_size:
format: int
default: 100
last_note_text_length:
format: int
default: 30
non_working_week_days:
serialized: true
default:
public/stylesheets/application.css
tr.project.idnt-8 td.name {padding-left: 11em;}
tr.project.idnt-9 td.name {padding-left: 12.5em;}
tr.issue { text-align: center; white-space: nowrap; }
tr.issue { text-align: center; }
tr.issue td.subject, tr.issue td.category, td.assigned_to, tr.issue td.string, tr.issue td.text, tr.issue td.relations, tr.issue td.parent { white-space: normal; }
tr.issue td.relations { text-align: left; }
tr.issue td.done_ratio table.progress { margin-left:auto; margin-right: auto;}
    (1-1/1)