TM1WebCubeViewerWidget.js 73 KB

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