'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Licensed Materials - Property of IBM * IBM Business Analytics (C) Copyright IBM Corp. 2019, 2020 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** * @class VisDnD * @hideconstructor * * @classdesc Handles drag and drop of metadata to create a visualization. */ define(['./api/VisDnDAPI', '../../../lib/@waca/dashboard-common/dist/core/APIFactory', './VisDnDProviderSet'], function (DnDProviderAPI, APIFactory, VisDnDProviderSet) { return function () { function VisDnD(_ref) { var content = _ref.content, features = _ref.features; _classCallCheck(this, VisDnD); this.content = content; this.dashboardAPI = features['API']; this.dashboardDnD = features['Dashboard.DashboardDnd']; this.visualization = features['Visualization']; this.providerSets = {}; } //to fix the problem that constructor won't be invoked when vidDnd feature is loaded VisDnD.prototype.initialize = function initialize() {}; VisDnD.prototype.getAPI = function getAPI() { if (!this.api) { this.api = APIFactory.createAPI(this, [DnDProviderAPI]); } return this.api; }; VisDnD.prototype.destroy = function destroy() { var _this = this; this.dashboardAPI = null; this.content = null; this.utils && this.utils.destroy(); this.utilsApi = null; this.api = null; Object.keys(this.providerSets).forEach(function (providerKey) { _this.providerSets[providerKey].destroy(); }); this.providerSets = null; }; VisDnD.prototype.registerProviders = function registerProviders(type) { var providers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; var containedTargetsToIgnore = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; if (type && providers && providers.length) { var providerSet = this.providerSets[type]; if (providerSet) { providerSet.addProviders(providers); } else { this.providerSets[type] = new VisDnDProviderSet({ dashboardAPI: this.dashboardAPI, dashboardDnD: this.dashboardDnD, content: this.content, targetType: type, dndProviderList: providers, containedTargetsToIgnore: containedTargetsToIgnore }); } } }; VisDnD.prototype.accepts = function accepts(source, target) { if (this.providerSets[target.type] && this.providerSets[target.type].accepts) { return this.providerSets[target.type].accepts(source, target); } return false; }; VisDnD.prototype.onDrop = function onDrop(source, target) { if (this.providerSets[target.type] && this.providerSets[target.type].onDrop) { this.providerSets[target.type].onDrop(source, target); } }; return VisDnD; }(); }); //# sourceMappingURL=VisDnD.js.map