FIX Display Super Issue
This commit is contained in:
parent
e6f5ce1e0d
commit
0bbdafee99
102
bookmarklet.js
102
bookmarklet.js
@ -1,6 +1,6 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var global = {};
|
var global = {};
|
||||||
global.version = "4.2.3";
|
global.version = "4.2.4";
|
||||||
global.issueTrackingUrl = "https://github.com/qoomon/Jira-Issue-Card-Printer";
|
global.issueTrackingUrl = "https://github.com/qoomon/Jira-Issue-Card-Printer";
|
||||||
global.isDev = document.currentScript == null;
|
global.isDev = document.currentScript == null;
|
||||||
global.isProd = !global.isDev;
|
global.isProd = !global.isDev;
|
||||||
@ -26,7 +26,8 @@
|
|||||||
init().then(function(){
|
init().then(function(){
|
||||||
main();
|
main();
|
||||||
}).catch(function(cause){
|
}).catch(function(cause){
|
||||||
alert("ERROR on init! Please create an issue at " + global.issueTrackingUrl);
|
console.log("ERROR " + JSON.stringify(cause,2,2));
|
||||||
|
alert("Sorry somthing went wrong. Please create an issue at " + global.issueTrackingUrl);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -114,19 +115,19 @@
|
|||||||
initGoogleAnalytics();
|
initGoogleAnalytics();
|
||||||
}
|
}
|
||||||
|
|
||||||
promises.push(httpGetCors(global.hostOrigin + "card.html").then(function(data){
|
promises.push(httpGetCORS(global.hostOrigin + "card.html").then(function(data){
|
||||||
global.cardHtml = data;
|
global.cardHtml = data;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
promises.push(httpGetCors(global.hostOrigin + "card.css").then(function(data){
|
promises.push(httpGetCORS(global.hostOrigin + "card.css").then(function(data){
|
||||||
global.cardCss = data.replace(/https:\/\/qoomon.github.io\/Jira-Issue-Card-Printer\/resources/g, global.resourceOrigin);
|
global.cardCss = data.replace(/https:\/\/qoomon.github.io\/Jira-Issue-Card-Printer\/resources/g, global.resourceOrigin);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
promises.push(httpGetCors(global.hostOrigin + "printPreview.html").then(function(data){
|
promises.push(httpGetCORS(global.hostOrigin + "printPreview.html").then(function(data){
|
||||||
global.printPreviewHtml = data
|
global.printPreviewHtml = data
|
||||||
}));
|
}));
|
||||||
|
|
||||||
promises.push(httpGetCors(global.hostOrigin + "printPreview.css").then(function(data){
|
promises.push(httpGetCORS(global.hostOrigin + "printPreview.css").then(function(data){
|
||||||
global.printPreviewCss = data.replace(/https:\/\/qoomon.github.io\/Jira-Issue-Card-Printer\/resources/g, global.resourceOrigin);
|
global.printPreviewCss = data.replace(/https:\/\/qoomon.github.io\/Jira-Issue-Card-Printer\/resources/g, global.resourceOrigin);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -169,7 +170,7 @@
|
|||||||
jQuery("body", printDocument).append(card);
|
jQuery("body", printDocument).append(card);
|
||||||
|
|
||||||
promises.push(global.appFunctions.getCardData(issueKey).then(function(cardData) {
|
promises.push(global.appFunctions.getCardData(issueKey).then(function(cardData) {
|
||||||
//console.log("cardData: " + cardData);
|
console.log("cardData: " + JSON.stringify(cardData,2,2));
|
||||||
if (global.isProd) {
|
if (global.isProd) {
|
||||||
ga('send', 'event', 'card', 'generate', cardData.type);
|
ga('send', 'event', 'card', 'generate', cardData.type);
|
||||||
}
|
}
|
||||||
@ -188,7 +189,9 @@
|
|||||||
});
|
});
|
||||||
console.log("wait for resources loaded...");
|
console.log("wait for resources loaded...");
|
||||||
printDocument.close();
|
printDocument.close();
|
||||||
});
|
}).catch(function(cause){
|
||||||
|
console.log("ERROR " + JSON.stringify(cause))
|
||||||
|
});;
|
||||||
}
|
}
|
||||||
|
|
||||||
function redrawCards() {
|
function redrawCards() {
|
||||||
@ -251,9 +254,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Epic
|
//Epic
|
||||||
if (data.epicKey) {
|
if (data.superIssue) {
|
||||||
card.find(".issue-epic-id").text(data.epicKey);
|
card.find(".issue-epic-id").text(data.superIssue.key);
|
||||||
card.find(".issue-epic-name").text(data.epicName);
|
card.find(".issue-epic-name").text(data.superIssue.summary);
|
||||||
} else {
|
} else {
|
||||||
card.find(".issue-epic-box").addClass("hidden");
|
card.find(".issue-epic-box").addClass("hidden");
|
||||||
}
|
}
|
||||||
@ -818,10 +821,18 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function httpGetCors(url, callback){
|
function httpGetCORS(){
|
||||||
return jQuery.get('https://jsonp.afeld.me/?url=' + url, callback);
|
arguments[0] = 'https://jsonp.afeld.me/?url=' + arguments[0];
|
||||||
|
return httpGet.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function httpGet(){
|
||||||
|
return Promise.resolve(jQuery.get.apply(this, arguments));
|
||||||
|
}
|
||||||
|
|
||||||
|
function httpGetJSON(){
|
||||||
|
return Promise.resolve(jQuery.getJSON.apply(this, arguments));
|
||||||
|
}
|
||||||
|
|
||||||
function multilineString(commentFunction) {
|
function multilineString(commentFunction) {
|
||||||
return commentFunction.toString()
|
return commentFunction.toString()
|
||||||
@ -892,6 +903,7 @@
|
|||||||
var issueData = {};
|
var issueData = {};
|
||||||
|
|
||||||
promises.push(module.getIssueData(issueKey).then(function(data) {
|
promises.push(module.getIssueData(issueKey).then(function(data) {
|
||||||
|
var promises = [];
|
||||||
issueData.key = data.key;
|
issueData.key = data.key;
|
||||||
issueData.type = data.fields.issuetype.name.toLowerCase();
|
issueData.type = data.fields.issuetype.name.toLowerCase();
|
||||||
issueData.summary = data.fields.summary;
|
issueData.summary = data.fields.summary;
|
||||||
@ -911,11 +923,18 @@
|
|||||||
|
|
||||||
issueData.hasAttachment = data.fields.attachment.length > 0;
|
issueData.hasAttachment = data.fields.attachment.length > 0;
|
||||||
issueData.storyPoints = data.fields.storyPoints;
|
issueData.storyPoints = data.fields.storyPoints;
|
||||||
issueData.epicKey = data.fields.epicLink;
|
|
||||||
|
|
||||||
if (issueData.epicKey) {
|
if (data.fields.parent) {
|
||||||
promises.push(module.getIssueData(issueData.epicKey).then(function(data) {
|
promises.push(module.getIssueData(data.fields.parent.key).then(function(data) {
|
||||||
issueData.epicName = data.fields.epicName;
|
issueData.superIssue = {};
|
||||||
|
issueData.superIssue.key = data.key;
|
||||||
|
issueData.superIssue.summary = data.fields.summary;
|
||||||
|
}));
|
||||||
|
} else if (data.fields.epicLink) {
|
||||||
|
promises.push(module.getIssueData(data.fields.epicLink).then(function(data) {
|
||||||
|
issueData.superIssue = {};
|
||||||
|
issueData.superIssue.key = data.key;
|
||||||
|
issueData.superIssue.summary = data.fields.epicName;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,13 +947,11 @@
|
|||||||
issueData.dueDate = new Date(data.fields.desiredDate).format('D d.m.');
|
issueData.dueDate = new Date(data.fields.desiredDate).format('D d.m.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Promise.all(promises);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return Promise.all(promises).then(function(results){return issueData;});
|
||||||
Promise.all(promises)
|
|
||||||
.then(function(){resolve(issueData);})
|
|
||||||
.catch(function(cause){reject(cause);});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.getIssueData = function(issueKey) {
|
module.getIssueData = function(issueKey) {
|
||||||
@ -942,7 +959,9 @@
|
|||||||
var url = '/rest/api/2/issue/' + issueKey + '?expand=renderedFields,names';
|
var url = '/rest/api/2/issue/' + issueKey + '?expand=renderedFields,names';
|
||||||
console.log("IssueUrl: " + url);
|
console.log("IssueUrl: " + url);
|
||||||
//console.log("Issue: " + issueKey + " Loading...");
|
//console.log("Issue: " + issueKey + " Loading...");
|
||||||
return jQuery.getJSON(url).then(function(responseData) {
|
|
||||||
|
|
||||||
|
return httpGetJSON(url).then(function(responseData) {
|
||||||
//console.log("Issue: " + issueKey + " Loaded!");
|
//console.log("Issue: " + issueKey + " Loaded!");
|
||||||
// add custom fields with field names
|
// add custom fields with field names
|
||||||
jQuery.each(responseData.names, function(key, value) {
|
jQuery.each(responseData.names, function(key, value) {
|
||||||
@ -952,6 +971,7 @@
|
|||||||
responseData.fields[fieldName] = responseData.fields[key];
|
responseData.fields[fieldName] = responseData.fields[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return responseData;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -988,29 +1008,12 @@
|
|||||||
|
|
||||||
if (data.field.assignee) {
|
if (data.field.assignee) {
|
||||||
issueData.assignee = data.field.assignee[0].fullName;
|
issueData.assignee = data.field.assignee[0].fullName;
|
||||||
// var avatarUrl = data.fields.assignee.avatarUrls['48x48'];
|
|
||||||
// if (avatarUrl.indexOf("ownerId=") >= 0) {
|
|
||||||
// issueData.avatarUrl = avatarUrl;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// if (data.fields.duedate) {
|
|
||||||
// issueData.dueDate = new Date(data.fields.duedate).format('D d.m.');
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
if (data.field.attachments) {
|
if (data.field.attachments) {
|
||||||
issueData.hasAttachment = data.field.attachments.length > 0;
|
issueData.hasAttachment = data.field.attachments.length > 0;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// issueData.storyPoints = data.fields.storyPoints;
|
|
||||||
//
|
|
||||||
// issueData.epicKey = data.fields.epicLink;
|
|
||||||
// if (issueData.epicKey) {
|
|
||||||
// jiraFunctions.getIssueData(issueData.epicKey, function(data) {
|
|
||||||
// issueData.epicName = data.fields.epicName;
|
|
||||||
// }, false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
issueData.url = window.location.origin + "/youtrack/issue/" + issueData.key;
|
issueData.url = window.location.origin + "/youtrack/issue/" + issueData.key;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -1025,7 +1028,7 @@
|
|||||||
var url = '/youtrack/rest/issue/' + issueKey + '?';
|
var url = '/youtrack/rest/issue/' + issueKey + '?';
|
||||||
console.log("IssueUrl: " + url);
|
console.log("IssueUrl: " + url);
|
||||||
//console.log("Issue: " + issueKey + " Loading...");
|
//console.log("Issue: " + issueKey + " Loading...");
|
||||||
return jQuery.getJSON(url).then(function(responseData) {
|
return httpGet(url).then(function(responseData) {
|
||||||
//console.log("Issue: " + issueKey + " Loaded!");
|
//console.log("Issue: " + issueKey + " Loaded!");
|
||||||
jQuery.each(responseData.field, function(key, value) {
|
jQuery.each(responseData.field, function(key, value) {
|
||||||
// add fields with field names
|
// add fields with field names
|
||||||
@ -1033,6 +1036,7 @@
|
|||||||
//console.log("add new field: " + newFieldId + " with value from " + fieldName);
|
//console.log("add new field: " + newFieldId + " with value from " + fieldName);
|
||||||
responseData.field[fieldName] = value.value;
|
responseData.field[fieldName] = value.value;
|
||||||
});
|
});
|
||||||
|
return responseData;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1079,14 +1083,6 @@
|
|||||||
issueData.hasAttachment = false;
|
issueData.hasAttachment = false;
|
||||||
issueData.storyPoints = data.estimate;
|
issueData.storyPoints = data.estimate;
|
||||||
|
|
||||||
// TODO
|
|
||||||
// issueData.epicKey = data.fields.epicLink;
|
|
||||||
// if ( issueData.epicKey ) {
|
|
||||||
// getIssueDataPivotalTracker(issueData.epicKey , function(data) {
|
|
||||||
// issueData.epicName = data.fields.epicName;
|
|
||||||
// }, false);
|
|
||||||
// }
|
|
||||||
|
|
||||||
issueData.url = data.url;
|
issueData.url = data.url;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -1102,7 +1098,7 @@
|
|||||||
var url = 'https://www.pivotaltracker.com/services/v5/stories/' + issueKey + "?fields=name,kind,description,story_type,owned_by(name),comments(file_attachments(kind)),estimate,deadline";
|
var url = 'https://www.pivotaltracker.com/services/v5/stories/' + issueKey + "?fields=name,kind,description,story_type,owned_by(name),comments(file_attachments(kind)),estimate,deadline";
|
||||||
console.log("IssueUrl: " + url);
|
console.log("IssueUrl: " + url);
|
||||||
//console.log("Issue: " + issueKey + " Loading...");
|
//console.log("Issue: " + issueKey + " Loading...");
|
||||||
return jQuery.getJSON(url);
|
return httpGetJSON(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
@ -1156,7 +1152,7 @@
|
|||||||
var url = "https://trello.com/1/cards/" + issueKey + "?members=true";
|
var url = "https://trello.com/1/cards/" + issueKey + "?members=true";
|
||||||
console.log("IssueUrl: " + url);
|
console.log("IssueUrl: " + url);
|
||||||
//console.log("Issue: " + issueKey + " Loading...");
|
//console.log("Issue: " + issueKey + " Loading...");
|
||||||
return jQuery.getJSON(url);
|
return httpGetJSON(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user