@rcsb/rcsb-saguaro-app
Version:
RCSB 1D Saguaro Web App
50 lines • 3.2 kB
JavaScript
import { __awaiter } from "tslib";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import React from "react";
import { GroupChartLayout } from "./GroupChartLayout";
import { SearchQueryTools as SQT } from "../../../RcsbSeacrh/SearchQueryTools";
import { GroupChartMap as GDCM } from "./GroupChartTools";
import * as classes from "../../../scss/bootstrap-group-display.module.scss";
import { SearchQueryComponentFactory } from "../RcsbGroupSeacrhQuery/RcsbGroupSeacrhQueryComponent";
//TODO include chartDisplayConfig?: Partial<ChartDisplayConfigInterface> in props and propagate it
export class RcsbGroupChartComponent extends React.Component {
componentDidMount() {
return __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 (_jsxs("div", { className: classes.bootstrapGroupComponentScope, children: [SearchQueryComponentFactory.getGroupSearchComponent(this.props.groupProvenanceId, this.props.groupId, this.props.searchQuery), _jsx(GroupChartLayout, { layout: this.state.layout, chartMap: this.state.chartMap })] }));
}
else {
return _jsx(_Fragment, {});
}
}
updateState() {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c;
const layout = (_a = this.props.facetLayoutGrid) !== null && _a !== void 0 ? _a : SQT.getFacetStoreFromGroupProvenance(this.props.groupProvenanceId).facetLayoutGrid;
const chartMap = yield GDCM.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);
});
});
}
}
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;
}
});
}
//# sourceMappingURL=RcsbGroupChartComponent.js.map