Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formanswerview-textarea-for-long-answers #136

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 42 additions & 34 deletions src/components/VolunteerTab/FormAnswersView.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,49 @@ export default class FromAnswersView extends Component {
return (
<div className="form-answers-view">
{this.props.answers && this.props.answers.map((question, index) =>
<Linkify key={`question-${index}`} properties={{target: '_blank'}}>
<div className={rtl ? 'rtl' : ''}>
{question.questionType === 'text' && (
<FormGroup controlId={`id-${index}`}>
<ControlLabel>{question.question}</ControlLabel>
<FormControl readOnly value={question.answer}/>
</FormGroup>
)}
{question.questionType === 'textarea' && (
<FormGroup controlId={`id-${index}`}>
<ControlLabel>{question.question}</ControlLabel>
<FormControl readOnly componentClass="textarea" value={question.answer}/>
</FormGroup>
)}
{question.questionType === 'checkbox' && (
<FormGroup controlId={`id-${index}`}>
<Checkbox inline readOnly checked={question.answer}><b>{question.question}</b></Checkbox>
</FormGroup>
)}
{question.questionType === 'radio' && (
<FormGroup controlId={`id-${index}`}>
<ControlLabel>{question.question}</ControlLabel>
<FormControl readOnly value={question.answer}/>
</FormGroup>
)}
{question.questionType === 'checkboxes' && (
<FormGroup controlId={`id-${index}`}>
<ControlLabel>{question.question}</ControlLabel>
<FormControl readOnly value={question.answer}/>
</FormGroup>
)}
</div>
</Linkify>
this._render_question(question, index, rtl)
)}
</div>
)
}
}

_render_question(question, index, rtl) {
const componentType = (question.answer.length > 60)? "textarea":"input";

return (
<Linkify key={`question-${index}`} properties={{target: '_blank'}}>
<div className={rtl ? 'rtl' : ''}>
{question.questionType === 'text' && (
<FormGroup controlId={`id-${index}`}>
<ControlLabel>{question.question}</ControlLabel>
<FormControl readOnly value={question.answer}/>
</FormGroup>
)}
{question.questionType === 'textarea' && (
<FormGroup controlId={`id-${index}`}>
<ControlLabel>{question.question}</ControlLabel>
<FormControl readOnly componentClass="textarea" value={question.answer}/>
</FormGroup>
)}
{question.questionType === 'checkbox' && (
<FormGroup controlId={`id-${index}`}>
<Checkbox inline readOnly checked={question.answer}><b>{question.question}</b></Checkbox>
</FormGroup>
)}
{question.questionType === 'radio' && (
<FormGroup controlId={`id-${index}`}>
<ControlLabel>{question.question}</ControlLabel>
<FormControl readOnly value={question.answer}/>
</FormGroup>
)}
{question.questionType === 'checkboxes' && (
<FormGroup controlId={`id-${index}`}>
<ControlLabel>{question.question}</ControlLabel>
<FormControl readOnly componentClass={componentType} value={question.answer}/>
</FormGroup>
)}
</div>
</Linkify>
)
}
}