SavedPromptsAPISpec.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019, 2020
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. /**
  9. *
  10. * @class APISpec
  11. * @hideconstructor
  12. * @classdesc
  13. */
  14. define([], function () {
  15. var APISpec = function () {
  16. function APISpec() {
  17. _classCallCheck(this, APISpec);
  18. }
  19. APISpec.prototype.getAPISpec = function getAPISpec() {
  20. var _this = this;
  21. if (!this.apiSpec) {
  22. this.apiSpec = {
  23. name: 'savedPrompts API',
  24. events: {
  25. propagationInfo: {
  26. namespace: 'savedPrompts',
  27. callStack: {
  28. name: 'getSavedPrompts'
  29. },
  30. info: {
  31. supportsUndoRedo: true,
  32. refresh: {
  33. dataIfQueryChanged: true
  34. }
  35. }
  36. },
  37. actions: {
  38. // todo: for now we wire off the new api events mechanism for Prompts API.
  39. // we need to consider the entire prompts feature in the future if we want to enable events here.
  40. 'save': {
  41. eventName: 'savedprompts:save',
  42. getInfo: function getInfo(args) {
  43. return {
  44. promptValueSpec: args ? args[0] : undefined
  45. };
  46. },
  47. getUndoActions: function getUndoActions() {
  48. var currentValue = _this.widgetModel.get('savedPrompts');
  49. return [{
  50. name: 'reset',
  51. params: [currentValue ? JSON.parse(JSON.stringify(currentValue)) : undefined, true]
  52. }];
  53. }
  54. },
  55. 'reset': {
  56. eventName: 'savedprompts:reset',
  57. getInfo: function getInfo(args) {
  58. return {
  59. promptValueSpec: args ? args[0] : undefined
  60. };
  61. },
  62. getUndoActions: function getUndoActions(args) {
  63. return [{
  64. name: 'reset',
  65. params: [args[0], true]
  66. }];
  67. },
  68. isTriggerEvent: function isTriggerEvent(action, undoActions, returnValue) {
  69. return returnValue;
  70. }
  71. }
  72. }
  73. }
  74. };
  75. }
  76. return this.apiSpec;
  77. };
  78. return APISpec;
  79. }();
  80. return APISpec;
  81. });
  82. //# sourceMappingURL=SavedPromptsAPISpec.js.map