12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- '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 Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019, 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['./Canvas', '../features/content/InlineFeatures'], function (CanvasImpl, InlineFeatures) {
- var CanvasFactory = function () {
- function CanvasFactory(options) {
- _classCallCheck(this, CanvasFactory);
- this.dashboardAPI = options.dashboardAPI;
- this.glassContext = options.glassContext;
- this.logger = options.logger;
- this.featureLoader = options.featureLoader;
- this.inlineFeature = options.inlineFeature || InlineFeatures;
- this.extensions = options.extensions;
- this.boardModel = options.boardModel;
- this.eventRouter = options.eventRouter;
- this.widgetRegistry = options.widgetRegistry;
- this.featureLoader = options.featureLoader;
- this.stringResources = this.dashboardAPI.getDashboardCoreSvc('.StringResources');
- this._dashboardContent = options.dashboardContent;
- this.profile = this.dashboardAPI.getAppConfig('profile') || null;
- }
- CanvasFactory.prototype.createCanvas = function createCanvas() {
- var _this = this;
- var options = {
- // Features required by the canvas and the content API
- dashboardFeatures: this.featureLoader,
- boardModel: this.boardModel,
- extensions: this.extensions,
- // the following 2 should be cleaned up
- copyCallbabck: this.dashboardAPI.copy.bind(this.dashboardAPI),
- pasteCallback: this.dashboardAPI.paste.bind(this.dashboardAPI),
- profile: this.profile,
- dashboardContent: this._dashboardContent
- };
- return this.dashboardAPI.findGlassCollection('com.ibm.bi.dashboard.content-features').then(function (collectionItems) {
- options.contentFeatureCollection = _this.inlineFeature.concat(collectionItems || []);
- var contentTypeRegistry = _this.dashboardAPI.getFeature('ContentTypeRegistry');
- if (contentTypeRegistry) {
- options.contentFeatureCollection = contentTypeRegistry.processFeatureCollection(options.contentFeatureCollection);
- }
- var canvasImpl = new CanvasImpl(options);
- // Create the canvas API
- _this.featureLoader.registerFeature('Canvas', canvasImpl);
- return canvasImpl.initialize().then(function () {
- // now the canvas is ready, dashboard spec is available via the 'Serializer' feature, no need of the initial one
- _this.boardModel.deleteInitialSpec();
- return {
- canvas: canvasImpl.getAPI(),
- internalCanvas: {
- whenContentReady: function whenContentReady(contentId) {
- return canvasImpl.whenContentReady(contentId);
- },
- registerFeatureCollection: function registerFeatureCollection(contentId, collectionName) {
- return _this.dashboardAPI.findGlassCollection(collectionName).then(function (collectionItems) {
- return canvasImpl.registerContentFeatures(contentId, collectionItems || []);
- });
- },
- registerFeature: function registerFeature(contentId, featureId, featureInstance, featureSpec) {
- return canvasImpl.registerContentFeature(contentId, featureId, featureInstance, featureSpec);
- },
- registerDeprecatedFeature: function registerDeprecatedFeature(contentId, featureId, featureInstance) {
- return canvasImpl.registerContentFeature(contentId, featureId, featureInstance, {}, true);
- },
- destroy: function destroy() {
- canvasImpl.destroy();
- }
- }
- };
- });
- });
- };
- return CanvasFactory;
- }();
- return CanvasFactory;
- });
- //# sourceMappingURL=CanvasFactory.js.map
|