render-comments.xslt 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: HTS
  5. (C) Copyright IBM Corp. 2005, 2010
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:hts="http://developer.cognos.com/myinbox/common/hts_ui" exclude-result-prefixes="xts hts">
  9. <xsl:import href="../../menu/render-toolbar.xslt"/>
  10. <xsl:import href="../../common/json-converter.xslt"/>
  11. <xsl:import href="../../common/task-info.xslt"/>
  12. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
  13. <xsl:template match="/">
  14. <xsl:apply-templates select="/" mode="common"/>
  15. <hts:script language="javascript">
  16. var oNotificationTaskInfo;
  17. _F_config.enableLog = false;
  18. _THIS_.addEventListener("fragment.load", "_THIS_init");
  19. _THIS_.addEventListener("fragment.retrieve.after", "_THIS_retrieveAfter");
  20. _THIS_.parent.addEventListener("fragment.unload", "_THIS_unload");
  21. function _THIS_unload(evt) {
  22. if(oNotificationTaskInfo)
  23. _THIS_.raiseEvent('cognos.hts.showNotificationTaskViewer');
  24. else
  25. _THIS_.raiseEvent('cognos.hts.showTaskViewer');
  26. }
  27. function _THIS_init() {
  28. //update the comments menus
  29. initFilter(_THIS_commentsMenu,_THIS_.transientState['Task.Comments']);
  30. //get the task info as a JSON string and fire the event
  31. <xsl:variable name="jsonTaskInfo">
  32. <xsl:call-template name="convertToJSON">
  33. <xsl:with-param name="taskInfo" select="/root/input[@name='dep']/queryResponse/*[local-name()='getTaskInfoResponse']"/>
  34. </xsl:call-template>
  35. </xsl:variable>
  36. //encode the JSON task info object
  37. <xsl:if test="$jsonTaskInfo != ''">
  38. try {
  39. var jsonTaskInfo = "({<xsl:value-of select="xtsext:javascriptencode(string($jsonTaskInfo))"/>})";
  40. if(jsonTaskInfo &amp;&amp; jsonTaskInfo.indexOf("taskType:&apos;NOTIFICATION&apos;") != -1){
  41. oNotificationTaskInfo = eval("({<xsl:value-of select="xtsext:javascriptencode(string($jsonTaskInfo))"/>})");
  42. oNotificationTaskInfo = oNotificationTaskInfo.task;
  43. }
  44. } catch (ex) {
  45. alert('<xts:string id="IDS_FRAG_ERROR_MESSAGE" encode="javascript"/>' + ex);
  46. }
  47. </xsl:if>
  48. }
  49. function _THIS_retrieveAfter(evt) {
  50. if (evt.target.id == "_THIS_") {
  51. //get the selected task, JSONify it and raise the event
  52. if(oNotificationTaskInfo &amp;&amp; oNotificationTaskInfo.id == _THIS_.transientState['notificationtaskid']) {
  53. //pass the task details to those fragments interested
  54. _THIS_.raiseEvent('cognos.hts.notification_info',oNotificationTaskInfo);
  55. }else{
  56. _THIS_raiseTaskInfo();
  57. }
  58. }
  59. var taskId = _THIS_.transientState['taskid'];
  60. if (taskId &amp;&amp; taskId != '') {
  61. //This is to hide the waiting div and show the correct div (task details where comment tab is visible)
  62. _THIS_.raiseEvent('cognos.hts.showTaskViewer');
  63. }
  64. var noteTaskId = _THIS_.transientState['notificationtaskid'];
  65. if (noteTaskId &amp;&amp; noteTaskId != '') {
  66. //This is to hide the waiting div and show the correct div (task details where comment tab is visible)
  67. _THIS_.raiseEvent('cognos.hts.showNotificationTaskViewer');
  68. }
  69. }
  70. function _THIS_action(action) {
  71. if(arguments.length==3) {
  72. //Call the set filter. This is the same as the one used for toolbar.js menu.
  73. setFilter(arguments[0],arguments[1],arguments[2]);
  74. } else if (action == 'addComment') {
  75. _THIS_addUserComment();
  76. }
  77. }
  78. function _THIS_action_getItemState(menudef, item) {
  79. //TODO Check for capabilities/task status here to determine whether the menu is shown
  80. //return "hide" or "show"
  81. }
  82. function _THIS_addUserComment() {
  83. _F_log("D", "User has selected to add a comment.");
  84. var dialog_title = '<xts:string id="IDS_FRAG_COMMENT_VIEWER_ADD_COMMENT_PROMPT" encode="javascript"/>';
  85. var dlg = new ui_dialog(this.fragID + "addComment", dialog_title, ui_dialog.style.BTN_OKCANCEL | ui_dialog.style.CENTER | ui_dialog.style.RESIZABLE, -1, -1, 480, 275);
  86. dlg.processCommand = function(cmd) {
  87. var comment = $(&quot;commentTextArea&quot;);
  88. if(comment &amp;&amp; comment.value){
  89. comment = comment.value
  90. }else{
  91. comment="";
  92. }
  93. if ((cmd == ui_dialog.button.OK)) {
  94. _THIS_.retrieve("action=addComment&amp;comment="+_F_Strings.urlEncode(comment));
  95. }
  96. this.destroy();
  97. return true;
  98. };
  99. var markup = "&lt;table width=\&quot;100%\&quot; border=\&quot;0\&quot; cellspacing=\&quot;0\&quot; cellpadding=\&quot;4\&quot;&gt;";
  100. markup += "&lt;tr&gt;";
  101. markup += "&lt;td&gt;";
  102. markup += '<xts:string id="IDS_FRAG_COMMENT_VIEWER_ADD_COMMENT_HINT" encode="javascript"/>';
  103. markup += "&lt;/td&gt;";
  104. markup += "&lt;/tr&gt;";
  105. markup += "&lt;tr&gt;";
  106. markup += "&lt;td style=\&quot;margin: auto\&quot; valign=\&quot;center\&quot; align=\&quot;center\&quot; &gt;";
  107. markup += "&lt;textarea rows='15' cols='75' maxlength='2000' class=\&quot;cogstyle-comment-area\&quot; id=\&quot;commentTextArea\&quot;&gt;&lt;/textarea&gt;";
  108. markup += "&lt;/td&gt;";
  109. markup += "&lt;/tr&gt;";
  110. markup += "&lt;/table&gt;";
  111. dlg.setContent(markup);
  112. dlg.show();
  113. document.getElementById('commentTextArea').focus();
  114. }
  115. </hts:script>
  116. <hts:section format="select-dialog">
  117. <hts:rowset cellpadding="3" cellspacing="2" width="100%">
  118. <hts:row>
  119. <hts:action colspan="3">
  120. <xsl:call-template name="renderToolbar">
  121. <xsl:with-param name="toolbar" select="/root/input/commentsMenu"/>
  122. </xsl:call-template>
  123. </hts:action>
  124. </hts:row>
  125. <hts:row format="header" class="tableHeader">
  126. <hts:text width="1%"/>
  127. <hts:text width="15%">
  128. <xts:string id="IDS_FRAG_COMMENT_VIEWER_LABEL_AUTHOR"/>
  129. </hts:text>
  130. <hts:text width="67%">
  131. <xts:string id="IDS_FRAG_COMMENT_VIEWER_LABEL_COMMENT"/>
  132. </hts:text>
  133. <hts:text width="17%">
  134. <xts:string id="IDS_FRAG_COMMENT_VIEWER_LABEL_DATE"/>
  135. </hts:text>
  136. </hts:row>
  137. <xsl:call-template name="displayComment" />
  138. </hts:rowset>
  139. </hts:section>
  140. </xsl:template>
  141. <xsl:template name="displayComment">
  142. <xsl:for-each select ="/root/input[@name='dep']/queryResponse/*[local-name()='getCommentsByTypeResponse']/*[local-name()='getCommentsByTypeGroup']/*[local-name()='comment']">
  143. <xsl:variable name="type" select="./../*[local-name()='commentType']"/>
  144. <xsl:variable name="res">
  145. <xsl:choose>
  146. <xsl:when test="$type = 'AUDIT'" >
  147. <src>
  148. <xsl:value-of select='"_THIS?frag-resource=/fragments/myinbox/images/audit_comments.gif/THIS_"'/>
  149. </src>
  150. <tooltip>
  151. <xts:string id="IDS_FRAG_COMMENT_VIEWER_LABEL_AUDIT_COMMENTS"/>
  152. </tooltip>
  153. </xsl:when>
  154. <xsl:otherwise>
  155. <src>
  156. <xsl:value-of select='"_THIS?frag-resource=/fragments/myinbox/images/user_comments.gif/THIS_"'/>
  157. </src>
  158. <tooltip>
  159. <xts:string id="IDS_FRAG_COMMENT_VIEWER_LABEL_USER_COMMENTS"/>
  160. </tooltip>
  161. </xsl:otherwise>
  162. </xsl:choose>
  163. </xsl:variable>
  164. <hts:row>
  165. <hts:action tabindex="0">
  166. <img id="{./*[local-name()='id']}_img" border="0" src="{$res/src}" alt="{$res/tooltip}" title="{$res/tooltip}"/>
  167. </hts:action>
  168. <hts:action tabindex="0">
  169. <hts:text>
  170. <xsl:value-of select="./*[local-name()='formattedAddedBy']"/>
  171. </hts:text>
  172. </hts:action>
  173. <hts:action tabindex="0">
  174. <hts:text>
  175. <xsl:value-of select="./*[local-name()='text']"/>
  176. </hts:text>
  177. </hts:action>
  178. <hts:action tabindex="0">
  179. <hts:text>
  180. <xsl:value-of select="./*[local-name()='addedAt']"/>
  181. </hts:text>
  182. </hts:action>
  183. </hts:row>
  184. </xsl:for-each>
  185. <xsl:for-each select ="/root/input[@name='dep']/queryResponse/*[local-name()='getCommentsResponse']/*[local-name()='comment']">
  186. <xsl:variable name="type" select="./*[local-name()='commentType']"/>
  187. <xsl:variable name="res">
  188. <xsl:choose>
  189. <xsl:when test="$type = 'AUDIT'" >
  190. <src>
  191. <xsl:value-of select='"_THIS?frag-resource=/fragments/myinbox/images/audit_comments.gif/THIS_"'/>
  192. </src>
  193. <tooltip>
  194. <xts:string id="IDS_FRAG_COMMENT_VIEWER_LABEL_AUDIT_COMMENTS"/>
  195. </tooltip>
  196. </xsl:when>
  197. <xsl:otherwise>
  198. <src>
  199. <xsl:value-of select='"_THIS?frag-resource=/fragments/myinbox/images/user_comments.gif/THIS_"'/>
  200. </src>
  201. <tooltip>
  202. <xts:string id="IDS_FRAG_COMMENT_VIEWER_LABEL_USER_COMMENTS"/>
  203. </tooltip>
  204. </xsl:otherwise>
  205. </xsl:choose>
  206. </xsl:variable>
  207. <hts:row>
  208. <hts:action tabindex="0">
  209. <img id="{./*[local-name()='id']}_img" border="0" src="{$res/src}" alt="{$res/tooltip}" title="{$res/tooltip}"/>
  210. </hts:action>
  211. <hts:action tabindex="0">
  212. <hts:text>
  213. <xsl:value-of select="./*[local-name()='formattedAddedBy']"/>
  214. </hts:text>
  215. </hts:action>
  216. <hts:action tabindex="0">
  217. <hts:text>
  218. <xsl:value-of select="./*[local-name()='text']"/>
  219. </hts:text>
  220. </hts:action>
  221. <hts:action tabindex="0">
  222. <hts:text>
  223. <xsl:value-of select="./*[local-name()='addedAt']"/>
  224. </hts:text>
  225. </hts:action>
  226. </hts:row>
  227. </xsl:for-each>
  228. </xsl:template>
  229. </xsl:stylesheet>