defineDataItem.xts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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, 2009
  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. ===============================================================================================
  13. -->
  14. <xts:block id="formlogic_init" type="exec" mode="interpret" processor="XSLT" path="/logicsheets/formlogic_init.xslt"/>
  15. <!--
  16. ================================================================================
  17. Page Renderer
  18. ================================================================================
  19. -->
  20. <xts:block id="page" type="exec" mode="output" processor="XSLT" mimeType="text/html" dependency="formlogic_init">
  21. <!-- get the debug logic sheet -->
  22. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  23. <!-- get the new theme stuff -->
  24. <xts:logicsheet path="logicsheets/portal.xsl"/>
  25. <xts:logicsheet path="ags/logicsheets/condition-ui-templates.xslt"/>
  26. <xts:logicsheet path="ags/logicsheets/dialogs.xsl"/>
  27. <xts:logicsheet path="logicsheets/presentation/dialog/framework.xsl"/>
  28. <xts:logicsheet path="logicsheets/presentation/dialog/presentation.xsl"/>
  29. <xts:logicsheet path="logicsheets/presentation/controls/framework.xsl"/>
  30. <xts:logicsheet path="logicsheets/presentation/controls/presentation.xsl"/>
  31. <xts:logicsheet path="logicsheets/presentation/layout.xsl"/>
  32. <xts:logicsheet path="logicsheets/cm-logic.xsl"/>
  33. <!-- apply the form logic -->
  34. <xts:logicsheet path="logicsheets/formlogic.xslt"/>
  35. <xsl:stylesheet version="1.0"
  36. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  37. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  38. xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/"
  39. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  40. xmlns:dp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/presentation/"
  41. xmlns:df="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/framework/"
  42. xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/"
  43. xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/"
  44. xmlns:dbg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/debug/"
  45. xmlns:utml="http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/"
  46. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  47. xmlns:agscnd="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/condition/"
  48. xmlns:ags="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/condition/"
  49. xmlns:agsdlg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/dialog/"
  50. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  51. exclude-result-prefixes="xsl xts lyt pf dp df cp cf dbg utml xtsext agscnd agsdlg cm ags">
  52. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  53. <!-- Global template variables -->
  54. <pf:variables/>
  55. <df:variables/>
  56. <dp:variables/>
  57. <pf:gen-icon/>
  58. <xsl:variable name="form-read-only">false</xsl:variable>
  59. <!-- start the output -->
  60. <xsl:template match="/root">
  61. <xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html&gt;</xsl:text>
  62. <dp:page>
  63. <!-- specify the style sheet(used to render the active/inactive hint text)
  64. todo move this into its own xslt file. Do not put it into the dp stuff because that is relevant to the whole portal
  65. -->
  66. <link href="{$skin_root}/ags/ags.css" type="text/css" rel="stylesheet"/>
  67. <link href="{$skin_root}/ags/crn.css" type="text/css" rel="stylesheet"/>
  68. <utml:form name="pform" method="post" action="{$gateway}">
  69. <utml:input type="hidden" name="hid" id="hid" utml:update="false" value="ug_cr_as_ag_wrk_crt_calc"/>
  70. <!--utml:exclusion-list>
  71. <xsl:value-of select="' method '"/>
  72. </utml:exclusion-list-->
  73. <!-- put some variables in for the validation -->
  74. <utml:input type="hidden" name="inlineSpec" id="inlineSpec" value=""/>
  75. <!-- hack to specify that we need to build the run options -->
  76. <dp:header>
  77. <dp:meta>
  78. <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  79. </dp:meta>
  80. <dp:title>
  81. <xts:string id="DIALOG_DATAITEM_LABEL"/>
  82. </dp:title>
  83. <dp:description>
  84. <xts:string id="DIALOG_DATAITEM_DESCRIPTION"/>
  85. </dp:description>
  86. <dp:close>
  87. <a href="#" onclick="parent.getConfigFrame().hideDialogFrame();">
  88. <dp:closeMarker/>
  89. </a>
  90. </dp:close>
  91. </dp:header>
  92. <!-- ================================================================ -->
  93. <!-- B O D Y -->
  94. <!-- ================================================================ -->
  95. <!-- have to define the list of exluded tabs -->
  96. <lyt:layout style="1">
  97. <lyt:section>
  98. <dp:box title="DIALOG_DATAITEM_NAME" noSpace="true">
  99. <dp:boxSection valign="top" hgap="30">
  100. <utml:input type="text" name="dataItem_name" id="dataItem_name" size="70"/>
  101. <!-- add another hidden input here - FORM behaviour is to submit the form on ENTER if we have a single text field -->
  102. <!-- 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 -->
  103. <input type="text" name="cancel_enter" id="cancel_enter" size="0" style="display:none"/>
  104. </dp:boxSection>
  105. <!-- This has been removed for now It might be reintroduced in the future -->
  106. <!-- This key is supposed to indicate whether this dataitme is to be added -->
  107. <!-- as an event key. -->
  108. <!--dp:boxSection valign="middle">
  109. <utml:input type="checkbox" name="di_insert" id="di_insert" value="false" />
  110. </dp:boxSection>
  111. <dp:boxSection>
  112. <xts:string id="DIALOG_DATAITEM_INCLUDE_EVENT_KEY"/>
  113. </dp:boxSection-->
  114. </dp:box>
  115. </lyt:section>
  116. <agscnd:dataItemUI>
  117. <agscnd:param name="textareaId">dataItem_expression</agscnd:param>
  118. <agscnd:param name="errorDiv">errorDataItem</agscnd:param>
  119. <agscnd:param name="infoDiv">infoDataItem</agscnd:param>
  120. </agscnd:dataItemUI>
  121. </lyt:layout>
  122. <!-- footer -->
  123. <dp:footer>
  124. <df:button df:id="IDS_OK" df:style="href" df:href="#" onclick="return doOK();"/>
  125. <df:button df:id="IDS_CANCEL" df:style="href" df:href="#" onclick="parent.getConfigFrame().hideDialogFrame();"/>
  126. <df:button df:id="IDS_APPLY" df:style="href" df:href="#" onclick="return doApply();"/>
  127. </dp:footer>
  128. </utml:form>
  129. <dp:script>
  130. <pf:help context="ug_cr_as_ag_wrk_crt_calc" eventStudio="true"/>
  131. <script type="text/javascript" src="../ags/help.js"/>
  132. <script type="text/javascript" src="../ags/dragDropHandler.js">//</script>
  133. <script type="text/javascript" src="../ags/agentTreeObjects.js">//</script>
  134. <script type="text/javascript">
  135. var cf = parent.getConfigFrame();
  136. var adding = <xsl:choose><xsl:when test="/root/env/param[@name='method'] = 'add'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>;
  137. var dataItemTree = new Array();
  138. var currentDataItemNode;
  139. var dirty=false;
  140. function hasChanged() {
  141. return dirty;
  142. }
  143. function trim(line)
  144. {
  145. var re = /^\s*|\s*$/g;
  146. return line.replace(re,"");
  147. }
  148. function getName()
  149. {
  150. return trim(document.pform.dataItem_name.value);
  151. }
  152. function getExpression()
  153. {
  154. return trim(document.pform.dataItem_expression.value);
  155. }
  156. function processDataItem()
  157. {
  158. // get the name and the expression - and trim whitespace from the front and the end
  159. var name = getName();
  160. //hold the calculation items by their calc name as the id
  161. var old_name = currentDataItemNode ? currentDataItemNode.getValue().name : "?";
  162. cf.getAgentItemsListener().updateId(name, old_name, window.name);
  163. var expression = getExpression();
  164. var aggregate = "automatic";
  165. // create the expression
  166. var obj = cf.createDataItemObj(name, expression,aggregate);
  167. //This has been edited so we should not allow auto delete.
  168. obj.isDeletable = false;
  169. if (currentDataItemNode &amp;&amp; currentDataItemNode != 'undefined') {
  170. aggregate = currentDataItemNode.getValue().regularAggregate;
  171. currentDataItemNode = cf.updateDataItem(obj,currentDataItemNode);
  172. } else {
  173. currentDataItemNode = cf.updateDataItem(obj);
  174. }
  175. return true;
  176. }
  177. function doApply()
  178. {
  179. var result = false;
  180. if (validate()) {
  181. // just have to create or amend the data item
  182. result = processDataItem();
  183. dirty=false;
  184. }
  185. return result;
  186. }
  187. // function which is called when we ok
  188. function doOK(evt)
  189. {
  190. var result = false;
  191. var name = getName();
  192. if (validate()) {
  193. // create or amend the data item
  194. result = processDataItem();
  195. }
  196. if (result) {
  197. cf.hideDialogFrame();
  198. }
  199. return result;
  200. }
  201. // function to make sure that we add a subject
  202. function validate()
  203. {
  204. var name = getName();
  205. var expression = getExpression();
  206. // check that we have a data item name
  207. if (name.length == 0) {
  208. // throw up an alert box
  209. alert(&quot;<xts:string id="DIALOG_DATAITEM_NO_NAME" encode="javascript"/>&quot;);
  210. // we can't exit here
  211. return false;
  212. }
  213. // check that we have a data item expression
  214. if (expression.length == 0) {
  215. // throw up an alert box
  216. alert(&quot;<xts:string id="DIALOG_DATAITEM_NO_EXPRESSION" encode="javascript"/>&quot;);
  217. // we can't exit here
  218. return false;
  219. }
  220. // have to make sure that we don't have special characters in the data item name either.
  221. // check to see if we have special characters.
  222. if (name.indexOf("[") >= 0 || name.indexOf("]") >=0 || name.indexOf(".") >= 0) {
  223. // throw up an alert box
  224. alert(&quot;<xts:string id="DIALOG_DATAITEM_INVALID_CHARS" encode="javascript"/>&quot;);
  225. // we can't exit here
  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.getNodeFromTreeWithValue(name,"name", dataItemTree)) {
  233. alert(&quot;<xts:string id="DIALOG_DATAITEM_DUPLICATE_NAME" encode="javascript"/>&quot;);
  234. return false;
  235. }
  236. return true;
  237. }
  238. function validateSpec() {
  239. //since validating doesn't alter the state of the dialog, temporarily set the dirty flag to false, this is because the
  240. //validate calls checkCAF which calls the dialog commit function
  241. savedState = dirty;
  242. dirty=false;
  243. if (validate()) {
  244. var name = getName();
  245. var expression = getExpression();
  246. var aggregate = "automatic";
  247. // create the expression
  248. var obj = cf.createDataItemObj(name, expression, aggregate);
  249. var items = cf.getTreeValues(cf.getDataItemsTree(), new excludeName(name));
  250. var location_id = "dataItem["+ (items.length + 1) +"]/expression";
  251. if(items.length == 0){
  252. location_id = "dataItem/expression";
  253. }
  254. //we can check the expression here, to see if there are any topics
  255. //if not, then push a warning validation message.
  256. if(!checkExpressionForTopics(expression)){
  257. var dm = new cf.DefectMessage(cf.noTopicsValidationError_string, "warn", location_id);
  258. var defects = new cf.DefectMessages(new Array(dm));
  259. cf.cfgSet(cf.VALIDATE_ERRORS_KEY, defects);
  260. }
  261. items.push(obj);
  262. //save the items
  263. cf.cfgSet("inlineSpec_items",items);
  264. var cmd = cf.createValidateCommandStackObject(location_id, 'errorDataItem');
  265. //must validate all the agent items in case we have referenced items within the calc expression
  266. cf.getCommandStackManager().initiateCommandStack("checkCAF()","getReportSpec()", "doWait('validate')", cmd);
  267. window.setTimeout('dirty=savedState', 3000) ;
  268. }
  269. }
  270. //this very simply looks for more than zero matching pairs of []
  271. function checkExpressionForTopics(expression){
  272. areTopics = expression &amp;&amp; expression != '';
  273. var OPEN = "[";
  274. var CLOSE = "]";
  275. if(areTopics){
  276. var lookingFor = OPEN;
  277. var found = false;
  278. for(var i = 0; i &lt; expression.length; i++){
  279. if(expression.charAt(i) == lookingFor){
  280. lookingFor = lookingFor == OPEN ? CLOSE : OPEN;
  281. found = true;
  282. }
  283. }
  284. //found something and all matched
  285. areTopics = found &amp;&amp; lookingFor == OPEN;
  286. }
  287. return areTopics;
  288. }
  289. function onInputChanged() {
  290. dirty=true;
  291. return true;
  292. }
  293. // function to initialize the script for the contents of the screen
  294. function init()
  295. {
  296. cf.addEvent(document.getElementById('dataItem_name'),"change",onInputChanged);
  297. cf.addEvent(document.getElementById('dataItem_expression'),"change",onInputChanged);
  298. cf.updateInformationTip();
  299. var nodeRef = &quot;<xsl:value-of select="xtsext:javascriptencode(string(/root/env/param[@name = 'nodeRef']))"/>&quot;
  300. if (nodeRef &amp;&amp; nodeRef != '') {
  301. //This holds the calc info
  302. currentDataItemNode = cf.getTreeNode(cf.getDataItemsTree().getName(), nodeRef);
  303. }
  304. var exisiting_name = currentDataItemNode ? currentDataItemNode.getValue().name : "?";
  305. // cool have a built in on load handler
  306. droppy.registerDropZone("dataItem_expression",""," ", false, exisiting_name, "", true);
  307. //If we are editing then we perform this bit of Code.
  308. if (!adding) {
  309. document.pform.dataItem_name.value = currentDataItemNode.getValue().name;
  310. //This should never be set directly. We should always use the method setDopZoneValue.
  311. droppy.setDropZoneValue(currentDataItemNode.getValue().ref,'dataItem_expression');
  312. cf.changeMenu(cf.TAB_DATAITEMS);
  313. //only when editing
  314. droppy.registerPostEventHandler("dataItem_expression", "onblur",updateDlgParams);
  315. }
  316. var treeNodes = cf.getTreeChildNodes(cf.getDataItemsTree());
  317. var nodeId = currentDataItemNode &amp;&amp; currentDataItemNode != 'undefined'?currentDataItemNode.getId():"";
  318. for (var i=0;i&lt;treeNodes.length;i++) {
  319. //Copy all the ones we are not editintg.
  320. if (nodeId != treeNodes[i].getId()) {
  321. dataItemTree.push(treeNodes[i]);
  322. }
  323. }
  324. //cf.showDialogFrame("62%");
  325. //Show it now
  326. cf.showDialogFrame(540);
  327. //This function is used to fix scroll bar issue of dialogIFrame in Standards mode.
  328. resetMargin();
  329. // set the focus to the name of the data item
  330. document.pform.dataItem_name.focus();
  331. }
  332. function resetMargin(){
  333. var elementArray = document.getElementsByTagName("body");
  334. var iframeBody = elementArray[0];
  335. iframeBody.style.margin = "0px";
  336. }
  337. //take what was passed and update it to what is on the screen, ready for a navigate away and back
  338. //Only when editing.
  339. function updateDlgParams(){
  340. //I do not think that we will ever navigate away and back.
  341. //cf.dlgSetParm("editedNode", currentDataItemNode);
  342. }
  343. function excludeName(name){
  344. this.name = name;
  345. this.match = match;
  346. function match(tree_item){
  347. if(tree_item.name &amp;&amp; tree_item.name != name){
  348. return true;
  349. }
  350. return false;
  351. }
  352. }
  353. </script>
  354. </dp:script>
  355. </dp:page>
  356. </xsl:template>
  357. <!-- pull in other templates that are needed -->
  358. <agscnd:buildInfoTab/>
  359. <agscnd:buildInfoSection/>
  360. <ags:buildButtons/>
  361. <agscnd:expressionBaseUI/>
  362. <agscnd:script/>
  363. </xsl:stylesheet>
  364. </xts:block>
  365. <!--
  366. ===============================================================================================
  367. faultHandler
  368. ===============================================================================================
  369. -->
  370. <xts:block id="faultHandler" type="fault" processor="XSLT">
  371. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  372. <xsl:output method="xml"/>
  373. <xsl:template match="/root/fault">
  374. <xsl:choose>
  375. <xsl:when test="./*[local-name() = 'exception']/*[local-name() = 'exceptionDetail']/*[local-name() = 'exception']/errorCode = 'cmArchiveEncrypted' or ./*[local-name() = 'exception']/*[local-name() = 'exceptionDetail']/*[local-name() = 'exception']/errorCode = 'cmImportCryptoFailed'">
  376. <copyFault>
  377. <xsl:copy-of select="."/>
  378. </copyFault>
  379. </xsl:when>
  380. <xsl:otherwise>
  381. <xsl:copy-of select="."/>
  382. </xsl:otherwise>
  383. </xsl:choose>
  384. </xsl:template>
  385. <xsl:template match="text()"/>
  386. </xsl:stylesheet>
  387. </xts:block>
  388. <!-- =========================================================================================
  389. D E B U G B L O C K
  390. =========================================================================================
  391. -->
  392. <xts:block id="debug" type="exec" mode="output" processor="XSLT" condition=".[/root/session/param[@name = 'debug'] = '1']" mandatory="false" mimeType="text/html" dependency="page">
  393. <!-- Get the debug logicsheet. -->
  394. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  395. <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">
  396. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  397. <xsl:template match="/">
  398. <dbg:dumpxml select="/root"/>
  399. </xsl:template>
  400. </xsl:stylesheet>
  401. </xts:block>
  402. </xts:morphlet>