@rcsb/rcsb-saguaro-app
Version:
RCSB 1D Saguaro Web App
54 lines (53 loc) • 3.54 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RcsbGroupChartComponent = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = tslib_1.__importDefault(require("react"));
const GroupChartLayout_1 = require("./GroupChartLayout");
const SearchQueryTools_1 = require("../../../RcsbSeacrh/SearchQueryTools");
const GroupChartTools_1 = require("./GroupChartTools");
const classes = tslib_1.__importStar(require("../../../scss/bootstrap-group-display.module.scss"));
const RcsbGroupSeacrhQueryComponent_1 = require("../RcsbGroupSeacrhQuery/RcsbGroupSeacrhQueryComponent");
//TODO include chartDisplayConfig?: Partial<ChartDisplayConfigInterface> in props and propagate it
class RcsbGroupChartComponent extends react_1.default.Component {
componentDidMount() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
yield this.updateState();
});
}
render() {
var _a, _b, _c, _d, _e;
if (((_a = this.state) === null || _a === void 0 ? void 0 : _a.layout) && ((_b = this.state) === null || _b === void 0 ? void 0 : _b.chartMap) && ((_e = (_d = (_c = this.state) === null || _c === void 0 ? void 0 : _c.layout) === null || _d === void 0 ? void 0 : _d.filter((e) => { var _a, _b; return ((_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.chartMap) === null || _b === void 0 ? void 0 : _b.get(e)); })) !== null && _e !== void 0 ? _e : []).length > 0) {
return ((0, jsx_runtime_1.jsxs)("div", { className: classes.bootstrapGroupComponentScope, children: [RcsbGroupSeacrhQueryComponent_1.SearchQueryComponentFactory.getGroupSearchComponent(this.props.groupProvenanceId, this.props.groupId, this.props.searchQuery), (0, jsx_runtime_1.jsx)(GroupChartLayout_1.GroupChartLayout, { layout: this.state.layout, chartMap: this.state.chartMap })] }));
}
else {
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
}
}
updateState() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
var _a, _b, _c;
const layout = (_a = this.props.facetLayoutGrid) !== null && _a !== void 0 ? _a : SearchQueryTools_1.SearchQueryTools.getFacetStoreFromGroupProvenance(this.props.groupProvenanceId).facetLayoutGrid;
const chartMap = yield GroupChartTools_1.GroupChartMap.getChartMap(this.props.groupProvenanceId, this.props.groupId, this.props.searchQuery);
if ((_b = this.props.additionalProperties) === null || _b === void 0 ? void 0 : _b.layoutConfig)
applyLayoutConfig(layout, chartMap, (_c = this.props.additionalProperties) === null || _c === void 0 ? void 0 : _c.layoutConfig);
this.setState({ layout, chartMap }, () => {
var _a;
if (typeof ((_a = this.props.additionalProperties) === null || _a === void 0 ? void 0 : _a.componentMountCallback) === "function")
this.props.additionalProperties.componentMountCallback(this.state.chartMap, this.state.layout);
});
});
}
}
exports.RcsbGroupChartComponent = RcsbGroupChartComponent;
function applyLayoutConfig(layout, chartMap, layoutConfig) {
layout.forEach(attr => {
var _a;
if (chartMap.has(attr) && layoutConfig[attr]) {
const o = (_a = chartMap.get(attr)) === null || _a === void 0 ? void 0 : _a[0];
if (o)
o.title = layoutConfig[attr].title;
}
});
}