TM1WebWebSheetWidget.js 51 KB

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