TM1WebWebSheetWidget.js 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579
  1. dojo.provide("TM1WebWebSheetWidget");
  2. dojo.require("bux.i18n");
  3. dojo.require("bux.Helper");
  4. dojo.require("bux.data.UserPreferencesStore");
  5. dojo.require("bux.iwidget.utilities.UtilityWidgetBase"); //For Bux Action Button issue, can't remove
  6. dojo.require("bux.dialogs.WidgetPropertiesFromJSON"); //fix for BUX resource loading
  7. dojo.declare("TM1WebWebSheetWidget", null,
  8. {
  9. iframeCtrl: null,
  10. iframeCtrlCantLoadDojo: null,
  11. dimensionNames: null,
  12. elementNames:null,
  13. _exportContainer:null,
  14. elementNameCounter: 0,
  15. filterElement:null,
  16. undoRedoStatus:null,
  17. subscriptionHandle:null,
  18. cubeViewState:null,
  19. app: null,
  20. app2: null,
  21. inDoMore:false,
  22. webUrl: null,
  23. cantLoadDojo: false,
  24. // ====== Multilingual Support - Start ========
  25. _productLocale:null,
  26. _tm1messages:null,
  27. // ====== Multilingual Support - End ========
  28. _firstVisible:false,
  29. onLoad : function() {
  30. // ====== Multilingual Support - Start ========
  31. // Remember where we were loaded from: this is our path for future AJAX calls and .js loads
  32. dojo.registerModulePath("TM1WebWebSheetWidget",this.iContext.io.rewriteURI("js"));
  33. this.setLanguage().then(dojo.hitch(this, "getWidgetAttributes"));
  34. // ====== Multilingual Support - End ========
  35. },
  36. loadWithAttributes: function () {
  37. var url = this.tm1WebURL;
  38. var lastSlashIndex = url.lastIndexOf("/");
  39. this.webUrl = url.substring(0, lastSlashIndex);
  40. url += "/scripts/tm1web";
  41. var url2 = this.tm1WebURL;
  42. url2 += "/scripts/com";
  43. dojo.registerModulePath("tm1web", url);
  44. dojo.registerModulePath("com", url2);
  45. if (this.getCookie("tm1webwremote") != "") {
  46. this.cantLoadDojo = true;
  47. } else {
  48. try {
  49. dojo.require("tm1web.websheet.Workbooker");
  50. } catch (err) {
  51. this.cantLoadDojo = true;
  52. document.cookie = "tm1webwremote=true; path=/";
  53. }
  54. }
  55. this.app = null;
  56. if (this.areTM1ParametersValid ()) {
  57. this.refreshView();
  58. } else {
  59. this.onGetProperties(null, true);
  60. }
  61. },
  62. getCookie: function (name) {
  63. if ( document.cookie.length <= 0 )
  64. return(""); // no cookies
  65. var search = name + "=";
  66. var offset = document.cookie.indexOf(search);
  67. if ( offset == -1 )
  68. return(""); // cookie does not exist
  69. offset += search.length;
  70. // set index of beginning of value
  71. var end = document.cookie.indexOf(";", offset);
  72. // set index of end of cookie value
  73. if ( end == -1 )
  74. end = document.cookie.length;
  75. return(unescape(document.cookie.substring(offset, end)));
  76. },
  77. updateView: function() {
  78. this.setLanguage();
  79. },
  80. setLanguage: function() {
  81. // Setup Localization tables - Use the BUX preferences for locale. Use Product locale for loading strings
  82. var curProductLocale=bux.Helper.getUserPreference("productLocale");
  83. if (this._productLocale != curProductLocale)
  84. {
  85. this._productLocale = curProductLocale;
  86. var deferred = new dojo.Deferred();
  87. var self = this;
  88. dojo.requireLocalization("TM1WebWebSheetWidget","tm1ContentWebSheetViewerWidget_msg", curProductLocale);
  89. dojo.ready(function() {
  90. self._tm1messages = dojo.i18n.getLocalization("TM1WebWebSheetWidget", "tm1ContentWebSheetViewerWidget_msg", curProductLocale);
  91. deferred.resolve();
  92. });
  93. return deferred;
  94. }
  95. },
  96. createBasicWidgetToolbar: function () {
  97. var toolbarItems =
  98. [
  99. {
  100. _root:
  101. [
  102. {separator: true },
  103. {name: "Restart", action: "IDM_RESTART", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESTART, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada"}
  104. ]
  105. }
  106. ];
  107. this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, toolbarItems);
  108. },
  109. createWidgetToolbar: function () {
  110. var toolbarItems =
  111. [
  112. {
  113. _root:
  114. [
  115. {separator: true },
  116. {name: "Refresh", action: "IDM_RECALCULATE", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_REFRESH, showLabel: false, "iconClass": "bux-refresh-image"},
  117. {name: "Restart", action: "IDM_RESTART", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESTART, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada"}
  118. ]
  119. }
  120. ];
  121. toolbarItems = this.addToolbutton(toolbarItems, "IDM_COMMIT");
  122. // toolbarItems = this.addToolbutton(toolbarItems, "IDM_SAVEDATACHANGES");
  123. // toolbarItems = this.addToolbutton(toolbarItems, "IDM_REVIEWDATACHANGES");
  124. // toolbarItems = this.addSeparator(toolbarItems);
  125. // toolbarItems = this.addToolbuttonWithSubmenu (toolbarItems, "IDM_EXPORT");
  126. toolbarItems = this.addSeparator(toolbarItems);
  127. toolbarItems = this.addToolbutton(toolbarItems, "IDM_SANDBOX_UNDO");
  128. toolbarItems = this.addToolbutton(toolbarItems, "IDM_SANDBOX_REDO");
  129. toolbarItems = this.addSeparator(toolbarItems);
  130. toolbarItems = this.addToolbutton(toolbarItems, "IDM_RECALCULATE");
  131. toolbarItems = this.addToolbutton(toolbarItems, "IDM_REBUILDACTIVEFORMS");
  132. // toolbarItems = this.addToolbutton(toolbarItems, "IDM_TOGGLE_AUTOMATICRECALCULATE");
  133. toolbarItems = this.addToolbutton(toolbarItems, "IDM_AUTO_FIT_COL");
  134. // toolbarItems = this.addToolbutton(toolbarItems, "IDM_ZOOM_IN");
  135. // toolbarItems = this.addToolbutton(toolbarItems, "IDM_ZOOM_OUT");
  136. // toolbarItems = this.addToolbutton(toolbarItems, "IDM_ZOOM_NORMAL");
  137. toolbarItems = this.addSeparator(toolbarItems);
  138. // toolbarItems = this.addToolbutton(toolbarItems, "IDM_RESET_DATA");
  139. toolbarItems = this.addToolbuttonWithSubmenu (toolbarItems, "IDM_SANDBOX");
  140. toolbarItems = this.addToolbuttonWithSubmenu (toolbarItems, "IDM_SANDBOXITEMS");
  141. this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, toolbarItems);
  142. },
  143. addSeparator: function (toolbarItems) {
  144. var separator = { "separator": true };
  145. return toolbarItems.concat(separator);
  146. },
  147. addToolbutton: function (toolbarItems, toolbarAction) {
  148. if (this.isToolbuttonVisible(toolbarAction)) {
  149. return toolbarItems.concat(this.createSimpleToolbutton(toolbarAction));
  150. } else {
  151. return toolbarItems;
  152. }
  153. },
  154. addToolbuttonWithSubmenu: function (toolbarItems, toolbarAction) {
  155. if (this.isToolbuttonVisible(toolbarAction)) {
  156. return toolbarItems.concat(this.createToolbuttonWithSubmenu(toolbarAction));
  157. } else {
  158. return toolbarItems;
  159. }
  160. },
  161. createSimpleToolbutton: function (toolbarAction) {
  162. var toolbutton = {
  163. "name" : toolbarAction,
  164. "action" : toolbarAction,
  165. "label": this.getToolbuttonTooltip(toolbarAction),
  166. "iconClass": this.getToolbuttonImage(toolbarAction),
  167. "disabled": this.isToolbuttonDisabled(toolbarAction)
  168. }
  169. return toolbutton;
  170. },
  171. appendSandboxMenuChoice: function (menuItems, sandboxIndex, sandboxName, activeSandbox) {
  172. var toolbarAction = "SANDBOXCHOICE" + sandboxIndex;
  173. var toolbutton = {
  174. "name" : toolbarAction,
  175. "action" : toolbarAction,
  176. "label": sandboxName,
  177. "iconClass": (activeSandbox == sandboxName ? "tm1-menu-radioselection" : "tm1-menu-empty")
  178. }
  179. return menuItems.concat(toolbutton);
  180. },
  181. createToolbuttonWithSubmenu: function (toolbarAction) {
  182. var menuitems = null;
  183. if (toolbarAction == "IDM_EXPORT") {
  184. var menuItems = [];
  185. menuItems = this.addToolbutton(menuItems, "IDM_SLICE_TO_EXCEL");
  186. menuItems = this.addToolbutton(menuItems, "IDM_SNAPSHOT_TO_EXCEL");
  187. menuItems = this.addToolbutton(menuItems, "IDM_EXPORT_TO_PDF");
  188. var toolbutton = {
  189. "name" : toolbarAction,
  190. "action" : toolbarAction,
  191. "label": this.getToolbuttonTooltip(toolbarAction),
  192. "iconClass": this.getToolbuttonImage(toolbarAction),
  193. "disabled": this.isToolbuttonDisabled(toolbarAction),
  194. "items" : menuItems
  195. }
  196. return toolbutton;
  197. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS") {
  198. var menuItems = [];
  199. menuItems = this.addToolbutton(menuItems, "IDM_SUPPRESS_ZEROS_ROWS_COLUMNS");
  200. menuItems = this.addToolbutton(menuItems, "IDM_SUPPRESS_ZEROS_ROWS");
  201. menuItems = this.addToolbutton(menuItems, "IDM_SUPPRESS_ZEROS_COLUMNS");
  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. "items" : menuItems
  209. }
  210. return toolbutton;
  211. } else if (toolbarAction == "IDM_CHART-SELECT") {
  212. var menuItems = [];
  213. menuItems = this.addToolbuttonWithSubmenu (menuItems, "IDM_CHARTTYPE");
  214. var toolbutton = {
  215. "name" : toolbarAction,
  216. "action" : toolbarAction,
  217. "label": this.getToolbuttonTooltip(toolbarAction),
  218. "iconClass": this.getToolbuttonImage(toolbarAction),
  219. "disabled": this.isToolbuttonDisabled(toolbarAction),
  220. "items" : menuItems
  221. }
  222. return toolbutton;
  223. } else if (toolbarAction == "IDM_CHARTTYPE") {
  224. var menuItems = [];
  225. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_POINT");
  226. menuItems = this.addToolbutton(menuItems, "IDM_CHART_BUBBLE");
  227. menuItems = this.addToolbutton(menuItems, "IDM_CHART_LINE");
  228. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_SPLINE");
  229. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_STEPLINE");
  230. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_FASTLINE");
  231. menuItems = this.addToolbutton(menuItems, "IDM_CHART_BAR");
  232. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDBAR");
  233. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDBAR100");
  234. menuItems = this.addToolbutton(menuItems, "IDM_CHART_COLUMN");
  235. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDCOLUMN");
  236. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDCOLUMN100");
  237. menuItems = this.addToolbutton(menuItems, "IDM_CHART_AREA");
  238. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDAREA");
  239. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDAREA100");
  240. menuItems = this.addToolbutton(menuItems, "IDM_CHART_PIE");
  241. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_DOUGHNUT");
  242. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_STOCK");
  243. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_CANDLESTICK");
  244. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_RANGE");
  245. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_SPLINERANGE");
  246. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_GANTT");
  247. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_RANGECOLUMN");
  248. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_RADAR");
  249. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_POLAR");
  250. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_BOXPLOT");
  251. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_FUNNEL");
  252. //menuItems = this.addToolbutton(menuItems, "IDM_CHART_PYRAMID");
  253. var toolbutton = {
  254. "name" : toolbarAction,
  255. "action" : toolbarAction,
  256. "label": this.getToolbuttonTooltip(toolbarAction),
  257. "iconClass": this.getToolbuttonImage(toolbarAction),
  258. "disabled": this.isToolbuttonDisabled(toolbarAction),
  259. "items" : menuItems
  260. }
  261. return toolbutton;
  262. } else if (toolbarAction == "IDM_SANDBOX") {
  263. var menuItems = [];
  264. menuItems = this.addToolbutton(menuItems, "IDM_CREATE_SANDBOX");
  265. menuItems = this.addToolbutton(menuItems, "IDM_DELETE_SANDBOX");
  266. var toolbutton = {
  267. "name" : toolbarAction,
  268. "action" : toolbarAction,
  269. "label": this.getToolbuttonTooltip(toolbarAction),
  270. "iconClass": this.getToolbuttonImage(toolbarAction),
  271. "disabled": this.isToolbuttonDisabled(toolbarAction),
  272. "items" : menuItems
  273. }
  274. return toolbutton;
  275. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  276. var menuItems = [];
  277. if (this.sandboxNames) {
  278. menuItems = this.appendSandboxMenuChoice(menuItems, 0, "[Base]", this.sandboxNames.currentSandbox);
  279. if (this.sandboxNames.sandboxes.length > 1) {
  280. for (i=1; i<this.sandboxNames.sandboxes.length; i++) {
  281. menuItems = this.appendSandboxMenuChoice(menuItems, i, this.sandboxNames.sandboxes[i].name, this.sandboxNames.currentSandbox);
  282. }
  283. }
  284. } else {
  285. menuItems = this.appendSandboxMenuChoice(menuItems, 0, "[Base]", "[Base]");
  286. }
  287. var toolbutton = {
  288. "name" : toolbarAction,
  289. "action" : toolbarAction,
  290. "label": this.getToolbuttonTooltip(toolbarAction),
  291. "iconClass": this.getToolbuttonImage(toolbarAction),
  292. "disabled": this.isToolbuttonDisabled(toolbarAction),
  293. "items" : menuItems
  294. }
  295. return toolbutton;
  296. }
  297. var toolbutton = {
  298. "name" : toolbarAction,
  299. "action" : toolbarAction,
  300. "label": this.getToolbuttonTooltip(toolbarAction),
  301. "iconClass": this.getToolbuttonImage(toolbarAction),
  302. "disabled": this.isToolbuttonDisabled(toolbarAction),
  303. "items" : menuitems
  304. }
  305. return toolbutton;
  306. },
  307. isToolbuttonVisible: function(toolbarAction) {
  308. return true;
  309. },
  310. isToolbuttonDisabled: function(toolbarAction) {
  311. if (toolbarAction == "IDM_CHART-SELECT") {
  312. return false;
  313. } else if (toolbarAction == "IDM_COMMIT") {
  314. if (this.app != null) {
  315. if (this.cubeViewState == null) {
  316. return true;
  317. } else {
  318. return this.cubeViewState.baseSandbox;
  319. }
  320. }
  321. return true;
  322. } else if (toolbarAction == "IDM_SAVEVIEW") {
  323. return false;
  324. } else if (toolbarAction == "IDM_SAVEDATACHANGES") {
  325. if (this.app != null) {
  326. if (this.cubeViewState == null) {
  327. return true;
  328. } else {
  329. return (this.cubeViewState.unsavedChanges == false);
  330. }
  331. }
  332. return true;
  333. } else if (toolbarAction == "IDM_REVIEWDATACHANGES") {
  334. if (this.app != null) {
  335. if (this.cubeViewState == null) {
  336. return true;
  337. } else {
  338. return (this.cubeViewState.unsavedChanges == false);
  339. }
  340. }
  341. return true;
  342. } else if (toolbarAction == "IDM_RESET_DATA") {
  343. if (this.app != null) {
  344. if (this.cubeViewState == null) {
  345. return true;
  346. } else {
  347. return this.cubeViewState.baseSandbox;
  348. }
  349. }
  350. } else if (toolbarAction == "IDM_SANDBOX_UNDO") {
  351. if (this.app != null) {
  352. if (this.cubeViewState == null) {
  353. return true;
  354. } else {
  355. return (this.cubeViewState.redoUndoStatus.canUndo == false);
  356. }
  357. }
  358. return true;
  359. } else if (toolbarAction == "IDM_SANDBOX_REDO") {
  360. if (this.app != null) {
  361. if (this.cubeViewState == null) {
  362. return true;
  363. } else {
  364. return (this.cubeViewState.redoUndoStatus.canRedo == false);
  365. }
  366. }
  367. return true;
  368. } else if (toolbarAction == "IDM_SANDBOX") {
  369. return false;
  370. } else if (toolbarAction == "IDM_CREATE_SANDBOX") {
  371. return false;
  372. } else if (toolbarAction == "IDM_DELETE_SANDBOX") {
  373. return false;
  374. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  375. return false;
  376. } else {
  377. return false;
  378. }
  379. return "tm1-toolbar-empty";
  380. },
  381. getToolbuttonTooltip: function(toolbarAction) {
  382. if (toolbarAction == "IDM_SUPPRESS_ZEROS") {
  383. return MessageLocalizer.getMessage("SUPPRESS_ZEROES_TOOLTIP_STR"); } else if (toolbarAction == "IDM_COMMIT") {
  384. return MessageLocalizer.getMessage("COMMIT_TOOLTIP_STR");
  385. } else if (toolbarAction == "IDM_SAVEVIEW") {
  386. return MessageLocalizer.getMessage("SAVE_VIEW_TOOLTIP_STR");
  387. } else if (toolbarAction == "IDM_SAVEAS") {
  388. return MessageLocalizer.getMessage("SAVE_AS_TOOLTIP_STR");
  389. } else if (toolbarAction == "IDM_EXPORT") {
  390. return MessageLocalizer.getMessage("EXPORT_TOOLTIP_STR");
  391. } else if (toolbarAction == "IDM_SLICE_TO_EXCEL") {
  392. return MessageLocalizer.getMessage("SLICE_TO_EXCEL_STR");
  393. } else if (toolbarAction == "IDM_SNAPSHOT_TO_EXCEL") {
  394. return MessageLocalizer.getMessage("SNAP_TO_EXCEL_STR");
  395. } else if (toolbarAction == "IDM_EXPORT_TO_PDF") {
  396. return MessageLocalizer.getMessage("EXPORT_TO_PDF_STR");
  397. } else if (toolbarAction == "IDM_SAVEDATACHANGES") {
  398. return MessageLocalizer.getMessage("SAVE_DATA_CHANGES_TOOLTIP_STR");
  399. } else if (toolbarAction == "IDM_REVIEWDATACHANGES") {
  400. return MessageLocalizer.getMessage("REVIEW_DATA_CHANGES_TOOLTIP_STR");
  401. } else if (toolbarAction == "IDM_RECALCULATE") {
  402. return MessageLocalizer.getMessage("RECALCULATE_TOOLTIP_STR");
  403. } else if (toolbarAction == "IDM_REBUILDACTIVEFORMS") {
  404. return MessageLocalizer.getMessage("REBUILD_ACTIVE_FORMS_TOOLTIP_STR");
  405. } else if (toolbarAction == "IDM_AUTO_FIT_COL") {
  406. return MessageLocalizer.getMessage("AUTO_FIT_COLUMNS_TOOLTIP_STR");
  407. } else if (toolbarAction == "IDM_ZOOM_IN") {
  408. return MessageLocalizer.getMessage("RECALCULATE_TOOLTIP_STR");
  409. } else if (toolbarAction == "IDM_ZOOM_OUT") {
  410. return MessageLocalizer.getMessage("RECALCULATE_TOOLTIP_STR");
  411. } else if (toolbarAction == "IDM_ZOOM_NORMAL") {
  412. return MessageLocalizer.getMessage("RECALCULATE_TOOLTIP_STR");
  413. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS_COLUMNS") {
  414. return MessageLocalizer.getMessage("SUP_ZERO_ROW_COL_STR"); } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS") {
  415. return MessageLocalizer.getMessage("SUP_ZERO_ROW_STR"); } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_COLUMNS") {
  416. return MessageLocalizer.getMessage("SUP_ZERO_COL_STR"); } else if (toolbarAction == "IDM_CHART") {
  417. return MessageLocalizer.getMessage("VIEW_CHART_TOOLTIP_STR");
  418. } else if (toolbarAction == "IDM_CHARTANDGRID") {
  419. return MessageLocalizer.getMessage("VIEW_CHARTGRID_TOOLTIP_STR");
  420. } else if (toolbarAction == "IDM_GRID") {
  421. return MessageLocalizer.getMessage("VIEW_GRID_TOOLTIP_STR");
  422. } else if (toolbarAction == "IDM_CHART-SELECT") {
  423. return MessageLocalizer.getMessage("CHART_PROP_TOOLTIP_STR");
  424. } else if (toolbarAction == "IDM_CHARTTYPE") {
  425. return MessageLocalizer.getMessage("CHART_TYPE_STR");
  426. } else if (toolbarAction == "IDM_CHART_POINT") {
  427. return MessageLocalizer.getMessage("POINT_CHART_STR");
  428. } else if (toolbarAction == "IDM_CHART_BUBBLE") {
  429. return MessageLocalizer.getMessage("BUBBLE_CHART_STR");
  430. } else if (toolbarAction == "IDM_CHART_LINE") {
  431. return MessageLocalizer.getMessage("LINE_CHART_STR");
  432. } else if (toolbarAction == "IDM_CHART_SPLINE") {
  433. return MessageLocalizer.getMessage("SPLINE_CHART_STR");
  434. } else if (toolbarAction == "IDM_CHART_STEPLINE") {
  435. return MessageLocalizer.getMessage("STEP_LINE_CHART_STR");
  436. } else if (toolbarAction == "IDM_CHART_FASTLINE") {
  437. return MessageLocalizer.getMessage("FAST_LINE_CHART_STR");
  438. } else if (toolbarAction == "IDM_CHART_BAR") {
  439. return MessageLocalizer.getMessage("BAR_CHART_STR");
  440. } else if (toolbarAction == "IDM_CHART_STACKEDBAR") {
  441. return MessageLocalizer.getMessage("STACKED_BAR_CHART_STR");
  442. } else if (toolbarAction == "IDM_CHART_STACKEDBAR100") {
  443. return MessageLocalizer.getMessage("STACKED_BAR_100_CHART_STR");
  444. } else if (toolbarAction == "IDM_CHART_COLUMN") {
  445. return MessageLocalizer.getMessage("COLUMN_CHART_STR");
  446. } else if (toolbarAction == "IDM_CHART_STACKEDCOLUMN") {
  447. return MessageLocalizer.getMessage("STACKED_COL_CHART_STR");
  448. } else if (toolbarAction == "IDM_CHART_STACKEDCOLUMN100") {
  449. return MessageLocalizer.getMessage("STACKED_COL_100_CHART_STR");
  450. } else if (toolbarAction == "IDM_CHART_AREA") {
  451. return MessageLocalizer.getMessage("AREA_CHART_STR");
  452. } else if (toolbarAction == "IDM_CHART_SPLINEAREA") {
  453. return MessageLocalizer.getMessage("SPLINE_AREA_CHART_STR");
  454. } else if (toolbarAction == "IDM_CHART_STACKEDAREA") {
  455. return MessageLocalizer.getMessage("STACKED_AREA_CHART_STR");
  456. } else if (toolbarAction == "IDM_CHART_STACKEDAREA100") {
  457. return MessageLocalizer.getMessage("STACKED_AREA_100_CHART_STR");
  458. } else if (toolbarAction == "IDM_CHART_PIE") {
  459. return MessageLocalizer.getMessage("PIE_CHART_STR");
  460. } else if (toolbarAction == "IDM_CHART_DOUGHNUT") {
  461. return MessageLocalizer.getMessage("DOUGHNUT_CHART_STR");
  462. } else if (toolbarAction == "IDM_CHART_STOCK") {
  463. return MessageLocalizer.getMessage("STOCK_CHART_STR");
  464. } else if (toolbarAction == "IDM_CHART_CANDLESTICK") {
  465. return MessageLocalizer.getMessage("CANDLE_STICK_CHART_STR");
  466. } else if (toolbarAction == "IDM_CHART_RANGE") {
  467. return MessageLocalizer.getMessage("RANGE_CHART_STR");
  468. } else if (toolbarAction == "IDM_CHART_SPLINERANGE") {
  469. return MessageLocalizer.getMessage("SPLINE_RANGE_CHART_STR");
  470. } else if (toolbarAction == "IDM_CHART_GANTT") {
  471. return MessageLocalizer.getMessage("GANTT_CHART_STR");
  472. } else if (toolbarAction == "IDM_CHART_RANGECOLUMN") {
  473. return MessageLocalizer.getMessage("RANGE_COLUMN_CHART_STR");
  474. } else if (toolbarAction == "IDM_CHART_RADAR") {
  475. return MessageLocalizer.getMessage("RADAR_CHART_STR");
  476. } else if (toolbarAction == "IDM_CHART_POLAR") {
  477. return MessageLocalizer.getMessage("POLAR_CHART_STR");
  478. } else if (toolbarAction == "IDM_CHART_BOXPLOT") {
  479. return MessageLocalizer.getMessage("BOX_PLOT_CHART_STR");
  480. } else if (toolbarAction == "IDM_CHART_FUNNEL") {
  481. return MessageLocalizer.getMessage("FUNNEL_CHART_STR");
  482. } else if (toolbarAction == "IDM_CHART_PYRAMID") {
  483. return MessageLocalizer.getMessage("PYRAMID_CHART_STR");
  484. } else if (toolbarAction == "IDM_RESET_DATA") {
  485. return MessageLocalizer.getMessage("RESET_DATA_STR");
  486. } else if (toolbarAction == "IDM_SANDBOX_UNDO") {
  487. return MessageLocalizer.getMessage("UNDO_TOOLTIP_STR");
  488. } else if (toolbarAction == "IDM_SANDBOX_REDO") {
  489. return MessageLocalizer.getMessage("REDO_TOOLTIP_STR");
  490. } else if (toolbarAction == "IDM_SANDBOX") {
  491. return MessageLocalizer.getMessage("SANDBOX_TOOLTIP_STR");
  492. } else if (toolbarAction == "IDM_CREATE_SANDBOX") {
  493. return MessageLocalizer.getMessage("CREATE_SANDBOX_STR");
  494. } else if (toolbarAction == "IDM_DELETE_SANDBOX") {
  495. return MessageLocalizer.getMessage("DELETE_SANDBOX_STR");
  496. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  497. if (this.sandboxNames) {
  498. return this.sandboxNames.currentSandbox;
  499. } else {
  500. return "[Base]";
  501. }
  502. }
  503. return "";
  504. },
  505. getToolbuttonImage: function(toolbarAction) {
  506. if (toolbarAction == "IDM_CHARTTYPE") {
  507. return "tm1-toolbar-chart-select";
  508. } else if (toolbarAction == "IDM_CHART_POINT") {
  509. return "tm1-toolbar-chart-point";
  510. } else if (toolbarAction == "IDM_CHART_BUBBLE") {
  511. return "tm1-toolbar-chart-bubble";
  512. } else if (toolbarAction == "IDM_CHART_LINE") {
  513. return "tm1-toolbar-chart-line";
  514. } else if (toolbarAction == "IDM_CHART_SPLINE") {
  515. return "tm1-toolbar-chart-spline";
  516. } else if (toolbarAction == "IDM_CHART_STEPLINE") {
  517. return "tm1-toolbar-chart-stepline";
  518. } else if (toolbarAction == "IDM_CHART_FASTLINE") {
  519. return "tm1-toolbar-chart-fastline";
  520. } else if (toolbarAction == "IDM_CHART_BAR") {
  521. return "tm1-toolbar-chart-bar";
  522. } else if (toolbarAction == "IDM_CHART_STACKEDBAR") {
  523. return "tm1-toolbar-chart-stackedbar";
  524. } else if (toolbarAction == "IDM_CHART_STACKEDBAR100") {
  525. return "tm1-toolbar-chart-stackedbar100";
  526. } else if (toolbarAction == "IDM_CHART_COLUMN") {
  527. return "tm1-toolbar-chart-column";
  528. } else if (toolbarAction == "IDM_CHART_STACKEDCOLUMN") {
  529. return "tm1-toolbar-chart-stackedcolumn";
  530. } else if (toolbarAction == "IDM_CHART_STACKEDCOLUMN100") {
  531. return "tm1-toolbar-chart-stackedcolumn100";
  532. } else if (toolbarAction == "IDM_CHART_AREA") {
  533. return "tm1-toolbar-chart-area";
  534. } else if (toolbarAction == "IDM_CHART_SPLINEAREA") {
  535. return "tm1-toolbar-chart-splinearea";
  536. } else if (toolbarAction == "IDM_CHART_STACKEDAREA") {
  537. return "tm1-toolbar-chart-stackedarea";
  538. } else if (toolbarAction == "IDM_CHART_STACKEDAREA100") {
  539. return "tm1-toolbar-chart-stackedarea100";
  540. } else if (toolbarAction == "IDM_CHART_PIE") {
  541. return "tm1-toolbar-chart-pie";
  542. } else if (toolbarAction == "IDM_CHART_DOUGHNUT") {
  543. return "tm1-toolbar-chart-doughnut";
  544. } else if (toolbarAction == "IDM_CHART_STOCK") {
  545. return "tm1-toolbar-chart-stock";
  546. } else if (toolbarAction == "IDM_CHART_CANDLESTICK") {
  547. return "tm1-toolbar-chart-candlestick";
  548. } else if (toolbarAction == "IDM_CHART_RANGE") {
  549. return "tm1-toolbar-chart-range";
  550. } else if (toolbarAction == "IDM_CHART_SPLINERANGE") {
  551. return "tm1-toolbar-chart-splinerange";
  552. } else if (toolbarAction == "IDM_CHART_GANTT") {
  553. return "tm1-toolbar-chart-gantt";
  554. } else if (toolbarAction == "IDM_CHART_RANGECOLUMN") {
  555. return "tm1-toolbar-chart-rangecolumn";
  556. } else if (toolbarAction == "IDM_CHART_RADAR") {
  557. return "tm1-toolbar-chart-radar";
  558. } else if (toolbarAction == "IDM_CHART_POLAR") {
  559. return "tm1-toolbar-chart-polar";
  560. } else if (toolbarAction == "IDM_CHART_BOXPLOT") {
  561. return "tm1-toolbar-chart-boxplot";
  562. } else if (toolbarAction == "IDM_CHART_FUNNEL") {
  563. return "tm1-toolbar-chart-funnel";
  564. } else if (toolbarAction == "IDM_CHART_PYRAMID") {
  565. return "tm1-toolbar-chart-pyramid";
  566. } else if (toolbarAction == "IDM_SLICE_TO_EXCEL") {
  567. return "tm1-toolbar-slice-excel2";
  568. } else if (toolbarAction == "IDM_SNAPSHOT_TO_EXCEL") {
  569. return "tm1-toolbar-slice-snapshot";
  570. } else if (toolbarAction == "IDM_EXPORT_TO_PDF") {
  571. return "tm1-toolbar-slice-pdf";
  572. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS") {
  573. if (this.app.GetSuppressZerosInfo().both == true) {
  574. return "tm1-toolbar-suppress-zeros dijitToggleButtonChecked";
  575. } else if (this.app.GetSuppressZerosInfo().row == true) {
  576. return "tm1-toolbar-suppress-zeros-on-rows dijitToggleButtonChecked";
  577. } else if (this.app.GetSuppressZerosInfo().column == true) {
  578. return "tm1-toolbar-suppress-zeros-on-columns dijitToggleButtonChecked";
  579. } else {
  580. return "tm1-toolbar-suppress-zeros";
  581. }
  582. } else if (toolbarAction == "IDM_COMMIT") {
  583. if (this.isToolbuttonDisabled("IDM_COMMIT")) {
  584. return "tm1-toolbar-apply disabled-toolbutton";
  585. } else {
  586. return "tm1-toolbar-apply";
  587. }
  588. } else if (toolbarAction == "IDM_SAVEVIEW") {
  589. if (this.isToolbuttonDisabled("IDM_SAVEVIEW")) {
  590. return "tm1-toolbar-save-view disabled-toolbutton";
  591. } else {
  592. return "tm1-toolbar-save-view";
  593. }
  594. } else if (toolbarAction == "IDM_SAVEAS") {
  595. if (this.isToolbuttonDisabled("IDM_SAVEAS")) {
  596. return "tm1-toolbar-save-view-as disabled-toolbutton";
  597. } else {
  598. return "tm1-toolbar-save-view-as";
  599. }
  600. } else if (toolbarAction == "IDM_EXPORT") {
  601. if (this.isToolbuttonDisabled("IDM_EXPORT")) {
  602. return "tm1-toolbar-export disabled-toolbutton";
  603. } else {
  604. return "tm1-toolbar-export";
  605. }
  606. } else if (toolbarAction == "IDM_SAVEDATACHANGES") {
  607. if (this.isToolbuttonDisabled("IDM_SAVEDATACHANGES")) {
  608. return "tm1-toolbar-save_data_changes disabled-toolbutton";
  609. } else {
  610. return "tm1-toolbar-save_data_changes";
  611. }
  612. } else if (toolbarAction == "IDM_REVIEWDATACHANGES") {
  613. if (this.isToolbuttonDisabled("IDM_REVIEWDATACHANGES")) {
  614. return "tm1-toolbar-review_data_changes disabled-toolbutton";
  615. } else {
  616. return "tm1-toolbar-review_data_changes";
  617. }
  618. } else if (toolbarAction == "IDM_RECALCULATE") {
  619. if (this.isToolbuttonDisabled("IDM_RECALCULATE")) {
  620. return "tm1-toolbar-recalculate disabled-toolbutton";
  621. } else {
  622. return "tm1-toolbar-recalculate";
  623. }
  624. } else if (toolbarAction == "IDM_REBUILDACTIVEFORMS") {
  625. // if (!this.isToolbuttonDisabled("IDM_REBUILDACTIVEFORMS")) {
  626. return "tm1-toolbar-rebuild_active_forms";
  627. // } else {
  628. // return "tm1-toolbar-rebuild_active_forms disabled-toolbutton";
  629. // }
  630. } else if (toolbarAction == "IDM_AUTO_FIT_COL") {
  631. // if (this.tm1Toolbar.ToolbarInfo.AutoRecalcButton.IsEnabled) {
  632. return "tm1-toolbar-auto-fit-col";
  633. // } else {
  634. // return "tm1-toolbar-auto-fit-col disabled-toolbutton";
  635. // }
  636. } else if (toolbarAction == "IDM_ZOOM_IN") {
  637. // if (this.tm1Toolbar.ToolbarInfo.ZoomInButton.IsEnabled) {
  638. return "tm1-toolbar-zoom-in";
  639. // } else {
  640. // return "tm1-toolbar-zoom-in disabled-toolbutton";
  641. // }
  642. } else if (toolbarAction == "IDM_ZOOM_OUT") {
  643. // if (this.tm1Toolbar.ToolbarInfo.ZoomOutButton.IsEnabled) {
  644. return "tm1-toolbar-zoom-out";
  645. // } else {
  646. // return "tm1-toolbar-zoom-out disabled-toolbutton";
  647. // }
  648. } else if (toolbarAction == "IDM_ZOOM_NORMAL") {
  649. // if (this.tm1Toolbar.ToolbarInfo.NormalViewButton.IsEnabled) {
  650. return "tm1-toolbar-zoom-normal";
  651. // } else {
  652. // return "tm1-toolbar-zoom-normal disabled-toolbutton";
  653. // }
  654. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS_COLUMNS") {
  655. if (this.app.GetSuppressZerosInfo().both == true) {
  656. return "tm1-menu-radioselection";
  657. }
  658. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_ROWS") {
  659. if ((this.app.GetSuppressZerosInfo().row == true) ||
  660. (this.app.GetSuppressZerosInfo().both == true)) {
  661. return "tm1-menu-radioselection";
  662. }
  663. } else if (toolbarAction == "IDM_SUPPRESS_ZEROS_COLUMNS") {
  664. if ((this.app.GetSuppressZerosInfo().column == true) ||
  665. (this.app.GetSuppressZerosInfo().both == true)) {
  666. return "tm1-menu-radioselection";
  667. }
  668. } else if (toolbarAction == "IDM_CHART") {
  669. if (this.app && this.cubeViewState && this.cubeViewState.displayMode == "Chart") {
  670. return "tm1-toolbar-chart_only dijitToggleButtonChecked";
  671. } else {
  672. return "tm1-toolbar-chart_only";
  673. }
  674. } else if (toolbarAction == "IDM_CHARTANDGRID") {
  675. if (this.app && this.cubeViewState && this.cubeViewState.displayMode == "GridAndChart") {
  676. return "tm1-toolbar-chart-grid dijitToggleButtonChecked";
  677. } else {
  678. return "tm1-toolbar-chart-grid";
  679. }
  680. } else if (toolbarAction == "IDM_GRID") {
  681. if (this.app && this.cubeViewState && this.cubeViewState.displayMode == "Grid") {
  682. return "tm1-toolbar-grid_only dijitToggleButtonChecked";
  683. } else {
  684. return "tm1-toolbar-grid_only";
  685. }
  686. } else if (toolbarAction == "IDM_CHART-SELECT") {
  687. if (this.isToolbuttonDisabled("IDM_CHART-SELECT")) {
  688. return "tm1-toolbar-chart-select_type disabled-toolbutton";
  689. } else {
  690. return "tm1-toolbar-chart-select_type";
  691. }
  692. } else if (toolbarAction == "IDM_RESET_DATA") {
  693. if (this.isToolbuttonDisabled("IDM_RESET_DATA")) {
  694. return "tm1-toolbar-sandbox-reset disabled-toolbutton";
  695. } else {
  696. return "tm1-toolbar-sandbox-reset";
  697. }
  698. } else if (toolbarAction == "IDM_SANDBOX_UNDO") {
  699. if (this.isToolbuttonDisabled("IDM_SANDBOX_UNDO")) {
  700. return "tm1-toolbar-sandbox-undo disabled-toolbutton";
  701. } else {
  702. return "tm1-toolbar-sandbox-undo";
  703. }
  704. } else if (toolbarAction == "IDM_SANDBOX_REDO") {
  705. if (this.isToolbuttonDisabled("IDM_SANDBOX_REDO")) {
  706. return "tm1-toolbar-sandbox-redo disabled-toolbutton";
  707. } else {
  708. return "tm1-toolbar-sandbox-redo";
  709. }
  710. } else if (toolbarAction == "IDM_SANDBOX") {
  711. if (this.isToolbuttonDisabled("IDM_SANDBOX")) {
  712. return "tm1-toolbar-sandbox-select disabled-toolbutton";
  713. } else {
  714. return "tm1-toolbar-sandbox-select";
  715. }
  716. } else if (toolbarAction == "IDM_CREATE_SANDBOX") {
  717. return "tm1-toolbar-sandbox-new";
  718. } else if (toolbarAction == "IDM_DELETE_SANDBOX") {
  719. return "tm1-toolbar-sandbox-delete";
  720. } else if (toolbarAction == "IDM_SANDBOXITEMS") {
  721. return null;
  722. }
  723. return "tm1-toolbar-empty";
  724. },
  725. //
  726. areTM1ParametersValid: function () {
  727. var bParametersAreValid = true;
  728. if (this.tm1Cube == "") {
  729. bParametersAreValid = false;
  730. } else if (this.tm1Host == "") {
  731. bParametersAreValid = false;
  732. } else if (this.tm1Server == "") {
  733. bParametersAreValid = false;
  734. } else if (this.tm1CubeView == "") {
  735. bParametersAreValid = false;
  736. }
  737. if (!bParametersAreValid) {
  738. console.log (this.tm1Cube);
  739. console.log (this.tm1Host);
  740. console.log (this.tm1Server);
  741. console.log (this.tm1CubeView);
  742. }
  743. return bParametersAreValid == true;
  744. },
  745. getWidgetAttributes : function (){
  746. this.tm1WebURL = this.iContext.getiWidgetAttributes().getItemValue("tm1WebURL");
  747. this.tm1Host = this.iContext.getiWidgetAttributes().getItemValue("tm1Host");
  748. this.tm1Server = this.iContext.getiWidgetAttributes().getItemValue("tm1Server");
  749. this.tm1CubeView = this.iContext.getiWidgetAttributes().getItemValue("tm1CubeView");
  750. this.tm1UserName = this.iContext.getiWidgetAttributes().getItemValue("tm1UserName");
  751. this.tm1Password = this.iContext.getiWidgetAttributes().getItemValue("tm1Password");
  752. this.filterPackages = this.iContext.getiWidgetAttributes().getItemValue("FilterPackages");
  753. this.tm1Height = this.iContext.getiWidgetAttributes().getItemValue("tHeight");
  754. this.tm1Width = this.iContext.getiWidgetAttributes().getItemValue("tWidth");
  755. this.tm1FiltersToSetPayload = eval ("(" + this.iContext.getiWidgetAttributes().getItemValue("filtersToSetPayload") + ")");
  756. if (this.tm1UserName == null || this.tm1UserName.length == 0) {
  757. var cookieValue = dojo.cookie("cam_passport");
  758. if (cookieValue && cookieValue.length > 0) {
  759. this.tm1Password = cookieValue;
  760. }
  761. }
  762. this.loadWithAttributes();
  763. this._firstVisible = true;
  764. },
  765. refreshView : function () {
  766. if (this.cantLoadDojo) {
  767. if (this.iframeCtrlCantLoadDojo) {
  768. this.iframeCtrlCantLoadDojo.setUrl(this.getIFrameUrl()); //
  769. } else {
  770. var widgetTitle = "widgetTitle";
  771. var domObject = this.iContext.getElementById("_" + this.iContext.widgetId + "_" + "widgetFrame");
  772. this.iframeCtrlCantLoadDojo = new tm1.iwidget.utilities.IFrame({
  773. url: this.getIFrameUrl(), //
  774. frameTitle: widgetTitle
  775. }, domObject);
  776. this.iframeCtrlCantLoadDojo.startup();
  777. }
  778. this.createBasicWidgetToolbar();
  779. } else { var identity={host:this.tm1Host,userName:this.tm1UserName,password:this.tm1Password,serverName:this.tm1Server,webSheet:this.tm1CubeView};
  780. if (this._exportContainer == null) {
  781. this._exportContainer = new dijit.layout.BorderContainer({ gutters: false }, dojo.byId("_" + this.iContext.widgetId + "_" + "widgetFrame2"));
  782. this._exportContainer.download = function (url, frameId) {
  783. var webUrl = this.webUrl + "/tm1web/" + url;
  784. var hiddenFrame = dojo.byId(frameId);
  785. if (hiddenFrame == null) {
  786. hiddenFrame = dojo.create("iframe", { id: frameId });
  787. dojo.style(hiddenFrame, { display: "none" });
  788. document.body.appendChild(hiddenFrame);
  789. }
  790. hiddenFrame.src = webUrl;
  791. };
  792. this._exportContainer.webUrl = this.webUrl;
  793. dojo.addClass(this._exportContainer.domNode, " downloadParent");
  794. }
  795. var createPromise = null;
  796. dojo.ready(dojo.hitch(this, function(){
  797. // Workbooker needs to be visible when loading, so load offscreen.
  798. var div = dojo.create("div", {
  799. style: "width: 750px; height: 750px; top: -1000px; position: absolute"
  800. }, document.body);
  801. this.app = new Workbooker(div, identity, true);
  802. createPromise = this.app.create();
  803. createPromise.then(dojo.hitch(this, function() {
  804. document.body.removeChild(div);
  805. var style = div.style;
  806. style.postition = "";
  807. style.top = "";
  808. style.width = "100%";
  809. style.height = "100%";
  810. dojo.place(div, dojo.byId("_" + this.iContext.widgetId + "_" + "widgetFrame"));
  811. this.app.resize();
  812. this.createCompleteCallback();
  813. }));
  814. }));
  815. }
  816. },
  817. refreshMore : function () {
  818. if (this.app != null) {
  819. if (this.subscribeToActiveSheetChangedNotifications) {
  820. this.app.unsubscribeFromActiveSheetChangedNotifications(this.subscribeToActiveSheetChangedNotifications);
  821. }
  822. if (this.subscriptionHandle) {
  823. this.app.unsubscribeFromStateChangeUpdates(this.subscriptionHandle);
  824. }
  825. this.app.dispose();
  826. this.app = null;
  827. }
  828. if (this.iframeCtrl ) {
  829. this.iframeCtrl.setUrl( this.getIFrameUrl());// + "&ObjectId=" + this.widg1.getObjectId());
  830. } else {
  831. var widgetTitle = "widgetTitle";
  832. this.iframeCtrl = new tm1.iwidget.utilities.IFrame({
  833. url: this.getIFrameUrl(),// + "&ObjectId=" + this.widg1.getObjectId(),
  834. frameTitle: widgetTitle
  835. }, this.iContext.getElementById("_" + this.iContext.widgetId + "_" + "widgetFrameA"));
  836. this.iframeCtrl.startup();
  837. }
  838. },
  839. getIFrameUrl: function () {
  840. return this.tm1WebURL + "/TM1WebWebSheeter.jsp?WebSheet=" + this.tm1CubeView + "&ServerName=" + this.tm1Server + "&HostName=" + this.tm1Host + "&UserName=" + this.tm1UserName + "&Password=" + ((this.tm1Password == null) ? "" : this.tm1Password) + "&AccessType=" + this.tm1AccessType;
  841. },
  842. createCompleteCallback: function (value)
  843. {
  844. if (!this.inDoMore) {
  845. //this.app.toggleDimensionBar(true);
  846. this.createWidgetToolbar();
  847. }
  848. if (this.subscribeToActiveSheetChangedNotifications) {
  849. try {
  850. this.app.unsubscribeFromActiveSheetChangedNotifications(this.subscribeToActiveSheetChangedNotifications);
  851. } catch (error) {}
  852. }
  853. try {
  854. this.subscribeToActiveSheetChangedNotifications = this.app.subscribeToActiveSheetChangedNotifications(dojo.hitch(this, this.getActiveSheetChangesCallback));
  855. } catch (error) {
  856. this.subscribeToActiveSheetChangedNotifications = null;
  857. }
  858. this.getActiveSheetChangesCallback(""); // may not be needed
  859. if (this.subscriptionHandle) {
  860. try {
  861. this.app.unsubscribeFromStateChangeUpdates(this.subscriptionHandle);
  862. } catch (error) {}
  863. }
  864. try {
  865. this.subscriptionHandle = this.app.subscribeToStateChangeUpdates(dojo.hitch(this, this.getCubeViewStateCallback));
  866. } catch (error) {
  867. this.subscriptionHandle = null;;
  868. }
  869. },
  870. getActiveSheetChangesCallback: function (value)
  871. {
  872. var dimensionNamePromise = this.app.getDimensionNames();
  873. dimensionNamePromise.promise.then(dojo.hitch(this, function (inDimensionNames) {
  874. this.dimensionNames=inDimensionNames;
  875. this.elementNameCounter = 0;
  876. this.elementNames = [];
  877. if (inDimensionNames != null && inDimensionNames.length > 0) {
  878. var elementsPromise = this.app.getElementNames(this.dimensionNames[0]);
  879. elementsPromise.promise.then( dojo.hitch(this, this.getElementNamesCallback));
  880. }
  881. }));
  882. },
  883. onView: function(iEvent) {
  884. if (this.inDoMore) {
  885. this.inDoMore = false;
  886. this.refreshView();
  887. }
  888. },
  889. onEdit: function(iEvent) {
  890. this.refreshView();
  891. // example of a toolbar for edit mode
  892. this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, [{
  893. label: "Edit action",
  894. iconClass: "bux-toolbar-button-edit",
  895. action: "action.edit"
  896. }]);
  897. },
  898. onMore: function(iEvent) {
  899. if (!this.inDoMore) {
  900. this.inDoMore = true;
  901. this.refreshMore();
  902. }
  903. // example of a toolbar for more mode (not supported by BUX right now)
  904. // this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, [{
  905. // label: "More action",
  906. // iconClass: "bux-toolbar-button-more",
  907. // action: "action.more"
  908. // }]);
  909. },
  910. // ui actions
  911. doMode: function(mode) {
  912. // switch back to view mode
  913. this.iContext.iEvents.fireEvent("onModeChanged", null, {
  914. newMode: mode
  915. });
  916. },
  917. onModeChanged: function (mode) {
  918. },
  919. onToolbarAction: function(evt)
  920. {
  921. if (evt.payload == "IDM_RESTART") {
  922. if (this.app != null) {
  923. if (this.subscribeToActiveSheetChangedNotifications) {
  924. this.app.unsubscribeFromActiveSheetChangedNotifications(this.subscribeToActiveSheetChangedNotifications);
  925. }
  926. if (this.subscriptionHandle) {
  927. this.app.unsubscribeFromStateChangeUpdates(this.subscriptionHandle);
  928. }
  929. this.app.dispose();
  930. this.app = null;
  931. }
  932. this.refreshView();
  933. } else if (this.app == null) {
  934. return;
  935. } else if (evt.payload == "IDM_RESET") {
  936. this.app.resetView ();
  937. } else if (evt.payload == "IDM_COMMIT") {
  938. this.app.commitSandbox();
  939. } else if (evt.payload == "IDM_SAVEVIEW") {
  940. alert ("not implemented yet");
  941. } else if (evt.payload == "IDM_SAVEAS") {
  942. alert ("not implemented yet");
  943. } else if (evt.payload == "IDM_SAVEDATACHANGES") {
  944. this.app.saveData();
  945. } else if (evt.payload == "IDM_REVIEWDATACHANGES") {
  946. alert ("not implemented yet");
  947. } else if (evt.payload == "IDM_RECALCULATE") {
  948. this.app.recalculate();
  949. } else if (evt.payload == "IDM_REBUILDACTIVEFORMS") {
  950. this.app.rebuildActiveForms();
  951. } else if (evt.payload == "IDM_AUTO_FIT_COL") {
  952. this.app.autoFitSelectedColumns();
  953. } else if (evt.payload == "IDM_SLICE_TO_EXCEL") {
  954. this.app.displayExportOptions("SLICE");
  955. } else if (evt.payload == "IDM_SNAPSHOT_TO_EXCEL") {
  956. this.app.displayExportOptions("SNAPSHOT");
  957. } else if (evt.payload == "IDM_EXPORT_TO_PDF") {
  958. this.app.displayExportOptions("PRINTTOPDF");
  959. } else if (evt.payload == "IDM_SUPPRESS_ZEROS_ROWS_COLUMNS") {
  960. this.app.SuppressZerosBoth();
  961. this.createWidgetToolbar();
  962. } else if (evt.payload == "IDM_SUPPRESS_ZEROS_ROWS") {
  963. this.app.SuppressZerosRows();
  964. this.createWidgetToolbar();
  965. } else if (evt.payload == "IDM_SUPPRESS_ZEROS_COLUMNS") {
  966. this.app.SuppressZerosCols();
  967. this.createWidgetToolbar();
  968. } else if (evt.payload == "IDM_CHART") {
  969. this.app.ChangeDisplayMode("Chart");
  970. } else if (evt.payload == "IDM_CHARTANDGRID") {
  971. this.app.ChangeDisplayMode("GridAndChart");
  972. } else if (evt.payload == "IDM_GRID") {
  973. this.app.ChangeDisplayMode("Grid");
  974. } else if (evt.payload == "IDM_CHART_POINT") {
  975. this.app.ChartTypeChanged(0);
  976. } else if (evt.payload == "IDM_CHART_BUBBLE") {
  977. this.app.ChartTypeChanged(1);
  978. } else if (evt.payload == "IDM_CHART_LINE") {
  979. this.app.ChartTypeChanged(2);
  980. } else if (evt.payload == "IDM_CHART_SPLINE") {
  981. this.app.ChartTypeChanged(3);
  982. } else if (evt.payload == "IDM_CHART_STEPLINE") {
  983. this.app.ChartTypeChanged(4);
  984. } else if (evt.payload == "IDM_CHART_FASTLINE") {
  985. this.app.ChartTypeChanged(5);
  986. } else if (evt.payload == "IDM_CHART_BAR") {
  987. this.app.ChartTypeChanged(6);
  988. } else if (evt.payload == "IDM_CHART_STACKEDBAR") {
  989. this.app.ChartTypeChanged(7);
  990. } else if (evt.payload == "IDM_CHART_STACKEDBAR100") {
  991. this.app.ChartTypeChanged(8);
  992. } else if (evt.payload == "IDM_CHART_COLUMN") {
  993. this.app.ChartTypeChanged(9);
  994. } else if (evt.payload == "IDM_CHART_STACKEDCOLUMN") {
  995. this.app.ChartTypeChanged(10);
  996. } else if (evt.payload == "IDM_CHART_STACKEDCOLUMN100") {
  997. this.app.ChartTypeChanged(11);
  998. } else if (evt.payload == "IDM_CHART_AREA") {
  999. this.app.ChartTypeChanged(12);
  1000. } else if (evt.payload == "IDM_CHART_SPLINEAREA") {
  1001. this.app.ChartTypeChanged(13);
  1002. } else if (evt.payload == "IDM_CHART_STACKEDAREA") {
  1003. this.app.ChartTypeChanged(14);
  1004. } else if (evt.payload == "IDM_CHART_STACKEDAREA100") {
  1005. this.app.ChartTypeChanged(15);
  1006. } else if (evt.payload == "IDM_CHART_PIE") {
  1007. this.app.ChartTypeChanged(16);
  1008. } else if (evt.payload == "IDM_CHART_DOUGHNUT") {
  1009. this.app.ChartTypeChanged(17);
  1010. } else if (evt.payload == "IDM_CHART_STOCK") {
  1011. this.app.ChartTypeChanged(18);
  1012. } else if (evt.payload == "IDM_CHART_CANDLESTICK") {
  1013. this.app.ChartTypeChanged(19);
  1014. } else if (evt.payload == "IDM_CHART_RANGE") {
  1015. this.app.ChartTypeChanged(20);
  1016. } else if (evt.payload == "IDM_CHART_SPLINERANGE") {
  1017. this.app.ChartTypeChanged(21);
  1018. } else if (evt.payload == "IDM_CHART_GANTT") {
  1019. this.app.ChartTypeChanged(22);
  1020. } else if (evt.payload == "IDM_CHART_RANGECOLUMN") {
  1021. this.app.ChartTypeChanged(23);
  1022. } else if (evt.payload == "IDM_CHART_RADAR") {
  1023. this.app.ChartTypeChanged(24);
  1024. } else if (evt.payload == "IDM_CHART_POLAR") {
  1025. this.app.ChartTypeChanged(25);
  1026. } else if (evt.payload == "IDM_CHART_BOXPLOT") {
  1027. this.app.ChartTypeChanged(26);
  1028. } else if (evt.payload == "IDM_CHART_FUNNEL") {
  1029. this.app.ChartTypeChanged(27);
  1030. } else if (evt.payload == "IDM_CHART_PYRAMID") {
  1031. this.app.ChartTypeChanged(28);
  1032. } else if (evt.payload == "IDM_RESET_DATA") {
  1033. this.app.resetData();
  1034. } else if (evt.payload == "IDM_SANDBOX_UNDO") {
  1035. this.app.undo();
  1036. } else if (evt.payload == "IDM_SANDBOX_REDO") {
  1037. this.app.redo();
  1038. } else if (evt.payload == "IDM_CREATE_SANDBOX") {
  1039. this.app.createSandbox();
  1040. } else if (evt.payload == "IDM_DELETE_SANDBOX") {
  1041. this.app.deleteSandboxes();
  1042. } else if (evt.payload.substring(0, 13) == "SANDBOXCHOICE") {
  1043. var sandBoxId = evt.payload.substring(13, evt.payload.length);
  1044. if (sandBoxId == 0) {
  1045. this.app.setActiveSandbox("[Base]");
  1046. } else {
  1047. this.app.setActiveSandbox(this.sandboxNames.sandboxes[sandBoxId].name);
  1048. }
  1049. }
  1050. },
  1051. getCubeViewStateCallback: function ( inCubeViewState) {
  1052. this.cubeViewState = inCubeViewState;
  1053. var sandboxPromise = this.app.getSandboxes();
  1054. sandboxPromise.then(dojo.hitch(this, this.getSandboxNamesCallback));
  1055. },
  1056. getSandboxNamesCallback: function( inSandboxNames ) {
  1057. this.sandboxNames = inSandboxNames;
  1058. this.createWidgetToolbar();
  1059. },
  1060. getElementNamesCallback: function( elements ) {
  1061. this.elementNames[this.elementNameCounter++] = elements;
  1062. if (this.elementNameCounter < this.dimensionNames.length) {
  1063. var elementsPromise = this.app.getElementNames(this.dimensionNames[this.elementNameCounter]);
  1064. elementsPromise.promise.then( dojo.hitch(this, this.getElementNamesCallback ) );
  1065. } else {
  1066. this.setExistingFilters();
  1067. }
  1068. },
  1069. setExistingFilters: function () {
  1070. if (this.tm1FiltersToSetPayload != null) {
  1071. for (var filters = 0; filters < this.tm1FiltersToSetPayload.length; filters++) {
  1072. try {
  1073. var filterPayload = this.tm1FiltersToSetPayload[filters];
  1074. var selectValueControl = this.tm1FiltersToSetPayload[filters]["com.ibm.widget.context.bux.selectValueControl"].selectValueControl;
  1075. var itemSpecification = "/content/package[@name='" + this.filterPackages + "']";
  1076. var itemSpec2 = this.tm1FiltersToSetPayload[filters]["com.ibm.widget.context.bux.selectValueControl"].selectValueControl.itemSpecification[itemSpecification];
  1077. var correctDimName = null;
  1078. for (var i = 0; i < this.dimensionNames.length; i++) {
  1079. correctDimName = itemSpec2[this.dimensionNames[i]];
  1080. if (correctDimName != null) {
  1081. break;
  1082. }
  1083. }
  1084. if (correctDimName != null) {
  1085. var itemSpec3 = correctDimName.values[0].mun;
  1086. this.app.filterElement(itemSpec3);
  1087. }
  1088. } catch (err) { }
  1089. }
  1090. // this.filtersToSetPayload = null;
  1091. }
  1092. },
  1093. onGetCanvasContextDone: function (evt) {
  1094. if (evt != null && typeof evt != "undefined" && evt.payload && evt.payload.length != 0) {
  1095. this.tm1FiltersToSetPayload = evt.payload;
  1096. var filterPayload = (evt.type == "string" ? evt.payload : dojo.toJson(evt.payload));
  1097. this.iContext.getiWidgetAttributes().setItemValue("filtersToSetPayload", filterPayload);
  1098. }
  1099. },
  1100. getElementNameFromMUN: function(mun) {
  1101. var positionInMUN = ".[";
  1102. var indexInMUN = mun.lastIndexOf(positionInMUN);
  1103. var elementName = mun.substring(indexInMUN + positionInMUN.length);
  1104. elementName = elementName.substring(0, elementName.indexOf("]"));
  1105. return elementName;
  1106. },
  1107. getMUN: function(dimensionName, elementName) {
  1108. // { caption: "Europe", mun: "[plan_BudgetPlan].[plan_business_unit].[plan_business_unit]->:[TM].[plan_business_unit].[plan_business_unit].[@Member].[Europe]" },
  1109. var mun = "[";
  1110. mun += this.iContext.getiWidgetAttributes().getItemValue("tm1CubeView");
  1111. mun += "].[";
  1112. mun += dimensionName;
  1113. mun += "].[";
  1114. mun += dimensionName;
  1115. mun += "]->:[TM].[";
  1116. mun += dimensionName;
  1117. mun += "].[";
  1118. mun += dimensionName;
  1119. mun += "].[@MEMBER].[";
  1120. mun += elementName;
  1121. mun += "]";
  1122. return mun;
  1123. },
  1124. createMunFromFacet: function(facetMun) {
  1125. // { caption: "Europe", mun: "[plan_BudgetPlan].[plan_business_unit].[plan_business_unit]->:[TM].[plan_business_unit].[plan_business_unit].[@Member].[Europe]" },
  1126. var lastOpenBracketIndex = facetMun.lastIndexOf("[");
  1127. var elementName = facetMun.substring(lastOpenBracketIndex);
  1128. elementName = elementName.substring(1, elementName.length - 1);
  1129. var dimensionName = facetMun.substring(1, lastOpenBracketIndex - 2);
  1130. var mun = "[";
  1131. mun += this.iContext.getiWidgetAttributes().getItemValue("tm1CubeView");
  1132. mun += "].[";
  1133. mun += dimensionName;
  1134. mun += "].[";
  1135. mun += dimensionName;
  1136. mun += "]->:[TM].[";
  1137. mun += dimensionName;
  1138. mun += "].[";
  1139. mun += dimensionName;
  1140. mun += "].[@MEMBER].[";
  1141. mun += elementName;
  1142. mun += "]";
  1143. return mun;
  1144. },
  1145. onFilter: function(evt) {
  1146. if( evt != null && typeof evt != "undefined" && this.app != null) {
  1147. var parms = eval("(" + evt.payload + ")");
  1148. this.app.filterElement(parms.values[0].values[0].mun);
  1149. }
  1150. },
  1151. onGenericSelectValueControl: function(evt) {
  1152. if( evt != null && typeof evt != "undefined" && this.app != null) {
  1153. try {
  1154. var filterPayload = (evt.type=="string" ? evt.payload : dojo.toJson(evt.payload));
  1155. var selectValueControl = evt.payload["com.ibm.widget.context.bux.selectValueControl"].selectValueControl;
  1156. var itemSpecification = "/content/package[@name='" + this.filterPackages + "']";
  1157. var itemSpec2 = evt.payload["com.ibm.widget.context.bux.selectValueControl"].selectValueControl.itemSpecification[itemSpecification];
  1158. var correctDimName = null;
  1159. for (var i = 0; i < this.dimensionNames.length; i++) {
  1160. correctDimName = itemSpec2[this.dimensionNames[i]];
  1161. if (correctDimName != null)
  1162. {
  1163. break;
  1164. }
  1165. }
  1166. var itemSpec3 = correctDimName.values[0].mun;
  1167. this.app.filterElement(itemSpec3);
  1168. } catch (err) {}
  1169. }
  1170. },
  1171. onGetFilterableItems: function( evt )
  1172. {
  1173. var payload = { "invisible": {}, "visible": {}};
  1174. if (this.dimensionNames != null && this.elementNames != null && this.elementNames[0] != null) {
  1175. var visibleDimensions = [];
  1176. for (var i=0;i<this.dimensionNames.length;i++) {
  1177. visibleDimensions[i] = { "name": this.dimensionNames[i]};
  1178. }
  1179. payload.visible = visibleDimensions;
  1180. }
  1181. this.iContext.iEvents.fireEvent("com.ibm.bux.filter.items.get.done", null, payload);
  1182. },
  1183. getDimensionIndex: function (dimensionName)
  1184. {
  1185. var result = -1;
  1186. if (this.dimensionNames != null) {
  1187. for (var i=0; i < this.dimensionNames.length; i++) {
  1188. if (dimensionName == this.dimensionNames[i]) {
  1189. result = i;
  1190. break;
  1191. }
  1192. }
  1193. }
  1194. return result;
  1195. },
  1196. onGetFilterValues: function( evt )
  1197. {
  1198. // mun [plan_BudgetPlan].[plan_chart_of_accounts].[plan_chart_of_accounts]->:[TM].[plan_chart_of_accounts].[plan_chart_of_accounts].[@MEMBER].[Revenue]
  1199. var filterDimension = evt.payload.payload.name;
  1200. var pathInfo = "/content/package[@name='" + this.filterPackages + "']";
  1201. var payload = {
  1202. name: filterDimension,
  1203. modelInfo: { path: pathInfo },
  1204. values: []
  1205. };
  1206. var dimensionIndex = this.getDimensionIndex (filterDimension);
  1207. if (dimensionIndex > -1) {
  1208. for (var i=0; i < this.elementNames[dimensionIndex].length; i++) {
  1209. payload.values[i] = { caption: this.elementNames[dimensionIndex][i].alias, modelInfo: { path: pathInfo}, mun: this.getMUN(filterDimension,this.elementNames[dimensionIndex][i].name) };
  1210. }
  1211. }
  1212. this.iContext.iEvents.fireEvent("com.ibm.bux.filter.values.get.done", null, payload);
  1213. },
  1214. onUnload: function (evt) {
  1215. if(this.recalPromise) {
  1216. this.recalPromise.then(dojo.hitch(this, this.doOnUnload));
  1217. } else {
  1218. this.doOnUnload();
  1219. }
  1220. this.unloaded = true;
  1221. },
  1222. doOnUnload: function() {
  1223. if (this.app) {
  1224. if (this.subscribeToActiveSheetChangedNotifications) {
  1225. this.app.unsubscribeFromActiveSheetChangedNotifications(this.subscribeToActiveSheetChangedNotifications);
  1226. }
  1227. if (this.subscriptionHandle) {
  1228. this.app.unsubscribeFromStateChangeUpdates(this.subscriptionHandle);
  1229. }
  1230. this.app.dispose();
  1231. }
  1232. if (this.iframeCtrl != null) {
  1233. this.iframeCtrl.destroy();
  1234. }
  1235. if (this.iframeCtrlCantLoadDojo != null) {
  1236. this.iframeCtrlCantLoadDojo.destroy();
  1237. }
  1238. },
  1239. onSetVisible: function(evt)
  1240. {
  1241. if(!this.unloaded) {
  1242. if (evt.payload.isVisible) {
  1243. if (this.app != null) {
  1244. this.recalPromise = this.app.recalculate();
  1245. }
  1246. }
  1247. }
  1248. },
  1249. onWidgetRefresh: function(evt) // Invoked when User preferences get modified (Including locales)
  1250. {
  1251. if (this.app != null) {
  1252. this.app.recalculate();
  1253. }
  1254. return;
  1255. },
  1256. onWidgetSave: function() {
  1257. var saveDonePayload = {'status':true};
  1258. this.iContext.iEvents.fireEvent("com.ibm.bux.widget.save.done", null, saveDonePayload);
  1259. },
  1260. onWidgetResize: function(e) {
  1261. if (this.inDoMore) {
  1262. var newWidth = e.payload.resize.w;
  1263. var newHeight = e.payload.resize.h;
  1264. this.iframeCtrl.resize({
  1265. w: newWidth,
  1266. h: newHeight - 40
  1267. });
  1268. } else if (this.cantLoadDojo) {
  1269. var newWidth = e.payload.resize.w;
  1270. var newHeight = e.payload.resize.h;
  1271. this.iframeCtrlCantLoadDojo.resize({
  1272. w: newWidth,
  1273. h: newHeight
  1274. });
  1275. } else {
  1276. if (!this._preferredSizeSet) {
  1277. if(!this._firstVisible) {
  1278. setTimeout(dojo.hitch(this, this.onWidgetResize, e), 10);
  1279. return;
  1280. }
  1281. var attributes = this.iContext.getiWidgetAttributes();
  1282. var width = parseInt(((this.tm1Width != null) && (this.tm1Width > 0)) ? this.tm1Width : attributes.getItemValue("viewWidth"));
  1283. var height = parseInt(((this.tm1Height != null) && (this.tm1Height > 0)) ? this.tm1Height : attributes.getItemValue("viewHeight"));
  1284. var chromeObjectId = bux.Helper.widgetIdToChromeId(this.iContext.widgetId);
  1285. var chromeObject = bux.Helper.getChromeById(chromeObjectId);
  1286. chromeObject.setPreferredSize({w: width, h: height});
  1287. this._preferredSizeSet = true;
  1288. chromeObject.doChromeAutoResize();
  1289. }
  1290. if (this.app != null) {
  1291. this.app.resize();
  1292. this.tm1Height = e.payload.resize.h;
  1293. this.tm1Width = e.payload.resize.w;
  1294. this.iContext.getiWidgetAttributes().setItemValue("tHeight", this.tm1Height);
  1295. this.iContext.getiWidgetAttributes().setItemValue("tWidth", this.tm1Width);
  1296. }
  1297. }
  1298. },
  1299. onGetProperties: function (evt, init) {
  1300. /*
  1301. var attributes = this.iContext.getiWidgetAttributes();
  1302. var _properties = {
  1303. 'label': this.iContext.getiWidgetAttributes().getItemValue("tm1Host"),
  1304. 'serverLabel': this.iContext.getiWidgetAttributes().getItemValue("tm1Server"),
  1305. 'cubeLabel': this.iContext.getiWidgetAttributes().getItemValue("tm1Cube"),
  1306. 'cubeViewLabel': this.iContext.getiWidgetAttributes().getItemValue("tm1CubeView"),
  1307. 'userNameLabel': this.iContext.getiWidgetAttributes().getItemValue("tm1UserName"),
  1308. 'passwordLabel': this.iContext.getiWidgetAttributes().getItemValue("tm1Password")
  1309. };
  1310. var propertiesDialog = new CubeViewPropertiesPane({
  1311. properties: _properties,
  1312. title: dojo.string.substitute(BUXMSG.WDG.IDS_WDG_PROPERTIES_DIALOG_TITLE, [attributes.getItemValue("widgetTitle")]),
  1313. sourceWidget: this,
  1314. cancelPropertiesCallback: (init) ? dojo.hitch(this, this._onCancelProperties) : null
  1315. });
  1316. this._propertiesDialog = propertiesDialog;
  1317. var _payload = {properties: _properties, propertiesDialogSpec:null, propertiesDialogTab: propertiesDialog};
  1318. this.iContext.iEvents.fireEvent("com.ibm.bux.widget.properties.get.done", null, _payload);
  1319. */
  1320. },
  1321. _onCancelProperties: function() {
  1322. if (this._firstRender == true) {
  1323. var chromeObjectId = bux.Helper.widgetIdToChromeId(this.iContext.widgetId);
  1324. var chromeObject = bux.Helper.getChromeById(chromeObjectId);
  1325. chromeObject.widgetRemoveConfirmed();
  1326. }
  1327. },
  1328. onSetProperties: function(evt) {
  1329. if (evt.payload.properties) {
  1330. var attributes = this.iContext.getiWidgetAttributes();
  1331. var host = this._propertiesDialog.labelInput.value;
  1332. var server = this._propertiesDialog.serverLabelInput.value;
  1333. var cube = this._propertiesDialog.cubeLabelInput.value;
  1334. var cubeView = this._propertiesDialog.cubeViewLabelInput.value;
  1335. var userName = this._propertiesDialog.userNameLabelInput.value;
  1336. var password = this._propertiesDialog.passwordLabelInput.value;
  1337. if (host != attributes.getItemValue("tm1Host") ||
  1338. server != attributes.getItemValue("tm1Server") ||
  1339. cube != attributes.getItemValue("tm1Cube") ||
  1340. cubeView != attributes.getItemValue("tm1CubeView") ||
  1341. userName != attributes.getItemValue("tm1UserName") ||
  1342. password != attributes.getItemValue("tm1Password")) {
  1343. this.tm1Host = host;
  1344. this.tm1Server = server;
  1345. this.tm1Cube = cube;
  1346. this.tm1CubeView = cubeView;
  1347. this.tm1UserName = userName;
  1348. this.tm1Password = password;
  1349. // attributes.save();
  1350. this.refreshView();
  1351. }
  1352. return;
  1353. }
  1354. },
  1355. _onCancelProperties: function () {
  1356. if (this._firstRender == true) {
  1357. this.removeWidget();
  1358. }
  1359. },
  1360. removeWidget: function () {
  1361. var chromeObjectId = bux.Helper.widgetIdToChromeId(this.iContext.widgetId);
  1362. var chromeObject = bux.Helper.getChromeById(chromeObjectId);
  1363. chromeObject.widgetRemoveConfirmed();
  1364. },
  1365. _excludeList: ["copyright", "version"],
  1366. _getProps: function(asDialog) {
  1367. console.log ("_getProps");
  1368. var results = {};
  1369. var names = this.iContext.getiWidgetAttributes().getAllNames();
  1370. for (var i = 0, l = names.length; i < l; i++) {
  1371. var name = names[i];
  1372. if (-1 != dojo.indexOf(this._excludeList, name)) {
  1373. // skip read-only attributes
  1374. // BUG: can't use enabler's isReadOnly() fails with a bizare javascript error.
  1375. continue;
  1376. }
  1377. var value = this.iContext.getiWidgetAttributes().getItemValue(name);
  1378. results[name] = (asDialog) ? {
  1379. value: value
  1380. } : value;
  1381. }
  1382. return results;
  1383. }
  1384. });
  1385. dojo.provide("tm1.iwidget.utilities.IFrame");
  1386. dojo.declare("tm1.iwidget.utilities.IFrame", dijit._Widget, {
  1387. url: null,
  1388. frameTitle: null,
  1389. resizeZone: null,
  1390. iframe: null,
  1391. constructor: function(params) {
  1392. },
  1393. setUrl: function(url) {
  1394. this.url = url;
  1395. if (this.iframe) {
  1396. this.iframe.src = this.prepareUrl(url);
  1397. }
  1398. },
  1399. prepareUrl: function(url) {
  1400. if (url === null || url === "") {
  1401. return url;
  1402. }
  1403. url = bux.Helper.normalizeURL(url);
  1404. return url;
  1405. },
  1406. setFrameTitle: function(title) {
  1407. this.frameTitle = title;
  1408. if (this.iframe) {
  1409. this.iframe.title = bux.Encodings.htmlencode(title);
  1410. }
  1411. },
  1412. startup: function() {
  1413. this.inherited(arguments);
  1414. var dn = this.domNode;
  1415. this.resizeZone = dn.ownerDocument.createElement("div");
  1416. dn.appendChild(this.resizeZone);
  1417. dn = (this.iframe = dojo.doc.createElement('iframe'));
  1418. var url = this.url;
  1419. dn.id = this.id + "_iframe";
  1420. dn.style.border = "none";
  1421. dn.style.width = "100%";
  1422. dn.frameBorder = 0;
  1423. dn.tabIndex = 0;
  1424. dn.title = this.frameTitle;
  1425. dn.setAttribute('src', this.prepareUrl(url));
  1426. this.resizeZone.appendChild(dn);
  1427. if (dojo.isWebKit) {
  1428. setTimeout(function() {
  1429. dn.setAttribute('src', this.prepareUrl(url));
  1430. }, 0);
  1431. }
  1432. },
  1433. resize: function(size) {
  1434. dijit.layout._LayoutWidget.prototype.resize.apply(this, arguments);
  1435. if (dojo.isWebKit) {
  1436. this.domNode.style.display = "none";
  1437. setTimeout(dojo.hitch(this, function(){
  1438. this.domNode.style.display = "";
  1439. }), 1);
  1440. }
  1441. },
  1442. layout: function() {
  1443. this.resizeZone.style.height = this._contentBox.h + "px";
  1444. if (this.iframe) {
  1445. this.iframe.style.height = "100%";
  1446. }
  1447. }
  1448. });