TM1WebCubeViewerWidget.js 65 KB

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