DeleteAction.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 DeleteAction()
  13. {
  14. this.m_sAction = "Delete";
  15. }
  16. DeleteAction.prototype = new ModifyReportAction();
  17. DeleteAction.baseclass = ModifyReportAction.prototype;
  18. DeleteAction.prototype.getUndoHint = function()
  19. {
  20. return RV_RES.IDS_JS_DELETE;
  21. };
  22. DeleteAction.prototype.canDelete = function()
  23. {
  24. if(!this.m_oCV.isLimitedInteractiveMode()) {
  25. var selectedObjects = this.m_oCV.getSelectionController().getAllSelectedObjects();
  26. if (selectedObjects.length>0) {
  27. for (var i=0; i<selectedObjects.length; ++i) {
  28. var selObj=selectedObjects[i];
  29. var cellRef=selObj.getCellRef();
  30. if( !selObj.hasContextInformation() || selObj.isHomeCell() ||
  31. (selObj.getLayoutType() != 'columnTitle' && selObj.getDataContainerType() != 'list' ) ||
  32. cellRef.getAttribute("cc") == "true") {
  33. return false;
  34. }
  35. }
  36. return true;
  37. }
  38. }
  39. return false;
  40. };
  41. DeleteAction.prototype.execute = function() {
  42. DeleteAction.baseclass.execute.call(this);
  43. //While the server is working, clear the selection and rebuild the
  44. //context menu so that users won't be able to see commands from
  45. //the deleted selection. (COGCQ00252407).
  46. this.m_oCV.getSelectionController().clearSelectionData();
  47. this.m_oCV.getViewerWidget().onContextMenu(null);
  48. };
  49. DeleteAction.prototype.keepRAPCache = function()
  50. {
  51. return false;
  52. };
  53. DeleteAction.prototype.updateMenu = function(jsonSpec)
  54. {
  55. jsonSpec.visible = this.ifContainsInteractiveDataContainer();
  56. if (! jsonSpec.visible)
  57. {
  58. return jsonSpec;
  59. }
  60. jsonSpec.disabled = !this.canDelete();
  61. return jsonSpec;
  62. };
  63. DeleteAction.prototype.addActionContextAdditionalParms = function()
  64. {
  65. return this.getSelectedCellTags();
  66. };