@gooddata/react-components
Version:
GoodData.UI - A powerful JavaScript library for building analytical applications
47 lines • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var IntlStore_1 = require("../helpers/IntlStore");
var OverTimeComparison_1 = require("../interfaces/OverTimeComparison");
/**
* Factory that builds formatted localized suffix string for derived measure based on the over time comparison type.
* The suffix is used during AFM execution and for bucket item titles.
*
* @internal
*/
var DerivedMeasureTitleSuffixFactory = /** @class */ (function () {
/**
* Create a new instance of the class.
* @param {Localization.ILocale} locale - The locale used for translation.
*/
function DerivedMeasureTitleSuffixFactory(locale) {
this.locale = locale;
}
/**
* Returns formatted localized suffix string for derived measure based on the over time comparison type.
* In case when unsupported over time comparison type is provided the empty string is returned.
*
* @param {OverTimeComparisonType} overTimeComparisonType - The over time comparison type for which the
* suffix must be obtained.
* @returns {string}
*/
DerivedMeasureTitleSuffixFactory.prototype.getSuffix = function (overTimeComparisonType) {
var localizationKey = this.getSuffixLocalizationKey(overTimeComparisonType);
return localizationKey === null ? "" : " - " + this.translateKey(localizationKey);
};
DerivedMeasureTitleSuffixFactory.prototype.getSuffixLocalizationKey = function (overTimeComparisonType) {
switch (overTimeComparisonType) {
case OverTimeComparison_1.OverTimeComparisonTypes.SAME_PERIOD_PREVIOUS_YEAR:
return "measure.title.suffix.same_period_year_ago";
case OverTimeComparison_1.OverTimeComparisonTypes.PREVIOUS_PERIOD:
return "measure.title.suffix.previous_period";
default:
return null;
}
};
DerivedMeasureTitleSuffixFactory.prototype.translateKey = function (localizationKey) {
return IntlStore_1.default.getTranslation(localizationKey, this.locale);
};
return DerivedMeasureTitleSuffixFactory;
}());
exports.default = DerivedMeasureTitleSuffixFactory;
//# sourceMappingURL=DerivedMeasureTitleSuffixFactory.js.map