render-approveRenderings.xslt 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:xts="http://developer.cognos.com/schemas/xts/">
  9. <xsl:import href="../../common/render-outputs.xslt"/>
  10. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
  11. <xsl:template match="/">
  12. <xsl:variable name="acceptText">
  13. <xsl:call-template name="getAcceptText">
  14. <xsl:with-param name="input" select="/root/input[@name='dep']/*[local-name()='queryResponse']/*[local-name()='manualTask']"/>
  15. </xsl:call-template>
  16. </xsl:variable>
  17. <xsl:variable name="rejectText">
  18. <xsl:call-template name="getRejectText">
  19. <xsl:with-param name="input" select="/root/input[@name='dep']/*[local-name()='queryResponse']/*[local-name()='manualTask']"/>
  20. </xsl:call-template>
  21. </xsl:variable>
  22. <script language="javascript">
  23. _THIS_.addEventListener('fragment.unload','_THIS_unload');
  24. _THIS_.addEventListener("fragment.load", "_THIS_init");
  25. /*
  26. This function is called when the subfrag is loaded to alter to style of the fragment if
  27. we're not the owner
  28. */
  29. function _THIS_init(evt)
  30. {
  31. dojo.require("dijit.form.Button");
  32. //check if we have the button
  33. var btnAccept = dijit.byId('_THIS_buttonAccept');
  34. var btnReject = dijit.byId('_THIS_buttonReject');
  35. //destroy the old ones
  36. if (btnAccept) {
  37. btnAccept.destroy();
  38. }
  39. if (btnReject) {
  40. btnReject.destroy();
  41. }
  42. //create the dojo buttons
  43. var btnAccept = hts_createButton('<xsl:value-of select="xtsext:javascriptencode(string($acceptText))"/>',_THIS_acceptClicked,'_THIS_buttonAccept');
  44. var btnReject = hts_createButton('<xsl:value-of select="xtsext:javascriptencode(string($rejectText))"/>',_THIS_rejectClicked,'_THIS_buttonReject');
  45. //Distribute to children. Pass it down further.
  46. //Parent is explicitly passing the event here,
  47. //so cascade it further down.
  48. var _THIS_distList = new Array();
  49. var _THIS_children = _THIS_.getChildren();
  50. var i, l = _THIS_children.length;
  51. for (i = 0; i &lt; l; i++) {
  52. _THIS_distList[i] = _THIS_children[i].id;
  53. }
  54. _F_Event.distribute(_THIS_distList,evt);
  55. }
  56. function _THIS_acceptClicked() {
  57. _THIS_buildOutputXML("accept");
  58. }
  59. function _THIS_rejectClicked() {
  60. _THIS_buildOutputXML("reject");
  61. }
  62. /**
  63. * Just pass it on.
  64. */
  65. function _THIS_unload(evt){
  66. var _THIS_distList = new Array();
  67. var _THIS_children = _THIS_.getChildren();
  68. var i, l = _THIS_children.length;
  69. for (i = 0; i &lt; l; i++) {
  70. _THIS_distList[i] = _THIS_children[i].id;
  71. }
  72. //do not bubble.
  73. evt.bubbles = false;
  74. _F_Event.distribute(_THIS_distList,evt);
  75. }
  76. </script>
  77. <xsl:choose>
  78. <xsl:when test="/root/input[@name='dep']/queryResponse/*[local-name()='approveOutput']">
  79. <xsl:apply-templates select="/root/input[@name='dep']/queryResponse/*[local-name()='approveOutput']"/>
  80. </xsl:when>
  81. <xsl:when test="/root/input[@name='dep']/queryResponse/hideRendering">
  82. <xsl:call-template name="renderUI">
  83. <xsl:with-param name="path" select="/root/input/queryResponse/*[local-name()='manualTask']/*[local-name()='preview']/*[local-name()='tsePreview']/*[local-name()='agentPreview']"/>
  84. </xsl:call-template>
  85. </xsl:when>
  86. <xsl:otherwise>
  87. <xsl:apply-templates select="/root/input/queryResponse/*[local-name()='manualTask']/*[local-name()='preview']/*[local-name()='tsePreview']/*[local-name()='agentPreview']"/>
  88. </xsl:otherwise>
  89. </xsl:choose>
  90. </xsl:template>
  91. <xsl:template match="*[local-name()='approveOutput']">
  92. <xsl:call-template name="renderUI">
  93. <xsl:with-param name="path" select="/root/input/queryResponse/*[local-name()='manualTask']/*[local-name()='preview']/*[local-name()='tsePreview']/*[local-name()='agentPreview']"/>
  94. </xsl:call-template>
  95. <div>
  96. <table border='0'>
  97. <tr>
  98. <td tabindex="0" class="taskMainSubTitle"><xts:string id="IDS_FRAG_APPROVE_STATUS"/></td>
  99. </tr>
  100. <tr>
  101. <td tabindex="0"><xsl:value-of select="./*[local-name()='outcome']"/></td>
  102. </tr>
  103. <tr>
  104. <td tabindex="0" class="taskMainSubTitle"><xts:string id="IDS_FRAG_APPROVE_MESSAGE"/></td>
  105. </tr>
  106. <tr>
  107. <td tabindex="0"><xsl:value-of select="./*[local-name()='outcomeComment']"/></td>
  108. </tr>
  109. </table>
  110. </div>
  111. </xsl:template>
  112. <xsl:template match="*[local-name()='agentPreview']">
  113. <xsl:variable name="description"><xsl:value-of select="./description"/></xsl:variable>
  114. <xsl:variable name="acceptText">
  115. <xsl:call-template name="getAcceptText">
  116. <xsl:with-param name="input" select="/root/input[@name='dep']/*[local-name()='queryResponse']/*[local-name()='manualTask']"/>
  117. </xsl:call-template>
  118. </xsl:variable>
  119. <xsl:variable name="rejectText">
  120. <xsl:call-template name="getRejectText">
  121. <xsl:with-param name="input" select="/root/input[@name='dep']/*[local-name()='queryResponse']/*[local-name()='manualTask']"/>
  122. </xsl:call-template>
  123. </xsl:variable>
  124. <script type="text/javascript">
  125. function _THIS_buildOutputXML(status) {
  126. var status_text = '';
  127. if(status == 'accept'){
  128. var btnAccept = dijit.byId('_THIS_buttonAccept');
  129. if (btnAccept) {
  130. btnAccept.attr("disabled",true);
  131. }
  132. status_text = '<xsl:value-of select="xtsext:javascriptencode(string($acceptText))"/>';
  133. }else{
  134. var btnReject = dijit.byId('_THIS_buttonReject');
  135. if (btnReject) {
  136. btnReject.attr("disabled",true);
  137. }
  138. status_text = '<xsl:value-of select="xtsext:javascriptencode(string($rejectText))"/>';
  139. }
  140. var outputXML = '&lt;approveOutput&gt;';
  141. <!--blanket approve everything -->
  142. <xsl:for-each select="./*[local-name()='agentTaskPreview']/*[local-name()='taskRunPreview']/@eventId">
  143. outputXML += "&lt;item id='<xsl:value-of select="."/>' status='"+status+"' /&gt;" ;
  144. </xsl:for-each>
  145. var completion_comment = document.getElementById("task_completion_comment");
  146. if(completion_comment){
  147. completion_comment = _F_Strings.xmlEncode(completion_comment.value);
  148. }else{
  149. completion_comment = "";
  150. }
  151. outputXML += "&lt;outcome&gt;"+status_text+"&lt;/outcome&gt;";
  152. outputXML += "&lt;outcomeComment&gt;"+ completion_comment + "&lt;/outcomeComment&gt;";
  153. outputXML += '&lt;/approveOutput&gt;';
  154. _THIS_.retrieve("action=complete&amp;output="+_F_Strings.urlEncode(outputXML),null,true);
  155. //update the viewer
  156. _THIS_.transientUpdate("display_id", "", "page", "taskLinkViewer");
  157. _THIS_.transientUpdate('cognosTaskChanged',new Date().toUTCString());
  158. }
  159. </script>
  160. <xsl:call-template name="renderUI">
  161. <xsl:with-param name="path" select="."/>
  162. </xsl:call-template>
  163. <div>
  164. <div><label class="task_name"><xts:string id="IDS_FRAG_APPROVE_COMMENT_MESSAGE"/></label></div>
  165. <textarea rows="1" cols="50" style="overflow:hidden;" tabindex="0" onclick="hts_resizeTextArea(this);" onkeyup="hts_resizeTextArea(this);" id="task_completion_comment" value=""/>
  166. <div>
  167. <div id="_THIS_buttonAccept"/>
  168. <div id="_THIS_buttonReject"/>
  169. </div>
  170. </div>
  171. <!--div tabindex="0" class="viewer" id="_THIS_viewercontent">_THIS?frag-subfragment=viewer/THIS_</div-->
  172. </xsl:template>
  173. </xsl:stylesheet>