defineParameter.xts 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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, 2021
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xts:morphlet version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/" messageBase="messages/portal.xml,messages/AGS.xml,messages/portalRL.xml" requiredCapability="canUseEventStudio">
  9. <!--
  10. ===============================================================================================
  11. formlogic_init - standard form logic initialization
  12. Note the condition here which checks the dialog source[ps_nav_source] from the last stack operation against the current morphlet[m].
  13. The new dialog will not be pushed onto the stack if they are the same thus preventing multiple consecutives instances of the same dialog.
  14. ===============================================================================================
  15. -->
  16. <xts:block id="formlogic_init" type="exec" mode="interpret" processor="XSLT" path="/logicsheets/formlogic_init.xslt" mandatory="false" condition=".[ /root/env/param[@name = 'm'] != /root/env/param[@name='ps_nav_source']]"/>
  17. <!--
  18. ================================================================================
  19. Page Renderer
  20. ================================================================================
  21. -->
  22. <xts:block id="page" type="exec" mode="output" processor="XSLT" mimeType="text/html" dependency="formlogic_init">
  23. <!-- get the debug logic sheet -->
  24. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  25. <!-- get the new theme stuff -->
  26. <xts:logicsheet path="logicsheets/portal.xsl"/>
  27. <xts:logicsheet path="ags/logicsheets/dialogs.xsl"/>
  28. <xts:logicsheet path="logicsheets/presentation/dialog/framework.xsl"/>
  29. <xts:logicsheet path="logicsheets/presentation/dialog/presentation.xsl"/>
  30. <xts:logicsheet path="logicsheets/presentation/layout.xsl"/>
  31. <xts:logicsheet path="logicsheets/cm-logic.xsl"/>
  32. <!-- apply the form logic -->
  33. <xts:logicsheet path="logicsheets/formlogic.xslt"/>
  34. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/" xmlns:pf="http://developer.cognos.com/schemas/xts/pf" 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:dbg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/debug/" xmlns:utml="http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:ags="http://developer.cognos.com/schemas/xts/ags" exclude-result-prefixes="xsl xts lyt pf dp df dbg utml xtsext">
  35. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  36. <!-- Global template variables -->
  37. <pf:variables/>
  38. <df:variables/>
  39. <!-- start the output -->
  40. <xsl:template match="/root">
  41. <dp:page>
  42. <link href="{$skin_root}/ags/ags.css" type="text/css" rel="stylesheet"/>
  43. <utml:form name="pform" method="post" action="{$gateway}">
  44. <utml:input type="hidden" name="hid" id="hid" utml:update="false" value="ug_cr_as_ag_wrk_dfn_prm"/>
  45. <!-- ================================================================ -->
  46. <!-- HEADER -->
  47. <!-- ================================================================ -->
  48. <dp:header>
  49. <dp:title>
  50. <xts:string id="DIALOG_PARAMETER_LABEL"/>
  51. </dp:title>
  52. <dp:description>
  53. <xts:string id="DIALOG_PARAMETER_DESCRIPTION"/>
  54. </dp:description>
  55. <dp:close>
  56. <a href="#" onclick="parent.getConfigFrame().hideDialogFrame();">
  57. <dp:closeMarker/>
  58. </a>
  59. </dp:close>
  60. </dp:header>
  61. <!-- ================================================================ -->
  62. <!-- B O D Y -->
  63. <!-- ================================================================ -->
  64. <body>
  65. <lyt:layout style="1">
  66. <lyt:section>
  67. <!-- Name -->
  68. <dp:input>
  69. <dp:section1>
  70. <xts:string id="DIALOG_PARAMETER_NAME"/>
  71. </dp:section1>
  72. <!-- creates a new row -->
  73. <dp:section2>
  74. <utml:input type="text" name="parameter_name" id="parameter_name" size="50"/>
  75. <!-- add another hidden input here - FORM behaviour is to submit the form on ENTER if we have a single text field -->
  76. <!-- add another hidden text field here to stop this - we could do a form submit handler - but that's going to be hard to track -->
  77. <input type="text" name="cancel_enter" id="cancel_enter" size="0" style="display:none"/>
  78. </dp:section2>
  79. </dp:input>
  80. <!-- body -->
  81. <!--dp:choice>
  82. <dp:section1>
  83. <utml:input type="checkbox" name="accept_range" id="accept_range" value="false"/>
  84. </dp:section1>
  85. <dp:section2>
  86. <xts:string id="DIALOG_PARAMETER_CHECKBOX_ACCEPT_RANGE"/>
  87. </dp:section2>
  88. </dp:choice-->>
  89. </lyt:section>
  90. </lyt:layout>
  91. </body>
  92. <!-- ================================================================ -->
  93. <!-- F O O T E R -->
  94. <!-- ================================================================ -->
  95. <dp:footer>
  96. <df:button df:id="IDS_OK" df:style="href" df:href="#" onclick="return doOK();" />
  97. <df:button df:id="IDS_CANCEL" df:style="href" df:href="#" onclick="parent.getConfigFrame().hideDialogFrame();"/>
  98. <df:button df:id="IDS_APPLY" df:style="href" df:href="#" onclick="return doApply();"/>
  99. </dp:footer>
  100. </utml:form>
  101. <dp:script>
  102. <pf:help context="ug_cr_as_ag_wrk_dfn_prm" eventStudio="true"/>
  103. <script type="text/javascript" src="../ags/help.js"/>
  104. <script type="text/javascript">
  105. // get access to the config Frame
  106. var cf = parent.getConfigFrame();
  107. var adding = <xsl:choose><xsl:when test="/root/env/param[@name='method'] = 'add'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
  108. var saved_name;
  109. var paramTree = new Array();
  110. var currentParamNode;
  111. var dirty=false;
  112. function hasChanged() {
  113. return dirty;
  114. }
  115. function trim(line)
  116. {
  117. var re = /^\s*|\s*$/g;
  118. return line.replace(re,"");
  119. }
  120. function getName()
  121. {
  122. return htmlEncode(trim(document.pform.parameter_name.value));
  123. }
  124. <!-- encode the html metacharacters -->
  125. function htmlEncode(string)
  126. {
  127. var returnString = string.replace(/&amp;/g, "&amp;amp;");
  128. returnString = returnString.replace(/&quot;/g, "&amp;quot;");
  129. returnString = returnString.replace(/&lt;/g, "&amp;lt;");
  130. returnString = returnString.replace(/&gt;/g, "&amp;gt;");
  131. returnString = returnString.replace(/&apos;/g, "&amp;apos;");
  132. return returnString;
  133. }
  134. function onInputChanged() {
  135. dirty=true;
  136. return true;
  137. }
  138. /*
  139. * Initialize the define parameter dialog
  140. */
  141. function init() {
  142. cf.addEvent(document.getElementById('parameter_name'),"change",onInputChanged);
  143. if (!adding) {
  144. var nodeRef = &quot;<xsl:value-of select="xtsext:javascriptencode(string(/root/env/param[@name = 'nodeRef']))"/>&quot;
  145. if (nodeRef &amp;&amp; nodeRef != '') {
  146. currentParamNode = cf.getTreeNode(cf.getParametersTree().getName(), nodeRef);
  147. }
  148. document.pform.parameter_name.value = currentParamNode.getValue().name;
  149. //document.pform.accept_range.checked = currentParamNode.getValue().acceptRange;
  150. cf.changeMenu(cf.TAB_PARAMETERS);
  151. if (cf.browserCheck.isIE5Up()) {
  152. document.pform.parameter_name.attachEvent("onblur", updateDlgParams);
  153. }
  154. else if (cf.browserCheck.isNav6Up()) {
  155. document.pform.parameter_name.addEventListener("blur",updateDlgParams,true);
  156. }
  157. }
  158. var treeNodes = cf.getTreeChildNodes(cf.getParametersTree());
  159. var nodeId = currentParamNode &amp;&amp; currentParamNode != 'undefined'?currentParamNode.getId():"";
  160. for (var i=0;i&lt;treeNodes.length;i++) {
  161. //Copy all the ones we are not editintg.
  162. if (nodeId != treeNodes[i].getId()) {
  163. paramTree.push(treeNodes[i]);
  164. }
  165. }
  166. //cf.showDialogFrame("30%");
  167. //Show it now
  168. cf.showDialogFrame(220);
  169. // set the focus into the parameter name item
  170. document.pform.parameter_name.focus();
  171. }
  172. //take what was passed and update it to what is on the screen, ready for a navigate away and back
  173. function updateDlgParams(){
  174. //cf.dlgSetParm("editedNode", currentParamNode);
  175. }
  176. function doApply()
  177. {
  178. var result = false;
  179. if (validate()) {
  180. // just have to create or amend the parameter
  181. result = process();
  182. dirty=false;
  183. }
  184. return result;
  185. }
  186. // function which is called when we ok
  187. function doOK()
  188. {
  189. var result = false;
  190. if (validate()) {
  191. // create or amend the calculation
  192. result = process();
  193. }
  194. if (result) {
  195. cf.hideDialogFrame();
  196. }
  197. return result;
  198. }
  199. // create the parameter object
  200. function process()
  201. {
  202. // get the name and trim whitespace from the front and the end
  203. var name = getName();
  204. // get the parameter usage boolean
  205. // var range = document.pform.accept_range.checked;
  206. // create the parameter
  207. var obj = cf.createParameterObj(name, false);
  208. // revise the item in the tree
  209. if(currentParamNode &amp;&amp; currentParamNode !='undefined') {
  210. // just a change in expression and revise entry
  211. currentParamNode = cf.updateParameter(obj, currentParamNode);
  212. } else {
  213. currentParamNode = cf.updateParameter(obj);
  214. }
  215. return true;
  216. }
  217. // validate the dialog
  218. function validate() {
  219. // trim the parameter name
  220. var name = getName();
  221. // check that we have a parameter name
  222. if (name.length == 0) {
  223. // throw up an alert box
  224. alert(&quot;<xts:string id="DIALOG_PARAMETER_NO_NAME" encode="javascript"/>&quot;);
  225. // we're not valid
  226. return false;
  227. }
  228. //We should always compare against the tree we have copied
  229. //if we are adding then it will hold only the items before adding
  230. //a new one, and if we are editing this copy we have will exclude
  231. //the node we are editing.
  232. //if (cf.nameInTree(name,paramTree)) {
  233. if (cf.getNodeFromTreeWithValue(name,"name", paramTree)) {
  234. alert(&quot;<xts:string id="DIALOG_PARAMETER_DUPLICATE_NAME" encode="javascript"/>&quot;);
  235. // this is bad
  236. return false;
  237. }
  238. // things are ok - so can proceed
  239. return true;
  240. }
  241. </script>
  242. </dp:script>
  243. </dp:page>
  244. </xsl:template>
  245. </xsl:stylesheet>
  246. </xts:block>
  247. <!-- =========================================================================================
  248. D E B U G B L O C K
  249. =========================================================================================
  250. -->
  251. <xts:block id="debug" type="exec" mode="output" processor="XSLT" condition=".[/root/session/param[@name = 'debug'] = '1']" mandatory="false" mimeType="text/html" dependency="page">
  252. <!-- Get the debug logicsheet. -->
  253. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  254. <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">
  255. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  256. <xsl:template match="/">
  257. <dbg:dumpxml select="/root"/>
  258. </xsl:template>
  259. </xsl:stylesheet>
  260. </xts:block>
  261. </xts:morphlet>