forked from holubv/s-forms-smart-components
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to render type question as separate question
- Loading branch information
Showing
6 changed files
with
103 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import {Card} from 'react-bootstrap'; | ||
import JsonLdUtils from 'jsonld-utils'; | ||
import {Question, Constants as SConstants, FormUtils} from 's-forms'; | ||
import Constants from "../Constants"; | ||
import classNames from "classnames"; | ||
import TypeQuestionAnswer from "./TypeQuestionAnswer"; | ||
|
||
export default class TypeQuestion extends Question { | ||
|
||
static mappingRule = q => !FormUtils.isSection(q) && TypeQuestionAnswer.mappingRule(q); | ||
|
||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
renderAnswers() { | ||
const question = this.props.question; | ||
const children = []; | ||
const answers = this._getAnswers(); | ||
|
||
for (let i = 0, len = answers.length; i < len; i++) { | ||
|
||
let cls = classNames( | ||
'answer', | ||
Question._getQuestionCategoryClass(question), | ||
Question.getEmphasizedOnRelevantClass(question) | ||
); | ||
|
||
children.push( | ||
<div key={'row-item-' + i} className={cls} id={question['@id']}> | ||
<div className="answer-content type-answer" style={this._getAnswerWidthStyle()}> | ||
<TypeQuestionAnswer | ||
index={i} | ||
answer={answers[i]} | ||
question={question} | ||
onChange={this.onAnswerChange} | ||
/> | ||
</div> | ||
{this._renderUnits()} | ||
{this._renderPrefixes()} | ||
</div> | ||
); | ||
} | ||
return children; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters