Hello,
i have a problem with my custom dialog in jira.
I created a custom dialog with the rest endpoint and fragment item and this works very well. The dialog opens and shows alle fields, tables. But now i need some javascript to give this dialog some functions. But i dont know, how to do it. I followed this blog from adaptavist.
If i add the <script>...</script> tag, the dialog wont open. And i cant find an error message, what the reason could be.
What i`m doing wrong? I hope you could help me.
I found the Dialogs (Advanced) documentation from adaptavist, but i dont understand js part below. What should i do? I hope you guys can guide me to the solution to successfully using javascript.
This is my rest endpoint script:
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue
import groovy.transform.BaseScript
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
@BaseScript CustomEndpointDelegate delegate
static getUsersFromAD(String adGroup) {
def groupManager = ComponentAccessor.getGroupManager()
Collection users = groupManager.getUsersInGroup(adGroup)
return users[0].getDisplayName()
}
static getDialogContent(String issueKey) {
return """
<script type="text/javascript">
</script>
<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">Edit cost units</h2>
<button class="aui-close-button" type="button" aria-label="close"></button>
</header>
<div class="aui-dialog2-content">
<div id="Container" style="width:px">
<form class="aui">
<div id="colmn1" class="field-group">
<label for="ktr-input">KTR</label>
<input id="ktr-input" class="text" type="number" name="ktr-input"/>
</div>
<div id="colmn2" class="field-group">
<label>KTR Identifkation</label>
<div>
<input type="radio" id="flag-3" name="flag" value="3" checked>
<label for="flag-3">first 3</label><br>
</div>
<div>
<input type="radio" id="flag-complete" name="flag" value="complete">
<label for="flag-complete">Complete</label><br>
</div>
</div>
<div id="colmn3" class="field-group">
<label for="select-responsible">responsible</label>
<select class="select" id="select-responsible" name="select-responsible">
<option>Person X</option>
<option>Person Y</option>
<option>Person Z</option>
</select>
</div>
<div id="colmn4" class="field-group">
<label for="select-gf">Manager</label>
<select class="select" id="select-gf" name="select-gf">
<option>Person X</option>
<option>Person Y</option>
<option>Person Z</option>
</select>
</div>
<div style="float: right; margin-top: 10px; margin-bottom: 20px;">
<button id="addToTable" class="aui-button aui-button-primary">add</button>
<button id="removeFromTable" class="aui-button">clear</button>
</div>
<table class="aui">
<thead>
<tr>
<th id="KTR">KTR</th>
<th id="Responsible">Responsible</th>
<th id="GF">GF</th>
<th id="Action">Action</th>
</tr>
</thead>
<tbody>
<tr>
<td headers="KTR">733</td>
<td headers="Responsible">Person X</td>
<td headers="GF">Person Y</td>
<td headers="Action">
<button class="aui-button aui-button-link" id="edit1">Edit</button>
<button class="aui-button aui-button-link" id="delete1">Delete</button>
</td>
</tr>
<tr>
<td headers="KTR">378</td>
<td headers="Responsible">Person Z</td>
<td headers="GF">Person ZZ</td>
<td headers="Action">
<button class="aui-button aui-button-link" id="edit2">Edit</button>
<button class="aui-button aui-button-link" id="delete2">Delete</button>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
<footer class="aui-dialog2-footer">
<div class="aui-dialog2-footer-actions">
<button class="aui-button aui-button-primary" id="submit">Update</button>
<button id="dialog-close-button" class="aui-button aui-button-link"">Close</button>
</div>
<div class="aui-dialog2-footer-hint">This is a footer message</div>
</footer>
</section>
"""
}
// REST
showEditDialogCostUnit(groups: ["jira-administrators"]) { MultivaluedMap queryParams ->
def issueKey = queryParams.getFirst("issueId") as String
//String users = getUsersFromAD("")
String dialog = getDialogContent(users);
Response.ok().type(MediaType.TEXT_HTML).entity(dialog.toString()).build()
}
My goal is to give these buttons some functionalities.
Our jira test system: v8.13.6, Scriptrunner: 6.23.0
Thx for your help.