I am wondering how could I open the Edit issue dialog programatically. I know how to do it on the issue page, but I would like to do it from elsewhere. I’ve been following this https://developer.atlassian.com/server/jira/platform/displaying-content-in-a-dialog-in-jira/
but it doesn’t seem to work.
Currently, I’m taking several operations from the REST resource for a selected issue, and appending the buttons to the document, some of them work fine, some of the redirect to a new page, but most of them I don’t need.
EDIT: What I mean by doesn’t seem to work is that some of the page data is missing, I guess, and I’m getting an error in the browser console like “x is undefined”. So what I tried to do is actually write own handler for the dialog, and what happened was after using AJS.$.load to load the data into the dialog there the CSS and all the fields would load, however, select2 wasn’t init’d on the fields it was supposed to.
I believe I’m missing something obvious, like I have to require an ADM module or there is a parameter I have to pass to “new JIRA.Dialog”, or something similar, but I don’t know where to start.
Weird thing is, issue transitions work perfectly, without custom handling of the dialogs or ajax requests.
I’m also tryna do this for the Assign and Comment form. JS which handles the Assign to me button is not initialized either, but I can init some custom js to select a value in the select on click so that is not a problem.
Another wierd thing is, these dialogs are opened based on the page they fetch using the specified URL in the anchor tag, which is kinda cool. However, other parameters I found on some of these links (like data-issuekey, data-issueid) don’t seem to be taken into consideration when creating a new JIRA.Dialog (after inspection those values turn out to be null), as well as the returnUrl I specifiy to go to the my (current) page, actually points to /browse/ISSUE-KEY. Not a problem since I will handle the Cancel button with a closing operation on the dialog, but still, could it actually be a bug? The behaviour is the same when I open the link in a new tab - the form is displayed, everything works fine, but the “Return to issue” link points to an issue, instead of returnUrl. Is this the desired behaviour, or is it a bug?
EDIT 2: After solution found
So, now I have another problem, and it’s related to the attachment field; what happens is this (after I run JIRA.trigger): “l[z] is not a function”
I inspected the line throwing the error and it looks to be tied to a define directive defining “dndattachment/init” so … This is all I’ve got so far. I’ll update this topic if I find more stuff.