123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- 'use strict';
- define(['underscore', '../../lib/@waca/core-client/js/core-client/ui/core/Class', '../../apiHelpers/SlotAPIHelper'], function (_, Class, SlotAPIHelper) {
-
- 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 (id === slotDef.name) {
- indices.push(index);
- }
- index++;
- } else {
- _.each(slotAPI.getDataItemList(), function () {
- if (id === slotDef.name) {
- indices.push(index);
- }
- index++;
- });
- }
- });
- return indices;
- }
- });
-
- 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));
- },
-
- getDataSetMapping: function getDataSetMapping(index) {
- return this._aVIPRSlotMapping[index];
- }
- });
- return VIPRSlotMapping;
- });
|