Skip to content

Commit

Permalink
Merge pull request #2283 from akvo/#2268-project-summary-markdown
Browse files Browse the repository at this point in the history
[#2268] Added markdown support to project summary field
  • Loading branch information
KasperBrandt authored Jun 30, 2016
2 parents 2627b71 + 782aae1 commit d9f7370
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ function renderReportTab() {
var projectPlanText = {__html: micromarkdown.parse(proj.project_plan)};
var goalsOverviewText = {__html: micromarkdown.parse(proj.goals_overview)};
var targetGroupText = {__html: micromarkdown.parse(proj.target_group)};
var projectPlanSummaryText = {__html: micromarkdown.parse(proj.project_plan_summary)};
var backgroundText = {__html: micromarkdown.parse(proj.background)};
var currentStatusText = {__html: micromarkdown.parse(proj.current_status)};
var sustainabilityText = {__html: micromarkdown.parse(proj.sustainability)};
Expand All @@ -426,7 +427,7 @@ function renderReportTab() {
),
React.DOM.tr(null,
React.DOM.th( {scope:"row"}, i18nReport.project_plan_summary),
React.DOM.td(null, proj.project_plan_summary)
React.DOM.td( {dangerouslySetInnerHTML:projectPlanSummaryText} )
),
React.DOM.tr(null,
React.DOM.th( {scope:"row"}, i18nReport.background),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ function renderReportTab() {
var projectPlanText = {__html: micromarkdown.parse(proj.project_plan)};
var goalsOverviewText = {__html: micromarkdown.parse(proj.goals_overview)};
var targetGroupText = {__html: micromarkdown.parse(proj.target_group)};
var projectPlanSummaryText = {__html: micromarkdown.parse(proj.project_plan_summary)};
var backgroundText = {__html: micromarkdown.parse(proj.background)};
var currentStatusText = {__html: micromarkdown.parse(proj.current_status)};
var sustainabilityText = {__html: micromarkdown.parse(proj.sustainability)};
Expand All @@ -426,7 +427,7 @@ function renderReportTab() {
</tr>
<tr>
<th scope="row">{i18nReport.project_plan_summary}</th>
<td>{proj.project_plan_summary}</td>
<td dangerouslySetInnerHTML={projectPlanSummaryText} />
</tr>
<tr>
<th scope="row">{i18nReport.background}</th>
Expand Down
12 changes: 12 additions & 0 deletions akvo/rsr/static/scripts-src/project-main/project-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,17 @@ function readMoreOnClicks() {
}
}

function setSummaryMarkdown() {
var summaryTruncated = document.getElementById('summary-truncated');
var summaryFull = document.getElementById('summary-full');
if (summaryTruncated !== null) {
summaryTruncated.innerHTML = micromarkdown.parse(summaryTruncated.innerHTML.trim());
}
if (summaryFull !== null) {
summaryFull.innerHTML = micromarkdown.parse(summaryFull.innerHTML.trim());
}
}

function showTab(tabClass) {
var allTabs = document.querySelectorAll('.project-tab');
var allTabLinks = document.querySelectorAll('.tab-link.selected');
Expand Down Expand Up @@ -478,6 +489,7 @@ document.addEventListener('DOMContentLoaded', function() {
defaultValues = JSON.parse(document.getElementById("default-values").innerHTML);

// Setup project tabs
setSummaryMarkdown();
setTabsOnClicks();
readTabFromFragment();
readMoreOnClicks();
Expand Down
12 changes: 12 additions & 0 deletions akvo/rsr/static/scripts-src/project-main/project-main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,17 @@ function readMoreOnClicks() {
}
}

function setSummaryMarkdown() {
var summaryTruncated = document.getElementById('summary-truncated');
var summaryFull = document.getElementById('summary-full');
if (summaryTruncated !== null) {
summaryTruncated.innerHTML = micromarkdown.parse(summaryTruncated.innerHTML.trim());
}
if (summaryFull !== null) {
summaryFull.innerHTML = micromarkdown.parse(summaryFull.innerHTML.trim());
}
}

function showTab(tabClass) {
var allTabs = document.querySelectorAll('.project-tab');
var allTabLinks = document.querySelectorAll('.tab-link.selected');
Expand Down Expand Up @@ -478,6 +489,7 @@ document.addEventListener('DOMContentLoaded', function() {
defaultValues = JSON.parse(document.getElementById("default-values").innerHTML);

// Setup project tabs
setSummaryMarkdown();
setTabsOnClicks();
readTabFromFragment();
readMoreOnClicks();
Expand Down

0 comments on commit d9f7370

Please sign in to comment.