mxAtlassian.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /**
  2. * $Id: mxAtlassian.js,v 1.0 2018/24/05 12:32:06 mate Exp $
  3. * Copyright (c) 2006-2018, JGraph Ltd
  4. */
  5. //**********************************************************************************************************************************************************
  6. // Issue
  7. //**********************************************************************************************************************************************************
  8. /**
  9. * Extends mxShape.
  10. */
  11. function mxAtlassianJiraIssue(bounds, fill, stroke, strokewidth)
  12. {
  13. mxShape.call(this);
  14. this.bounds = bounds;
  15. this.fill = fill;
  16. this.stroke = stroke;
  17. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  18. this.dx = 0.5;
  19. };
  20. /**
  21. * Extends mxShape.
  22. */
  23. mxUtils.extend(mxAtlassianJiraIssue, mxRectangleShape);
  24. mxAtlassianJiraIssue.prototype.customProperties = [
  25. {name: 'issueType', dispName: 'Issue Type', type: 'enum',
  26. enumList: [{val: 'story', dispName: 'Story'},
  27. {val: 'task', dispName: 'Task'},
  28. {val: 'subTask', dispName: 'Sub-Task'},
  29. {val: 'feature', dispName: 'Feature'},
  30. {val: 'bug', dispName: 'Bug'},
  31. {val: 'techTask', dispName: 'Tech Task'},
  32. {val: 'epic', dispName: 'Epic'},
  33. {val: 'improvement', dispName: 'Improvement'},
  34. {val: 'fault', dispName: 'Fault'},
  35. {val: 'change', dispName: 'Change'},
  36. {val: 'access', dispName: 'Access'},
  37. {val: 'purchase', dispName: 'Purchase'},
  38. {val: 'itHelp', dispName: 'IT Help'}]
  39. },
  40. {name: 'issuePriority', dispName: 'Issue Priority', type: 'enum',
  41. enumList: [{val: 'blocker', dispName: 'Blocker'},
  42. {val: 'critical', dispName: 'Critical'},
  43. {val: 'major', dispName: 'Major'},
  44. {val: 'minor', dispName: 'Minor'},
  45. {val: 'trivial', dispName: 'Trivial'}]
  46. },
  47. {name: 'issueStatus', dispName: 'Issue Status', type: 'enum',
  48. enumList: [{val: 'todo', dispName: 'TODO'},
  49. {val: 'inProgress', dispName: 'In Progress'},
  50. {val: 'inReview', dispName: 'In Review'},
  51. {val: 'done', dispName: 'Done'}]
  52. }
  53. ];
  54. mxAtlassianJiraIssue.prototype.cst = {ISSUE : 'mxgraph.atlassian.issue'};
  55. /**
  56. * Function: paintVertexShape
  57. *
  58. * Paints the vertex shape.
  59. */
  60. mxAtlassianJiraIssue.prototype.paintForeground = function(c, x, y, w, h)
  61. {
  62. c.translate(x, y);
  63. var issueType = mxUtils.getValue(this.style, 'issueType', 'task');
  64. var issuePriority = mxUtils.getValue(this.style, 'issuePriority', 'minor');
  65. var issueStatus = mxUtils.getValue(this.style, 'issueStatus', 'todo');
  66. c.setStrokeColor('none');
  67. switch (issueType) {
  68. case 'story':
  69. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.story');
  70. if (stencil != null)
  71. {
  72. c.setFillColor('#61B659');
  73. stencil.drawShape(c, this, 5, 5, 10, 10);
  74. }
  75. break;
  76. case 'task':
  77. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.task');
  78. if (stencil != null)
  79. {
  80. c.setFillColor('#5EA3E4');
  81. stencil.drawShape(c, this, 5, 5, 10, 10);
  82. }
  83. break;
  84. case 'subTask':
  85. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.subtask');
  86. if (stencil != null)
  87. {
  88. c.setFillColor('#5EA3E4');
  89. stencil.drawShape(c, this, 5, 5, 10, 10);
  90. }
  91. break;
  92. case 'feature':
  93. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.new_feature');
  94. if (stencil != null)
  95. {
  96. c.setFillColor('#61B659');
  97. stencil.drawShape(c, this, 5, 5, 10, 10);
  98. }
  99. break;
  100. case 'bug':
  101. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.bug');
  102. if (stencil != null)
  103. {
  104. c.setFillColor('#CE0000');
  105. stencil.drawShape(c, this, 5, 5, 10, 10);
  106. }
  107. break;
  108. case 'techTask':
  109. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.tech_task');
  110. if (stencil != null)
  111. {
  112. c.setFillColor('#999C95');
  113. stencil.drawShape(c, this, 5, 5, 10, 10);
  114. }
  115. break;
  116. case 'epic':
  117. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.epic');
  118. if (stencil != null)
  119. {
  120. c.setFillColor('#9E4ADD');
  121. stencil.drawShape(c, this, 5, 5, 10, 10);
  122. }
  123. break;
  124. case 'improvement':
  125. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.improvement');
  126. if (stencil != null)
  127. {
  128. c.setFillColor('#61B659');
  129. stencil.drawShape(c, this, 5, 5, 10, 10);
  130. }
  131. break;
  132. case 'fault':
  133. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.fault');
  134. if (stencil != null)
  135. {
  136. c.setFillColor('#F8902F');
  137. stencil.drawShape(c, this, 5, 5, 10, 10);
  138. }
  139. break;
  140. case 'change':
  141. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.change');
  142. if (stencil != null)
  143. {
  144. c.setFillColor('#9E4ADD');
  145. stencil.drawShape(c, this, 5, 5, 10, 10);
  146. }
  147. break;
  148. case 'access':
  149. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.access');
  150. if (stencil != null)
  151. {
  152. c.setFillColor('#F8902F');
  153. stencil.drawShape(c, this, 5, 5, 10, 10);
  154. }
  155. break;
  156. case 'purchase':
  157. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.purchase');
  158. if (stencil != null)
  159. {
  160. c.setFillColor('#61B659');
  161. stencil.drawShape(c, this, 5, 5, 10, 10);
  162. }
  163. break;
  164. case 'itHelp':
  165. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.it_help');
  166. if (stencil != null)
  167. {
  168. c.setFillColor('#5EA3E4');
  169. stencil.drawShape(c, this, 5, 5, 10, 10);
  170. }
  171. break;
  172. }
  173. switch (issuePriority) {
  174. case 'blocker':
  175. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.no');
  176. if (stencil != null)
  177. {
  178. c.setFillColor('#CE0000');
  179. stencil.drawShape(c, this, 85, 5, 10, 10);
  180. }
  181. break;
  182. case 'critical':
  183. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.critical');
  184. if (stencil != null)
  185. {
  186. c.setFillColor('#CE0000');
  187. stencil.drawShape(c, this, 86, 3, 8, 14);
  188. }
  189. break;
  190. case 'major':
  191. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.double_up');
  192. if (stencil != null)
  193. {
  194. c.setFillColor('#CE0000');
  195. stencil.drawShape(c, this, 85, 5, 10, 10);
  196. }
  197. break;
  198. case 'minor':
  199. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.double');
  200. if (stencil != null)
  201. {
  202. c.setFillColor('#2A8735');
  203. stencil.drawShape(c, this, 85, 5, 10, 10);
  204. }
  205. break;
  206. case 'trivial':
  207. var stencil = mxStencilRegistry.getStencil('mxgraph.atlassian.single');
  208. if (stencil != null)
  209. {
  210. c.setFillColor('#9AA1B2');
  211. stencil.drawShape(c, this, 85, 5, 10, 10);
  212. }
  213. break;
  214. }
  215. c.setFillColor('#FFFFFD');
  216. c.setFontColor('#4E6B89');
  217. switch (issueStatus) {
  218. case 'todo':
  219. c.rect(w - 45, 5, 40, 20);
  220. c.fill();
  221. c.text(w - 25, 15, 0, 0, 'TO DO', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  222. break;
  223. case 'inProgress':
  224. c.rect(w - 85, 5, 80, 20);
  225. c.fill();
  226. c.text(w - 45, 15, 0, 0, 'IN PROGRESS', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  227. break;
  228. case 'inReview':
  229. c.rect(w - 75, 5, 70, 20);
  230. c.fill();
  231. c.text(w - 40, 15, 0, 0, 'IN REVIEW', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  232. break;
  233. case 'done':
  234. c.rect(w - 45, 5, 40, 20);
  235. c.fill();
  236. c.text(w - 25, 15, 0, 0, 'DONE', mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  237. break;
  238. default:
  239. var tw = mxUtils.getValue(this.style, 'issueStatusWidth', issueStatus.length * 6.5);
  240. c.rect(w - tw - 5, 5, tw, 20);
  241. c.fill();
  242. c.text(w - 7, 15, 0, 0, issueStatus, mxConstants.ALIGN_RIGHT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  243. }
  244. };
  245. mxCellRenderer.registerShape(mxAtlassianJiraIssue.prototype.cst.ISSUE, mxAtlassianJiraIssue);