TM1WebCubeViewerWidget.js 73 KB

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