Hello community!
I've created script fragments "Custom Web item" with name "MyButton" which runs code and displays a dialog (Link: https://myjira.com/rest/scriptrunner/latest/custom/showDialogNew)
In REST Endpoints I've created Rest Endpoint showDialogNew
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.transform.BaseScript
@BaseScript CustomEndpointDelegate delegate
showDialog { MultivaluedMap queryParams ->
//Some groovy here
def dialog =
"""
<section id="create-dialog" class="aui-dialog2 aui-dialog2-large aui-layer" data-aui-remove-on-hide="true" role="dialog" aria-hidden="true">
<form id="new-change-form" class="aui">
//Form is here
</form> <footer class="aui-dialog2-footer">
<div class="aui-dialog2-footer-actions">
<button id="my-dialog-ok-button" form="new-change-form" type="submit">Save</button>
<button id="my-dialog-cancel-button" Cancel</button>
</div>
</footer>
\$("#new-change-form").submit(function (e) {
e.preventDefault();
var form_data = \$(this).serializeObject();
form_data.parentIssue = JIRA.Issue.getIssueKey();
var request = JIRA.SmartAjax.makeRequest({
type: 'POST',
data: JSON.stringify(form_data),
dataType: 'json',
contentType: 'application/json'
});
request.fail(function(){
alert(Some problem: '+request.responseText);
});
request.done(function(){
location.reload();
});
AJS.dialog2("#create-dialog").hide();
}); </script>
"""
Response.ok().type(MediaType.TEXT_HTML).entity(dialog.toString()).build()
}
I want to debug this script in chrome dev tools when I push "MyButton", but I can't find my script in source tab. How can I debug it?
Also why making ajax calls like JIRA.SmartAjax.makeRequest({ }); works but here it looks like AJS.$.ajax({ }); what is the difference and where can I find any docs about js api?
I will be glad for any help.