'use strict'; /** *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Dashboard *| (C) Copyright IBM Corp. 2017, 2019 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define(['underscore', '../../lib/@waca/core-client/js/core-client/ui/core/Class', '../../apiHelpers/SlotAPIHelper'], function (_, Class, SlotAPIHelper) { // implements IDataSetMapping var VIPRDatasetMapping = Class.extend({ init: function init(slotAPIs, datasetId) { this.slotAPIs = slotAPIs; this.datasetId = datasetId; }, getDataItemsFor: function getDataItemsFor(slotDef) { var indices = []; var index = 0; _.each(this.slotAPIs, function (slotAPI) { var id = slotAPI.getId(); if (slotAPI.isStacked() || SlotAPIHelper.isMultiMeasuresSeriesSlot(slotAPI) || SlotAPIHelper.isMultiMeasuresValueSlot(slotAPI)) { //If a slot is stacked or has multiple measures, all items in the slot have a single index. if (id === slotDef.name) { indices.push(index); } index++; } else { _.each(slotAPI.getDataItemList(), function () { if (id === slotDef.name) { indices.push(index); } index++; }); } }); return indices; } }); // implements ISlotMapping var VIPRSlotMapping = Class.extend({ init: function init(visualization) { this._aVIPRSlotMapping = []; var aDataSets = visualization.getDefinition().getDatasetList(); _.each(aDataSets, function (dataset) { var aMatchedSlots = SlotAPIHelper.getMappedSlotListByDataset(visualization, dataset.id); if (!aMatchedSlots || aMatchedSlots.length === 0) { this._aVIPRSlotMapping.push(null); } else { this._aVIPRSlotMapping.push(new VIPRDatasetMapping(aMatchedSlots, dataset.id)); } }.bind(this)); }, // implement IVIPRSlotMapping getDataSetMapping: function getDataSetMapping(index) { return this._aVIPRSlotMapping[index]; } }); return VIPRSlotMapping; }); //# sourceMappingURL=VIPRSlotMapping.js.map