Is it possible to change label color in any simple way?
For instance:
If Task has not reached it's due date, then make this 'Due' string with green color, if past due - red one.
Community moderators have prevented the ability to post new answers.
You could create a Scripted Field (via Script Runner plugin) with following details:
and this script:
import com.atlassian.jira.util.I18nHelper import com.atlassian.jira.web.bean.I18nBean import com.atlassian.jira.web.util.OutlookDate def outlookDateManager = componentManager.outlookDateManager def user = componentManager.jiraAuthenticationContext.getLoggedInUser() I18nHelper i18nBean = new I18nBean(user) OutlookDate outlookDate = outlookDateManager.getOutlookDate(i18nBean.getLocale()) def dueDate = issue.getDueDate() def now = new Date() if (dueDate) { def dueDateText = outlookDate.formatDatePicker(dueDate) if (now > dueDate) { return "<div style='color:red;'><b>" + dueDateText + "</b></div>" } else { return "<div style='color:green;'>" + dueDateText + "</div>" } } else { return null }
Now you could use this custom field in your issue navigator to display the colored due date.
Henning
Hi jeetu,
the OutlookDateManager has nothing to do with MS Outlook. It's a class from the JIRA API to format dates.
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Henning,
I am getting following error
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script2.groovy: 15: expecting ')', found ';' @ line 15, column 16.
if (now > dueDate) {
^
1 error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh, yes, seems to be a transfer error from moving the answer from Answers to Community... I corrected the script.
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Henning ,placed the code in the scripted field. i am getting the floowing error.Could you please debug the error
ERROR [customfield.GroovyCustomField]: Script field failed on issue: BISR-25, field: Dt
groovy.lang.MissingPropertyException: No such property: outlookDateManager for class: com.atlassian.jira.ComponentManager
at Script4.run(Script4.groovy:5)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Which JIRA version do you use?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, the code above is for an older version. Use this instead:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.datetime.DateTimeFormatterFactory
def formatter = ComponentAccessor.getComponent(DateTimeFormatterFactory).formatter()
def dueDate = issue.getDueDate()
def now = new Date()
if (dueDate) {
def dueDateText = formatter.format(dueDate)
if (now > dueDate) {
return "<div style='color:red;'><b>" + dueDateText + "</b></div>"
} else {
return "<div style='color:green;'>" + dueDateText + "</div>"
}
} else {
return null
}
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How about trying it by yourself? :-) It's important to learn this stuff because you have to support it for system updates and so on...
You can simply substract days from dates. So "dueDate - 3" is three days before due date. And "color:yellow" could be used for yellow.
If you have problems, paste your code and the errors you get.
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well done! :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've created a javascript script, then my issue labels show as follows:
Selection_038.jpg
Setup the color on the board
Selection_040.jpg
Selection_039.jpg
Show the labels on the cards
Selection_042.jpg
Use the script bellow on tampermonkey extension (tampermonkey is a script runner extension for many browsers)
// ==UserScript== // @name New Userscript // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://youratlassian.atlassian.net/secure/* // @grant none // ==/UserScript== (function($) { function doSomething(){ $('*[data-tooltip*="Labels"]').each(function(){ var css = $(this).parents('.js-detailview') .find('.ghx-grabber').attr('style') ; $(this).attr('style', css).css({ 'padding': '2px 3px', 'color': '#303030', 'text-shadow': '1px 1px 1px white', 'border': '1px solid #808080' }); }); } setTimeout(doSomething, 1000); setInterval(doSomething, 1000 * 10); })(jQuery);
Obs: there is a limitation, JIRA will apply only one color by card
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I don't understand your question, could you provide more details? What do you mean with label?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.