diff --git a/packages/cms/src/components/ProfileRenderer.jsx b/packages/cms/src/components/ProfileRenderer.jsx
index 84666a096..c29df1b45 100644
--- a/packages/cms/src/components/ProfileRenderer.jsx
+++ b/packages/cms/src/components/ProfileRenderer.jsx
@@ -17,6 +17,7 @@ import Subnav from "./sections/components/Subnav";
import Mirror from "./Viz/Mirror";
import isIE from "../utils/isIE.js";
import hashCode from "../utils/hashCode.js";
+import stripHTML from "../utils/formatters/stripHTML";
import deepClone from "../utils/deepClone.js";
@@ -197,9 +198,9 @@ class ProfileRenderer extends Component {
const innerGroupedSections = []; // array for sections to be accumulated into
let groupedSections = [];
- let printTables = [];
+ let printSections = [];
if (print) {
- printTables = sections.reduce((acc, d) => acc.concat(d.visualizations), []);
+ printSections = sections.filter(d => d.visualizations.length > 0);
}
// make sure there are sections to loop through (issue #700)
@@ -293,22 +294,20 @@ class ProfileRenderer extends Component {
}
{
- printTables.length > 0 &&
-
LOOK
- {printTables.map(d =>
-
+ printSections.length > 0 &&
+
APPENDIX
+ {printSections.map(section =>
+
+
{stripHTML(section.title)}
+ {section.visualizations.map((viz, i) =>
+
+ )}
+
)}
}
diff --git a/packages/cms/src/components/Viz/Options.jsx b/packages/cms/src/components/Viz/Options.jsx
index 201d08c0f..6010768dd 100644
--- a/packages/cms/src/components/Viz/Options.jsx
+++ b/packages/cms/src/components/Viz/Options.jsx
@@ -69,6 +69,29 @@ class Options extends Component {
this.dialog = React.createRef();
}
+ componentDidMount() {
+ // Options.jsx can be mounted in "dataOnly" mode, just prints all the data in a ReactTable. Used for printing PDFs.
+ // Therefore, fetch the data on mount (as opposed to behind a "view data" button click, as with regular Options)
+ const {dataOnly} = this.props;
+ if (dataOnly) {
+ const {data, dataFormat} = this.props;
+ const paths = typeof data === "string" ? [data] : data;
+ this.setState({loading: true});
+ Promise.all(paths.map(path => typeof path === "string" ? axios.get(path) : {data: path})).then(resps => {
+ const loaded = resps.map(d => d.data);
+ let results;
+ try {
+ results = dataFormat(loaded.length === 1 ? loaded[0] : loaded);
+ }
+ catch (e) {
+ console.log("Error in Options Panel: ", e);
+ results = [];
+ }
+ this.setState({loading: false, results});
+ });
+ }
+ }
+
componentDidUpdate(prevProps) {
const {data} = this.props;
if (JSON.stringify(prevProps.data) !== JSON.stringify(data)) {
@@ -320,7 +343,7 @@ class Options extends Component {
render() {
const {backgroundColor, imageContext, imageFormat, imageProcessing, includeSlug, dialogOpen, results, focusOptions} = this.state;
- const {data, iconOnly, slug, t, transitionDuration} = this.props;
+ const {data, dataOnly, iconOnly, slug, t, transitionDuration} = this.props;
// construct URL from a combination of redux & context (#537)
const domain = this.props.location.origin;
@@ -393,6 +416,22 @@ class Options extends Component {
;
+ if (dataOnly) {
+ return results ?