'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 Dashboard *| (C) Copyright IBM Corp. 2018 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define(['underscore'], function (_) { var WidgetUpgradeUtils = function () { function WidgetUpgradeUtils() { _classCallCheck(this, WidgetUpgradeUtils); } WidgetUpgradeUtils.prototype.findProperty = function findProperty(id, properties) { return _.find(properties, function (property) { return property.id === id; }); }; WidgetUpgradeUtils.prototype.findLayout = function findLayout() { var layouts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var widgetId = arguments[1]; var match = null; for (var i = 0; i < layouts.length; i++) { if (layouts[i].id === widgetId) { match = layouts[i]; } if (!match && layouts[i].items) { match = this.findLayout(layouts[i].items, widgetId); } if (match) { break; } } return match; }; WidgetUpgradeUtils.prototype.specHasWidgets = function specHasWidgets(spec) { return spec && spec.widgets && !_.isEmpty(spec.widgets); }; WidgetUpgradeUtils.prototype.isLiveWidgetModel = function isLiveWidgetModel(model) { return model && model.type && model.type === 'live'; }; WidgetUpgradeUtils.prototype.setDefaultProperty = function setDefaultProperty(model, propertyName, defaultValue) { var oldProp = this.findProperty(propertyName, model.properties); if (!oldProp) { if (!model.properties) { model.properties = []; } model.properties.push({ id: propertyName, value: defaultValue }); } }; return WidgetUpgradeUtils; }(); return new WidgetUpgradeUtils(); }); //# sourceMappingURL=WidgetUpgradeUtils.js.map