@gooddata/react-components
Version:
GoodData.UI - A powerful JavaScript library for building analytical applications
72 lines • 3.49 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// (C) 2007-2018 GoodData Corporation
var get = require("lodash/get");
function getDisplayFormFromAttr(attrs, attributeName, displayFormName, property) {
if (!displayFormName) {
return get(attrs, [attributeName, "defaultDisplayForm", property]);
}
return get(attrs, [attributeName, "displayForms", displayFormName, property]);
}
/**
* CatalogHelper
* is a tool that exposes API that to look up measures, attributes, visualizations and other metadata elements
* example usage:
* import catalog from './catalog.json';
* const C = new CatalogHelper(catalog);
*/
var CatalogHelper = /** @class */ (function () {
function CatalogHelper(catalog) {
this.measures = catalog.measures;
this.visualizations = catalog.visualizations;
this.attributes = catalog.attributes;
this.dateDataSets = catalog.dateDataSets;
}
CatalogHelper.prototype.measure = function (name) {
return get(this, ["measures", name, "identifier"]);
};
CatalogHelper.prototype.measureTags = function (name) {
return get(this, ["measures", name, "tags"]);
};
CatalogHelper.prototype.visualization = function (name) {
return get(this, ["visualizations", name, "identifier"]);
};
CatalogHelper.prototype.visualizationTags = function (name) {
return get(this, ["visualizations", name, "tags"]);
};
CatalogHelper.prototype.attribute = function (attributeName) {
return get(this, ["attributes", attributeName, "identifier"]);
};
CatalogHelper.prototype.attributeTags = function (attributeName) {
return get(this, ["attributes", attributeName, "tags"]);
};
CatalogHelper.prototype.attributeDisplayForm = function (attributeName, displayFormName) {
return getDisplayFormFromAttr(this.attributes, attributeName, displayFormName, "identifier");
};
CatalogHelper.prototype.attributeDisplayFormTags = function (attributeName, displayFormName) {
return getDisplayFormFromAttr(this.attributes, attributeName, displayFormName, "tags");
};
CatalogHelper.prototype.dateDataSet = function (dataSetName) {
return get(this, ["dateDataSets", dataSetName, "identifier"]);
};
CatalogHelper.prototype.dateDataSetTags = function (dataSetName) {
return get(this, ["dateDataSets", dataSetName, "tags"]);
};
CatalogHelper.prototype.dateDataSetAttribute = function (dataSetName, attrName) {
return get(this, ["dateDataSets", dataSetName, "attributes", attrName, "identifier"]);
};
CatalogHelper.prototype.dateDataSetAttributeTags = function (dataSetName, attrName) {
return get(this, ["dateDataSets", dataSetName, "attributes", attrName, "tags"]);
};
CatalogHelper.prototype.dateDataSetDisplayForm = function (dataSetName, attributeName, displayFormName) {
var attrs = get(this, ["dateDataSets", dataSetName, "attributes"]);
return getDisplayFormFromAttr(attrs, attributeName, displayFormName, "identifier");
};
CatalogHelper.prototype.dateDataSetDisplayFormTags = function (dataSetName, attributeName, displayFormName) {
var attrs = get(this, ["dateDataSets", dataSetName, "attributes"]);
return getDisplayFormFromAttr(attrs, attributeName, displayFormName, "tags");
};
return CatalogHelper;
}());
exports.default = CatalogHelper;
//# sourceMappingURL=CatalogHelper.js.map