CTemplateDialog.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /****************************************************************
  2. ** Licensed Materials - Property of IBM
  3. **
  4. ** BI and PM: qs
  5. **
  6. ** (C) Copyright IBM Corp. 2001, 2015
  7. **
  8. ** US Government Users Restricted Rights - Use, duplication or
  9. ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *****************************************************************/
  11. // Copyright (C) 2008 Cognos ULC, an IBM Company. All Rights Reserved.
  12. // Cognos and the Cognos logo are trademarks of Cognos ULC (formerly Cognos Incorporated) in the United States and/or other countries. IBM and the IBM logo are trademarks of International Business Machines Corporation in the United States, or other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
  13. function CTemplateDialog(sXtsName, sReportTemplateSearchPath)
  14. {
  15. this.m_sXtsName = sXtsName;
  16. this.m_sReportTemplateSearchPath = sReportTemplateSearchPath;
  17. this.m_oCF = getConfigFrame();
  18. this.init();
  19. };
  20. CTemplateDialog.prototype.execute = function()
  21. {
  22. var cmd = "OL:";
  23. if (this.isTemplateSelected())
  24. {
  25. cmd += this.m_oCF.escapeParam(document.f.templateSearchPath.value);
  26. }
  27. this.m_oCF.addColumnsForReselection();
  28. if (document.f.resetStyles.checked)
  29. {
  30. cmd += ";ZR";
  31. }
  32. this.m_oCF.sendCmd(cmd, "", true);
  33. this.m_oCF.hideDialogFrame();
  34. };
  35. CTemplateDialog.prototype.init = function()
  36. {
  37. if (typeof document.getElementById("loadingIcon") === "object"
  38. && document.getElementById("loadingIcon") !== null
  39. && typeof document.getElementById("loadingContainer") === "object" && document.getElementById("loadingContainer") !== null)
  40. {
  41. document.getElementById("loadingIcon").src = this.m_oCF.TREE_LOADING;
  42. document.getElementById("loadingContainer").appendChild(document.createTextNode(this.m_oCF.PMT_TRE_TREE_LOADING));
  43. if (typeof attachMouseEvents === "function")
  44. {
  45. attachMouseEvents();
  46. }
  47. if (this.m_oCF)
  48. {
  49. if(typeof this.m_oCF.showDialogFrame == "function")
  50. {
  51. this.m_oCF.showDialogFrame(245);
  52. }
  53. if (this.m_sReportTemplateSearchPath)
  54. {
  55. this.m_oCF.dlgGlobalSetParm('sReportTemplateSearchPath', this.m_sReportTemplateSearchPath);
  56. }
  57. else
  58. {
  59. this.m_sReportTemplateSearchPath = this.m_oCF.dlgGlobalGetParm('sReportTemplateSearchPath');
  60. }
  61. if (this.m_sReportTemplateSearchPath !== "" && this.m_sReportTemplateSearchPath !== null)
  62. {
  63. this.setTemplateSelected(true);
  64. }
  65. }
  66. this.sendRequestForPath();
  67. }
  68. };
  69. CTemplateDialog.prototype.sendRequestForPath = function()
  70. {
  71. var url = "m=/" + this.m_oCF.qs_dir + "/reportTemplateRequest.xts&b_action=xts.run";
  72. var sPath = this.m_sReportTemplateSearchPath;
  73. if (!sPath)
  74. {
  75. sPath = this.m_oCF.dlgGlobalGetParm('sReportTemplateSearchPath');
  76. }
  77. if (sPath !== "" && sPath !== null)
  78. {
  79. url += "&xxPath=" + encodeURIComponent(sPath);
  80. }
  81. if (this.m_oCF.cafContextId !== "")
  82. {
  83. url += "&ui.cafcontextid=" + this.m_oCF.cafContextId;
  84. }
  85. this.m_oCF.sendDispatcherRequest(url, this.processResponse);
  86. };
  87. CTemplateDialog.prototype.processResponse = function(response)
  88. {
  89. var htmlMatch = response.match(/<HTML>/i);
  90. if (htmlMatch && (htmlMatch.length >= 1))
  91. {
  92. document.write(response);
  93. document.close();
  94. return;
  95. }
  96. eval(response);
  97. var sSearchPath = responseArray[0];
  98. var sFolderName = responseArray[1];
  99. document.f.templateSearchPath.value = sSearchPath;
  100. var oContents = document.getElementById("pathContents");
  101. if (oContents.lastChild)
  102. {
  103. oContents.removeChild(oContents.lastChild);
  104. }
  105. oContents.appendChild(document.createTextNode(sFolderName));
  106. document.getElementById("pathContainer").style.display = "inline";
  107. var loadingContainer = document.getElementById("loadingContainer");
  108. loadingContainer.parentNode.removeChild(loadingContainer);
  109. };
  110. CTemplateDialog.prototype.selectTmpl = function()
  111. {
  112. this.m_oCF.cfgSet("LAST_DIALOG", "reportTemplate");
  113. this.m_oCF.dlgReset();
  114. this.m_oCF.dlgSetParm("m", "portal/select/select.xts");
  115. this.m_oCF.dlgSetParm("so.select", "reportTemplate.query");
  116. this.m_oCF.dlgSetParm("so.defaultObject", encodeURIComponent(document.f.templateSearchPath.value));
  117. if (document.f.templateSearchPath.value)
  118. {
  119. this.m_oCF.dlgSetParm("so.defaultLocation", encodeURIComponent(document.f.templateSearchPath.value.replace(/\WreportTemplate.*/g, "")));
  120. }
  121. else
  122. {
  123. this.m_oCF.dlgSetParm("so.defaultLocation", this.m_oCF.cfgGet("ReportFolder"));
  124. }
  125. this.m_oCF.dlgSetParm("so.return.m", "/" + this.m_oCF.qs_dir + "/" + this.m_sXtsName);
  126. this.m_oCF.dlgSubmit();
  127. this.m_oCF.showDialogFrame(290);
  128. };
  129. CTemplateDialog.prototype.isTemplateSelected = function()
  130. {
  131. var bTemplateSelected = false
  132. if (typeof document.f === "object" && typeof document.f.templateMode === "object")
  133. {
  134. if (typeof document.f.templateMode[0] === "object")
  135. {
  136. bTemplateSelected = document.f.templateMode[1].checked;
  137. }
  138. else
  139. {
  140. bTemplateSelected = document.f.templateMode
  141. }
  142. }
  143. return bTemplateSelected;
  144. };
  145. CTemplateDialog.prototype.setTemplateSelected = function(bSelected)
  146. {
  147. if (typeof document.f === "object" && typeof document.f.templateMode === "object")
  148. {
  149. if (typeof document.f.templateMode[0] === "object")
  150. {
  151. document.f.templateMode[1].checked = bSelected;
  152. }
  153. else
  154. {
  155. document.f.templateMode.checked = bSelected;
  156. }
  157. }
  158. };