Project

General

Profile

Modify subject field formatting

Added by Marco Ceppi almost 14 years ago

Hello,

We're using Redmine to track multiple internal projects - however we have a custom field setup with the name "Task ID" which tracks the task ID assigned via our company's methods. ID: AA001, CD005, etc - What I'm trying to do is modify the default formatting from {Issue.tracker} #{Issue.id} to instead show that custom field. I'm having a difficult time tracking down which file actually performs the formatting of the title. I'm sure if I can locate that I can inject my poorly formatted code to poll the Task ID and replace the previous format.

My system:
About your application's environment
Ruby version 1.8.7 (x86_64-linux)
RubyGems version 1.3.6
Rack version 1.0
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Application root /opt/redmine
Environment production
Database adapter mysql
Database schema version 20100221100219

About your Redmine plugins
Issue Due Date 0.1.0
Redmine Stealth plugin 0.1.0
Bulk Time Entry 0.5.0
Redmine Scrum Sprints plugin 0.1.3

Redmine 0.9.3-stable


Replies (5)

RE: Modify subject field formatting - Added by Marco Ceppi almost 14 years ago

Of course it's only moments after I post this that I find the file: app/helpers/application_helper.rb - I've tried to query the specific custom field I created (in this event custom field id 2) which is required for all issue subjects. But can't seem to get this to work. (I understand in the grand scheme of creating good hard coding values is a bad idea. Though I just need it for this project.

Any assistance would be appreciated,

Marco

RE: Modify subject field formatting - Added by Felix Schäfer almost 14 years ago

How did you try to get the custom field?

RE: Modify subject field formatting - Added by Marco Ceppi almost 14 years ago

I eventually got this to work:

  def link_to_issue(issue, options={})
    title = nil
    subject = nil
    if options[:subject] == false
      title = truncate(issue.subject, :length => 60)
    else
      subject = issue.subject
      if options[:truncate]
        subject = truncate(subject, :length => options[:truncate])
      end
    end
    if issue.custom_field_values.empty?
        s = link_to "#{issue.tracker} #{issue.id}", {:controller => "issues", :action => "show", :id => issue},
                                                     :class => issue.css_classes,
                                                     :title => title
    else
        ordered_values = []
        half = (issue.custom_field_values.size / 2.0).ceil
        half.times do |i|
           ordered_values << issue.custom_field_values[i]
           ordered_values << issue.custom_field_values[i + half]
        end   
        s = "" 
        n = 0
        ordered_values.compact.each do |value|
           s = link_to "#{ simple_format_without_paragraph(h(show_value(value))) }", {:controller => "issues", :action => "show", :id => issue},
                                                                                      :class => issue.css_classes,
                                                                                      :title => title
        end
    end
    s << ": #{h subject}" if subject
    s = "#{h issue.project} - " + s if options[:project]
    s
  end

However it's still looping through all custom fields - while I only have this one I know that will cause a problem when I have a tracker with multiple fields. I also am having a hard time finding the rest of the instances within the script - that works for only a handful of instances. There are still texts (Like on the activity page, and elsewhere) that report either a full link or no link (just the text) is that built in each of the helper/controller files or elsewhere?

Thanks,
Marco

RE: Modify subject field formatting - Added by Felix Schäfer almost 14 years ago

Not sure what all the loops are that you are going through, but you can access the content of the custom field with the ID 2 with issue.custom_value_for(2).value.

The helper seems to be used throughout the views (or at many places in the views at least), so that should work "everywhere", have a look at the views to see exactly how the links are created.

RE: Modify subject field formatting - Added by Marco Ceppi almost 14 years ago

Hello

Thank you for your help - the syntax is what I was looking for - the loop was pulled I believe from the issues_controller, I was able to remove that now. I'll continue my hunt - thanks again Felix for your guidance.

Marco

    (1-5/5)