SlotEditorActionHandler.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. 'use strict';
  2. /*
  3. *+------------------------------------------------------------------------+
  4. *| Licensed Materials - Property of IBM
  5. *| IBM Cognos Products: Content Explorer
  6. *| (C) Copyright IBM Corp. 2019
  7. *|
  8. *| US Government Users Restricted Rights - Use, duplication or disclosure
  9. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *+------------------------------------------------------------------------+
  11. */
  12. define(['../../../lib/@waca/core-client/js/core-client/ui/core/Class'], function (Class) {
  13. var SlotEditorActionHandler = Class.extend({
  14. reload: function reload() {
  15. if (this.context && this.context.pushState) {
  16. // the slot editor is open.. refresh.
  17. this.openSlotEditor();
  18. }
  19. },
  20. onPress: function onPress(context) {
  21. this.context = context;
  22. if (!this.isRegisteredAsReloadable) {
  23. this.isRegisteredAsReloadable = true;
  24. context.glassContext.appController.getCurrentContentView().addReloadableObject('SlotEditorActionHandler', this);
  25. }
  26. if (context.pushState) {
  27. context.target.plugin.actionController = this;
  28. this.openSlotEditor(context);
  29. } else {
  30. this.onHide(context);
  31. }
  32. },
  33. onHide: function onHide(context) {
  34. var api = this._getDashboardApi(context);
  35. if (api) {
  36. api.toggleSlotEditor(false, context);
  37. }
  38. },
  39. openSlotEditor: function openSlotEditor(context) {
  40. var api = this._getDashboardApi(context);
  41. if (api) {
  42. api.toggleSlotEditor(true, context);
  43. }
  44. },
  45. _getDashboardApi: function _getDashboardApi(context) {
  46. if (!this._api && context && context.glassContext) {
  47. this._api = context.glassContext.appController.getCurrentContentView().getDashboardApi();
  48. }
  49. return this._api;
  50. }
  51. });
  52. return SlotEditorActionHandler;
  53. });
  54. //# sourceMappingURL=SlotEditorActionHandler.js.map