ChangeDisplayVariationsAction.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2011
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. function ChangeDisplayVariationsAction(){}
  13. ChangeDisplayVariationsAction.prototype = new CognosViewerAction();
  14. function ChangeDisplayVariationsAction()
  15. {
  16. this.m_requestParams = null;
  17. }
  18. ChangeDisplayVariationsAction.prototype.setRequestParms = function(parms)
  19. {
  20. this.m_requestParams = parms;
  21. };
  22. ChangeDisplayVariationsAction.prototype.execute = function() {
  23. var groupId = this.m_requestParams.groupId; //from dialog.
  24. var viewer = this.getCognosViewer();
  25. var selectedObject = this.getSelectedReportInfo();
  26. if(selectedObject)
  27. {
  28. var viewerWidget = viewer.getViewerWidget();
  29. if (typeof selectedObject.suggestedDisplayVariations == "undefined")
  30. {
  31. var asynchRequest = new AsynchJSONDispatcherEntry(this.m_oCV);
  32. asynchRequest.setCallbacks({
  33. "complete": {"object": this, "method": this.handleResponse}
  34. });
  35. asynchRequest.setRequestIndicator(viewer.getRequestIndicator());
  36. asynchRequest.addFormField("ui.action", "getInfoFromReportSpec");
  37. asynchRequest.addFormField("bux", "true");
  38. asynchRequest.addNonEmptyStringFormField("modelPath", this.m_oCV.getModelPath());
  39. asynchRequest.addFormField("ui.object", this.m_oCV.envParams["ui.object"]);
  40. asynchRequest.addDefinedFormField("ui.spec", this.m_oCV.envParams["ui.spec"]);
  41. asynchRequest.addFormField("cv.actionContext", this.addActionContext(groupId));
  42. viewer.dispatchRequest(asynchRequest);
  43. }
  44. else
  45. {
  46. viewerWidget.updateDisplayTypeDialogVariations(selectedObject.possibleDisplayTypes,selectedObject.suggestedDisplayVariations );
  47. }
  48. }
  49. };
  50. ChangeDisplayVariationsAction.prototype.handleResponse = function(asynchJSONResponse)
  51. {
  52. var viewer = this.getCognosViewer();
  53. var viewerWidget = viewer.getViewerWidget();
  54. var reportInfos = asynchJSONResponse.getResult();
  55. for ( var i in reportInfos.containers)
  56. {
  57. var selectedReportInfo = this.getReportInfo(reportInfos.containers[i].container);
  58. selectedReportInfo.possibleDisplayTypes = reportInfos.containers[i].possibleDisplayTypes;
  59. selectedReportInfo.variationGroups = reportInfos.containers[i].variationGroups;
  60. }
  61. var selectedObject = this.getSelectedReportInfo();
  62. viewerWidget.updateDisplayTypeDialogVariations(selectedObject.possibleDisplayTypes,selectedObject.variationGroups);
  63. };
  64. ChangeDisplayVariationsAction.prototype.addActionContext = function(groupId)
  65. {
  66. var actionContext = "<getInfoActions>";
  67. actionContext += "<getInfoAction name=\"GetInfo\">";
  68. actionContext += "<include><suggestedDisplayVariations/></include>";
  69. actionContext += this.getDataItemInfoMap();;
  70. actionContext += this.addClientContextData(/*maxValuesPerRDI*/3);
  71. actionContext += "<groupId>";
  72. actionContext += groupId;
  73. actionContext += "</groupId>";
  74. actionContext += "</getInfoAction>";
  75. actionContext += "</getInfoActions>";
  76. return actionContext;
  77. };