Skip to content

Commit

Permalink
[Enhancement #60] WizardStep has now a QuestionCommentIcon.
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed Oct 12, 2021
1 parent 1519f76 commit 693cebb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/components/wizard/WizardStep.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Constants from '../../constants/Constants';
import HelpIcon from '../HelpIcon';
import { FormQuestionsContext } from '../../contexts/FormQuestionsContext';
import Question from '../Question';
import QuestionCommentIcon from "../comment/QuestionCommentIcon";
import JsonLdObjectMap from "../../util/JsonLdObjectMap";


export default class WizardStep extends React.Component {
Expand Down Expand Up @@ -34,6 +36,24 @@ export default class WizardStep extends React.Component {
) : null;
};

_renderQuestionCommentIcon = () => {
const question = this.context.getFormQuestionsData([this.props.stepIndex]);

return <QuestionCommentIcon question={question} onChange={this.onCommentChange} />
}

onCommentChange = (commentIndex, change) => {
this._onChange(Constants.HAS_COMMENT, commentIndex, change)
}

_onChange(att, valueIndex, newValue) {
let newState = { ...this.props.step};
newState[att][valueIndex] = newValue;

JsonLdObjectMap.putObject(newState['@id'], newState);
this.onChange(this.props.index, newState);
}

_renderWizardStepButtons = () => {
return (
<ButtonToolbar className="m-3 float-right">
Expand Down Expand Up @@ -73,6 +93,7 @@ export default class WizardStep extends React.Component {
<Card.Header className="bg-primary text-white" as="h6" id={this.props.step['@id']}>
{JsonLdUtils.getLocalized(this.props.step[JsonLdUtils.RDFS_LABEL], this.props.options.intl)}
{this._renderHelpIcon()}
{this._renderQuestionCommentIcon()}
</Card.Header>
<Card.Body className={categoryClass}>
{questionElement}
Expand Down

0 comments on commit 693cebb

Please sign in to comment.