12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- /**
- * Licensed Materials - Property of IBM
- * IBM Business Analytics (C) Copyright IBM Corp. 2018, 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- /**
- * @class SavedPromptsImpl
- *
- */
- define(['../SavedPromptsAPI', './SavedPromptsAPISpec', '../../lib/@waca/dashboard-common/dist/core/APIFactory', 'underscore'], function (SavedPromptsAPI, SavedPromptsAPISpec, APIFactory, _) {
- /**
- * [livewidgt-cleanup] todo: we need to revisit this api and redesign the interface:
- * e.g. // the logic for savedPrompts.save() is duplicated in dataQueryExecution.js..
- */
- /** Class representing a SavedPrompts Implementation */
- var SavedPromptsImpl = function (_SavedPromptsAPISpec) {
- _inherits(SavedPromptsImpl, _SavedPromptsAPISpec);
- /**
- * Create a SavedPromptsImpl of SavedPromtsAPI
- * @param widget the corresponding widget.
- */
- function SavedPromptsImpl(widgetModel) {
- _classCallCheck(this, SavedPromptsImpl);
- var _this = _possibleConstructorReturn(this, _SavedPromptsAPISpec.call(this));
- _this.widgetModel = widgetModel;
- return _this;
- }
- SavedPromptsImpl.prototype.destroy = function destroy() {
- this.widgetModel = null;
- };
- SavedPromptsImpl.prototype.getAPI = function getAPI() {
- return APIFactory.createAPI(this, [SavedPromptsAPI]);
- };
- SavedPromptsImpl.prototype.save = function save(promptValueSpec) {
- var specToSave = _.pick(promptValueSpec, SavedPromptsImpl.PromptValueSpec_KEYS);
- var savedPrompts = this.widgetModel.get('savedPrompts') || {};
- savedPrompts[specToSave.name] = specToSave;
- return this.reset(savedPrompts);
- };
- SavedPromptsImpl.prototype.reset = function reset(promptValueSpec) {
- var refresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- //silently change the model. an api event will be triggered for this method.
- this.widgetModel['savedPrompts'] = promptValueSpec;
- return refresh;
- };
- SavedPromptsImpl.prototype.getPromptSpec = function getPromptSpec(promptName) {
- var savedPrompts = this.widgetModel.get('savedPrompts');
- if (!savedPrompts || promptName && !savedPrompts[promptName]) {
- return undefined;
- } else {
- var savedPromptsCopy = JSON.parse(JSON.stringify(savedPrompts));
- return savedPromptsCopy[promptName];
- }
- };
- SavedPromptsImpl.prototype.getPromptSpecList = function getPromptSpecList() {
- var savedPrompts = this.widgetModel.get('savedPrompts') || {};
- var savedPromptsCopy = JSON.parse(JSON.stringify(savedPrompts));
- return _.values(savedPromptsCopy);
- };
- return SavedPromptsImpl;
- }(SavedPromptsAPISpec);
- /**
- * Enum for PROMPTVALUE_KEY.
- * @readonly
- * @enum {string}
- */
- SavedPromptsImpl.PromptValueSpec_KEYS = ['name', 'capabilities', 'dataType', 'values', 'modelFilterItem'];
- return SavedPromptsImpl;
- });
- //# sourceMappingURL=SavedPrompts.js.map
|