123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- '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 Cognos Products: BI Cloud (C) Copyright IBM Corp. 2018, 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['underscore', '../VisDefinitionAPI', './VisDefinitionAPISpec', '../../lib/@waca/dashboard-common/dist/core/APIFactory', './SlotDefinition', './VisDefinitionState'], function (_, VisDefinitionAPI, VisDefinitionAPISpec, APIFactory, SlotDefinition, VisDefinitionStateImpl) {
- var DEFAULT_PREFERRED_SIZE = {
- width: 520,
- height: 400
- };
- var VisDefinitionImpl = function (_VisDefinitionAPISpec) {
- _inherits(VisDefinitionImpl, _VisDefinitionAPISpec);
- function VisDefinitionImpl(visSpec, visDefinitionManager) {
- _classCallCheck(this, VisDefinitionImpl);
- var _this = _possibleConstructorReturn(this, _VisDefinitionAPISpec.call(this));
- _this.visDefinitionManager = visDefinitionManager;
- _this.visSpec = visSpec;
- // We hold on to the impl so that we can destroy the objects.
- _this.slotDefinitionImpls = [];
- _this.slotDefinitionAPIs = [];
- _this._visDefinitionStateImpl = new VisDefinitionStateImpl();
- return _this;
- }
- VisDefinitionImpl.prototype.destroy = function destroy() {
- if (this.slotDefinitionImpls) {
- this.slotDefinitionImpls.forEach(function (def) {
- return def.destroy();
- });
- }
- this.slotDefinitionImpls = null;
- this.visDefinitionManager = null;
- this.visSpec = null;
- this.slotDefinitionAPIs = null;
- this._visDefinitionStateImpl = null;
- };
- VisDefinitionImpl.prototype.getAPI = function getAPI() {
- return APIFactory.createAPI(this, [VisDefinitionAPI]);
- };
- VisDefinitionImpl.prototype.getType = function getType() {
- return this.visSpec.type;
- };
- VisDefinitionImpl.prototype.getId = function getId() {
- return this.visSpec.id;
- };
- VisDefinitionImpl.prototype.getDatasetList = function getDatasetList() {
- return _.map(this.visSpec.datasets, function (dataset) {
- return {
- id: dataset.name,
- caption: dataset.caption,
- optional: dataset.optional,
- suppressMissing: dataset.suppressMissing,
- needsSorted: dataset.needsSorted,
- requiresValues: dataset.requiresValues
- };
- });
- };
- VisDefinitionImpl.prototype.getLabel = function getLabel() {
- return this.visSpec.label;
- };
- VisDefinitionImpl.prototype.getIcon = function getIcon() {
- return this.visSpec.icon;
- };
- VisDefinitionImpl.prototype.getIconUri = function getIconUri() {
- return this.visSpec.iconUri;
- };
- VisDefinitionImpl.prototype.getPlaceholderIconUri = function getPlaceholderIconUri() {
- return this.visSpec.placeholderIcon;
- };
- VisDefinitionImpl.prototype.getPreferredSize = function getPreferredSize() {
- return this.visSpec.preferredSize || DEFAULT_PREFERRED_SIZE;
- };
- VisDefinitionImpl.prototype.getSlot = function getSlot(id) {
- return this.getSlotList().find(function (slot) {
- return slot.getId() === id;
- });
- };
- VisDefinitionImpl.prototype.getSlotList = function getSlotList() {
- var _this2 = this;
- if (this.slotDefinitionAPIs.length === 0) {
- _.each(this.visSpec.dataSlots, function (slot) {
- var impl = new SlotDefinition(slot);
- _this2.slotDefinitionImpls.push(impl);
- _this2.slotDefinitionAPIs.push(impl.getAPI());
- });
- }
- return this.slotDefinitionAPIs;
- };
- VisDefinitionImpl.prototype.getMultiEdgeSort = function getMultiEdgeSort() {
- return this.visSpec.queryHints && this.visSpec.queryHints.multiEdgeSort;
- };
- VisDefinitionImpl.prototype.getDefaultDatasetId = function getDefaultDatasetId() {
- return this.visSpec.defaultDatasetId || undefined;
- };
- VisDefinitionImpl.prototype.getState = function getState() {
- return this._visDefinitionStateImpl.getAPI();
- };
- VisDefinitionImpl.prototype.setError = function setError(error) {
- this._visDefinitionStateImpl.setError(error);
- };
- VisDefinitionImpl.prototype.refresh = function refresh() {
- var _this3 = this;
- var visId = this.visSpec.id;
- return this.visDefinitionManager.refresh(visId).then(function (newDef) {
- _this3.visSpec = newDef;
- if (_this3.getState().getError() && !newDef.empty) {
- _this3.setError(undefined); //only if an error is undefined is treated as no error, ref livewidget=>isInvalidVisDefinition
- }
- //clear the slot def cache
- _this3.slotDefinitionAPIs = [];
- return newDef;
- });
- };
- VisDefinitionImpl.prototype.getProperty = function getProperty(id) {
- return this.visSpec[id];
- };
- return VisDefinitionImpl;
- }(VisDefinitionAPISpec);
- return VisDefinitionImpl;
- });
- //# sourceMappingURL=VisDefinition.js.map
|