@gooddata/react-components
Version:
GoodData.UI - A powerful JavaScript library for building analytical applications
75 lines • 4.53 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
// (C) 2007-2020 GoodData Corporation
var React = require("react");
var react_intl_1 = require("react-intl");
var noop = require("lodash/noop");
var headerPredicate_1 = require("../../../helpers/headerPredicate");
var Headline_1 = require("./Headline");
var HeadlineTransformationUtils_1 = require("./utils/HeadlineTransformationUtils");
var drilldownEventing_1 = require("../utils/drilldownEventing");
var drilldownEventingLegacy_1 = require("../utils/drilldownEventingLegacy");
/**
* The React component that handles the transformation of the execution objects into the data accepted by the {Headline}
* React component that this components wraps. It also handles the propagation of the drillable items to the component
* and drill events out of it.
*/
var HeadlineTransformation = /** @class */ (function (_super) {
__extends(HeadlineTransformation, _super);
function HeadlineTransformation(props) {
var _this = _super.call(this, props) || this;
_this.handleOnDrill = function (item) {
var _a = _this.props, executionRequest = _a.executionRequest, executionResponse = _a.executionResponse, onDrill = _a.onDrill;
var drillEventDataExtended = HeadlineTransformationUtils_1.buildDrillEventData(item, executionRequest, executionResponse);
onDrill(drillEventDataExtended);
};
_this.handleFiredDrillEvent = _this.handleFiredDrillEvent.bind(_this);
return _this;
}
HeadlineTransformation.prototype.render = function () {
var _a = this.props, intl = _a.intl, executionRequest = _a.executionRequest, executionResponse = _a.executionResponse, executionResult = _a.executionResult, drillableItems = _a.drillableItems, config = _a.config, onAfterRender = _a.onAfterRender;
var data = HeadlineTransformationUtils_1.getHeadlineData(executionResponse, executionResult, intl);
var drillablePredicates = headerPredicate_1.convertDrillableItemsToPredicates(drillableItems);
var dataWithUpdatedDrilling = HeadlineTransformationUtils_1.applyDrillableItems(data, drillablePredicates, executionRequest, executionResponse);
var disableDrillUnderline = this.getDisableDrillUnderlineFromConfig();
return (React.createElement(Headline_1.default, { data: dataWithUpdatedDrilling, config: config, onFiredDrillEvent: this.handleFiredDrillEvent, onDrill: this.handleOnDrill, onAfterRender: onAfterRender, disableDrillUnderline: disableDrillUnderline }));
};
HeadlineTransformation.prototype.getDisableDrillUnderlineFromConfig = function () {
if (this.props.config) {
return this.props.config.disableDrillUnderline;
}
};
// legacy drill handling
HeadlineTransformation.prototype.handleFiredDrillEvent = function (item, target) {
var _a = this.props, onFiredDrillEvent = _a.onFiredDrillEvent, executionRequest = _a.executionRequest, executionResponse = _a.executionResponse;
var drillEventDataExtended = HeadlineTransformationUtils_1.buildDrillEventData(item, executionRequest, executionResponse);
var executionContext = drillEventDataExtended.executionContext, drillContext = drillEventDataExtended.drillContext;
var drillEventDataOld = {
executionContext: executionContext,
drillContext: drilldownEventingLegacy_1.convertDrillContextToLegacy(drillContext, executionContext),
};
drilldownEventing_1.fireDrillEvent(onFiredDrillEvent, drillEventDataOld, target);
};
HeadlineTransformation.defaultProps = {
drillableItems: [],
onFiredDrillEvent: function () { return true; },
onDrill: noop,
onAfterRender: noop,
};
return HeadlineTransformation;
}(React.Component));
exports.default = react_intl_1.injectIntl(HeadlineTransformation);
//# sourceMappingURL=HeadlineTransformation.js.map