Skip to content

Commit

Permalink
[Enhancement #62] It is now possible to turn-off/on the comments in t…
Browse files Browse the repository at this point in the history
…he options
  • Loading branch information
LaChope committed Oct 19, 2021
1 parent 297c2b2 commit 344d3ed
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 18 deletions.
22 changes: 15 additions & 7 deletions src/components/Answer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,28 @@ const Answer = (props) => {
/>
) : null;

const _renderQuestionCommentIcon = () => {
if (options.enableComments) {
return (
<Col className="no-padding-left" lg="auto">
<QuestionCommentIcon
question={question}
onChange={props.onCommentChange}
/>
</Col>
);
} else return null;
}

return (
<Row>
<Col className="no-padding-right" lg="auto">{label}</Col>
{questionHelp ?
<>
<Col className="no-padding-left" lg="1" >{questionHelp}</Col>
<Col className="no-padding-left" lg="auto"><QuestionCommentIcon question={question} onChange={props.onCommentChange}/></Col>
{_renderQuestionCommentIcon()}
</>
: <Col className="no-padding-left" lg="auto">
<QuestionCommentIcon
question={question}
onChange={props.onCommentChange}
/>
</Col>
: _renderQuestionCommentIcon()
}
</Row>
);
Expand Down
17 changes: 10 additions & 7 deletions src/components/Question.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,9 @@ export default class Question extends React.Component {
<Col className="no-padding-left" lg="auto">
{this._renderQuestionHelp()}
</Col>
<Col className="no-padding-left" lg="auto">
{this._renderQuestionComment()}
</Col>
</>
: <Col className="no-padding-left" lg="auto">{this._renderQuestionComment()}</Col>
: this._renderQuestionComment()
}
</Row>
</Accordion.Toggle>
Expand Down Expand Up @@ -337,10 +335,15 @@ export default class Question extends React.Component {
}

_renderQuestionComment() {
return <QuestionCommentIcon
question={this.props.question}
onChange={this.onCommentChange}
/>
if (this.context.options.enableComments) {
return (
<Col className="no-padding-left" lg="auto">
<QuestionCommentIcon
question={this.props.question}
onChange={this.onCommentChange} />
</Col>
);
} else return null;
}

_renderPrefixes() {
Expand Down
15 changes: 12 additions & 3 deletions src/components/wizard/WizardStep.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,16 @@ export default class WizardStep extends React.Component {
_renderQuestionCommentIcon = () => {
const question = this.context.getFormQuestionsData([this.props.stepIndex]);

return <QuestionCommentIcon question={question} onChange={this.onCommentChange} />
if (this.props.options.enableComments) {
return (
<Col className="no-padding-left" lg="auto">
<QuestionCommentIcon
question={question}
onChange={this.onCommentChange}
/>
</Col>
);
} else return null;
}

onCommentChange = (commentIndex, change) => {
Expand Down Expand Up @@ -96,9 +105,9 @@ export default class WizardStep extends React.Component {
{this._renderHelpIcon() ?
<>
<Col className="no-padding-left" lg="auto">{this._renderHelpIcon()}</Col>
<Col className="no-padding-left" lg="auto">{this._renderQuestionCommentIcon()}</Col>
{this._renderQuestionCommentIcon()}
</>
: <Col className="no-padding-left" lg="auto">{this._renderQuestionCommentIcon()}</Col>
: this._renderQuestionCommentIcon()
}
</Row>
</Card.Header>
Expand Down
3 changes: 2 additions & 1 deletion test/rendering/TestApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class TestApp extends React.Component {
users: [
{id: "http://fel.cvut.cz/people/max-chopart", label: "Max Chopart"},
{id: "http://fel.cvut.cz/people/miroslav-blasko", label: "Miroslav Blasko"}],
currentUser: "http://fel.cvut.cz/people/max-chopart"
currentUser: "http://fel.cvut.cz/people/max-chopart",
enableComments: false
};

return (
Expand Down

0 comments on commit 344d3ed

Please sign in to comment.