TM1WebWebSheetWidget.js 58 KB

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