ViewAllSnapshotsAction.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 ViewAllSnapshotsAction(){}
  13. ViewAllSnapshotsAction.prototype = new SnapshotsAction();
  14. ViewAllSnapshotsAction.prototype.updateMenu = function(jsonSpec) {
  15. var oCV = this.getCognosViewer();
  16. var widget = oCV.getViewerWidget();
  17. if (widget.m_bNoSavedOutputs == true) {
  18. jsonSpec.disabled = true;
  19. }
  20. return jsonSpec;
  21. };
  22. ViewAllSnapshotsAction.prototype.execute = function() {
  23. if (!this.getCognosViewer().getViewerWidget().getSavedOutputsCMResponse()) {
  24. this.queryCMForSavedOutputs({"complete" : {"object" : this, "method" : this.handleQueryResponse}});
  25. }
  26. else {
  27. this.showDialog();
  28. }
  29. };
  30. ViewAllSnapshotsAction.prototype.handleQueryResponse = function(response) {
  31. this.setSavedOutputsCMResponse(response);
  32. this.showDialog();
  33. };
  34. ViewAllSnapshotsAction.prototype.showDialog = function() {
  35. var oCV = this.getCognosViewer();
  36. var widget = oCV.getViewerWidget();
  37. var cmResponse = widget.getSavedOutputsCMResponse();
  38. var queryResult = null;
  39. var queryItems = null;
  40. if (cmResponse) {
  41. queryResult = XMLHelper_FindChildByTagName(cmResponse, "result", true);
  42. if (queryResult) {
  43. queryItems = XMLHelper_FindChildrenByTagName(queryResult, "item", false);
  44. }
  45. }
  46. if (!cmResponse || !queryItems || queryItems.length == 0) {
  47. widget.m_bNoSavedOutputs = true;
  48. var warningDialog = new WarningMessageDialog(oCV, RV_RES.IDS_JS_NO_SAVED_OUTPUTS);
  49. warningDialog.renderInlineDialog();
  50. //widget.showErrorMessage(RV_RES.IDS_JS_NO_SAVED_OUTPUTS);
  51. }
  52. else {
  53. var cognosViewerObjectString = getCognosViewerObjectString(this.m_oCV.getId());
  54. var menuItemString = RV_RES.IDS_JS_SELECT_SNAPSHOT_DIALOG_TITLE;
  55. var enterNumberLabel = RV_RES.IDS_JS_SELECT_SNAPSHOT_DIALOG_DESC;
  56. var creationTime = this.getCognosViewer().envParams["creationTime"];
  57. this.selectSnapshotDialog = new viewer.dialogs.SelectSnapshot({
  58. sTitle:menuItemString,
  59. sLabel:enterNumberLabel,
  60. cmResponse:cmResponse,
  61. currentSnapshotCreationTime: creationTime,
  62. okHandler: function(sStoreID, sCreationTime)
  63. {
  64. window[cognosViewerObjectString].executeAction("ViewSavedOutput", {obj:sStoreID, creationTime: sCreationTime});
  65. },
  66. cancelHandler: function() {}
  67. });
  68. this.selectSnapshotDialog.startup();
  69. this.selectSnapshotDialog.show();
  70. }
  71. };