redmine-last-note-patch.diff

Tom Bull, 2016-03-07 20:45

Download (6.7 KB)

View differences:

app/helpers/queries_helper.rb
17 17
# along with this program; if not, write to the Free Software
18 18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 19

  
20
require "htmlentities"
21

  
20 22
module QueriesHelper
21 23
  include ApplicationHelper
22 24

  
......
150 152
      content_tag('span',
151 153
        value.to_s(issue) {|other| link_to_issue(other, :subject => false, :tracker => false)}.html_safe,
152 154
        :class => value.css_classes_for(issue))
155
    when :latest_journal_text
156
      last_note_html = textilizable(value, :inline_attachments => false, :attachments => false)
157
      last_note_html = last_note_html.gsub('>', '> ')
158
      last_note_unformatted_text = strip_tags(last_note_html)
159
      last_note_unformatted_text = last_note_unformatted_text.gsub('ΒΆ', '')
160
      html_decoder = HTMLEntities.new
161
      last_note_unformatted_text = html_decoder.decode(last_note_unformatted_text)
162
      last_note_unformatted_text = last_note_unformatted_text.gsub(/\s+/, ' ')
163
      truncated_text = truncate(last_note_unformatted_text, length: Setting.last_note_text_length.to_i, separator: ' ')
164
      format_object(truncated_text)
153 165
    else
154 166
      format_object(value)
155 167
    end
app/models/issue.rb
740 740
    end
741 741
  end
742 742

  
743
  # Returns the notes from the latest journal where notes exist
744
  def latest_journal_text
745
    if new_record?
746
      nil
747
    else
748
      last_note_object = journals.where.not(notes: '').order(created_on: :desc).first
749
      last_note_object.nil? ? "" : last_note_object.notes
750
    end
751
  end
752

  
743 753
  # Returns a scope for journals that have an id greater than journal_id
744 754
  def journals_after(journal_id)
745 755
    scope = journals.reorder("#{Journal.table_name}.id ASC")
app/models/issue_query.rb
43 43
    QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
44 44
    QueryColumn.new(:closed_on, :sortable => "#{Issue.table_name}.closed_on", :default_order => 'desc'),
45 45
    QueryColumn.new(:relations, :caption => :label_related_issues),
46
    QueryColumn.new(:latest_journal_text, :caption => :label_last_note),
46 47
    QueryColumn.new(:description, :inline => false)
47 48
  ]
48 49

  
app/views/settings/_display.html.erb
24 24
<p><%= setting_check_box :thumbnails_enabled %></p>
25 25

  
26 26
<p><%= setting_text_field :thumbnails_size, :size => 6 %></p>
27

  
28
<p><%= setting_text_field :last_note_text_length, :size => 6 %></p>
27 29
</div>
28 30

  
29 31
<%= submit_tag l(:button_save) %>
config/locales/en.yml
419 419
  setting_session_timeout: Session inactivity timeout
420 420
  setting_thumbnails_enabled: Display attachment thumbnails
421 421
  setting_thumbnails_size: Thumbnails size (in pixels)
422
  setting_last_note_text_length: Length of text to display in 'Last Note' field (characters)
422 423
  setting_non_working_week_days: Non-working days
423 424
  setting_jsonp_enabled: Enable JSONP support
424 425
  setting_default_projects_tracker_ids: Default trackers for new projects
......
779 780
  label_permissions_report: Permissions report
780 781
  label_watched_issues: Watched issues
781 782
  label_related_issues: Related issues
783
  label_last_note: Last note
782 784
  label_applied_status: Applied status
783 785
  label_loading: Loading...
784 786
  label_relation_new: New relation
config/settings.yml
254 254
thumbnails_size:
255 255
  format: int
256 256
  default: 100
257
last_note_text_length:
258
  format: int
259
  default: 30
257 260
non_working_week_days:
258 261
  serialized: true
259 262
  default:
public/stylesheets/application.css
154 154
tr.project.idnt-8 td.name {padding-left: 11em;}
155 155
tr.project.idnt-9 td.name {padding-left: 12.5em;}
156 156

  
157
tr.issue { text-align: center; white-space: nowrap; }
157
tr.issue { text-align: center; }
158 158
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; }
159 159
tr.issue td.relations { text-align: left; }
160 160
tr.issue td.done_ratio table.progress { margin-left:auto; margin-right: auto;}
161
-