Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Scriptrunner: Dialog to feature assignee search field

Matt October 9, 2019

I'm trying to implement a popup dialog on web item click using ScriptRunner. The Adaptavist docs on the subject are sorely lacking, and it doesn't seem to be widely documented elsewhere.

Can anyone point me at some resources, or provide some sample code, to help me have an assignee search field appear on the dialog? 

The dialog will prompt the user to choose between available sub-task types, pick an assignee and then hits an endpoint with given data to create a sub-task. 

My dialog code so far:

import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response


@BaseScript CustomEndpointDelegate delegate

createSubTask { MultivaluedMap queryParams ->
def typesOptionsHTML = ""
def allIssueTypes = ComponentAccessor.constantsManager.subTaskIssueTypeObjects.each { type ->
typesOptionsHTML += "<option value=\"${type.name}\">${type.name}</option>"
}

def issueKey = queryParams.getFirst("issueKey") as String

def dialog =
"""<section role="dialog" id="sr-dialog" class="aui-layer aui-dialog2 aui-dialog2-medium" aria-hidden="true" data-aui-remove-on-hide="true">
<header class="aui-dialog2-header">
<h2 class="aui-dialog2-header-main">Clone ${issueKey} as Sub-Task</h2>
<a class="aui-dialog2-header-close">
<span class="aui-icon aui-icon-small aui-iconfont-close-dialog">Close</span>
</a>
</header>

<div class="aui-dialog2-content">
<p>Select an assignee and issue type for the Sub-Task</p><br>
<div id="container" style="width:px">
<form class="aui">
<div id="type">
<div class="aui-dropdown2-section">Type:
<select>
${typesOptionsHTML}
</select>
</div>
</div>
</form>
</div>
</div>

<footer class="aui-dialog2-footer">
<div class="aui-dialog2-footer-actions">
<button id="dialog-close-button" class="aui-button aui-button-link">Close</button>
</div>
<div class="aui-dialog2-footer-hint">All issue details will be copied over into the new Sub-Task</div>
</footer>
</section>
"""

Response.ok().type(MediaType.TEXT_HTML).entity(dialog.toString()).build()
}

Also, as an aside, I could do with some explanation on the classes used in the Adaptavist examples. Are these implemented by JIRA - can I just use these to maintain a consistent style? Are these documented anywhere? 

 

Thanks!!

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events