Created
January 11, 2019 14:22
-
-
Save chuikoaleksandr/31cdf0797c72fabf3527316f5e7998d5 to your computer and use it in GitHub Desktop.
Atlasteam, Jira, plugin JsIncluder. Set assignee. For https://atlasteam.ru/?p=1925
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
setAssignee('admin'); | |
function setAssignee(name) { | |
var setValue = name; | |
var $field = $("#assignee"); | |
$.get(AJS.params.baseURL + "/rest/api/latest/user", { | |
username: setValue | |
}, function (data) { | |
$("#assignee-single-select").remove(); | |
var option = $("#assignee").find("option[value=\"" + setValue + "\"]"); | |
if (option.length === 0) { | |
option = $("<option></option>"); | |
option.text(data.displayName); | |
option.attr("value", data.name); | |
option.attr("data-field-text", data.displayName); | |
option.attr("data-icon", data.avatarUrls["16x16"]); | |
option.attr("data-field-label", AJS.format( | |
"{0} - {1} ({2})", | |
data.displayName, | |
data.emailAddress, | |
data.name | |
)); | |
$("#assignee-group-suggested").append(option); | |
} | |
$field.val(setValue); | |
option.attr("selected", "selected"); | |
var picker = new JIRA.AssigneePicker({ | |
element: $field, | |
editValue: setValue | |
}); | |
$("#assignee").trigger('set-selection-value', setValue); | |
}); | |
} | |
})(AJS.$) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment