Skip to content

Commit

Permalink
Render advanced answerable question
Browse files Browse the repository at this point in the history
  • Loading branch information
holubv committed Mar 22, 2021
1 parent 11dffd5 commit 73ebca6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/FormManager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FormManager extends React.Component {

const advancedQuestionMap = q => {

if (!FormUtils.isSection(q)) {
if (!FormUtils.isSection(q) && !FormUtils.isAnswerable(q)) {
return false;
}
let subQuestions = q[Constants.HAS_SUBQUESTION];
Expand Down
29 changes: 26 additions & 3 deletions src/components/QuestionWithAdvanced.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,32 @@ export default class QuestionWithAdvanced extends Question {
return null;
}

const showAdvancedQuestion = this._getShowAdvancedQuestion(question).question;
const advancedQuestionLabel = JsonldUtils.getLocalized(showAdvancedQuestion[Constants.RDFS_LABEL], this.context.options.intl);

if (FormUtils.isAnswerable(question)) {
return (
<div id={question['@id']}>
{this.renderAnswers()}
<div className="ml-4 mt-n2">
<div>
<Form.Switch
onChange={this._toggleAdvanced}
id={'--switch-' + showAdvancedQuestion['@id']}
label={advancedQuestionLabel}
checked={this.state.showAdvanced}
inline
/>

{this._renderShowAdvancedHelp()}
</div>

{this.renderSubQuestions()}
</div>
</div>
);
}

const { collapsible, withoutCard } = this.props;
const categoryClass = Question._getQuestionCategoryClass(question);

Expand All @@ -129,9 +155,6 @@ export default class QuestionWithAdvanced extends Question {
collapsible ? 'cursor-pointer' : ''
);

const showAdvancedQuestion = this._getShowAdvancedQuestion(question).question;
const advancedQuestionLabel = JsonldUtils.getLocalized(showAdvancedQuestion[Constants.RDFS_LABEL], this.context.options.intl);

return (
<Accordion defaultActiveKey={!this.state.expanded ? label : undefined}>
<Card className="mb-3">
Expand Down

0 comments on commit 73ebca6

Please sign in to comment.