tm1ContentWebSheetViewerWidget.js 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *|
  5. *| BI and PM: BUX
  6. *|
  7. *| (C) Copyright IBM Corp. 2009
  8. *|
  9. *| US Government Users Restricted Rights - Use, duplication or
  10. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11. *|
  12. *+------------------------------------------------------------------------+
  13. */
  14. // create script variables used to store TM1 callbacks
  15. var COGNOS_TM1_webShtWgtToolbarFuncs;
  16. var COGNOS_TM1_webShtWgtFltrFuncs;
  17. dojo.require("dojo.string");
  18. dojo.require("dojo._base.array");
  19. dojo.require("bux.i18n");
  20. dojo.require("bux.Helper");
  21. dojo.require("bux.data.UserPreferencesStore");
  22. dojo.provide("tm1ContentWebSheetViewerWidget");
  23. dojo.declare("tm1ContentWebSheetViewerWidget", null, {
  24. iframeCtrl: null,
  25. _paramgizmo_id: null,
  26. returnURL: null,
  27. initialHeight: 286,
  28. xmlhttp: null,
  29. commonDomain: null,
  30. bTurnOffCallbacks: false,
  31. tm1Toolbar: null,
  32. _currentRole: null,
  33. // ====== DefaultSize Support - Start ========
  34. _defaultWidth:700,
  35. _defaultHeight:400,
  36. _firstRender:true,
  37. // ====== DefaultSize Support - End ========
  38. _productLocale:null,
  39. _tm1messages:null,
  40. onLoad: function(evt) {
  41. // ====== Multilingual Support - Start ========
  42. // Remember where we were loaded from: this is our path for future AJAX calls and .js loads
  43. dojo.registerModulePath("tm1ContentWebSheetViewerWidget",this.iContext.io.rewriteURI("js"));
  44. this.setLanguage().then(dojo.hitch(this, "continueOnLoad"));
  45. // ====== Multilingual Support - End ========
  46. },
  47. continueOnLoad: function() {
  48. this.getRole();
  49. this.createBasicWidgetToolbar();
  50. this.getWidgetAttributes();
  51. if (this.areTM1ParametersValid ()) {
  52. this.refreshView();
  53. }
  54. // ====== DefaultSize Support - Start ========
  55. //Delay the creation of some dynamic content to allow the widget to render first,
  56. //otherwise the dojo controlscannot properly render within its allowed real-estate.
  57. setTimeout(dojo.hitch(this,this.postLoadInit),1);
  58. // ====== DefaultSize Support - End ========
  59. },
  60. // ====== Multilingual Support - Start ========
  61. updateView: function() {
  62. this.setLanguage();
  63. },
  64. setLanguage: function() {
  65. // Setup Localization tables - Use the BUX preferences for locale. Use Product locale for loading strings
  66. var curProductLocale=bux.Helper.getUserPreference("productLocale");
  67. if (this._productLocale != curProductLocale)
  68. {
  69. this._productLocale = curProductLocale;
  70. var deferred = new dojo.Deferred();
  71. var self = this;
  72. dojo.requireLocalization("tm1ContentWebSheetViewerWidget","tm1ContentWebSheetViewerWidget_msg", curProductLocale);
  73. dojo.ready(function() {
  74. self._tm1messages = dojo.i18n.getLocalization("tm1ContentWebSheetViewerWidget", "tm1ContentWebSheetViewerWidget_msg", curProductLocale);
  75. deferred.resolve();
  76. });
  77. return deferred;
  78. }
  79. },
  80. // ====== Multilingual Support - End ========
  81. // ====== DefaultSize Support - Start ========
  82. postLoadInit: function()
  83. {
  84. // In this function, create the dynamic contents of the iWidget that are dojo objects based on dynamic HTML
  85. // call auto resize if it's the first time and is this widget was never saved.
  86. if (this._firstRender == true) {
  87. this._firstRender = false;
  88. var setDefaultSize = this.iContext.getiWidgetAttributes().getItemValue("setDefaultSize");
  89. if (setDefaultSize == "1") {
  90. // Next time the container dashboard loads, the default size must be ignored - as desired
  91. this.iContext.getiWidgetAttributes().setItemValue("setDefaultSize", "0");
  92. this.setPreferredSize();
  93. }
  94. }
  95. },
  96. getChrome: function() {
  97. var chromeObjectId = bux.Helper.widgetIdToChromeId(this.iContext.widgetId);
  98. var chromeObject = bux.Helper.getChromeById(chromeObjectId);
  99. return chromeObject;
  100. },
  101. setPreferredSize: function() {
  102. var chromeObject = this.getChrome();
  103. var newSize = {h: this._defaultHeight, w : this._defaultWidth};
  104. chromeObject.setPreferredSize(newSize);
  105. chromeObject.doChromeAutoResize();
  106. },
  107. // ====== DefaultSize Support - End ========
  108. getRole: function () {
  109. if( this.iContext ) {
  110. var userProfileItemSet = this.iContext.getItemSet("buxuserprofile", false);
  111. if( userProfileItemSet ){
  112. var role = userProfileItemSet.getItemValue("currentUserRole");
  113. if( role && bux.UserRole.isValidRole(role) ) {
  114. this._currentRole = role;
  115. }
  116. }
  117. }
  118. },
  119. createBasicWidgetToolbar: function () {
  120. if (this.bTurnOffCallbacks) {
  121. var toolbarItems =
  122. [
  123. {
  124. _root:
  125. [
  126. {separator: true },
  127. {name: "Restart", action: "IDM_RESTART", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESTART, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada"}
  128. ]
  129. }
  130. ];
  131. this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, toolbarItems);
  132. } else {
  133. var toolbarItems =
  134. [
  135. {
  136. _root:
  137. [
  138. {separator: true },
  139. {name: "Refresh", action: "IDM_RECALCULATE", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_REFRESH, showLabel: false, "iconClass": "bux-refresh-image"},
  140. {name: "Restart", action: "IDM_RESTART", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESTART, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada"}
  141. ]
  142. }
  143. ];
  144. this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, toolbarItems);
  145. }
  146. },
  147. createWidgetToolbar: function (inToolbar) {
  148. var temptoolbarItems;
  149. this.tm1Toolbar = inToolbar;
  150. var toolbarItems =
  151. [
  152. {
  153. _root:
  154. [
  155. {separator: true },
  156. {name: "Refresh", action: "IDM_RECALCULATE", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_REFRESH, showLabel: false, "iconClass": "bux-refresh-image"},
  157. {name: "Restart", action: "IDM_RESTART", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESTART, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada"}
  158. ]
  159. }
  160. ];
  161. toolbarItems = this.addToolbutton(toolbarItems, "IDM_COMMIT");
  162. toolbarItems = this.addToolbutton(toolbarItems, "IDM_SAVEDATACHANGES");
  163. toolbarItems = this.addToolbutton(toolbarItems, "IDM_REVIEWDATACHANGES");
  164. toolbarItems = this.addSeparator(toolbarItems);
  165. toolbarItems = this.addToolbuttonWithSubmenu (toolbarItems, "IDM_EXPORT");
  166. toolbarItems = this.addSeparator(toolbarItems);
  167. toolbarItems = this.addToolbutton(toolbarItems, "IDM_RECALCULATE");
  168. toolbarItems = this.addToolbutton(toolbarItems, "IDM_REBUILDACTIVEFORMS");
  169. toolbarItems = this.addToolbutton(toolbarItems, "IDM_TOGGLE_AUTOMATICRECALCULATE");
  170. toolbarItems = this.addToolbutton(toolbarItems, "IDM_AUTO_FIT_COL");
  171. toolbarItems = this.addToolbutton(toolbarItems, "IDM_ZOOM_IN");
  172. toolbarItems = this.addToolbutton(toolbarItems, "IDM_ZOOM_OUT");
  173. toolbarItems = this.addToolbutton(toolbarItems, "IDM_ZOOM_NORMAL");
  174. toolbarItems = this.addSeparator(toolbarItems);
  175. toolbarItems = this.addToolbutton(toolbarItems, "IDM_RESET_DATA");
  176. toolbarItems = this.addToolbutton(toolbarItems, "IDM_SANDBOX_UNDO");
  177. toolbarItems = this.addToolbutton(toolbarItems, "IDM_SANDBOX_REDO");
  178. toolbarItems = this.addSeparator(toolbarItems);
  179. toolbarItems = this.addToolbuttonWithSubmenu (toolbarItems, "IDM_SANDBOX");
  180. toolbarItems = this.addToolbuttonWithSubmenu (toolbarItems, "IDM_SANDBOXITEMS");
  181. this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, toolbarItems);
  182. },
  183. addSeparator: function (toolbarItems) {
  184. var separator = { "separator": true };
  185. return toolbarItems.concat(separator);
  186. },
  187. addToolbutton: function (toolbarItems, toolbarAction) {
  188. if (this.isToolbuttonVisible(toolbarAction)) {
  189. return toolbarItems.concat(this.createSimpleToolbutton(toolbarAction));
  190. } else {
  191. return toolbarItems;
  192. }
  193. },
  194. addToolbuttonWithSubmenu: function (toolbarItems, toolbarAction) {
  195. if (this.isToolbuttonVisible(toolbarAction)) {
  196. return toolbarItems.concat(this.createToolbuttonWithSubmenu(toolbarAction));
  197. } else {
  198. return toolbarItems;
  199. }
  200. },
  201. createSimpleToolbutton: function (toolbarAction) {
  202. var toolbutton = {
  203. "name" : toolbarAction,
  204. "action" : toolbarAction,
  205. "label": this.getToolbuttonTooltip(toolbarAction),
  206. "iconClass": this.getToolbuttonImage(toolbarAction),
  207. "disabled": this.isToolbuttonDisabled(toolbarAction)
  208. }
  209. return toolbutton;
  210. },
  211. appendSandboxMenuChoice: function (menuItems, sandboxIndex, sandboxName, activeSandbox) {
  212. var toolbarAction = "SANDBOXCHOICE" + sandboxIndex;
  213. var toolbutton = {
  214. "name" : toolbarAction,
  215. "action" : toolbarAction,
  216. "label": sandboxName,
  217. "iconClass": (activeSandbox == sandboxName ? "tm1-menu-radioselection" : "tm1-menu-empty")
  218. }
  219. return menuItems.concat(toolbutton);
  220. },
  221. createToolbuttonWithSubmenu: function (toolbarAction) {
  222. var menuitems = null;
  223. if (toolbarAction == "IDM_EXPORT") {
  224. var menuItems = [];
  225. menuItems = this.addToolbutton(menuItems, "IDM_SLICE_TO_EXCEL");
  226. menuItems = this.addToolbutton(menuItems, "IDM_SNAPSHOT_TO_EXCEL");
  227. menuItems = this.addToolbutton(menuItems, "IDM_EXPORT_TO_PDF");
  228. var toolbutton = {
  229. "name" : toolbarAction,
  230. "action" : toolbarAction,
  231. "label": this.getToolbuttonTooltip(toolbarAction),
  232. "iconClass": this.getToolbuttonImage(toolbarAction),
  233. "disabled": this.isToolbuttonDisabled(toolbarAction),
  234. "items" : menuItems
  235. }
  236. return toolbutton;
  237. } else if (toolbarAction == "IDM_SANDBOX") {
  238. var menuItems = [];
  239. menuItems = this.addToolbutton(menuItems, "IDM_CREATE_SANDBOX");
  240. menuItems = this.addToolbutton(menuItems, "IDM_DELETE_SANDBOX");
  241. var toolbutton = {
  242. "name" : toolbarAction,
  243. "action" : toolbarAction,
  244. "label": this.getToolbuttonTooltip(toolbarAction),
  245. "iconClass": this.getToolbuttonImage(toolbarAction),
  246. "disabled": this.isToolbuttonDisabled(toolbarAction),
  247. "items" : menuItems
  248. }
  249. return toolbutton;
  250. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  251. var menuItems = [];
  252. menuItems = this.appendSandboxMenuChoice(menuItems, 0, "[Base]", this.tm1Toolbar.ToolbarInfo.Sandbox.ActiveSandbox);
  253. if (this.tm1Toolbar.ToolbarInfo.Sandbox.SandboxList.length > 0) {
  254. for (i=0; i<this.tm1Toolbar.ToolbarInfo.Sandbox.SandboxList.length; i++) {
  255. menuItems = this.appendSandboxMenuChoice(menuItems, i+1, this.tm1Toolbar.ToolbarInfo.Sandbox.SandboxList[i], this.tm1Toolbar.ToolbarInfo.Sandbox.ActiveSandbox);
  256. }
  257. }
  258. var toolbutton = {
  259. "name" : toolbarAction,
  260. "action" : toolbarAction,
  261. "label": this.getToolbuttonTooltip(toolbarAction),
  262. "iconClass": this.getToolbuttonImage(toolbarAction),
  263. "disabled": this.isToolbuttonDisabled(toolbarAction),
  264. "items" : menuItems
  265. }
  266. return toolbutton;
  267. }
  268. var toolbutton = {
  269. "name" : toolbarAction,
  270. "action" : toolbarAction,
  271. "label": this.getToolbuttonTooltip(toolbarAction),
  272. "iconClass": this.getToolbuttonImage(toolbarAction),
  273. "disabled": this.isToolbuttonDisabled(toolbarAction),
  274. "items" : menuitems
  275. }
  276. return toolbutton;
  277. },
  278. getSandboxName: function(sandboxId) {
  279. if (sandboxId == 1) {
  280. return "[Base]";
  281. } else {
  282. return this.tm1Toolbar.ToolbarInfo.Sandbox.SandboxList[sandboxId - 1];
  283. }
  284. },
  285. getSandboxCheck: function (sandboxId) {
  286. if (this.getSandboxName(sandboxId) == this.tm1Toolbar.ToolbarInfo.Sandbox.ActiveSandbox) {
  287. return "tm1-toolbar-apply";
  288. } else {
  289. return "tm1-toolbar-empty";
  290. }
  291. },
  292. getToolbuttonIsDisabled: function(toolbarAction) {
  293. if (toolbarAction == "IDM_CHART-SELECT") {
  294. if (this.tm1Toolbar.ToolbarInfo.DisplayMode == 0) {
  295. return true;
  296. } else {
  297. return false;
  298. }
  299. } else if (toolbarAction == "IDM_SANDBOX_UNDO") {
  300. if (this.tm1Toolbar.ToolbarInfo.UndoButton.IsEnabled) {
  301. return true;
  302. } else {
  303. return false;
  304. }
  305. } else if (toolbarAction == "IDM_SANDBOX_REDO") {
  306. if (this.tm1Toolbar.ToolbarInfo.RedoButton.IsEnabled) {
  307. return true;
  308. } else {
  309. return false;
  310. }
  311. }
  312. return false;
  313. },
  314. isToolbuttonVisible: function(toolbarAction) {
  315. if (toolbarAction == "IDM_SUPPRESS_ZEROS") {
  316. return this.tm1Toolbar.ToolbarInfo.SuppressZerosButton != null && this.tm1Toolbar.ToolbarInfo.SuppressZerosButton.IsAdded;
  317. } else if (toolbarAction == "IDM_COMMIT") {
  318. return this.tm1Toolbar.ToolbarInfo.CommitSandboxButton != null && this.tm1Toolbar.ToolbarInfo.CommitSandboxButton.IsAdded;
  319. } else if (toolbarAction == "IDM_SAVEVIEW") {
  320. return this.tm1Toolbar.ToolbarInfo.SaveViewButton != null && this.tm1Toolbar.ToolbarInfo.SaveViewButton.IsAdded;
  321. } else if (toolbarAction == "IDM_SAVEAS") {
  322. return this.tm1Toolbar.ToolbarInfo.SaveAsViewButton != null && this.tm1Toolbar.ToolbarInfo.SaveAsViewButton.IsAdded;
  323. } else if (toolbarAction == "IDM_EXPORT") {
  324. return this.tm1Toolbar.ToolbarInfo.ExportButton != null && this.tm1Toolbar.ToolbarInfo.ExportButton.IsAdded;
  325. } else if (toolbarAction == "IDM_SLICE_TO_EXCEL") {
  326. return this.tm1Toolbar.ToolbarInfo.ExportButton != null && this.tm1Toolbar.ToolbarInfo.ExportButton.MenuItemSlice != null && this.tm1Toolbar.ToolbarInfo.ExportButton.MenuItemSlice.IsAdded;
  327. } else if (toolbarAction == "IDM_SNAPSHOT_TO_EXCEL") {
  328. return this.tm1Toolbar.ToolbarInfo.ExportButton != null && this.tm1Toolbar.ToolbarInfo.ExportButton.MenuItemSnapshot != null && this.tm1Toolbar.ToolbarInfo.ExportButton.MenuItemSnapshot.IsAdded;
  329. } else if (toolbarAction == "IDM_EXPORT_TO_PDF") {
  330. return this.tm1Toolbar.ToolbarInfo.ExportButton != null && this.tm1Toolbar.ToolbarInfo.ExportButton.MenuItemExportPDF != null && this.tm1Toolbar.ToolbarInfo.ExportButton.MenuItemExportPDF.IsAdded;
  331. } else if (toolbarAction == "IDM_SAVEDATACHANGES") {
  332. return this.tm1Toolbar.ToolbarInfo.SaveDataChangesButton != null && this.tm1Toolbar.ToolbarInfo.SaveDataChangesButton.IsAdded;
  333. } else if (toolbarAction == "IDM_REVIEWDATACHANGES") {
  334. return this.tm1Toolbar.ToolbarInfo.ReviewDataChangesButton != null && this.tm1Toolbar.ToolbarInfo.ReviewDataChangesButton.IsAdded;
  335. } else if (toolbarAction == "IDM_RECALCULATE") {
  336. return this.tm1Toolbar.ToolbarInfo.RecalcButton != null && this.tm1Toolbar.ToolbarInfo.RecalcButton.IsAdded;
  337. } else if (toolbarAction == "IDM_TOGGLE_AUTOMATICRECALCULATE") {
  338. return this.tm1Toolbar.ToolbarInfo.AutoRecalcButton != null && this.tm1Toolbar.ToolbarInfo.AutoRecalcButton.IsAdded;
  339. } else if (toolbarAction == "IDM_REBUILDACTIVEFORMS") {
  340. return this.tm1Toolbar.ToolbarInfo.RebuildActiveFormButton != null && this.tm1Toolbar.ToolbarInfo.RebuildActiveFormButton.IsAdded;
  341. } else if (toolbarAction == "IDM_AUTO_FIT_COL") {
  342. return this.tm1Toolbar.ToolbarInfo.AutoFitButton != null && this.tm1Toolbar.ToolbarInfo.AutoFitButton.IsAdded;
  343. } else if (toolbarAction == "IDM_ZOOM_IN") {
  344. return this.tm1Toolbar.ToolbarInfo.ZoomInButton != null && this.tm1Toolbar.ToolbarInfo.ZoomInButton.IsAdded;
  345. } else if (toolbarAction == "IDM_ZOOM_OUT") {
  346. return this.tm1Toolbar.ToolbarInfo.ZoomOutButton != null && this.tm1Toolbar.ToolbarInfo.ZoomOutButton.IsAdded;
  347. } else if (toolbarAction == "IDM_ZOOM_NORMAL") {
  348. return this.tm1Toolbar.ToolbarInfo.NormalViewButton != null && this.tm1Toolbar.ToolbarInfo.NormalViewButton.IsAdded;
  349. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS_COLUMNS") {
  350. if (this.tm1Toolbar.ToolbarInfo.SuppressZerosButton.SuppressZeros) {
  351. return "tm1-toolbar-apply";
  352. }
  353. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS") {
  354. if (this.tm1Toolbar.ToolbarInfo.SuppressZerosButton.SuppressZerosOnRows) {
  355. return "tm1-toolbar-apply";
  356. }
  357. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_COLUMNS") {
  358. if (this.tm1Toolbar.ToolbarInfo.SuppressZerosButton.SuppressZerosOnColumns) {
  359. return "tm1-toolbar-apply";
  360. }
  361. } else if (toolbarAction == "IDM_RESET_DATA") {
  362. return this.tm1Toolbar.ToolbarInfo.ResetSandboxButton != null && this.tm1Toolbar.ToolbarInfo.ResetSandboxButton.IsAdded;
  363. } else if (toolbarAction == "IDM_SANDBOX_UNDO") {
  364. return this.tm1Toolbar.ToolbarInfo.UndoButton != null && this.tm1Toolbar.ToolbarInfo.UndoButton.IsAdded;
  365. } else if (toolbarAction == "IDM_SANDBOX_REDO") {
  366. return this.tm1Toolbar.ToolbarInfo.RedoButton != null && this.tm1Toolbar.ToolbarInfo.RedoButton.IsAdded;
  367. } else if (toolbarAction == "IDM_SANDBOX") {
  368. return this.tm1Toolbar.ToolbarInfo.SandboxButton != null && this.tm1Toolbar.ToolbarInfo.SandboxButton.IsAdded;
  369. } else if (toolbarAction == "IDM_CREATE_SANDBOX") {
  370. return this.tm1Toolbar.ToolbarInfo.SandboxButton != null && this.tm1Toolbar.ToolbarInfo.SandboxButton.MenuItemCreateSandbox != null && this.tm1Toolbar.ToolbarInfo.SandboxButton.MenuItemCreateSandbox.IsAdded;
  371. } else if (toolbarAction == "IDM_DELETE_SANDBOX") {
  372. return this.tm1Toolbar.ToolbarInfo.SandboxButton != null && this.tm1Toolbar.ToolbarInfo.SandboxButton.MenuItemDeleteSandbox != null && this.tm1Toolbar.ToolbarInfo.SandboxButton.MenuItemDeleteSandbox.IsAdded;
  373. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  374. return this.tm1Toolbar.ToolbarInfo.SandboxButton != null && this.tm1Toolbar.ToolbarInfo.SandboxButton.IsAdded;
  375. }
  376. return "tm1-toolbar-empty";
  377. },
  378. isToolbuttonDisabled: function(toolbarAction) {
  379. if (toolbarAction == "IDM_SUPPRESS_ZEROS") {
  380. return (this.tm1Toolbar.ToolbarInfo.SuppressZerosButton.IsEnabled == false);
  381. } else if (toolbarAction == "IDM_COMMIT") {
  382. return (this.tm1Toolbar.ToolbarInfo.CommitSandboxButton.IsEnabled == false);
  383. } else if (toolbarAction == "IDM_SAVEVIEW") {
  384. return (this.tm1Toolbar.ToolbarInfo.SaveViewButton.IsEnabled == false);
  385. } else if (toolbarAction == "IDM_SAVEAS") {
  386. return (this.tm1Toolbar.ToolbarInfo.SaveAsViewButton.IsEnabled == false);
  387. } else if (toolbarAction == "IDM_EXPORT") {
  388. return (this.tm1Toolbar.ToolbarInfo.ExportButton.IsEnabled == false);
  389. } else if (toolbarAction == "IDM_SLICE_TO_EXCEL") {
  390. return (this.tm1Toolbar.ToolbarInfo.ExportButton.MenuItemSlice.IsEnabled == false);
  391. } else if (toolbarAction == "IDM_SNAPSHOT_TO_EXCEL") {
  392. return (this.tm1Toolbar.ToolbarInfo.ExportButton.MenuItemSnapshot.IsEnabled == false);
  393. } else if (toolbarAction == "IDM_EXPORT_TO_PDF") {
  394. return (this.tm1Toolbar.ToolbarInfo.ExportButton.MenuItemExportPDF.IsEnabled == false);
  395. } else if (toolbarAction == "IDM_SAVEDATACHANGES") {
  396. return (this.tm1Toolbar.ToolbarInfo.SaveDataChangesButton.IsEnabled == false);
  397. } else if (toolbarAction == "IDM_REVIEWDATACHANGES") {
  398. return (this.tm1Toolbar.ToolbarInfo.ReviewDataChangesButton.IsEnabled == false);
  399. } else if (toolbarAction == "IDM_RECALCULATE") {
  400. return (this.tm1Toolbar.ToolbarInfo.RecalcButton.IsEnabled == false);
  401. } else if (toolbarAction == "IDM_TOGGLE_AUTOMATICRECALCULATE") {
  402. return (this.tm1Toolbar.ToolbarInfo.AutoRecalcButton.IsEnabled == false);
  403. } else if (toolbarAction == "IDM_REBUILDACTIVEFORMS") {
  404. return (this.tm1Toolbar.ToolbarInfo.RebuildActiveFormButton.IsEnabled == false);
  405. } else if (toolbarAction == "IDM_AUTO_FIT_COL") {
  406. return (this.tm1Toolbar.ToolbarInfo.AutoFitButton.IsEnabled == false);
  407. } else if (toolbarAction == "IDM_ZOOM_IN") {
  408. return (this.tm1Toolbar.ToolbarInfo.ZoomInButton.IsEnabled == false);
  409. } else if (toolbarAction == "IDM_ZOOM_OUT") {
  410. return (this.tm1Toolbar.ToolbarInfo.ZoomOutButton.IsEnabled == false);
  411. } else if (toolbarAction == "IDM_ZOOM_NORMAL") {
  412. return (this.tm1Toolbar.ToolbarInfo.NormalViewButton.IsEnabled == false);
  413. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS_COLUMNS") {
  414. if (this.tm1Toolbar.ToolbarInfo.SuppressZerosButton.SuppressZeros) {
  415. return "tm1-toolbar-apply";
  416. }
  417. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS") {
  418. if (this.tm1Toolbar.ToolbarInfo.SuppressZerosButton.SuppressZerosOnRows) {
  419. return "tm1-toolbar-apply";
  420. }
  421. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_COLUMNS") {
  422. if (this.tm1Toolbar.ToolbarInfo.SuppressZerosButton.SuppressZerosOnColumns) {
  423. return "tm1-toolbar-apply";
  424. }
  425. } else if (toolbarAction == "IDM_CHART") {
  426. return (this.tm1Toolbar.ToolbarInfo.ViewChartButton.IsEnabled == false);
  427. } else if (toolbarAction == "IDM_CHARTANDGRID") {
  428. return (this.tm1Toolbar.ToolbarInfo.ViewChartGridButton.IsEnabled == false);
  429. } else if (toolbarAction == "IDM_GRID") {
  430. return (this.tm1Toolbar.ToolbarInfo.ViewGridButton.IsEnabled == false);
  431. } else if (toolbarAction == "IDM_CHART-SELECT") {
  432. return (this.tm1Toolbar.ToolbarInfo.ChartPropertiesButton.IsEnabled == false);
  433. } else if (toolbarAction == "IDM_RESET_DATA") {
  434. return (this.tm1Toolbar.ToolbarInfo.ResetSandboxButton.IsEnabled == false);
  435. } else if (toolbarAction == "IDM_SANDBOX_UNDO") {
  436. return (this.tm1Toolbar.ToolbarInfo.UndoButton.IsEnabled == false);
  437. } else if (toolbarAction == "IDM_SANDBOX_REDO") {
  438. return (this.tm1Toolbar.ToolbarInfo.RedoButton.IsEnabled == false);
  439. } else if (toolbarAction == "IDM_SANDBOX") {
  440. return (this.tm1Toolbar.ToolbarInfo.SandboxButton.IsEnabled == false);
  441. } else if (toolbarAction == "IDM_CREATE_SANDBOX") {
  442. return (this.tm1Toolbar.ToolbarInfo.SandboxButton.MenuItemCreateSandbox.IsEnabled == false);
  443. } else if (toolbarAction == "IDM_DELETE_SANDBOX") {
  444. return (this.tm1Toolbar.ToolbarInfo.SandboxButton.MenuItemDeleteSandbox.IsEnabled == false);
  445. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  446. return (this.tm1Toolbar.ToolbarInfo.SandboxButton.IsEnabled == false);
  447. }
  448. return "tm1-toolbar-empty";
  449. },
  450. getToolbuttonTooltip: function(toolbarAction) {
  451. if (toolbarAction == "IDM_SUPPRESS_ZEROS") {
  452. return this.tm1Toolbar.ToolbarInfo.SuppressZerosButton.CurrentSuppressZerosStateTooltip;
  453. } else if (toolbarAction == "IDM_COMMIT") {
  454. return this.tm1Toolbar.ToolbarInfo.CommitSandboxButton.Tooltip;
  455. } else if (toolbarAction == "IDM_SAVEVIEW") {
  456. return this.tm1Toolbar.ToolbarInfo.SaveViewButton.Tooltip;
  457. } else if (toolbarAction == "IDM_SAVEAS") {
  458. return this.tm1Toolbar.ToolbarInfo.SaveAsViewButton.Tooltip;
  459. } else if (toolbarAction == "IDM_EXPORT") {
  460. return this.tm1Toolbar.ToolbarInfo.ExportButton.Tooltip;
  461. } else if (toolbarAction == "IDM_SLICE_TO_EXCEL") {
  462. return this.tm1Toolbar.ToolbarInfo.ExportButton.MenuItemSlice.Tooltip;
  463. } else if (toolbarAction == "IDM_SNAPSHOT_TO_EXCEL") {
  464. return this.tm1Toolbar.ToolbarInfo.ExportButton.MenuItemSnapshot.Tooltip;
  465. } else if (toolbarAction == "IDM_EXPORT_TO_PDF") {
  466. return this.tm1Toolbar.ToolbarInfo.ExportButton.MenuItemExportPDF.Tooltip;
  467. } else if (toolbarAction == "IDM_SAVEDATACHANGES") {
  468. return this.tm1Toolbar.ToolbarInfo.SaveDataChangesButton.Tooltip;
  469. } else if (toolbarAction == "IDM_REVIEWDATACHANGES") {
  470. return this.tm1Toolbar.ToolbarInfo.ReviewDataChangesButton.Tooltip;
  471. } else if (toolbarAction == "IDM_RECALCULATE") {
  472. return this.tm1Toolbar.ToolbarInfo.RecalcButton.Tooltip;
  473. } else if (toolbarAction == "IDM_TOGGLE_AUTOMATICRECALCULATE") {
  474. return this.tm1Toolbar.ToolbarInfo.AutoRecalcButton.Tooltip;
  475. } else if (toolbarAction == "IDM_REBUILDACTIVEFORMS") {
  476. return this.tm1Toolbar.ToolbarInfo.RebuildActiveFormButton.Tooltip;
  477. } else if (toolbarAction == "IDM_AUTO_FIT_COL") {
  478. return this.tm1Toolbar.ToolbarInfo.AutoFitButton.Tooltip;
  479. } else if (toolbarAction == "IDM_ZOOM_IN") {
  480. return this.tm1Toolbar.ToolbarInfo.ZoomInButton.Tooltip;
  481. } else if (toolbarAction == "IDM_ZOOM_OUT") {
  482. return this.tm1Toolbar.ToolbarInfo.ZoomOutButton.Tooltip;
  483. } else if (toolbarAction == "IDM_ZOOM_NORMAL") {
  484. return this.tm1Toolbar.ToolbarInfo.NormalViewButton.Tooltip;
  485. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS_COLUMNS") {
  486. if (this.tm1Toolbar.ToolbarInfo.SuppressZerosButton.SuppressZeros) {
  487. return "tm1-toolbar-apply";
  488. }
  489. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS") {
  490. if (this.tm1Toolbar.ToolbarInfo.SuppressZerosButton.SuppressZerosOnRows) {
  491. return "tm1-toolbar-apply";
  492. }
  493. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_COLUMNS") {
  494. if (this.tm1Toolbar.ToolbarInfo.SuppressZerosButton.SuppressZerosOnColumns) {
  495. return "tm1-toolbar-apply";
  496. }
  497. } else if (toolbarAction == "IDM_CHART") {
  498. return this.tm1Toolbar.ToolbarInfo.ViewChartButton.Tooltip;
  499. } else if (toolbarAction == "IDM_CHARTANDGRID") {
  500. return this.tm1Toolbar.ToolbarInfo.ViewChartGridButton.Tooltip;
  501. } else if (toolbarAction == "IDM_GRID") {
  502. return this.tm1Toolbar.ToolbarInfo.ViewGridButton.Tooltip;
  503. } else if (toolbarAction == "IDM_CHART-SELECT") {
  504. return this.tm1Toolbar.ToolbarInfo.ChartPropertiesButton.Tooltip;
  505. } else if (toolbarAction == "IDM_SANDBOX") {
  506. return this.tm1Toolbar.ToolbarInfo.SandboxButton.Tooltip;
  507. } else if (toolbarAction == "IDM_SANDBOX_UNDO") {
  508. return this.tm1Toolbar.ToolbarInfo.UndoButton.Tooltip;
  509. } else if (toolbarAction == "IDM_SANDBOX_REDO") {
  510. return this.tm1Toolbar.ToolbarInfo.RedoButton.Tooltip;
  511. } else if (toolbarAction == "IDM_RESET_DATA") {
  512. return this.tm1Toolbar.ToolbarInfo.ResetSandboxButton.Tooltip;
  513. } else if (toolbarAction == "IDM_CREATE_SANDBOX") {
  514. return this.tm1Toolbar.ToolbarInfo.SandboxButton.MenuItemCreateSandbox.Tooltip;
  515. } else if (toolbarAction == "IDM_DELETE_SANDBOX") {
  516. return this.tm1Toolbar.ToolbarInfo.SandboxButton.MenuItemDeleteSandbox.Tooltip;
  517. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  518. if (this.tm1Toolbar.ToolbarInfo.Sandbox.ActiveSandbox == null || this.tm1Toolbar.ToolbarInfo.Sandbox.ActiveSandbox == "") {
  519. return this.tm1Toolbar.ToolbarInfo.SandboxButton.Tooltip;
  520. } else {
  521. return this.tm1Toolbar.ToolbarInfo.Sandbox.ActiveSandbox;
  522. }
  523. }
  524. return "tm1-toolbar-empty";
  525. },
  526. getToolbuttonImage: function(toolbarAction) {
  527. if (toolbarAction == "IDM_SUPPRESS_ZEROS") {
  528. if (this.tm1Toolbar.ToolbarInfo.SuppressInfo.SuppressSeros)
  529. return "tm1-toolbar-suppress-zeros-on-both";
  530. else if (this.tm1Toolbar.ToolbarInfo.SuppressInfo.SuppressZerosOnRows)
  531. return "tm1-toolbar-suppress-zeros-on-rows";
  532. else if (this.tm1Toolbar.ToolbarInfo.SuppressInfo.SuppressZerosOnColumns)
  533. return "tm1-toolbar-suppress-zeros-on-columns";
  534. else {
  535. return "tm1-toolbar-suppress-zeros";
  536. }
  537. } else if (toolbarAction == "IDM_COMMIT") {
  538. if (this.tm1Toolbar.ToolbarInfo.CommitSandboxButton.IsEnabled) {
  539. return "tm1-toolbar-apply";
  540. } else {
  541. return "tm1-toolbar-apply disabled-toolbutton";
  542. }
  543. } else if (toolbarAction == "IDM_EXPORT") {
  544. if (this.tm1Toolbar.ToolbarInfo.ExportButton.IsEnabled) {
  545. return "tm1-toolbar-export";
  546. } else {
  547. return "tm1-toolbar-export disabled-toolbutton";
  548. }
  549. } else if (toolbarAction == "IDM_SLICE_TO_EXCEL") {
  550. return "tm1-toolbar-slice-excel2";
  551. } else if (toolbarAction == "IDM_SNAPSHOT_TO_EXCEL") {
  552. return "tm1-toolbar-slice-snapshot";
  553. } else if (toolbarAction == "IDM_EXPORT_TO_PDF") {
  554. return "tm1-toolbar-slice-pdf";
  555. } else if (toolbarAction == "IDM_SAVEDATACHANGES") {
  556. if (this.tm1Toolbar.ToolbarInfo.SaveDataChangesButton.IsEnabled) {
  557. return "tm1-toolbar-save_data_changes";
  558. } else {
  559. return "tm1-toolbar-save_data_changes disabled-toolbutton";
  560. }
  561. } else if (toolbarAction == "IDM_REVIEWDATACHANGES") {
  562. if (this.tm1Toolbar.ToolbarInfo.ReviewDataChangesButton.IsEnabled) {
  563. return "tm1-toolbar-review_data_changes";
  564. } else {
  565. return "tm1-toolbar-review_data_changes disabled-toolbutton";
  566. }
  567. } else if (toolbarAction == "IDM_RECALCULATE") {
  568. if (this.tm1Toolbar.ToolbarInfo.RecalcButton.IsEnabled) {
  569. return "tm1-toolbar-recalculate";
  570. } else {
  571. return "tm1-toolbar-recalculate disabled-toolbutton";
  572. }
  573. } else if (toolbarAction == "IDM_TOGGLE_AUTOMATICRECALCULATE") {
  574. if (this.tm1Toolbar.ToolbarInfo.AutoRecalcButton.IsEnabled) {
  575. if (this.tm1Toolbar.ToolbarInfo.AutoRecalc) {
  576. return "tm1-toolbar-recalculation dijitToggleButtonChecked";
  577. } else {
  578. return "tm1-toolbar-recalculation";
  579. }
  580. } else {
  581. if (this.tm1Toolbar.ToolbarInfo.AutoRecalc) {
  582. return "tm1-toolbar-recalculation disabled-toolbutton dijitToggleButtonChecked";
  583. } else {
  584. return "tm1-toolbar-recalculation disabled-toolbutton";
  585. }
  586. }
  587. } else if (toolbarAction == "IDM_REBUILDACTIVEFORMS") {
  588. if (this.tm1Toolbar.ToolbarInfo.RecalcButton.IsEnabled) {
  589. return "tm1-toolbar-rebuild_active_forms";
  590. } else {
  591. return "tm1-toolbar-rebuild_active_forms disabled-toolbutton";
  592. }
  593. } else if (toolbarAction == "IDM_AUTO_FIT_COL") {
  594. if (this.tm1Toolbar.ToolbarInfo.AutoRecalcButton.IsEnabled) {
  595. return "tm1-toolbar-auto-fit-col";
  596. } else {
  597. return "tm1-toolbar-auto-fit-col disabled-toolbutton";
  598. }
  599. } else if (toolbarAction == "IDM_ZOOM_IN") {
  600. if (this.tm1Toolbar.ToolbarInfo.ZoomInButton.IsEnabled) {
  601. return "tm1-toolbar-zoom-in";
  602. } else {
  603. return "tm1-toolbar-zoom-in disabled-toolbutton";
  604. }
  605. } else if (toolbarAction == "IDM_ZOOM_OUT") {
  606. if (this.tm1Toolbar.ToolbarInfo.ZoomOutButton.IsEnabled) {
  607. return "tm1-toolbar-zoom-out";
  608. } else {
  609. return "tm1-toolbar-zoom-out disabled-toolbutton";
  610. }
  611. } else if (toolbarAction == "IDM_ZOOM_NORMAL") {
  612. if (this.tm1Toolbar.ToolbarInfo.NormalViewButton.IsEnabled) {
  613. return "tm1-toolbar-zoom-normal";
  614. } else {
  615. return "tm1-toolbar-zoom-normal disabled-toolbutton";
  616. }
  617. } else if (toolbarAction == "IDM_SANDBOX_UNDO") {
  618. if (this.tm1Toolbar.ToolbarInfo.UndoButton.IsEnabled) {
  619. return "tm1-toolbar-sandbox-undo";
  620. } else {
  621. return "tm1-toolbar-sandbox-undo disabled-toolbutton";
  622. }
  623. } else if (toolbarAction == "IDM_RESET_DATA") {
  624. if (this.tm1Toolbar.ToolbarInfo.ResetSandboxButton.IsEnabled) {
  625. return "tm1-toolbar-sandbox-reset";
  626. } else {
  627. return "tm1-toolbar-sandbox-reset disabled-toolbutton";
  628. }
  629. } else if (toolbarAction == "IDM_SANDBOX") {
  630. if (this.tm1Toolbar.ToolbarInfo.SandboxButton.IsEnabled) {
  631. return "tm1-toolbar-sandbox-select";
  632. } else {
  633. return "tm1-toolbar-sandbox-select disabled-toolbutton";
  634. }
  635. } else if (toolbarAction == "IDM_SANDBOX_REDO") {
  636. if (this.tm1Toolbar.ToolbarInfo.RedoButton.IsEnabled) {
  637. return "tm1-toolbar-sandbox-redo";
  638. } else {
  639. return "tm1-toolbar-sandbox-redo disabled-toolbutton";
  640. }
  641. } else if (toolbarAction == "IDM_CREATE_SANDBOX") {
  642. return "tm1-toolbar-sandbox-new";
  643. } else if (toolbarAction == "IDM_DELETE_SANDBOX") {
  644. return "tm1-toolbar-sandbox-delete";
  645. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  646. return null;
  647. }
  648. return "tm1-toolbar-empty";
  649. },
  650. onToolbarAction: function(evt)
  651. {
  652. var toolbarAction = evt.payload;
  653. if (toolbarAction == "IDM_RECALCULATE") {
  654. if (this.tm1InternalToolbar == 1) {
  655. this.recalcCubeViewer();
  656. } else {
  657. this.tm1Toolbar.Recalc();
  658. }
  659. } else if (toolbarAction == "IDM_TOGGLE_AUTOMATICRECALCULATE") {
  660. this.tm1Toolbar.ToggleRecalc();
  661. } else if (toolbarAction == "IDM_REBUILDACTIVEFORMS") {
  662. this.tm1Toolbar.RebuildActiveForm();
  663. } else if (toolbarAction == "IDM_AUTO_FIT_COL") {
  664. this.tm1Toolbar.AutoFitToggle();
  665. } else if (evt.payload == "IDM_ZOOM_IN") {
  666. this.tm1Toolbar.WebSheetZoomIn();
  667. } else if (evt.payload == "IDM_ZOOM_OUT") {
  668. this.tm1Toolbar.WebSheetZoomOut();
  669. } else if (evt.payload == "IDM_ZOOM_NORMAL") {
  670. this.tm1Toolbar.WebSheetZoomNormal();
  671. } else if (evt.payload == "IDM_RESTART") {
  672. document.cookie="ASP.NET_SessionId=;path=/";
  673. this.refreshView();
  674. } else if (evt.payload == "IDM_SLICE_TO_EXCEL") {
  675. this.tm1Toolbar.ExportSlice();
  676. } else if (evt.payload == "IDM_SNAPSHOT_TO_EXCEL") {
  677. this.tm1Toolbar.ExportSnapshot();
  678. } else if (evt.payload == "IDM_EXPORT_TO_PDF") {
  679. this.tm1Toolbar.ExportPrintToPDF();
  680. } else if (evt.payload == "IDM_COMMIT") {
  681. this.tm1Toolbar.CommitSandbox();
  682. } else if (evt.payload == "IDM_CREATE_SANDBOX") {
  683. this.tm1Toolbar.CreateSandbox();
  684. } else if (evt.payload == "IDM_DELETE_SANDBOX") {
  685. this.tm1Toolbar.DeleteSandbox();
  686. } else if (evt.payload == "IDM_SAVEDATACHANGES") {
  687. this.tm1Toolbar.SaveDataChanges();
  688. } else if (evt.payload == "IDM_REVIEWDATACHANGES") {
  689. this.tm1Toolbar.ReviewDataChanges(evt);
  690. } else if (evt.payload == "IDM_RESET_DATA") {
  691. this.tm1Toolbar.ResetData();
  692. } else if (evt.payload == "IDM_SANDBOX_UNDO") {
  693. this.tm1Toolbar.Undo();
  694. } else if (evt.payload == "IDM_SANDBOX_REDO") {
  695. this.tm1Toolbar.Redo();
  696. } else if (evt.payload.substring(0, 13) == "SANDBOXCHOICE") {
  697. var sandBoxId = evt.payload.substring(13, evt.payload.length);
  698. if (sandBoxId == 0) {
  699. this.tm1Toolbar.SetActiveSandbox("[Base]");
  700. } else {
  701. this.tm1Toolbar.SetActiveSandbox(this.tm1Toolbar.ToolbarInfo.Sandbox.SandboxList[sandBoxId - 1]);
  702. }
  703. }
  704. return;
  705. },
  706. handleTM1DimensionUpdate: function(iEvent) {
  707. var filter = iEvent.payload;
  708. this.dimensionChangeWebsheet(filter);
  709. return;
  710. },
  711. dimensionChangeWebsheet : function (titleParams) {
  712. var url = this.iframeCtrl.getObjectIDURL();
  713. var url2 = url.replace("TM1WebSheet","TM1WebMain");
  714. url2 += "&";
  715. url2 += titleParams;
  716. this.iframeCtrl.setUrl(url2);
  717. return;
  718. },
  719. areTM1ParametersValid: function () {
  720. var bParametersAreValid = true;
  721. if (this.tm1Host == "") {
  722. bParametersAreValid = false;
  723. } else if (this.tm1Server == "") {
  724. bParametersAreValid = false;
  725. } else if (this.tm1CubeView == "") {
  726. bParametersAreValid = false;
  727. }
  728. return bParametersAreValid == true;
  729. },
  730. onUnload: function(evt) {
  731. if (this.iframeCtrl != null) {
  732. this.tm1Close();
  733. this.iframeCtrl.destroy();
  734. this.iframeCtrl = null;
  735. }
  736. },
  737. onSetVisible: function(evt) {
  738. if (evt.payload.isVisible) {
  739. if (this.tm1InternalToolbar == 1) {
  740. this.recalcCubeViewer();
  741. } else if (this.tm1Toolbar != null) {
  742. this.tm1Toolbar.Recalc();
  743. }
  744. }
  745. return;
  746. },
  747. onWidgetSave: function(evt) {
  748. this.iContext.iEvents.fireEvent("com.ibm.bux.widget.save.done", null, "");
  749. },
  750. onWidgetResize: function(evt) {
  751. var resize = evt.payload.resize;
  752. if (resize) {
  753. this.iframeCtrl.resize({
  754. w: resize.w,
  755. h: resize.h
  756. });
  757. }
  758. if (this.iframeCtrl.resizeZone != null) {
  759. if (resize.h > 0) {
  760. this.tm1Height = resize.h;
  761. this.saveTM1CubeViewerParams(this.iContext);
  762. }
  763. return;
  764. }
  765. },
  766. getWidgetAttributes : function (){
  767. this.tm1WebURL = this.iContext.getiWidgetAttributes().getItemValue("tm1WebURL");
  768. this.tm1Host = this.iContext.getiWidgetAttributes().getItemValue("tm1Host");
  769. this.tm1Server = this.iContext.getiWidgetAttributes().getItemValue("tm1Server");
  770. this.tm1CubeView = decodeURIComponent(this.iContext.getiWidgetAttributes().getItemValue("tm1CubeView"));
  771. this.tm1UserName = this.iContext.getiWidgetAttributes().getItemValue("tm1UserName");
  772. this.tm1Password = this.iContext.getiWidgetAttributes().getItemValue("tm1Password");
  773. this.tm1InternalToolbar = this.iContext.getiWidgetAttributes().getItemValue("TM1Toolbar");
  774. this.tm1Height = this.iContext.getiWidgetAttributes().getItemValue("tHeight");
  775. if (this.tm1Height == "") {
  776. this.tm1Height = this.initialHeight;
  777. }
  778. },
  779. saveTM1CubeViewerParams: function (inIContext) {
  780. inIContext.getiWidgetAttributes().setItemValue("tm1Host", this.tm1Host);
  781. inIContext.getiWidgetAttributes().setItemValue("tm1Server", this.tm1Server);
  782. inIContext.getiWidgetAttributes().setItemValue("tm1CubeView", encodeURIComponent(this.tm1CubeView));
  783. inIContext.getiWidgetAttributes().setItemValue("tHeight", this.tm1Height);
  784. inIContext.getiWidgetAttributes().setItemValue("tm1UserName", this.tm1UserName);
  785. inIContext.getiWidgetAttributes().setItemValue("tm1Password", this.tm1Password);
  786. inIContext.getiWidgetAttributes().setItemValue("TM1Toolbar", this.tm1InternalToolbar);
  787. return;
  788. },
  789. initializeiframe : function (url) {
  790. this.iframeCtrl = new webSheetViewerIFrame({
  791. url: url,
  792. iWidget: this
  793. }, this.iContext.getElementById("_" + this.iContext.widgetId + "_" + "tm1CubeViewerWidgetDiv"));
  794. if (this.tm1Height <= 0) {
  795. this.tm1Height = 402;
  796. }
  797. this.iframeCtrl.startup(this.tm1Height);
  798. // find out our working space
  799. var chromeObjectId = bux.Helper.widgetIdToChromeId(this.iContext.widgetId);
  800. var chromeObject = bux.Helper.getChromeById(chromeObjectId);
  801. var currentSize = chromeObject.getClientBox();
  802. this.iframeCtrl.resize(currentSize);
  803. },
  804. onWidgetRefresh: function(evt) // Invoked when User preferences get modified (Including locales)
  805. {
  806. this.recalcCubeViewer();
  807. return;
  808. },
  809. recalcCubeViewer : function () {
  810. var url = this.iframeCtrl.getObjectIDURL();
  811. var url2 = url.replace("TM1WebCubeViewer","TM1WebMain");
  812. url2 += "&Action=Recalc";
  813. this.iframeCtrl.setUrl(url2);
  814. return;
  815. },
  816. restartSession : function () {
  817. var url = this.iframeCtrl.getObjectIDURL();
  818. var url2 = url.replace("TM1WebCubeViewer","TM1WebMain");
  819. url2 += "&Action=Reload";
  820. this.iframeCtrl.setUrl(url2);
  821. return;
  822. },
  823. tm1Close : function () {
  824. if (!this.bTurnOffCallbacks) {
  825. var url = this.iframeCtrl.getObjectIDURL();
  826. var url2 = url.replace("TM1WebCubeViewer","TM1WebMain");
  827. url2 += "&Action=Close";
  828. this.iframeCtrl.setUrl(url2);
  829. }
  830. // remove callback functions to prevent memory leaks
  831. if (COGNOS_TM1_webShtWgtToolbarFuncs != null) {
  832. COGNOS_TM1_webShtWgtToolbarFuncs["_"+this.iContext.widgetId+"_"] = null;
  833. delete COGNOS_TM1_webShtWgtToolbarFuncs["_"+this.iContext.widgetId+"_"];
  834. }
  835. if (COGNOS_TM1_webShtWgtFltrFuncs != null) {
  836. COGNOS_TM1_webShtWgtFltrFuncs["_"+this.iContext.widgetId+"_"] = null;
  837. delete COGNOS_TM1_webShtWgtFltrFuncs["_"+this.iContext.widgetId+"_"];
  838. }
  839. return;
  840. },
  841. fireFilterChanged : function (dimName, subsetName, elemName) {
  842. // alert ("in webjsfunction");
  843. var extraParams = "title_";
  844. extraParams += dimName;
  845. extraParams += "=";
  846. extraParams += encodeURIComponent(elemName);
  847. this.iContext.iEvents.fireEvent("Context filter change", null, extraParams);
  848. return;
  849. },
  850. refreshDataAction : function () {
  851. var url = this.tm1WebURL;
  852. url += "/TM1WebMain.aspx?action=OpenObject&type=Cubeviewer&HideToolbar=0&HideTabs=1&TitleChangeCallback=JSFunction($dimName$, $subsetName$, $elemName$)&AdminHost=" + this.tm1Host + "&TM1server=" + this.tm1Server + "&value=" + this.tm1Cube + "$$" + this.tm1CubeView;
  853. if ((this.tm1UserName != null) && (this.tm1UserName != "")) {
  854. url += "&username=";
  855. url += this.tm1UserName;
  856. url += "&password=";
  857. url += this.tm1Password;
  858. }
  859. var xmlhttp;
  860. xmlhttp=new XMLHttpRequest();
  861. var _endRefreshDataAction = function () {
  862. xmlhttp.setRequestHeader ("Cookie", "");
  863. xmlhttp.setRequestHeader ("Cookie", "");
  864. xmlhttp.send(null);
  865. };
  866. if (xmlhttp!=null)
  867. {
  868. xmlhttp.open("GET",url,true);
  869. //setTimeout((function(obj){obj.xmlhttp.setRequestHeader ("Cookie", "");
  870. //obj.xmlhttp.setRequestHeader ("Cookie", "");
  871. //obj.xmlhttp.send(null);})(this),15000);
  872. setTimeout (_endRefreshDataAction, 15000);
  873. }
  874. return;
  875. },
  876. determineCommonDomain: function () {
  877. if (this.commonDomain == null) {
  878. this.commonDomain = "";
  879. var buxURL = document.URL;
  880. var buxDomain = bux.Helper.extractDomain(buxURL);
  881. var tm1WebDomain = bux.Helper.extractDomain(this.tm1WebURL);
  882. if (buxDomain.toLowerCase() == tm1WebDomain.toLowerCase()) {
  883. return;
  884. } else {
  885. this.bTurnOffCallbacks = true;
  886. /* var buxColonIndex = buxDomain.indexOf(":");
  887. if (buxColonIndex >= 0) {
  888. buxDomain = buxDomain.substring(0, buxColonIndex);
  889. }
  890. var tm1WebColonIndex = tm1WebDomain.indexOf(":");
  891. if (tm1WebColonIndex >= 0) {
  892. tm1WebDomain = tm1WebDomain.substring(0, tm1WebColonIndex);
  893. }
  894. var buxDotIndex = buxDomain.indexOf(".");
  895. var tm1WebDotIndex = tm1WebDomain.indexOf(".");
  896. if (buxDotIndex >= 0 && tm1WebDotIndex >= 0) {
  897. var buxDomainSuffix = buxDomain.substring(buxDotIndex + 1);
  898. var tm1DomainSuffix = tm1WebDomain.substring(tm1WebDotIndex + 1);
  899. if (buxDomainSuffix.toLowerCase() == tm1DomainSuffix.toLowerCase()) {
  900. this.commonDomain = buxDomainSuffix;
  901. return;
  902. }
  903. } */
  904. }
  905. }
  906. return;
  907. },
  908. refreshView : function () {
  909. // initialize javascript callback functions
  910. // callback functions are stored in an array where the array index
  911. // is the context widgetId
  912. if (COGNOS_TM1_webShtWgtToolbarFuncs == null)
  913. COGNOS_TM1_webShtWgtToolbarFuncs = new Array();
  914. if (COGNOS_TM1_webShtWgtFltrFuncs == null)
  915. COGNOS_TM1_webShtWgtFltrFuncs = new Array();
  916. if (COGNOS_TM1_webShtWgtToolbarFuncs["_"+this.iContext.widgetId+"_"] == null) {
  917. COGNOS_TM1_webShtWgtToolbarFuncs["_"+this.iContext.widgetId+"_"] = dojo.hitch(this, "createWidgetToolbar");
  918. }
  919. if (COGNOS_TM1_webShtWgtFltrFuncs["_"+this.iContext.widgetId+"_"] == null) {
  920. COGNOS_TM1_webShtWgtFltrFuncs["_"+this.iContext.widgetId+"_"] = dojo.hitch(this, "fireFilterChanged");
  921. }
  922. var url = this.tm1WebURL;
  923. url += "/TM1WebMain.aspx?action=OpenObject&type=Websheet&HideTabs=1&AdminHost=" + encodeURIComponent(this.tm1Host) + "&TM1server=" + encodeURIComponent(this.tm1Server) + "&value=" + encodeURIComponent(this.tm1CubeView);
  924. this.determineCommonDomain();
  925. if (this.bTurnOffCallbacks /* this.commonDomain != null && this.commonDomain.length > 0 */) {
  926. this.tm1InternalToolbar = 1;
  927. this.createBasicWidgetToolbar();
  928. // document.domain = this.commonDomain;
  929. // url += "&CommonDomain=";
  930. // url += encodeURIComponent(this.commonDomain);
  931. } else {
  932. if (this.tm1InternalToolbar == 1) {
  933. url += "&HideToolbar=0";
  934. } else {
  935. url += "&HideToolbar=1";
  936. }
  937. url += "&toolbarCallbackFunc=COGNOS_TM1_webShtWgtToolbarFuncs._"+encodeURIComponent(this.iContext.widgetId)+"_&TitleChangeCallback=COGNOS_TM1_webShtWgtFltrFuncs._"+encodeURIComponent(this.iContext.widgetId)+"_($dimName$, $subsetName$, $elemName$)";
  938. }
  939. if ((this.tm1UserName != null) && (this.tm1UserName != "")) {
  940. url += "&username=";
  941. url += encodeURIComponent(this.tm1UserName);
  942. url += "&password=";
  943. if ((this.tm1Password != null) && (this.tm1Password != "")) {
  944. url += encodeURIComponent(this.tm1Password);
  945. }
  946. }
  947. if (this.iframeCtrl == null) {
  948. this.initializeiframe (url);
  949. } else {
  950. this.iframeCtrl.setUrl(url);
  951. }
  952. }
  953. });
  954. dojo.provide("webSheetViewerIFrame");
  955. dojo.declare("webSheetViewerIFrame", dijit._Widget, {
  956. url: null,
  957. iWidget: null,
  958. resizeZone: null,
  959. iframe: null,
  960. recalcURL: null,
  961. constructor: function(params) {
  962. },
  963. getObjectIDURL: function () {
  964. this.recalcURL = null;
  965. if (this.iframe.contentDocument) {
  966. if (this.iframe.contentDocument.URL == "about:blank") {
  967. } else {
  968. this.recalcURL = this.iframe.contentDocument.URL;
  969. }
  970. } else if (this.iframe.contentWindow) {
  971. this.recalcURL = this.iframe.contentWindow.location.href;
  972. }
  973. return this.recalcURL;
  974. },
  975. setUrl: function(url) {
  976. this.url = url;
  977. if (this.iframe) {
  978. this.iframe.src = url;
  979. }
  980. },
  981. assignReturnURL: function () {
  982. },
  983. startup: function(inHght) {
  984. var ref = this;
  985. this.inherited(arguments);
  986. this.resizeZone = this.domNode.ownerDocument.createElement("div");
  987. this.domNode.appendChild(this.resizeZone);
  988. var dn = (this.iframe = dojo.doc.createElement('iframe'));
  989. var url = this.url;
  990. var widgetParent = this.iWidget;
  991. dn.id = this.id + "_iframe";
  992. dn.style.border = "none";
  993. dn.style.width = "100%";
  994. dn.style.height = inHght + "px";
  995. dn.frameBorder = 0;
  996. dn.tabIndex = 0;
  997. dn.setAttribute('src', url);
  998. dn.setAttribute('scrolling', "no");
  999. this.resizeZone.appendChild(dn);
  1000. if (dojo.isWebKit) { // Safari seems to always append iframe with src=about:blank
  1001. setTimeout(function() {
  1002. dn.setAttribute('src', url)
  1003. }, 0);
  1004. }
  1005. },
  1006. resize: function(size) {
  1007. dijit.layout._LayoutWidget.prototype.resize.apply(this, arguments);
  1008. },
  1009. layout: function() {
  1010. if (this.iframe.parentNode != null) {
  1011. if (this.iframe.clientHeight > 0) {
  1012. this.iframe.style.height = this.iframe.parentNode.parentNode.clientHeight + "px";
  1013. }
  1014. }
  1015. }
  1016. });