123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2019
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['jquery', 'underscore', 'doT', '../../../lib/@waca/core-client/js/core-client/ui/core/View', 'text!./LabeledValue.html'], function ($, _, dot, View, LabeledValueTemplate) {
- var LabeledValueView = View.extend({
- templateString: LabeledValueTemplate,
- init: function init(options) {
- LabeledValueView.inherited('init', this, arguments);
- this.$el.addClass('labeled-value');
- this.dashboardApi = options.dashboardApi;
- this._value = options.value;
- this._valueStyle = options.valueStyle;
- this._showValueTranslationIcon = !!options.showValueTranslationIcon;
- this._label = options.label;
- this._labelStyle = options.labelStyle;
- this._showLabel = options.showLabel !== undefined ? options.showLabel : true;
- this._showLabelTranslationIcon = !!options.showLabelTranslationIcon;
- this._conditionalFormatting = options.conditionalFormatting;
- },
- remove: function remove() {
- this.$el.removeClass('labeled-value');
- LabeledValueView.inherited('remove', this, arguments);
- },
- render: function render() {
- this.$el.empty();
- this.$el.prepend(this.dotTemplate({
- value: this._value,
- valueStyle: this._valueStyle,
- label: this._label,
- labelStyle: this._labelStyle,
- showLabel: this._showLabel,
- shapeId: this._conditionalFormatting && this._conditionalFormatting.shapeId,
- shapeColor: this._conditionalFormatting && this._conditionalFormatting.color
- }));
- this._valueNode = this.$el.find('.labeled-value-value');
- this._labelNode = this.$el.find('.labeled-value-label');
- if (this.dashboardApi && (this._showValueTranslationIcon || this._showLabelTranslationIcon)) {
- var translationService = this.dashboardApi.getDashboardCoreSvc('TranslationService');
- if (this._showValueTranslationIcon) {
- translationService.appendTranslationIcon(this.$el.find('.labeled-value-value > span'));
- }
- if (this._showLabelTranslationIcon && this._showLabel) {
- translationService.appendTranslationIcon(this.$el.find('.labeled-value-label > span'));
- }
- }
- return Promise.resolve(this);
- },
- setValue: function setValue(value) {
- this._value = value;
- },
- setValueStyle: function setValueStyle(valueStyle) {
- this._valueStyle = valueStyle;
- },
- setShowValueTranslationIcon: function setShowValueTranslationIcon(iconPresent) {
- this._showValueTranslationIcon = iconPresent;
- },
- setLabel: function setLabel(label) {
- this._label = label;
- },
- setLabelStyle: function setLabelStyle(labelStyle) {
- this._labelStyle = labelStyle;
- },
- setShowLabel: function setShowLabel(showLabel) {
- this._showLabel = showLabel;
- },
- setShowLabelTranslationIcon: function setShowLabelTranslationIcon(iconPresent) {
- this._showLabelTranslationIcon = iconPresent;
- },
- setConditionalFormatting: function setConditionalFormatting(conditionalFormatting) {
- this._conditionalFormatting = conditionalFormatting;
- },
- getShowLabel: function getShowLabel() {
- return this._showLabel;
- },
- getValueNode: function getValueNode() {
- return this._valueNode;
- },
- getLabelNode: function getLabelNode() {
- return this._labelNode;
- },
- hasShape: function hasShape() {
- return !!(this._conditionalFormatting && this._conditionalFormatting.shapeId);
- }
- });
- return LabeledValueView;
- });
- //# sourceMappingURL=LabeledValueView.js.map
|