Skip to content

Commit

Permalink
#3081: Make htmlTemplate for rickTextEditor configurable
Browse files Browse the repository at this point in the history
It is now possible to configure within the anet.yml, through
report.reportText.placeholder the html template to be used per
default for the report text.
  • Loading branch information
maradragan committed Jun 30, 2020
1 parent a116a82 commit a4ec1ac
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 43 deletions.
4 changes: 3 additions & 1 deletion anet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ dictionary:
reportTags: Tags
nextSteps: Next steps
keyOutcomes: Key outcomes
reportText: Key details
reportText:
label: Key details
placeholder: <h1 class="mandatory" placeholder="Key details 1">Key details 1</h1><p class="mandatory" placeholder="Type here key details 1 extra information">Type here key details 1 extra information</p><h1 class="mandatory" placeholder="Key details 2">Key details 2</h1><p class="mandatory" placeholder="Type here key details 2 extra information">Type here key details 2 extra information</p><h1 class="mandatory" placeholder="Key details 3">Key details 3</h1><p class="mandatory" placeholder="Type here key details 3 extra information">Type here key details 3 extra information</p>
customFields:
multipleButtons:
type: enumset
Expand Down
12 changes: 5 additions & 7 deletions client/src/components/RichTextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ class RichTextEditor extends Component {
value,
onChange,
onHandleBlur,
template,
templateHTML
htmlTemplate
} = this.props
const { sideToolbarPlugin } = this.state
const { SideToolbar } = sideToolbarPlugin
Expand All @@ -230,9 +229,9 @@ class RichTextEditor extends Component {
rawContentState={
value
? fromHTML(value)
: templateHTML
? fromHTML(templateHTML)
: template || null
: htmlTemplate
? fromHTML(htmlTemplate)
: null
}
showUndoControl
showRedoControl
Expand Down Expand Up @@ -267,8 +266,7 @@ RichTextEditor.propTypes = {
value: PropTypes.string,
onChange: PropTypes.func,
onHandleBlur: PropTypes.func,
template: PropTypes.object,
templateHTML: PropTypes.string
htmlTemplate: PropTypes.string
}

export default RichTextEditor
35 changes: 4 additions & 31 deletions client/src/pages/reports/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import ReportTags from "components/ReportTags"
import RichTextEditor from "components/RichTextEditor"
import { RECURSE_STRATEGY } from "components/SearchFilters"
import TaskTable from "components/TaskTable"
import { BLOCK_TYPE } from "draftail"
import { FastField, Field, Form, Formik } from "formik"
import _cloneDeep from "lodash/cloneDeep"
import _debounce from "lodash/debounce"
Expand Down Expand Up @@ -503,33 +502,6 @@ const BaseReportForm = ({
</div>
)
const isFutureEngagement = Report.isFuture(values.engagementDate)
const reportTextTemplateHTML =
'<h1 class="mandatory" style={ placeholder: "aaa" }>Key details 1</h1><p class="mandatory"></p><h1 class="mandatory" style={ placeholder: "aaa" }>Key details 2</h1><p class="mandatory"></p>'
const reportTextTemplate = {
blocks: [
{
data: { mandatory: true, class: "mandatory" },
text: "Step 1",
type: BLOCK_TYPE.HEADER_ONE
},
{
data: { mandatory: true },
text: "Step 2",
type: BLOCK_TYPE.HEADER_ONE
},
{
data: {},
text: "Step 3",
type: BLOCK_TYPE.HEADER_ONE
},
{
data: { class: "mandatory" },
text: "",
type: BLOCK_TYPE.HEADER_ONE
}
],
entityMap: {}
}
return (
<div className="report-form">
<NavigationWarning isBlocking={dirty} />
Expand Down Expand Up @@ -978,7 +950,7 @@ const BaseReportForm = ({

<FastField
name="reportText"
label={Settings.fields.report.reportText}
label={Settings.fields.report.reportText.label}
component={FieldHelper.SpecialField}
onChange={value => setFieldValue("reportText", value, true)}
widget={
Expand All @@ -988,8 +960,9 @@ const BaseReportForm = ({
// validation will be done by setFieldValue
setFieldTouched("reportText", true, false)
}}
template={reportTextTemplate}
templateHTML={reportTextTemplateHTML}
htmlTemplate={
Settings.fields.report.reportText.placeholder
}
/>
}
/>
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/reports/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ const BaseReportShow = ({ currentUser, setSearchQuery, pageDispatchers }) => {
/>
</Fieldset>
{report.reportText && (
<Fieldset title={Settings.fields.report.reportText}>
<Fieldset title={Settings.fields.report.reportText.label}>
{parseHtmlWithLinkTo(report.reportText)}
</Fieldset>
)}
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/anet-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,7 @@ properties:
title: The label for report's key outcomes
description: Used in the UI where report's key outcomes are shown.
reportText:
type: string
title: The label for report's engagement details
description: Used in the UI where report's engagement details are shown.
"$ref": "#/definitions/inputField"
customFields:
type: object
additionalProperties:
Expand Down

0 comments on commit a4ec1ac

Please sign in to comment.