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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,819
Community Members
 
Community Events
184
Community Groups

Displaying a searchable list of users in a generated dialog pop-up

Edited

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()
}

 

dialog.PNG

2 answers

1 accepted

1 vote
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 28, 2019

Hi Luke,

Thank you for your question.

I can confirm that ScriptRunner for Jira Server only has limited support for Dialogs as described in the documentation page located here.  

This means that with dialogs that to anything advanced such as creating a field which searches for users that you would need to write a bespoke javascript function that would search for the users that were typed in the field, as ScriptRunner for Jira Server contains no built in functionality to be able to put standard Jira custom fields such as User Picker fields on the Dialog.

I understand that this response is frustrating but please understand that the methods do not exist to create this functioanlity as explained above.

Regards,

Kristian

:'(

No worries, thank you for the response.

Hello Luke,

I'm in a similar situation where I have a list of values (just good old strings, nothing fancy) from a custom field displayed in a select list, and I'd like to be able to offer suggestions as the user starts typing in a search text field.

I was wondering where you ended up with your problem and if you'd have any suggestions or pointers for me. I'm not a JavaScript person but I have just about enough experience in coding that I should be able to cook something up once I have the starting point. 

Thank you so much!

Kamran 

@Luke Jones 

@Kristian Walker _Adaptavist_ 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events