promptValues.xslt 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: AGS
  5. (C) Copyright IBM Corp. 2005, 2014
  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:agspmt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/promptValues/" xmlns:xtscm="http://developer.cognos.com/schemas/xts-cm/1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:out="dummy-uri" xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/" xmlns:bus="http://developer.cognos.com/schemas/bibus/3/" 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:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/" xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/" xmlns:agsad="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/agentDefinition/" xmlns:utml="http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/" xmlns:agsdlg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/dialog/" xmlns:req-params="http://developer.cognos.com/schemas/request/params" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:xos="http://developer.cognos.com/schemas/xts/output/" exclude-result-prefixes="agspmt xtscm xsi cf bus pf xtsext lyt dp df cp cm agsad utml agsdlg req-params xts xos">
  9. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  10. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  11. <xsl:key name="request-param" match="/root/*[local-name()='requestParams']/*[local-name()='param']" use="@name"/>
  12. <!--pf:variables/>
  13. <pf:serialize-xml/-->
  14. <!-- start the output -->
  15. <xsl:template match="agspmt:promptValues">
  16. <out:template name="promptValues">
  17. <out:variable name="connection_type">
  18. <out:text><xts:string id="DIALOG_PROMPT_CONNECTION"/></out:text>
  19. </out:variable>
  20. <input type="hidden" id="m_obj" name="m_obj">
  21. <out:attribute name="value">
  22. <out:value-of select="/root/env/param[@name='selected_path']"/>
  23. </out:attribute>
  24. </input>
  25. <!-- taskParameters is stored in here too but as an updated mirror of taskParameters
  26. this is because we must capture them in the parent page and update them here
  27. so that if you move off the page quickly..... you dont loose the saved task parameter values-->
  28. <input type="hidden" id="updatedTaskParameters" name="updatedTaskParameters">
  29. <out:attribute name="value">
  30. <out:value-of select="/root/env/param[@name='taskParameters']"/>
  31. </out:attribute>
  32. </input>
  33. <input type="hidden" id="method" name="method" value="" utml:update="false"/>
  34. <input type="hidden" id="cleared_prompts" name="cleared_prompts" value="false"/>
  35. <input type="hidden" id="has_prompts" name="has_prompts">
  36. <out:attribute name="value">
  37. <out:value-of select="count(/root/parametersDisplay/parameter)>0"/>
  38. </out:attribute>
  39. </input>
  40. <dp:list width="100%" section3_align="right">
  41. <dp:section width="100%">
  42. <dp:text align="right">
  43. <out:if test="count(/root/parametersDisplay/parameter)>0">
  44. <xts:string align="right" id="IDS_ENTRIES"/>1 - <out:value-of select="count(/root/parametersDisplay/parameter)"/>
  45. </out:if>
  46. </dp:text>
  47. </dp:section>
  48. <dp:section width="100%">
  49. <cp:table name="parameterTable" showEmptyMsg="true" iterate="/root/parametersDisplay/parameter">
  50. <cp:tableHeader>
  51. <cp:columnHeader width="20%" align="middle">
  52. <!-- no effect with align - all to left-->
  53. <xts:string id="IDS_ADV_NAME"/>
  54. </cp:columnHeader>
  55. <cp:columnHeader width="10%" align="left">
  56. <xts:string id="IDS_TYPE"/>
  57. </cp:columnHeader>
  58. <cp:columnHeader width="2%" align="left">
  59. <xts:string id="DIALOG_PROMPT_REQUIRED"/>
  60. </cp:columnHeader>
  61. <cp:columnHeader width="8%" align="left">
  62. <xts:string id="DIALOG_PROMPT_MULTI_SELECT"/>
  63. </cp:columnHeader>
  64. <cp:columnHeader width="1%" align="left"/>
  65. <cp:columnHeader width="0%" align="middle">
  66. <xts:string id="DIALOG_PROMPT_METHOD"/>
  67. </cp:columnHeader>
  68. <cp:columnHeader width="100%" align="left">
  69. <xts:string id="DIALOG_PROMPT_VALUE"/>
  70. </cp:columnHeader>
  71. </cp:tableHeader>
  72. <cp:tableContent>
  73. <cp:common-render-variables>
  74. <out:variable name="drop_zone_name">
  75. <out:value-of select="concat('pv_dz_', @name, '_pv_dz')"/>
  76. </out:variable>
  77. <out:variable name="literalDiv" select="concat('literalDiv', position())"/>
  78. <out:variable name="modelDiv" select="concat('modelDiv', position())"/>
  79. <out:variable name="method_display">
  80. <out:choose>
  81. <!-- If both are there then model takes over.-->
  82. <out:when test="@modelValue">
  83. <literal>none</literal>
  84. </out:when>
  85. <out:otherwise>
  86. <model>none</model>
  87. </out:otherwise>
  88. </out:choose>
  89. </out:variable>
  90. </cp:common-render-variables>
  91. <cp:columnContent>
  92. <out:choose>
  93. <out:when test="@caption != ''"><out:value-of select="@caption"/></out:when>
  94. <out:otherwise>@name</out:otherwise>
  95. </out:choose>
  96. </cp:columnContent>
  97. <cp:columnContent>
  98. <out:value-of select="@type"/>
  99. </cp:columnContent>
  100. <cp:columnContent>
  101. <out:choose>
  102. <out:when test="@required = 'true'">
  103. <img alt="" border="0">
  104. <out:attribute name="src"><out:value-of select="$webcontent"/>/../ps/portal/images/active_namespace.gif</out:attribute>
  105. </img>
  106. <!--img src="{$webcontent}/../ps/portal/images/active_namespace.gif"!-->
  107. <!-- tick icon -->
  108. </out:when>
  109. <out:otherwise>
  110. <img alt="" border="0">
  111. <out:attribute name="src"><out:value-of select="$webcontent"/>/images/space.gif</out:attribute>
  112. </img>
  113. <!--img src="{$webcontent}/images/space.gif"-->
  114. </out:otherwise>
  115. </out:choose>
  116. </cp:columnContent>
  117. <cp:columnContent>
  118. <!-- Multi-select? -->
  119. <out:choose>
  120. <out:when test="@multivalued='true'">
  121. <img alt="" border="0">
  122. <out:attribute name="src"><out:value-of select="$webcontent"/>/../ps/portal/images/active_namespace.gif</out:attribute>
  123. </img>
  124. </out:when>
  125. <out:otherwise>
  126. <img alt="" border="0">
  127. <out:attribute name="src"><out:value-of select="$webcontent"/>/images/space.gif</out:attribute>
  128. </img>
  129. </out:otherwise>
  130. </out:choose>
  131. </cp:columnContent>
  132. <cp:columnContent>
  133. <img alt="" border="0">
  134. <out:attribute name="src"><out:value-of select="$webcontent"/>/../ags/images/summary/icon_prompt_values.gif</out:attribute>
  135. <out:attribute name="title"><xts:string id="DIALOG_REPORT_PROMPT_VALUE"/></out:attribute>
  136. </img>
  137. </cp:columnContent>
  138. <cp:columnContent>
  139. <select name="pv_selection_{'{@name}'}" id="pv_selection_{'{@name}'}" onchange="toggleDiv({'{position()}'},'{'{$drop_zone_name}'}')">
  140. <out:if test="@type=$connection_type or starts-with(/root/parametersDisplay/objectClass, 'powerPlay')" >
  141. <out:attribute name="disabled">
  142. <out:text>disabled</out:text>
  143. </out:attribute>
  144. </out:if>
  145. <option value="1">
  146. <!-- select this option is the value of the select is the value of the option -->
  147. <out:if test="not($method_display/model)">
  148. <out:attribute name="selected">true</out:attribute>
  149. </out:if>
  150. <xts:string id="DIALOG_PARAMETER_USE_ITEM"/>
  151. </option>
  152. <option value="2">
  153. <out:if test="not($method_display/literal)">
  154. <out:attribute name="selected">true</out:attribute>
  155. </out:if>
  156. <xts:string id="DIALOG_PARAMETER_USE_VALUE"/>
  157. </option>
  158. </select>
  159. <img height="15" width="5" border="0">
  160. <out:attribute name="src">
  161. <out:value-of select="$webcontent"/>/images/space.gif</out:attribute>
  162. </img>
  163. <!--img height="15" width="1" src="{$webcontent}/images/space.gif"-->
  164. </cp:columnContent>
  165. <cp:columnContent>
  166. <div id="{'{$literalDiv}'}" name="{'{$literalDiv}'}" style="display:{'{$method_display/literal}'}">
  167. <out:choose>
  168. <out:when test="@literalValue and not(@literalValue = '')">
  169. <out:value-of select="@literalValue"/>
  170. </out:when>
  171. <out:otherwise>
  172. <xts:string id="IDS_OTHERRUN_DEFAULT"/>
  173. </out:otherwise>
  174. </out:choose>
  175. </div>
  176. <div id="{'{$modelDiv}'}" name="{'{$modelDiv}'}" style="display:{'{$method_display/model}'}">
  177. <agsdlg:insertButton width="80%" targetId="{'{$drop_zone_name}'}" value="{'{@modelValue}'}">
  178. <input type="text" oncontextmenu="event.cancelBubble=true;event.returnValue=false;return false;" closePrevious="true" onKeyPress="event.cancelBubble=true;event.returnValue=false;return false;" onblur="event.cancelBubble=true;event.returnValue=false;return false;" onkeydown="event.cancelBubble=true;event.returnValue=false;return false;" id="{'{$drop_zone_name}'}" name="{'{$drop_zone_name}'}" value="{'{@modelValue}'}"/>
  179. </agsdlg:insertButton>
  180. </div>
  181. </cp:columnContent>
  182. </cp:tableContent>
  183. </cp:table>
  184. </dp:section>
  185. <!-- Only if we have any parameters we show the section below -->
  186. <dp:section width="100%">
  187. <dp:text align="right">
  188. <out:choose>
  189. <out:when test="starts-with(/root/parametersDisplay/objectClass, 'powerPlay')">
  190. <out:choose>
  191. <out:when test="count(/root/parametersDisplay/parameter) = 0">
  192. <a href="#" onclick="doPowerPlayPrompts('prompt_set');">
  193. <xts:string id="DIALOG_SPECIFY_VALUES"/>
  194. </a>
  195. </out:when>
  196. <out:otherwise>
  197. <!-- prompts for PowerPlay8 are handled differently -->
  198. <a href="#" onclick="doPowerPlayPrompts('prompt_edit');">
  199. <xts:string id="DIALOG_SPECIFY_VALUES"/>
  200. </a>
  201. <img height="15" width="5" border="0" src="../ags/images/space.gif"/>
  202. <a href="#" onclick="doPowerPlayPrompts('clear');">
  203. <xts:string id="DIALOG_PROMPT_RESET_DEFAULT_VALUES"/>
  204. </a>
  205. </out:otherwise>
  206. </out:choose>
  207. </out:when>
  208. <out:otherwise>
  209. <out:if test="count(/root/parametersDisplay/parameter) > 0">
  210. <out:if test="not(/root/env/param[@name='doSkip'])">
  211. <a href="#" align="right" onclick="doPrompts('edit');">
  212. <xts:string id="DIALOG_SPECIFY_VALUES"/>
  213. </a>
  214. </out:if>
  215. <out:if test="/root/parametersDisplay//parameter[@literalValue != '']">
  216. <img height="15" width="5" border="0" src="../ags/images/space.gif"/>
  217. <a align="right" href="#" onclick="clearModelPrompts()">
  218. <xts:string align="right" id="DIALOG_PROMPT_RESET_DEFAULT_VALUES"/>
  219. </a>
  220. </out:if>
  221. </out:if>
  222. </out:otherwise>
  223. </out:choose>
  224. </dp:text>
  225. </dp:section>
  226. </dp:list>
  227. </out:template>
  228. </xsl:template>
  229. <xsl:template match="agspmt:promptValuesScript">
  230. <out:template name="promptValuesScript">
  231. <script type="text/javascript">
  232. function initPromptPage(parameterArray)
  233. {
  234. var dropZones = new Array();
  235. var dropZone;
  236. for (var i = 0; i &lt; parameterArray.length; i++) {
  237. var dropzone_name = "pv_dz_" + parameterArray[i].name + "_pv_dz";
  238. if (parameterArray[i].modelValue) {
  239. document.getElementById(dropzone_name).value = parameterArray[i].modelValue;
  240. }
  241. dropZone = new DropZone(dropzone_name,"","",'true',"<out:value-of select="key('request-param','tabSelectedID')"/>",true);
  242. droppy.registerDropZoneObject(dropZone);
  243. dropZones.push(dropZone);
  244. // define a function which is going to handle the data from the drop
  245. //droppy.registerPreEventHandler(dropzone_name,"ondrop", clearBeforeDrop);
  246. }
  247. //pass the group to a listener in case number of members dynamically changes
  248. droppy.registerDropZoneGroup(dropZones, "<out:value-of select="key('request-param','tabSelectedID')"/>");
  249. }
  250. /*
  251. this is called afetr the asynch get parameters html is injected into the waiting div
  252. the asynch getParametersResponse has an updated value for taskParameters that must
  253. be used to change the original value that is stored in the parent page.
  254. */
  255. function initInjectedHtml(){
  256. var cf = parent.getConfigFrame();
  257. cf.showDialogFrame(0);
  258. if(document.pform.updatedTaskParameters){
  259. var tps = document.getElementById('taskParameters');
  260. var utps = document.getElementById('updatedTaskParameters');
  261. //update the real task parameters
  262. tps.value = utps.value;
  263. utps.parentNode.removeChild(utps);
  264. //update the event handlers
  265. cf.attachHandlers(document.forms);
  266. }
  267. }
  268. /*
  269. // only the last item dropped visible but previous selections left in the agent tree
  270. function clearBeforeDrop()
  271. {
  272. //the id is a global generated by the drag drop handler before this method is called
  273. //and is the correct id for whatever dropzone is being used
  274. droppy.setDropZoneValue("");
  275. }
  276. */
  277. function validatePromptPage()
  278. {
  279. return true;
  280. }
  281. function toggleDiv(position, dz_name)
  282. {
  283. var modelDiv = "modelDiv" + position;
  284. var literalDiv = "literalDiv" + position;
  285. var displayName;
  286. var hideName;
  287. if(document.getElementById(modelDiv).style.display == 'none')
  288. {
  289. displayName = modelDiv;
  290. hideName = literalDiv;
  291. }
  292. else
  293. {
  294. displayName = literalDiv;
  295. hideName = modelDiv;
  296. //model item div is being hidden, clear it
  297. droppy.setDropZoneValue("",dz_name);
  298. }
  299. showDiv(displayName );
  300. hideDiv(hideName );
  301. }
  302. function showDiv(name)
  303. {
  304. document.getElementById(name).style.display='';
  305. }
  306. function hideDiv(name)
  307. {
  308. document.getElementById(name).style.display='none';
  309. }
  310. function clearModelPrompts()
  311. {
  312. document.getElementById('cleared_prompts').value='true';
  313. document.getElementById('taskParameters').value = '';
  314. var frm = document.pform;
  315. //we must resubmit to ourselves
  316. frm.m.value = 'ags/dialogAdapter.xts';
  317. frm.ps_nav_op.value = "maintain";
  318. window.setTimeout('document.pform.submit();', 1 );
  319. }
  320. function doPrompts(cmd)
  321. {
  322. var frm = document.pform;
  323. //we must resubmit to ourselves
  324. frm.m.value = 'ags/promptValuesProxy.xts';
  325. frm.ps_nav_op.value = "maintain";
  326. if (cmd == 'clear')
  327. {
  328. frm.cleared_prompts.value = 'true';
  329. if (frm.m_rp_parameters)
  330. {
  331. frm.m_rp_parameters.value = '';
  332. }
  333. }
  334. else
  335. {
  336. frm.method.value=cmd;
  337. }
  338. window.setTimeout('document.pform.submit();', 1 );
  339. }
  340. function doPowerPlayPrompts(cmd)
  341. {
  342. if (cmd == 'clear')
  343. {
  344. if (pform.taskParameters) {
  345. pform.taskParameters.value = '';
  346. }
  347. if (pform.m_parameter) {
  348. pform.m_parameter.value = '';
  349. }
  350. window.setTimeout('document.pform.submit();', 1 );
  351. }
  352. else if (cmd == 'prompt_set' || cmd == 'prompt_edit' ) {
  353. // have to call powerplay prompts - need to get the saved state and m_parameter first -
  354. // need to setup a controller stack
  355. parent.getConfigFrame().getCommandStackManager().initiateCommandStack("parent.getConfigFrame().savePPState();","parent.getMessageIFrame().callPowerPlayPrompts();");
  356. }
  357. }
  358. function callPowerPlayPrompts()
  359. {
  360. var cf = parent.getConfigFrame();
  361. // build the form dynamically
  362. cf.dlgReset();
  363. cf.dlgSetParm('ui.backURL','<out:value-of select="xtsext:javascriptencode(string(concat($gateway,'?b_action=xts.run&amp;m=ags/dialogAdapter.xts&amp;ccstate=')))"/>'+cf.cfgGet("savedEnv")+'&amp;cafcontextid='+cf.cafContextId);
  364. cf.dlgSetParm('PP_BACK','<out:value-of select="xtsext:javascriptencode(string(concat($gateway,'?b_action=xts.run&amp;m=ags/dialogAdapter.xts&amp;ccstate=')))"/>'+cf.cfgGet("savedEnv")+'&amp;cafcontextid='+cf.cafContextId);
  365. cf.dlgSetParm('b_action','<out:value-of select="'powerPlayService'"/>');
  366. cf.dlgSetParm('ui.action','<out:value-of select="'setPowerPlay8Prompt'"/>');
  367. cf.dlgSetParm('m','<out:value-of select="'ags/dialogAdapter.xts'"/>');
  368. cf.dlgSetParm('crnobj','<out:value-of select="xtsext:javascriptencode(string(/root/cm:queryResponse/cm:queryReply[2]//cm:searchPath))"/>');
  369. cf.dlgSetParm('ui.crnfrm','<out:value-of select="'PDF'"/>');
  370. cf.dlgSetParm('opaque', cf.cfgGet("savedEnv"));
  371. cf.dlgSetParm('store_ID','<out:value-of select="xtsext:javascriptencode(string(/root/cm:queryResponse/cm:queryReply[2]//cm:storeID))"/>');
  372. if (cf.cfgGet("m_parameter") != '') {
  373. cf.dlgSetParm('m_parameter', cf.cfgGet("m_parameter"));
  374. }
  375. // want to submit this to this to the message frame
  376. cf.dlgSubmit("messageIFrame");
  377. }
  378. </script>
  379. </out:template>
  380. </xsl:template>
  381. <!--
  382. * - This next template is required to copy all other elements into the result.
  383. -->
  384. <xsl:template match="*">
  385. <xsl:copy>
  386. <xsl:copy-of select="@*"/>
  387. <xsl:apply-templates/>
  388. </xsl:copy>
  389. </xsl:template>
  390. </xsl:stylesheet>