I have a web panel displayed on jira issue details view page.
The content of this web panel should be refreshed after a click on a submit button (that also exist on same webpanel section).
The content is generated using a velocity template that get data from a ContextMap provider.
Currently, I use a location.load() after a click on submit button, but we need only refresh the webpanel component not reload the issue view page to get the new data.
web panel declaration:
<span><!-- Panel to display data from external app --></span>
<span><web-panel name="Test"
i18n-name-key="data-panel.name" key="data-panel"
location="atl.jira.view.issue.left.context" weight="200"></span>
<span><description key="data-panel.description"></span>The Issue View Data Panel<span></description></span>
<span><context-provider class="com.plugin.provider.ContextProvider"/></span>
<span><resource name="view" type="velocity"
location="/templates/webpanel-module/data-panel.vm" /></span>
<span><supports-ajax-load></span>true<span></supports-ajax-load></span>
<span></web-panel></span>
data-panel.vm file:
<span><div id="content-attach" style="display:none;"></span>
<span><form class="aui" action=""></span>
<span><div class="input-group"></span>
<span><input type="text"
class="controls-input" id="inputUrl"/></span>
<span><input class="aui-button aui-button-primary attach-button" id="submit-form" type="submit" value="Attach Data"/></span>
<span></div></span>
<span></form></span>
<span></div></span>
<span><div id="content-results"></span>
....
<span></div></span>
issue-view-controller.js :
AJS.$(<span>function()</span>{
AJS.$(<span>"#submit-form"</span>).click(<span>function(e)</span>{
e.preventDefault();
...
AJS.$.ajax({
<span>url</span>: AJS.params.baseURL+<span>'/rest/testforjira/1.0/config/object/issue/link'</span>,
<span>type</span>: <span>'PUT'</span>,
<span>contentType</span>: <span>'application/json'</span>,
<span>data</span>: <span>JSON</span>.stringify(dataInput),
<span>processData</span>: <span>false</span>,
<span>success</span>: <span>function() </span>{
AJS.$(<span>"#content-attach"</span>).hide();
<span>// refresh web-panel data</span>
location.reload();
AJS.$(<span>"#content-results"</span>).show();
showSuccessFlag(<span>'Object is linked to Jira issue.'</span>);
},
<span>error</span>: <span>function() </span>{
AJS.$(<span>"#content-attach"</span>).show();
AJS.$(<span>"#content-results"</span>).hide();
showErrorFlag(<span>'Failed to link Object to jira issue.'</span>);
}
});
});
});