@gooddata/react-components
Version:
GoodData.UI - A powerful JavaScript library for building analytical applications
92 lines • 6.82 kB
JavaScript
"use strict";
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) 2020 GoodData Corporation
var React = require("react");
var react_intl_1 = require("react-intl");
var classnames_1 = require("classnames");
var get = require("lodash/get");
var BubbleHoverTrigger_1 = require("@gooddata/goodstrap/lib/Bubble/BubbleHoverTrigger");
var bubble_1 = require("../../constants/bubble");
var Bubble_1 = require("@gooddata/goodstrap/lib/Bubble/Bubble");
var ConfigurationPanelContent_1 = require("./ConfigurationPanelContent");
var CheckboxControl_1 = require("../configurationControls/CheckboxControl");
var ConfigSection_1 = require("../configurationControls/ConfigSection");
var mdObjectHelper_1 = require("../../utils/mdObjectHelper");
var PushpinSizeControl_1 = require("../configurationControls/PushpinSizeControl");
var PushpinViewportControl_1 = require("../configurationControls/PushpinViewportControl");
var LegendSection_1 = require("../configurationControls/legend/LegendSection");
var ColorsSection_1 = require("../configurationControls/colors/ColorsSection");
var GeoPushpinConfigurationPanel = /** @class */ (function (_super) {
__extends(GeoPushpinConfigurationPanel, _super);
function GeoPushpinConfigurationPanel() {
return _super !== null && _super.apply(this, arguments) || this;
}
GeoPushpinConfigurationPanel.prototype.getControlProperties = function () {
var props = this.props;
var groupNearbyPoints = get(props, "properties.controls.points.groupNearbyPoints", true);
return {
groupNearbyPoints: groupNearbyPoints,
};
};
GeoPushpinConfigurationPanel.prototype.renderLegendSection = function () {
var _a = this.props, mdObject = _a.mdObject, properties = _a.properties, propertiesMeta = _a.propertiesMeta, pushData = _a.pushData;
var isLegendVisible = mdObjectHelper_1.hasSegmentAttribute(mdObject) || mdObjectHelper_1.hasColorMeasure(mdObject) || mdObjectHelper_1.hasSizeMeasure(mdObject);
var controlsDisabled = this.isControlDisabled() || !isLegendVisible;
return (React.createElement(LegendSection_1.default, { properties: properties, propertiesMeta: propertiesMeta, controlsDisabled: controlsDisabled, pushData: pushData }));
};
GeoPushpinConfigurationPanel.prototype.renderViewportSection = function () {
var _a = this.props, properties = _a.properties, propertiesMeta = _a.propertiesMeta, pushData = _a.pushData;
return (React.createElement(ConfigSection_1.default, { id: "map_section", title: "properties.map.title", propertiesMeta: propertiesMeta, properties: properties, pushData: pushData },
React.createElement(PushpinViewportControl_1.default, { properties: properties, disabled: this.isControlDisabled(), pushData: pushData })));
};
GeoPushpinConfigurationPanel.prototype.renderPointsSection = function () {
var groupNearbyPoints = this.getControlProperties().groupNearbyPoints;
var _a = this.props, properties = _a.properties, propertiesMeta = _a.propertiesMeta, pushData = _a.pushData, mdObject = _a.mdObject;
var isControlDisabled = this.isControlDisabled();
var isClusteringDisabled = isControlDisabled || mdObjectHelper_1.hasMeasures(mdObject) || mdObjectHelper_1.hasSegmentAttribute(mdObject);
var isPushpinSizeControlDisabled = isControlDisabled || !mdObjectHelper_1.hasSizeMeasure(mdObject);
return (React.createElement(ConfigSection_1.default, { id: "points_section", title: "properties.points.title", propertiesMeta: propertiesMeta, properties: properties, pushData: pushData },
React.createElement(CheckboxControl_1.default, { valuePath: "points.groupNearbyPoints", labelText: "properties.points.groupNearbyPoints", properties: properties, checked: groupNearbyPoints, disabled: isClusteringDisabled, showDisabledMessage: isClusteringDisabled, pushData: pushData }),
React.createElement(PushpinSizeControl_1.default, { properties: properties, disabled: isPushpinSizeControlDisabled, pushData: pushData })));
};
GeoPushpinConfigurationPanel.prototype.isControlDisabled = function () {
var _a = this.props, mdObject = _a.mdObject, isError = _a.isError, isLoading = _a.isLoading;
return !mdObjectHelper_1.hasLocationAttribute(mdObject) || isError || isLoading;
};
GeoPushpinConfigurationPanel.prototype.getBubbleClassNames = function () {
return classnames_1.default("bubble-primary", {
invisible: !this.isControlDisabled(),
});
};
GeoPushpinConfigurationPanel.prototype.renderConfigurationPanel = function () {
return (React.createElement(BubbleHoverTrigger_1.default, { showDelay: bubble_1.SHOW_DELAY_DEFAULT, hideDelay: bubble_1.HIDE_DELAY_DEFAULT },
React.createElement("div", null,
this.renderColorSection(),
this.renderLegendSection(),
this.renderViewportSection(),
this.renderPointsSection()),
React.createElement(Bubble_1.default, { className: this.getBubbleClassNames(), arrowOffsets: { "tc bc": [bubble_1.BUBBLE_ARROW_OFFSET_X, bubble_1.BUBBLE_ARROW_OFFSET_Y] }, alignPoints: [{ align: "tc bc" }] },
React.createElement(react_intl_1.FormattedMessage, { id: "properties.config.not_applicable" }))));
};
GeoPushpinConfigurationPanel.prototype.renderColorSection = function () {
var _a = this.props, properties = _a.properties, propertiesMeta = _a.propertiesMeta, pushData = _a.pushData, colors = _a.colors, featureFlags = _a.featureFlags, references = _a.references, isLoading = _a.isLoading;
var controlsDisabled = this.isControlDisabled();
return (React.createElement(ColorsSection_1.default, { properties: properties, propertiesMeta: propertiesMeta, references: references, colors: colors, controlsDisabled: controlsDisabled, pushData: pushData, hasMeasures: true, showCustomPicker: featureFlags.enableCustomColorPicker, isLoading: isLoading }));
};
return GeoPushpinConfigurationPanel;
}(ConfigurationPanelContent_1.default));
exports.default = GeoPushpinConfigurationPanel;
//# sourceMappingURL=GeoPushpinConfigurationPanel.js.map