calcStringLeftRightTrim.xts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. BI and PM: qs
  5. (C) Copyright IBM Corp. 2001, 2017
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <!--
  13. Used for left, right, trim
  14. -->
  15. <xts:morphlet resolverBase="prompting" version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/" messageBase="messages/QSRVUITextPL.xml,messages/portal.xml,messages/portalRL.xml" requiredCapability="canUseQueryStudio">
  16. <xts:block id="browserDetection" path="qs/browserDetection.xslt" mode="interpret" type="exec" processor="XSLT" contentId="browserDetection" partId="1"/>
  17. <xts:block id="page" type="exec" mode="output" processor="XSLT" mimeType="text/html" dependency="browserDetection">
  18. <!-- get the debug logic sheet -->
  19. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  20. <!-- get the new theme stuff -->
  21. <!-- apply the following logicsheets in order -->
  22. <xts:logicsheet path="qs/logicsheets/calc_theme.xsl"/>
  23. <xts:logicsheet path="logicsheets/portal.xsl"/>
  24. <xts:logicsheet path="qs/logicsheets/dialogs.xsl"/>
  25. <xts:logicsheet path="logicsheets/presentation/dialog/framework.xsl"/>
  26. <xts:logicsheet path="logicsheets/presentation/layout.xsl"/>
  27. <xts:logicsheet path="logicsheets/presentation/dialog/presentation.xsl"/>
  28. <xts:logicsheet path="logicsheets/presentation/controls/framework.xsl"/>
  29. <xts:logicsheet path="logicsheets/presentation/controls/presentation.xsl"/>
  30. <xts:logicsheet path="logicsheets/cm-logic.xsl"/>
  31. <!-- apply the form logic -->
  32. <xts:logicsheet path="logicsheets/formlogic.xslt"/>
  33. <xsl:stylesheet version="1.0"
  34. xmlns:clcdlg="test_calculationDlg"
  35. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  36. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  37. xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/"
  38. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  39. xmlns:dp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/presentation/"
  40. xmlns:df="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/framework/"
  41. xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/"
  42. xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/"
  43. xmlns:dbg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/debug/"
  44. xmlns:qsdlg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/qs/dialog/"
  45. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  46. exclude-result-prefixes="clcdlg xsl xts lyt pf dp df cp cf dbg qsdlg xtsext">
  47. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  48. <!-- Default variables (like skin) and prompt variables -->
  49. <qsdlg:variables/>
  50. <qsdlg:promptVariables/>
  51. <!-- Prompt Control XSL include -->
  52. <xsl:include href="p_include.xsl"/>
  53. <!-- add any theme variables -->
  54. <df:variables/>
  55. <pf:variables/>
  56. <!-- start the output -->
  57. <xsl:template match="/root">
  58. <dp:page>
  59. <dp:script>
  60. <xsl:call-template name="getPromptCommonIncludes"/>
  61. <xsl:call-template name="gettextBoxIncludes">
  62. <xsl:with-param name="promptLocale" select="$promptLocale"/>
  63. <xsl:with-param name="promptContentLocale" select="$contentLocale"/>
  64. </xsl:call-template>
  65. <link href="{$qsdlgskin}/qs/QSRVDialog.css" type="text/css" rel="stylesheet"/>
  66. <script type="text/javascript">
  67. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/qs/layout.js</xsl:attribute>
  68. <xsl:text/>//<xsl:text/>
  69. </script>
  70. <script type="text/javascript">
  71. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/rv/cvConstants.js</xsl:attribute>
  72. <xsl:text/>//<xsl:text/>
  73. </script>
  74. <script type="text/javascript">
  75. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/rv/common.js</xsl:attribute>
  76. <xsl:text/>//<xsl:text/>
  77. </script>
  78. <script type="text/javascript">
  79. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/rv/cvui.js</xsl:attribute>
  80. <xsl:text/>//<xsl:text/>
  81. </script>
  82. <script type="text/javascript">
  83. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/common/framework/notification/CObserver.js</xsl:attribute>
  84. <xsl:text/>//<xsl:text/>
  85. </script>
  86. <script type="text/javascript">
  87. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/qs/classes/CDialogManager.js</xsl:attribute>
  88. <xsl:text/>//<xsl:text/>
  89. </script>
  90. <script type="text/javascript">
  91. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/qs/classes/CWindowManager.js</xsl:attribute>
  92. <xsl:text/>//<xsl:text/>
  93. </script>
  94. <script type="text/javascript">&lt;!--
  95. var goDialogManager = new CDialogManager();
  96. <clcdlg:jvs/>
  97. var cf = getConfigFrame();
  98. var calcType = cf.dlgGlobalGetParm('xxCalcType');
  99. var substVarValue = null;
  100. function execute()
  101. {
  102. var before_col_id = cf.dlgGlobalGetParm('xxInsBeforeColid');
  103. var calcFormat = "none";
  104. var first = "";
  105. var second = "";
  106. var calcExpr = "";
  107. var calcOp = document.f.calcList.options[document.f.calcList.selectedIndex].value; // Left, Right, or Trim
  108. var listSeparator = goDialogManager.getMiniQueryManager().getListSeparator();
  109. var numChars = 0;
  110. if (cf.dlgGlobalGetParm('xxDialogType') != 'CALCULATION_TEXT_TRIM')
  111. {
  112. if ((getDisplayStyle("textBoxNumeric")!= "none")&amp;&amp;textBoxnumberValue&amp;&amp;(textBoxnumberValue.isValid())&amp;&amp;(textBoxnumberValue.sGetValue() > 0))
  113. numChars = parseInt(textBoxnumberValue.sGetValue());
  114. else if (getDisplayStyle("textBoxString") != "none" &amp;&amp; substVarValue != null)
  115. numChars = substVarValue;
  116. else
  117. return;
  118. }
  119. if (((calcOp == "left") || (calcOp == "right")) &amp;&amp; (numChars == 0))
  120. return;
  121. if (calcOp == "left")
  122. calcExpr = "substring( " + document.f.repSel.options[document.f.repSel.selectedIndex].value + " from 1 for " + numChars + " )";
  123. else if (calcOp == "right")
  124. {
  125. calcExpr = "substring( " + document.f.repSel.options[document.f.repSel.selectedIndex].value + listSeparator + " character_length( " + document.f.repSel.options[document.f.repSel.selectedIndex].value + " ) - ";
  126. if (getDisplayStyle("textBoxNumeric") != "none")
  127. calcExpr += (numChars - 1) + listSeparator + " " + numChars + " )";
  128. else
  129. calcExpr += "(" + numChars + " - 1)" + listSeparator + " " + numChars + " )";
  130. }
  131. else
  132. calcExpr = "trim(trailing" + listSeparator + " " + document.f.repSel.options[document.f.repSel.selectedIndex].value + ")";
  133. if (calcExpr != "")
  134. {
  135. var calcName = getCalcName();
  136. getConfigFrame().addCalcColumn(before_col_id, calcExpr, calcExpr, calcName, "none", calcOp, "none", calcFormat, 62, 7, "none", -1, "none"); //calcBy,calcBase="none",calculationType=62,usage=7,regularAgg="none",promptType=-1,detailAgg="none"
  137. }
  138. }
  139. function generateName (withQuotes)
  140. {
  141. var calcName = document.f.calcList.options[document.f.calcList.selectedIndex].value; // Left, Right, or Trim
  142. if (getDisplayStyle("textBoxNumeric") != "none")
  143. {
  144. var numChars = 0;
  145. if (cf.dlgGlobalGetParm('xxDialogType') != 'CALCULATION_TEXT_TRIM')
  146. {
  147. if (textBoxnumberValue &amp;&amp; (textBoxnumberValue.isValid())&amp;&amp;(textBoxnumberValue.sGetValue() > 0)) {
  148. numChars = textBoxnumberValue.sGetValue();
  149. }
  150. numChars = parseInt(numChars);
  151. }
  152. if (calcName == "left")
  153. calcName = (document.f.repSel.options[document.f.repSel.selectedIndex].text).substring(0, numChars);
  154. else if (calcName == "right")
  155. {
  156. calcName = document.f.repSel.options[document.f.repSel.selectedIndex].text;
  157. calcName = calcName.substr(calcName.length - numChars);
  158. }
  159. else
  160. calcName = stringReplace ("<xts:string id="CALCULATION_TRIM_EQUATION" encode="javascript"/>", "\\^0", document.f.repSel.options[document.f.repSel.options.selectedIndex].text);
  161. }
  162. else if (textBoxstringValue)
  163. {
  164. if (calcName == "left")
  165. calcName = stringReplace ("<xts:string id="CALCULATION_LEFTMOST_CHARACTERS_HINT" encode="javascript"/>", "\\^0", textBoxstringValue.sGetValue());
  166. else
  167. calcName = stringReplace ("<xts:string id="CALCULATION_RIGHTMOST_CHARACTERS_HINT" encode="javascript"/>", "\\^0", textBoxstringValue.sGetValue());
  168. }
  169. return calcName;
  170. }
  171. function init()
  172. {
  173. attachMouseEvents();
  174. // populate selected columns menu
  175. for (var i = 0; i &lt; cf.dlgGlobalSize('xxColInfo'); i++)
  176. {
  177. var label = cf.dlgGlobalGetParmAt('xxColInfo', i);
  178. document.f.repSel.options[document.f.repSel.options.length] = new Option(label[0], label[1]);
  179. }
  180. var validCalcs = new Array();
  181. for (var i = 0; i &lt; cf.dlgGlobalSize('xxValidCalcItem'); i++)
  182. validCalcs[validCalcs.length] = cf.dlgGlobalGetParmAt('xxValidCalcItem', i);
  183. populateCalculationList(calcType, validCalcs);
  184. // select calculation
  185. document.f.calcList.selectedIndex = cf.dlgGlobalGetParm('xxCalcTypeIdx');
  186. loadHint();
  187. getConfigFrame().cfgSet("CALCULATION_REFRESH", true);
  188. addInsert();
  189. setGlobals(calcType, false);
  190. if (typeof textBoxnumberValue != "undefined")
  191. {
  192. <xsl:choose>
  193. <xsl:when test="/root/browserInfo/isNS6='true'">
  194. textBoxnumberValue.m_oForm.addEventListener("keydown", redrawHint, true);
  195. </xsl:when>
  196. <xsl:otherwise>
  197. textBoxnumberValue.m_oForm.attachEvent("onkeydown", redrawHint);
  198. </xsl:otherwise>
  199. </xsl:choose>
  200. textBoxnumberValue.m_oForm.focus();
  201. }
  202. <xsl:if test="/root/env/param[@name='xxSubstVar']='true'">
  203. <clcdlg:subst_var numeric="true"/>
  204. //hide the second input field
  205. setDisplayStyle("textBoxString", "none");
  206. </xsl:if>
  207. }
  208. function redrawHint()
  209. {
  210. setTimeout(loadHint, 10);
  211. }
  212. //--&gt;</script>
  213. </dp:script>
  214. <form style="margin:0px" name="f" method="POST" onsubmit="execute();return false;">
  215. <table border="0" cellspacing="0" cellpadding="0" height="100%" width="100%">
  216. <tr>
  217. <td width="100%" height="0%">
  218. <!-- dialog header -->
  219. <clcdlg:basic_header/>
  220. </td>
  221. </tr>
  222. <tr>
  223. <td valign="top" width="100%" height="100%">
  224. <lyt:layout style="2" border="no">
  225. <lyt:section>
  226. <clcdlg:calculations/>
  227. <dp:input>
  228. <dp:section1>
  229. <xts:string id="CALCULATION_REP_ITEM"/>
  230. </dp:section1>
  231. <dp:section2>
  232. <select name="repSel" size="1" style="width:260" onChange="javascript:loadHint();"/>
  233. </dp:section2>
  234. </dp:input>
  235. <xsl:if test="/root/env/param[@name='xxDialogType'] != 'CALCULATION_TEXT_TRIM'">
  236. <dp:input>
  237. <dp:section1>
  238. <xsl:if test="/root/env/param[@name='xxDialogType'] = 'CALCULATION_LEFT'">
  239. <xts:string id="CALCULATION_LEFTMOST_CHARACTERS"/>
  240. </xsl:if>
  241. <xsl:if test="/root/env/param[@name='xxDialogType'] = 'CALCULATION_RIGHT'">
  242. <xts:string id="CALCULATION_RIGHTMOST_CHARACTERS"/>
  243. </xsl:if>
  244. </dp:section1>
  245. <dp:section2>
  246. <table>
  247. <tr>
  248. <td id="textBoxNumeric" valign="bottom">
  249. <xsl:call-template name="getTextBox">
  250. <xsl:with-param name="promptLocale" select="$promptLocale"/>
  251. <xsl:with-param name="promptFormName" select="$promptFormName"/>
  252. <xsl:with-param name="promptRequired" select="'false'"/>
  253. <xsl:with-param name="promptId" select="'numberValue'"/>
  254. <xsl:with-param name="promptHideText" select="'false'"/>
  255. <xsl:with-param name="promptMultiLine" select="'false'"/>
  256. <xsl:with-param name="promptParameter" select="'numCharsParam'"/>
  257. <xsl:with-param name="promptDataType" select="'whole'"/>
  258. <xsl:with-param name="promptMaxLength" select="'15'"/>
  259. </xsl:call-template>
  260. </td>
  261. <xsl:if test="/root/env/param[@name='xxSubstVar']='true'">
  262. <td id="textBoxString" valign="bottom">
  263. <xsl:call-template name="getTextBox">
  264. <xsl:with-param name="promptLocale" select="$promptLocale"/>
  265. <xsl:with-param name="promptFormName" select="$promptFormName"/>
  266. <xsl:with-param name="promptRequired" select="'false'"/>
  267. <xsl:with-param name="promptId" select="'stringValue'"/>
  268. <xsl:with-param name="promptHideText" select="'false'"/>
  269. <xsl:with-param name="promptMultiLine" select="'false'"/>
  270. <xsl:with-param name="promptParameter" select="'numberParam2'"/>
  271. <xsl:with-param name="promptReadOnly" select="'true'"/>
  272. </xsl:call-template>
  273. </td>
  274. <td id="buttonContainer"/>
  275. </xsl:if>
  276. </tr>
  277. </table>
  278. </dp:section2>
  279. </dp:input>
  280. </xsl:if>
  281. </lyt:section>
  282. <lyt:section>
  283. <clcdlg:calc_hint/>
  284. </lyt:section>
  285. </lyt:layout>
  286. </td>
  287. </tr>
  288. <tr>
  289. <td width="100%" height="0%">
  290. <!-- Use default buttons [ OK = execute() and CANCEL = hideDialogFrame() ] -->
  291. <clcdlg:buttons/>
  292. </td>
  293. </tr>
  294. <!-- <dbg:dumpxml select="/"/> -->
  295. </table>
  296. </form>
  297. </dp:page>
  298. </xsl:template>
  299. </xsl:stylesheet>
  300. </xts:block>
  301. </xts:morphlet>