Hello 
I have set-up a script fragment with an associated REST Endpoint, to generate a dialog pop-up (please see screenshot). The current implementation is that the user selects as assignee from a drop-down list, an issue type from a drop-down list, and hits create to clone the current task as a sub-task, with the selected parameters from the pop-up.
The issue is that having a drop-down select list of assignees is bad as it isn't scalable. My intended implementation is for the assignee field to act similarly to the reporter/assignee field when creating an issue, where the user can start typing a name and a list of suggestions appears and updates with every keystroke. I'm struggling to figure out a way of making this happen.
My research leads me to believe that I need to use a custom field embedded within HTML in some way. However I'm at a total loss with how to do this. I'm not even sure if using a custom field is the right way to go about implementing this, is there some other way that I've missed.?
Below is my code for displaying the pop-up dialog, as you can see right now it displays the assignees as select options within a form. Any direction would be very much appreciated, thank you.
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.transform.BaseScript
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.config.properties.APKeys
@BaseScript CustomEndpointDelegate delegate
cloneSubTaskDialog { MultivaluedMap queryParams ->
def issueKey = queryParams.getFirst("issueKey").toString()
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject(issueKey)
// createIssue endpoint to run upon submitting form
def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
def actionUrl = """
${baseUrl}/rest/scriptrunner/latest/custom/cloneAsSubTask?
"""
def header = """
<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>
"""
def assigneeSelectHTML = ""
ComponentAccessor.userManager.getAllApplicationUsers().each { type ->
assigneeSelectHTML += "<option value=${type.name}>${type.name}</option>"
}
def issueTypesSelectHTML = ""
ComponentAccessor.constantsManager.subTaskIssueTypeObjects.each { type ->
issueTypesSelectHTML += "<option value=${type.id}>${type.name}</option>"
}
def content = """
<div class="aui-dialog2-content">
<p>Select an assignee and issue type for the Sub-Task</p><br>
<form id="clone-form" class="aui" action="${actionUrl}">
<p>Assignee</p>
<select name="assigneeId">
${assigneeSelectHTML.value}
</select><br><br>
<p>Issue type</p>
<select name="issueTypeId">
${issueTypesSelectHTML.value}
</select>
<input name='projectId' type='hidden' value="${issue.getProjectId()}">
<input name='reporterId' type='hidden' value="${issue.reporterId}">
<input name='summary' type='hidden' value="${issue.summary}">
<input name='description' type='hidden' value="${issue.description}">
<input name='priorityId' type='hidden' value="${issue.priority.id}">
<input name='parentId' type='hidden' value="${issue.getId()}">
</form>
</div>
"""
def footer = """
<footer class="aui-dialog2-footer">
<div class="aui-dialog2-footer-actions">
<button type="submit" form="clone-form" class="aui-button aui-button-primary">Create</button>
</div>
<div class="aui-dialog2-footer-hint">All issue details will be copied over into the new Sub-Task</div>
</footer>
"""
def dialog = """
<section id="static-dialog" class="aui-layer aui-dialog2 aui-dialog2-medium" role="dialog" aria-hidden="true">
${header}
${content}
${footer}
</section>
"""
Response.ok().type(MediaType.TEXT_HTML).entity(dialog.toString()).build()
}
