setLabels.xts 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ASV
  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. <xts:morphlet xmlns:xts="http://developer.cognos.com/schemas/xts/" messageBase="messages/portal.xml,messages/portalRL.xml,messages/subscribe.xml" resolverBase="prompting" includeConfig="true">
  9. <!--
  10. ===============================================================================================
  11. processRequestParams - Default any params that weren't passed in. Also this is where we would
  12. do validation (when time permits).
  13. ===============================================================================================
  14. -->
  15. <xts:block id="processRequestParams" processor="XSLT" type="exec" nodeList="/root/*[local-name()='requestParams']">
  16. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl">
  17. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  18. <xsl:template match="/">
  19. <xts:sequence>
  20. <xts:append select="/root/*[local-name()='requestParams']">
  21. <xts:transform src="portal/controls/gen_default_parameters.xslt" processor="XSLT">
  22. <root>
  23. <xts:transform name="XML">
  24. <xts:param name="systemId">subscribe/setLabels/setLabels_interface.xml</xts:param>
  25. </xts:transform>
  26. <xsl:copy-of select="/root/*[local-name()='requestParams']"/>
  27. </root>
  28. </xts:transform>
  29. </xts:append>
  30. </xts:sequence>
  31. </xsl:template>
  32. </xsl:stylesheet>
  33. </xts:block>
  34. <!--
  35. ===============================================================================================
  36. returnResult - We're done with the email options morphlet, so return the appropriate response
  37. ===============================================================================================
  38. -->
  39. <xts:block id="returnResult" type="exec" processor="XSLT" dependency="processRequestParams" condition=".[/root/*[local-name()='requestParams']/*[local-name()='param' and @name='requestState'] = 'finished' or /root/*[local-name()='requestParams']/*[local-name()='param' and @name='requestState'] = 'canceled']" mandatory="false">
  40. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  41. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xos="http://developer.cognos.com/schemas/xts/output/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" exclude-result-prefixes="xsl xos xtsext">
  42. <xsl:output method="xml" encoding="utf-8" indent="no"/>
  43. <xsl:key name="env-param" match="/root/env/param" use="@name"/>
  44. <xsl:key name="system-param" match="/root/system/param" use="@name"/>
  45. <xsl:key name="session-param" match="/root/session/param" use="@name"/>
  46. <xsl:key name="request-param" match="/root/*[local-name()='requestParams']/*[local-name()='param']" use="@name"/>
  47. <xsl:template match="/">
  48. <xts:sequence>
  49. <xts:append select="/root/output">
  50. <!-- build a part -->
  51. <xts:transform name="Null" option="part" mimeType="text/xml">
  52. <xsl:element name="{key('request-param','resultNode')}" namespace="">
  53. <xsl:choose>
  54. <xsl:when test="key('request-param','requestState') = 'canceled'">
  55. <canceled/>
  56. </xsl:when>
  57. <xsl:otherwise>
  58. <setLabels>
  59. <xsl:choose>
  60. <xsl:when test="key('env-param','owner_action')='approve'">
  61. <param name="m_ro_approveValue">
  62. <xsl:value-of select="key('env-param','approveText')"/>
  63. </param>
  64. <param name="m_ro_rejectValue">
  65. <xsl:value-of select="key('env-param','rejectText')"/>
  66. </param>
  67. </xsl:when>
  68. <xsl:when test="key('env-param','owner_action')='agent'">
  69. <param name="m_ro_submitValue">
  70. <xsl:value-of select="key('env-param','submitText')"/>
  71. </param>
  72. <xsl:copy-of select="/root/env/param[starts-with(@name, 'm_ro_agentTaskItem_')]"/>
  73. </xsl:when>
  74. </xsl:choose>
  75. </setLabels>
  76. </xsl:otherwise>
  77. </xsl:choose>
  78. </xsl:element>
  79. </xts:transform>
  80. </xts:append>
  81. </xts:sequence>
  82. </xsl:template>
  83. </xsl:stylesheet>
  84. </xts:block>
  85. <!--
  86. ===============================================================================================
  87. HTML output
  88. ===============================================================================================
  89. -->
  90. <xts:block id="genMarkup" type="exec" processor="XSLT" dependency="processRequestParams" condition=".[/root/*[local-name()='requestParams']/*[local-name()='param' and @name='requestState'] = 'markup'] " mandatory="false">
  91. <!-- logicsheets -->
  92. <!-- portal specific information -->
  93. <xts:logicsheet path="logicsheets/portal.xsl"/>
  94. <!-- Dialog specific logicsheets -->
  95. <xts:logicsheet path="subscribe/taskOptions/logicsheets/ui-templates.xsl"/>
  96. <xts:logicsheet path="logicsheets/presentation/dialog/controller-templates.xsl"/>
  97. <xts:logicsheet path="logicsheets/presentation/dialog/framework.xsl"/>
  98. <xts:logicsheet path="logicsheets/presentation/layout.xsl"/>
  99. <xts:logicsheet path="logicsheets/presentation/dialog/presentation.xsl"/>
  100. <!-- Generic logicsheets -->
  101. <xts:logicsheet path="logicsheets/presentation/controls/framework.xsl"/>
  102. <xts:logicsheet path="logicsheets/presentation/controls/presentation.xsl"/>
  103. <xts:logicsheet path="logicsheets/validation.xslt"/>
  104. <xts:logicsheet path="logicsheets/formlogic.xslt"/>
  105. <xts:logicsheet path="logicsheets/presentation/touch_up.xslt"/>
  106. <xsl:stylesheet version="1.0" xmlns:utml="http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" xmlns:pf="http://developer.cognos.com/schemas/xts/pf" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/" xmlns:dp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/presentation/" xmlns:df="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/framework/" xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/" xmlns:dlgctrl="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/controller-templates/" xmlns:xos="http://developer.cognos.com/schemas/xts/output/" xmlns:eut="http://developer.cognos.com/schemas/xts/logicsheets/xslt/emailOptions/logicsheets/" xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/" exclude-result-prefixes="xts xsl cm pf xtsext lyt dp df cf cp xos dlgctrl eut utml">
  107. <xsl:output method="xml" encoding="utf-8" indent="no"/>
  108. <xsl:key name="request-param" match="/root/*[local-name()='requestParams']/*[local-name()='param']" use="@name"/>
  109. <!-- Global template variables -->
  110. <pf:variables/>
  111. <dp:variables/>
  112. <!-- set up some variables -->
  113. <xsl:variable name="browserTitle">
  114. <xts:string id="IDS_SETLABEL_TITLE"/>
  115. </xsl:variable>
  116. <xsl:variable name="description">
  117. <xts:string id="IDS_SETLABEL_DESCRIPTION"/>
  118. </xsl:variable>
  119. <!-- start the output -->
  120. <xsl:template match="/root">
  121. <xts:sequence>
  122. <xts:append select="/root/output">
  123. <xos:part>
  124. <xos:entityHeader>
  125. <xos:param name="Content-Type">text/xml; charset=utf-8</xos:param>
  126. </xos:entityHeader>
  127. <xos:entityBody>
  128. <xsl:element name="{key('request-param','resultNode')}" namespace="">
  129. <markup>
  130. <xts:transform name="XMLEncode">
  131. <!-- adds standard hidden inputs and javascript -->
  132. <dlgctrl:markupHelper/>
  133. <dp:header div="div">
  134. <dp:title>
  135. <xsl:value-of select="$browserTitle"/>
  136. </dp:title>
  137. <dp:description>
  138. <xsl:value-of select="$description"/>
  139. </dp:description>
  140. <dp:close>
  141. <a href="#">
  142. <xsl:attribute name="onclick">
  143. <xsl:if test="key('request-param','isPopup')='true'">document.pform.target='_parent';</xsl:if>
  144. controller_changeState('canceled'); controller_submitForm('cancel');
  145. </xsl:attribute>
  146. <dp:closeMarker/>
  147. </a>
  148. </dp:close>
  149. <dp:useDIVS>
  150. <xsl:text>false</xsl:text>
  151. </dp:useDIVS>
  152. </dp:header>
  153. <pf:help context=""/>
  154. <script language="javascript">
  155. function init()
  156. {
  157. //nothing here yet
  158. }
  159. function validate()
  160. {
  161. <xsl:choose>
  162. <xsl:when test="key('request-param','owner_action')='approve'">
  163. <!-- have to make sure that approve/reject are not empty and they're unique -->
  164. var approveText = document.getElementById('approveText').value;
  165. var rejectText = document.getElementById('rejectText').value;
  166. if (approveText.length == 0) {
  167. alert('<xts:string id="IDS_SETLABEL_NOAPPROVE_TEXT" encode="javascript"/>');
  168. return false;
  169. }
  170. if (rejectText.length == 0) {
  171. alert('<xts:string id="IDS_SETLABEL_NOREJECT_TEXT" encode="javascript"/>');
  172. return false;
  173. }
  174. if (approveText == rejectText) {
  175. alert('<xts:string id="IDS_SETLABEL_APPROVE_REJECT_SAME" encode="javascript"/>');
  176. return false;
  177. }
  178. return true;
  179. </xsl:when>
  180. <xsl:when test="key('request-param','owner_action')='agent'">
  181. <!-- have to make sure that all the labels are not empty and they're unique -->
  182. var submitText = document.getElementById('submitText').value;
  183. if (submitText.length == 0) {
  184. alert('<xts:string id="IDS_SETLABEL_NOSUBMIT_TEXT" encode="javascript"/>');
  185. return false;
  186. }
  187. // have to keep all the values for the task labels
  188. var agentTaskArray = new Array();
  189. var value = "";
  190. <xsl:for-each select="/root/*[local-name()='requestParams']/*[local-name()='param' and @name='futureTasks']/futureTasks/futureTask">
  191. value = document.getElementById('<xsl:value-of select="concat('m_ro_agentTaskItem_display_', ./id)"/>').value;
  192. agentTaskArray.push(value);
  193. </xsl:for-each>
  194. <!-- make sure all the values are not empty -->
  195. if (empty(agentTaskArray)) {
  196. alert('<xts:string id="IDS_SETLABEL_NOTASK_TEXT" encode="javascript"/>');
  197. return false;
  198. }
  199. <!-- make sure they're all unique -->
  200. if (notUnique(agentTaskArray)) {
  201. alert('<xts:string id="IDS_SETLABEL_AGENTTASK_SAME" encode="javascript"/>');
  202. return false;
  203. }
  204. return true;
  205. </xsl:when>
  206. </xsl:choose>
  207. }
  208. function empty(agentTaskArray)
  209. {
  210. for (var i = 0; i &lt; agentTaskArray.length; i++) {
  211. if (agentTaskArray[i].length == 0) {
  212. return true;
  213. }
  214. }
  215. return false;
  216. }
  217. function notUnique(agentTaskArray)
  218. {
  219. for (var i = 0; i &lt; agentTaskArray.length; i++) {
  220. for (var j = i+1; j &lt; agentTaskArray.length; j++) {
  221. if (agentTaskArray[i] == agentTaskArray[j]) {
  222. return true;
  223. }
  224. }
  225. }
  226. return false;
  227. }
  228. </script>
  229. <!-- body -->
  230. <lyt:layout style="1">
  231. <lyt:section width="100%">
  232. <input type="hidden" name="owner_action" value="{key('request-param','owner_action')}"/>
  233. <xsl:choose>
  234. <xsl:when test="key('request-param','owner_action')='approve'">
  235. <dp:list>
  236. <dp:section>
  237. <dp:hint wrap="wrap">
  238. <xts:string id="IDS_SETLABEL_APPROVAL_HINT"/>
  239. </dp:hint>
  240. </dp:section>
  241. <dp:section>
  242. <!-- The approval button value -->
  243. <input type="text" id="approveText" name="approveText" value="{key('request-param', 'approveText')}"/>
  244. </dp:section>
  245. <dp:section>
  246. <dp:hint wrap="wrap">
  247. <xts:string id="IDS_SETLABEL_REJECT_HINT"/>
  248. </dp:hint>
  249. </dp:section>
  250. <dp:section>
  251. <!-- The reject button value -->
  252. <input type="text" id="rejectText" name="rejectText" value="{key('request-param', 'rejectText')}"/>
  253. </dp:section>
  254. </dp:list>
  255. </xsl:when>
  256. <xsl:when test="key('request-param','owner_action')='agent'">
  257. <!-- body -->
  258. <dp:list>
  259. <dp:section>
  260. <dp:hint wrap="wrap">
  261. <xts:string id="IDS_SETLABEL_AGENTSUBMIT_HINT"/>
  262. </dp:hint>
  263. </dp:section>
  264. <dp:section>
  265. <!-- The approval button value -->
  266. <input type="text" id="submitText" name="submitText" value="{key('request-param', 'submitText')}"/>
  267. </dp:section>
  268. <dp:section>
  269. <dp:hint wrap="wrap">
  270. <xsl:if test="/root/*[local-name()='requestParams']/*[local-name()='param' and @name='futureTasks']/futureTasks/futureTask">
  271. <xts:string id="IDS_SETLABEL_AGENTTASKS_HINT"/>
  272. </xsl:if>
  273. </dp:hint>
  274. </dp:section>
  275. <dp:section>
  276. <table cellspacing="0" cellpadding="0">
  277. <xsl:for-each select="/root/*[local-name()='requestParams']/*[local-name()='param' and @name='futureTasks']/futureTasks/futureTask">
  278. <xsl:variable name="displayID">
  279. <xsl:value-of select="concat('m_ro_agentTaskItem_display_', ./id)"/>
  280. </xsl:variable>
  281. <tr>
  282. <!-- we need a checkbox to say if the task is to be used -->
  283. <td>
  284. <input name="{$displayID}" id="{$displayID}" type="text" value="{./display}" size="80"/>
  285. </td>
  286. </tr>
  287. </xsl:for-each>
  288. </table>
  289. </dp:section>
  290. </dp:list>
  291. </xsl:when>
  292. </xsl:choose>
  293. </lyt:section>
  294. </lyt:layout>
  295. <dp:footer>
  296. <dlgctrl:okCancelButtons validateFunction="validate"/>
  297. </dp:footer>
  298. </xts:transform>
  299. </markup>
  300. </xsl:element>
  301. </xos:entityBody>
  302. </xos:part>
  303. </xts:append>
  304. </xts:sequence>
  305. </xsl:template>
  306. </xsl:stylesheet>
  307. </xts:block>
  308. <!--
  309. ===============================================================================================
  310. debug - display debug information
  311. ===============================================================================================
  312. -->
  313. <xts:block id="debug" dependency="genMarkup" condition=".[/root/session/param[@name='debug']='1']" type="exec" mode="output" processor="XSLT" mandatory="false" mimeType="text/html">
  314. <!-- get the debug logic sheet -->
  315. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  316. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dbg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/debug/" exclude-result-prefixes="dbg">
  317. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  318. <xsl:template match="/">
  319. <dbg:dumpxml select="/root"/>
  320. </xsl:template>
  321. </xsl:stylesheet>
  322. </xts:block>
  323. </xts:morphlet>