Skip to content

Instantly share code, notes, and snippets.

View chuikoaleksandr's full-sized avatar

Chuiko Aleksandr chuikoaleksandr

  • @Mail.Ru
  • Russia
View GitHub Profile
@chuikoaleksandr
chuikoaleksandr / Jira-JsIncluder-example-add required.js
Created January 11, 2019 14:09
Atlasteam, Jira, plugin JsIncluder. Add field is required. For https://atlasteam.ru/?p=1925
AJS.$('#customfield_10000, label[for="customfield_10000"]').append('<span class="aui-icon icon-required"></span>');
@chuikoaleksandr
chuikoaleksandr / Jira-JsIncluder-example-hide priority.js
Created January 11, 2019 14:00
Atlasteam, Jira, plugin JsIncluder. Hide priority option on create. For https://atlasteam.ru/?p=1925
AJS.$('#priority > option[value=1]').remove()
import com.opensymphony.workflow.InvalidInputException
if (issue.type.id in [10000]) {
throw new InvalidInputException("Not valid issue type")
}
@chuikoaleksandr
chuikoaleksandr / Jira-JsIncluder-example-hide issue type.js
Created January 11, 2019 13:54
Atlasteam, Jira, plugin JsIncluder. Hide issue type on create. For https://atlasteam.ru/?p=1925
function hideIssueType(issueTypeName) {
var elem = "<style type=\"text/css\">#issuetype-suggestions .aui-list-item-li-" + issueTypeName + " {display: none}</style>";
AJS.$("head").append(elem);
}
hideIssueType('application')
@chuikoaleksandr
chuikoaleksandr / Jira-JsIncluder-example-hide fileds for groups.js
Last active January 11, 2019 13:49
Atlasteam, Jira, plugin JsIncluder. When to hide fields depending on the user group. For https://atlasteam.ru/?p=1925
(function ($) {
function hideField(fieldId) {
$('div.field-group:has(#customfield_' + fieldId + ')').hide()
}
function isUserInGroup(groupName) {
return JS_INCLUDER.params.userDetails.groupNames.indexOf(groupName) != -1
}
if (isUserInGroup('jira-users')) {
@chuikoaleksandr
chuikoaleksandr / groovy easy base.groovy
Last active December 19, 2018 11:59
simple groovy base tutorial for https://atlasteam.ru/?p=1834
//Как объявить переменную
def a = 5 //целое число
def а = -5.4 //отрицательное число с дробной частью
def a = 'test' //обычная строка
def a = true //логическая переменная true/false
def a = null //значение отсутствует
//как вернуть/вывести на кран значение
return a
import com.atlassian.jira.component.ComponentAccessor
def getCustomFieldValue(issue, Long fieldId) {
ComponentAccessor.customFieldManager.getCustomFieldObject(fieldId)?.getValue(issue)
}
def customSelects = [10001,10002,10003]//todo set Custom Select List field id
def rezult = 1
customSelects.each{cfId->
rezult *= getCustomFieldValue(issue, cfId)?.data as Integer
@chuikoaleksandr
chuikoaleksandr / approve(next status) condition.groovy
Last active November 13, 2018 14:31
JIRA process approval. MyGroovy + Custom select. All process in 1 workflow status. https://atlasteam.ru/?p=1746
import com.atlassian.jira.component.ComponentAccessor
import groovy.json.JsonSlurper
cfStep = ComponentAccessor.customFieldManager.getCustomFieldObject(10003)//Text Field (single line)
cfCustomSelect = ComponentAccessor.customFieldManager.getCustomFieldObject(10004)//Custom Select List
def customSelectValue = issue.getCustomFieldValue(cfCustomSelect)
if(!customSelectValue){
return false
}
@chuikoaleksandr
chuikoaleksandr / validator-example1.groovy
Created November 13, 2018 14:21
Jira MyGroovy simple validator custom field example
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
def CUSTOM_FIELD_ID = 14910L
def MESSAGE_ERROR = "Field ${getCustomFieldObject(CUSTOM_FIELD_ID)} is required"
if(!getCustomFieldValue(issue, CUSTOM_FIELD_ID)){
throw new InvalidInputException(MESSAGE_ERROR)
}
@chuikoaleksandr
chuikoaleksandr / approve(next status) condition.groovy
Last active November 13, 2018 11:28
JIRA process approval. MyGroovy + Custom select. All process in 1 workflow status.
import com.atlassian.jira.component.ComponentAccessor
import groovy.json.JsonSlurper
cfStep = ComponentAccessor.customFieldManager.getCustomFieldObject(10003)//Text Field (single line)
cfCustomSelect = ComponentAccessor.customFieldManager.getCustomFieldObject(10004)//Custom Select List
def customSelectValue = issue.getCustomFieldValue(cfCustomSelect)
def processApproval = parseText(customSelectValue.getData())