'use strict'; /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2017 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['../../lib/@waca/core-client/js/core-client/ui/core/View', '../../lib/@waca/core-client/js/core-client/i18n/Formatter', '../nls/StringResources', 'text!./templates/Labels.html'], function (View, Formatter, stringResources, template) { var Labels = null; /** * Display a list of labels. Each label has a name and value. */ Labels = View.extend({ templateString: template, init: function init(options) { Labels.inherited('init', this, arguments); this.labels = options.labels; this.title = options.title; this._formatter = options.formatter || Formatter; }, /** * Draws the labels */ render: function render() { var labels = []; if (this.labels) { for (var i = 0; i < this.labels.length; i++) { var label = this.labels[i]; var value = this._getValue(label); var stringResourceName = value ? 'toolbarLabel' : 'toolbarNoValueLabel'; labels.push({ name: stringResources.get(stringResourceName, { labelName: label.name }), value: value }); } } var sHtml = this.dotTemplate({ title: this.title, labels: labels }); this.$el.addClass('labels'); this.$el.html(sHtml); }, _getValue: function _getValue(label) { var value = label.value; var formatSpec = label.formatSpec; if (label.dataType === 'date') { value = this._formatter.formatDateTime(value, formatSpec); } else if (!isNaN(value) && value !== null) { value = this._formatter.formatNumber(value, formatSpec); } return value; } }); return Labels; }); //# sourceMappingURL=Labels.js.map