'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. 2019 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ /** * Event helper class **/ define(['underscore'], function (_) { var _class, _temp; var EventUtils = (_temp = _class = function () { function EventUtils() { _classCallCheck(this, EventUtils); } // TODO QueryResultAPI: Remove after EventUtils.toDeprecatedPayload = function toDeprecatedPayload(value) { if (!value) { return value; } var useValue = value.value !== undefined ? value.value : value; var displayValue = value.label !== undefined ? value.label : useValue; var returnValue = { u: useValue, d: displayValue, value: useValue, label: displayValue }; if (value.p !== undefined && value.p !== null) { returnValue.p = value.p; } return returnValue; }; /** * Return keys for dataPoints. * @param datapoints Array of data points. */ EventUtils.getDataPointKey = function getDataPointKey(dataPoint) { var key = ''; var tempDataPoint = _.clone(dataPoint); //Make a copy to sort and keep dataPoint unchanged. var sortedDataPoint = tempDataPoint.sort(EventUtils.compareDataPointKey); _.each(sortedDataPoint, function (tuplePart) { var u = tuplePart.u || tuplePart; key += u + EventUtils.SEPARATOR; }); return key.slice(0, -1); }; EventUtils.compareDataPointKey = function compareDataPointKey(a, b) { if (a.u < b.u) { return -1; } if (a.u > b.u) { return 1; } return 0; }; /** * Return keys for items (datapoint/edge). * @param tuples Array of data points or edge object */ EventUtils.getItemKey = function getItemKey(tuple) { var key = void 0; if (Array.isArray(tuple)) { key = EventUtils.getDataPointKey(tuple); } else { key = tuple.u || tuple; } return key; }; return EventUtils; }(), _class.SEPARATOR = '\xD7', _temp); return EventUtils; }); //# sourceMappingURL=EventUtils.js.map