1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- '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: Dashboard
- * (C) Copyright IBM Corp. 2020
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['underscore'], function (_) {
- /**
- * Most of Dashboard references the board and widget specs using APIs - but processing on the raw specs before they are deserialized into APIs don't have this advantage.
- * This utility encapsulates operations which one may be tempted to hand craft, allowing for them to updated in one place, as a poor man's alternative to an API.
- */
- var DashboardSpecUtil = function () {
- function DashboardSpecUtil() {
- _classCallCheck(this, DashboardSpecUtil);
- }
- /**
- * @param {object} layout - a layout from a board spec
- * @return {object[]} the widget models in the given layout
- */
- DashboardSpecUtil.getWidgetModelList = function getWidgetModelList(layout) {
- //extract widget models from widget layouts
- return DashboardSpecUtil._getWidgetList(layout).map(function (widget) {
- return widget && widget.features && widget.features.Models_internal;
- }).filter(function (widgetModel) {
- return !!widgetModel;
- });
- };
- DashboardSpecUtil._getWidgetList = function _getWidgetList(layout) {
- var layouts = [];
- if (layout.type === 'widget') {
- //This layout is a widget - return it
- layouts.push(layout);
- }
- if (layout.items) {
- //Recursively search for widget layouts
- layouts = _.flatten([layouts, layout.items.map(function (item) {
- return DashboardSpecUtil._getWidgetList(item);
- })]);
- }
- return layouts;
- };
- return DashboardSpecUtil;
- }();
- return DashboardSpecUtil;
- });
- //# sourceMappingURL=DashboardSpecUtil.js.map
|