Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

Commit

Permalink
html to string in presentations report
Browse files Browse the repository at this point in the history
  • Loading branch information
santipalenque committed Feb 19, 2024
1 parent 35ecbcc commit 7cfcbab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/reports/smart-presentation-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Select from 'react-select';
const Query = require('graphql-query-builder');
import wrapReport from './report-wrapper';
import {flattenData} from "../../actions/report-actions";
import {parseAndFormat} from "../../utils/methods";
import {htmlToString, parseAndFormat} from "../../utils/methods";


const fieldNames = [
Expand Down Expand Up @@ -139,6 +139,12 @@ class SmartPresentationReport extends React.Component {
if (d.endDate) d.endDate = parseAndFormat(d.endDate, 'YYYY-MM-DDTHH:mm:ss+00:00', 'MM/DD/YYYY h:mma','UTC', currentSummit.time_zone_id);
// bc legacy SilverStripe
if (d.created) d.created = parseAndFormat(d.created, 'YYYY-MM-DDTHH:mm:ss+00:00', 'America/Chicago');

if (forExport) {
if (d.abstract) d.abstract = htmlToString(d.abstract);
if (d.socialSummary) d.socialSummary = htmlToString(d.socialSummary);
if (d.expectToLearn) d.expectToLearn = htmlToString(d.expectToLearn);
}
});

let columns = [
Expand Down
6 changes: 6 additions & 0 deletions src/utils/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,10 @@ export const joinCVSChunks = (chunks) => {
}, '');

return `${header}\n${csv}`;
}

export const htmlToString = (html) => {
return new DOMParser()
.parseFromString(html, "text/html")
.documentElement.textContent;
}

0 comments on commit 7cfcbab

Please sign in to comment.