How do I get the textual "issue type" name in the list view report, not just the icon?

John Pfotzer March 18, 2016

I would like to see the issue type " NAME" in my list view report, not only the issue type icon. How can I make that happen?

thanks

John

4 answers

1 accepted

0 votes
Answer accepted
Steven F Behnke
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 18, 2016

A quick fix could be to fix it with javascript. The real fix would be to customize the Issue Type field template. Both of these methods can be 'hacked' or implemented as plugins in the Server installation. There's really no help for JIRA Cloud folks on this matter.

For instance, you could toss this javascript in your announcement banner – 

<script>AJS.toInit(function(){
    // Our function that appends the image alt text to the image element
    function appendAltToImg(){
        AJS.$("td.issuetype > a > img").each(function(){
        $issueTypeElement = AJS.$(this);
        altTextReplacement = "<span> " + $issueTypeElement[0].alt + "</span>";
        $altTextReplacement = AJS.$(altTextReplacement);
        AJS.$(this).parent().append($altTextReplacement[0])
        });
    };
    // Call our function initally on page load
    appendAltToImg()
    // Also call the function when the navigator is refreshed
    JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) {
        if (reason == JIRA.CONTENT_ADDED_REASON.issueTableRefreshed) {
            appendAltToImg()
        };
    });
});
</script>

Or you could include a similar version of it as a webresource in a plugin within the Issue Navigator context.

 

Alternatively you can edit the template JIRA uses to display this field, located in the following path – 

<JIRA INSTALL DIRECTORY>/atlassian-jira/WEB-INF/classes/templates/jira/issue/field/issuetype-columnview.vm

You'd probably add something like <span> $textutils.htmlEncode($issuetype.getNameTranslation()</span> in between the <img> element and the end of the <a> element, something like this as the result – 

#if (!($displayParams &amp;&amp; $displayParams.get('nolink')))
    &lt;a class="issue-link" data-issue-key="${issue.getKey()}" href="${requestContext.baseUrl}/browse/${issue.getKey()}"&gt;#end #if ($displayParams.textOnly)$textutils.htmlEncode($!issuetype.nameTranslation, false)#else #set ($iconurl = $issuetype.iconUrlHtml)#if ($iconurl.startsWith('http://') || $iconurl.startsWith('https://'))&lt;img src="$iconurl" height="16" width="16" border="0" align="absmiddle" alt="$textutils.htmlEncode($issuetype.getNameTranslation(), false)" title="$textutils.htmlEncode($issuetype.getNameTranslation(), false) - $textutils.htmlEncode($!issuetype.getDescTranslation(), false)"&gt;#else&lt;img src="${requestContext.baseUrl}${iconurl}" height="16" width="16" border="0" align="absmiddle" alt="$textutils.htmlEncode($issuetype.getNameTranslation(), false)" title="$textutils.htmlEncode($issuetype.getNameTranslation(), false) - $textutils.htmlEncode($!issuetype.getDescTranslation(), false)"&gt;&lt;span&gt; $textutils.htmlEncode($issuetype.getNameTranslation()&lt;/span&gt;#end#end#if (!($displayParams &amp;&amp; $displayParams.get('nolink')))&lt;/a&gt;#end

Again, you could also package something similar to it up as a plugin.

John Pfotzer March 23, 2016

Steven, you are brilliant!!!!  I used the banner code above and BOOM. You make me look like a pro!!  

Thank you

John

Steven F Behnke
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 23, 2016

It's no problem, glad I could help. Consider marking my answer as correct!

A lot of the rendering is done client-side (anything that's not needed to be server-side validated) so Javascript in general is something you can use fairly heavily. It's good to either use a framework for it or to install it as plugins though, it's difficult to manage a lot of customizations in the announcement banner. Though for a quick fix it's nice.

I've faced this same question from a big customer in the past and had already performed some of this so adapting it for you was simple enough. Good luck! smile

Steven F Behnke
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 23, 2016

I'll note, a second glance at my logic in the if statement looks wonky. Looks like i was scripting late at night again. wink It's working but I am not performing the right check on the right reason. 

cross (reason !== JIRA.CONTENT_ADDED_REASON.issueTableRowRefreshed)

Should be

tick (reason == JIRA.CONTENT_ADDED_REASON.issueTableRefreshed)

 

The final script would be as follows, I'll edit my original response.– 

&lt;script&gt;AJS.toInit(function(){
    // Our function that appends the image alt text to the image element
    function appendAltToImg(){
        AJS.$("td.issuetype &gt; a &gt; img").each(function(){
        $issueTypeElement = AJS.$(this);
        altTextReplacement = "&lt;span&gt; " + $issueTypeElement[0].alt + "&lt;/span&gt;";
        $altTextReplacement = AJS.$(altTextReplacement);
        AJS.$(this).parent().append($altTextReplacement[0])
        });
    };
    // Call our function initally on page load
    appendAltToImg()
    // Also call the function when the navigator is refreshed
    JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) {
        if (reason == JIRA.CONTENT_ADDED_REASON.issueTableRefreshed) {
            appendAltToImg()
        };
    });
});
&lt;/script&gt;
0 votes
John Pfotzer March 23, 2016

wonderful thank you!

0 votes
John Pfotzer March 18, 2016

We use version 6.4.10 on server version on windows. I am not a coder, what level of customization are we talking? Obviously, this is not an out of the box change.

0 votes
Steven F Behnke
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 18, 2016

Can you describe your installation of JIRA? Server or Cloud? What version? Are you willing to customize the product?

Suggest an answer

Log in or Sign up to answer