'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. 2018 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define(['../../../apiHelpers/SlotAPIHelper', '../../../visualizations/recommender/IRUtils'], function (SlotAPIHelper, IRUtils) { 'use strict'; return function () { function Utils() { _classCallCheck(this, Utils); } // translation of top bottom spec into IR. TODO: use a common utility Utils.translateTopBottom2IR = function translateTopBottom2IR(tbEntry) { var entry = {}; entry.filterId = tbEntry.id; entry.columnId = tbEntry.itemId; entry.topBottomType = IRUtils.IRTopBottomType(tbEntry.selection.topBottom.type); entry.method = IRUtils.IRTopBottomMethod(tbEntry.selection.topBottom.type); entry.domainSize = tbEntry.selection.topBottom.value; if (tbEntry.selection.topBottom.context) { entry.byColumn = tbEntry.selection.topBottom.context.itemId; } entry.type = 'TOP_BOTTOM'; return entry; }; Utils.getTopBottomItems = function getTopBottomItems(visualization) { var mappedSlots = visualization.getSlots().getMappedSlotList(); if (!mappedSlots || !mappedSlots.length) { return; } var topBottomItems = []; // ignore hidden slots which are not considered as part of mappings // e.g. 'rank' slot of grid, 'size' slot of scatter mappedSlots.filter(function (slot) { return slot && !slot.getDefinition().isHidden(); }).forEach(function (mappedSlot) { var dataItemAPIs = Utils.filterInvalidDataItems(mappedSlot.getDataItemList()); dataItemAPIs.forEach(function (dataItemAPI) { var topBottomSpec = dataItemAPI.getTopBottom(); // Ignore all the non contextual top bottom modifiers // smarts only understand top bottom with context if (topBottomSpec && topBottomSpec.context) { var translatedSpec = Utils.translateTopBottom2IR({ id: dataItemAPI.getId(), itemId: dataItemAPI.getColumnId(), selection: { topBottom: topBottomSpec } }); topBottomItems.push(translatedSpec); } }); }); return topBottomItems; }; Utils.getUnboundColumnsIds = function getUnboundColumnsIds(visualization) { return Utils.filterInvalidDataItems(visualization.getSlots().getDataItemList()).map(function (dataItem) { return dataItem.getColumnId(); }); }; Utils.filterInvalidDataItems = function filterInvalidDataItems(list) { return list.filter(function (dataItem) { return !SlotAPIHelper.isMultiMeasuresSeriesOrValueDataItem(dataItem) && !dataItem.isColumnUnavailable(); }); }; Utils.getFilterItems = function getFilterItems(visualization) { var result = []; IRUtils.localFilters2IRFilters(visualization.getLocalFilters().getFilterList(), result); return result; }; return Utils; }(); }); //# sourceMappingURL=Utils.js.map