'use strict'; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** * Licensed Materials - Property of IBM * IBM Business Analytics (C) Copyright IBM Corp. 2019, 2020 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['underscore', './VIPRDecoratable', './VIPRFormatter', '../../../widgets/livewidget/nls/StringResources'], function (_, VIPRDecoratable, VIPRFormatter, StringResources) { // implements IItem var VIPRItem = function (_VIPRDecoratable) { _inherits(VIPRItem, _VIPRDecoratable); function VIPRItem(item, context, content) { _classCallCheck(this, VIPRItem); var _this = _possibleConstructorReturn(this, _VIPRDecoratable.call(this, item, context)); _this.item = item; _this.content = content; _this.context = context; _this._tuples = []; _this.dataset = context.dataset; _this._recalculateFormattedValue(); _this.dataset = context.dataset; return _this; } /** * We are checking here if the aggregateTypeVisible toggler is on/off for multiMeasures * Regardless of the formatted string, this unformattedValue will remain constant which allows usage such as color consistency (fred is red) */ VIPRItem.prototype._recalculateFormattedValue = function _recalculateFormattedValue() { var formatter = new VIPRFormatter(this.context.index.dataitem, this.context.index.tupleitem, this.context); if (this.item.value === undefined || this.item.label === null) { this.formattedValue = formatter.format(null); this.unformattedValue = this.formattedValue; } else if (this.item.aggregate) { var aggregateTypeVisible = !!this.content.getPropertyValue('widget.legend.aggregateTypeVisible'); if (aggregateTypeVisible) { this.formattedValue = formatter.format(StringResources.get('multiMeasureLabel', { 'measureName': this.item.label.toString(), 'aggregate': StringResources.get(this.item.aggregate.toString()) })); this.unformattedValue = this.item.label + this.item.aggregate; } else { this.formattedValue = formatter.format(StringResources.get('measureLabel', { 'measureName': this.item.label.toString() })); this.unformattedValue = this.item.label + this.item.aggregate; } } else { this.formattedValue = formatter.format(this.item.label.toString()); this.unformattedValue = this.item.label; } }; VIPRItem.prototype.addTuple = function addTuple(tuple) { this._tuples.push(tuple); this._datapoints = null; }; VIPRItem.prototype.getUniqueName = function getUniqueName() { return this.item.value === undefined || this.item.value === null ? this.item.value : this.item.value.toString(); }; VIPRItem.prototype.getCaption = function getCaption() { if (this.item.aggregate) { var currentAggregationPropertyValue = this.content.getPropertyValue('widget.legend.aggregateTypeVisible'); if (currentAggregationPropertyValue != this.aggregationPropertyValue) { this._recalculateFormattedValue(); this.aggregationPropertyValue = currentAggregationPropertyValue; } } if (!this.formattedValue) { this._recalculateFormattedValue(); } return this.formattedValue; }; VIPRItem.prototype.getParent = function getParent() { return this.item.p; }; VIPRItem.prototype.decorate = function decorate(action, value) { var _VIPRDecoratable$prot; (_VIPRDecoratable$prot = _VIPRDecoratable.prototype.decorate).call.apply(_VIPRDecoratable$prot, [this].concat(Array.prototype.slice.call(arguments))); var datapoints = this.datapoints; if (datapoints.length > 0) { this.context.version++; // decorate the datapoints for (var i = 0; i < datapoints.length; i++) { datapoints[i].decorate(action, value); } } }; _createClass(VIPRItem, [{ key: 'datapoints', get: function get() { if (!this._datapoints) { this._datapoints = []; for (var i = 0; i < this._tuples.length; i++) { var tuple = this._tuples[i]; for (var j = 0; j < tuple.datapoints.length; j++) { this._datapoints.push(tuple.datapoints[j]); } } } return this._datapoints; } }]); return VIPRItem; }(VIPRDecoratable); return VIPRItem; }); //# sourceMappingURL=VIPRItem.js.map