123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- '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. 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['../../../lib/@waca/dashboard-common/dist/core/APIFactory', '../../dashboard/serializer/SerializerAPI', '../../../dashboard/model/ModelUtils'], function (APIFactory, SerializerAPI, ModelUtils) {
- /**
- * @implements {SerializerAPI}
- */
- var Serializer = function () {
- /**
- * @param {Object} options
- * @param {Object} options.features An object of the defined dependencies from the feature contribution json
- */
- function Serializer(_ref) {
- var layoutModel = _ref.layoutModel,
- content = _ref.content,
- logger = _ref.logger;
- _classCallCheck(this, Serializer);
- this._layoutModel = layoutModel;
- this._content = content;
- this._logger = logger;
- this._api = APIFactory.createAPI(this, [SerializerAPI]);
- }
- Serializer.prototype.getAPI = function getAPI() {
- return this._api;
- };
- Serializer.prototype.destroy = function destroy() {
- delete this._layoutModel;
- delete this._content;
- delete this._api;
- };
- Serializer.prototype.toJSON = function toJSON() {
- var _this = this;
- var json = this._layoutModel.toJSON(null, ['items']);
- var children = this._layoutModel.items;
- if (children) {
- json.items = [];
- children.forEach(function (child) {
- var childContent = _this._content.getContent(child.id);
- if (childContent) {
- json.items.push(childContent.getFeature('Serializer').toJSON());
- } else {
- _this._logger.log('Cannot get the child content');
- }
- });
- }
- ModelUtils.pullPropertiesFromContentModelSpec(json);
- return json;
- };
- return Serializer;
- }();
- return Serializer;
- });
- //# sourceMappingURL=Serializer.js.map
|