You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
A custom field that pulls custom plugin data from the jira database is retaining data from the previous jira issue when nexting to the next jira issue. This leads to improper values being displayed to the user.
This issue only occurs with the custom field when nexting through Jira issue search results.
The version of Jira Data Center being used is version 9.4
Below is the view.vm file for the custom field, along with the javascript file executed by the field. id = id, issue.key = Jira Issue Key, stage = D,T,C
view.vm
#disable_html_escaping()
$webResourceManager.requireResource("com.custom.field:devops-revision-field-resources")
$webResourceManager.requireResource("com.atlassian.auiplugin:aui-experimental-expander")
<div id="${id}" class="devops">
<div id="${id}" class="button-spinner"></div>
</div>
<script>
// Idea for logic below came from https://javascript.info/onload-ondomcontentloaded#:~:text=we%20can%20check-,document.readyState,-and%20setup%20a
function loadRevs() {
return loadRevisionField("${id}","${issue.key}","${stage}");
}
if (document.readyState == 'loading') {
document.addEventListener('DOMContentLoaded', loadRevs);
} else {
loadRevs();
}
</script>
revisonfields.js
function loadRevisionField(fieldID,issueKey,stage){
console.log("Args: "+fieldID+":"+issueKey+":"+stage);
RevAPI.baseURL = window.location.origin;
function displayRevs(revInfo){
AJS.$('#'+fieldID+'.button-spinner').spinStop();
let domObj = AJS.$('#'+fieldID+'.devops');
for(let r in revInfo){
let rev = revInfo[r];
appendRevision(domObj, rev);
}
}
AJS.$('#'+fieldID+'.button-spinner').spin();
RevAPI.getRevisions(displayRevs,issueKey,stage)
}
function appendRevision(domObj,rev){
const maxPaths = 20;
console.log('adding revision');
console.log(rev);
let input = AJS.$('<input id="toggle-'+
rev.repo_name+'-'+rev.revision_number+
'" class="toggle devops-revs" type="checkbox">');
let label = AJS.$('<label for="toggle-'+
rev.repo_name+'-'+rev.revision_number+
'" class="devops-revs"></label>');
let revLink = AJS.$('<a href="'+rev.link+'">'+
rev.repo_name+'|'+rev.revision_number+'</a>');
label.append(revLink);
const expander = AJS.$('<div class="expand devops-revs"></div>');
let paths = AJS.$('<section></section>');
for (p in rev.paths){
let path = rev.paths[p];
let pathObj = AJS.$('<div class="rev-path"></div>')
if (path.isBuilt){
pathObj.append('<span class="circle green"></span>')
} else {
pathObj.append('<span class="circle red"></span>')
}
pathObj.append('<span class="path">'+path.path+'</span>')
paths.append(pathObj)
if(p==maxPaths){
let leftOver = rev.paths.length - maxPaths;
if(leftOver>0){
let more = AJS.$('<div class="rev-path"></div>');
more.append(leftOver+' more things on this revision');
paths.append(more);
}
break;
}
}
expander.append(paths);
domObj.append(input).append(label).append(expander);
}
var RevAPI={
baseURL: null,
getRevisions: function(callback, issueKey, stage){
const url = RevAPI.baseURL+'/rest/devops/1.0/rev/issue/'+issueKey+'/'+stage;
AJS.$.get(url,[],function(resp){
callback(resp);
});
}
}