TM1WebWebSheetWidget.js 50 KB

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