Configure custom icons for Project Categories

Added by Manuel Palachuk over 2 years ago

Hello all,

I've managed to get custom icons set up for Issue Statuses and for Issue trackers by following some very useful posts here.
I would also like to get icons set up for the Categories. I am not a real programmer but I'm not without some skill and understanding.

I've followed the same formatting in the application.css for the theme but I'm missing and important element for the category field or how to get the category field to show up. I only needed to enter a few lines of code to the end of the application.css, nothing else. It just worked.

Using firebug I can see that everything is set up correctly but there is a statement that is not picking up the category.

With the Categories set up for the project and the entries to show the icons set up in the current theme application.css I can even make the icons show up if I edit and inject the category ID into the <tr line in questions.

The problem seems to be in the <div id="content"> for the Issues page and specifically in the <tr id= line below.

The line currently represents as this:
<tr id="issue-411" class="hascontextmenu odd issue tracker-2 status-2 priority-2 priority-default overdue">

Notice that the Tracker, Priority and Status all have their ID number.
But no Category is showing up (with or without an ID)

What I know is that if I inject the category ID (see next line), everything works.
<tr id="issue-411" class="hascontextmenu category-3 odd issue tracker-2 status-2 priority-2 priority-default overdue">

I've looked around to see if there is some other thing I need to define or set up but I'm lost.

Any help is appreciated.

Thanks

- Saylrman64

application.css Magnifier - Theme snippet (885 Bytes)

Div ID Content HTML (1.48 KB)

Replies (5)

RE: Configure custom icons for Project Categories - Added by Mischa The Evil over 2 years ago

Manuel Palachuk wrote:

[...]
The line currently represents as this:
<tr id="issue-411" class="hascontextmenu odd issue tracker-2 status-2 priority-2 priority-default overdue">

Notice that the Tracker, Priority and Status all have their ID number.
But no Category is showing up (with or without an ID)

[...]

I've looked around to see if there is some other thing I need to define or set up but I'm lost.

Well, it all boils down to the fact that this feature (having a category_id CSS class for issues) has not (yet) been implemented in the Redmine core (see Issue#css_classes, source:/trunk/app/models/issue.rb@14420#L1202). A quick search through the open issues (here on redmine.org) shows me that this feature has not been requested before.
Nevertheless, it won't be very hard to implement it. Adding a line like s << " category-#{category_id}" if category.present? to Issue#css_classes will do the job. Here's a patch against current source:/trunk@14420:

diff --git a/app/models/issue.rb b/app/models/issue.rb
index e0f93fa..4f3b463 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1202,6 +1202,7 @@ class Issue < ActiveRecord::Base
   # Returns a string of css classes that apply to the issue
   def css_classes(user=User.current)
     s = "issue tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}" 
+    s << " category-#{category_id}" if category.present?
     s << ' closed' if closed?
     s << ' overdue' if overdue?
     s << ' child' if child?

I hope this helps. Kind regards,

Mischa.

RE: Configure custom icons for Project Categories - Added by Manuel Palachuk over 2 years ago

OK so that was so cool.

Thank you sooo much.
I added the one line to the issues.rb and in addition to my application.css entries indicated it works perfectly.

I did not mention that I had taken the time to search forums and wikis and everything I could think of for Category Icons and found absolutely nothing. I cant believe I'm the first one to ask for this.

Thank you for making this very simple.
But how do I give back? how do I correctly request this get added to the root so others can use it without a hack?

Again, thank you so much!

P.S. Redmine rocks.

Saylrman64

RE: Configure custom icons for Project Categories - Added by Mischa The Evil over 2 years ago

Manuel Palachuk wrote:

[...]
how do I correctly request this get added to the root so others can use it without a hack?

Well, submissions has some info about how to open feature requests. But in this case I'll take care of it. I'll update the diff I've attached here with a proper test and file it as a patch issue.

Mischa.

RE: Configure custom icons for Project Categories - Added by Mischa The Evil over 2 years ago

Mischa The Evil wrote:

[...] But in this case I'll take care of it. I'll update the diff I've attached here with a proper test and file it as a patch issue.

Patch created and attached to issue #20289.

(1-5/5)