Skip to content

Commit

Permalink
[new] Render questions with "ttl" layout class with YATE
Browse files Browse the repository at this point in the history
  • Loading branch information
YanDoroshenko committed Oct 21, 2018
1 parent b9e157a commit d1dd2ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/Answer.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ export default class Answer extends React.Component {

_renderTurtleInput(value, label, title) {
return <InputAnswer question={this.props.question} answer={this.props.answer} label={label} title={title}
value={value} onChange={this.onValueChange} sparql={true}/>;
value={value} onChange={this.onValueChange} turtle={true}/>;
}
}
2 changes: 1 addition & 1 deletion src/components/Question.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default class Question extends React.Component {
children = [], answers = this._getAnswers();
let row = [], cls, isTextarea;
for (let i = 0, len = answers.length; i < len; i++) {
isTextarea = FormUtils.isTextarea(this.props.question, FormUtils.resolveValue(answers[i])) || FormUtils.isSparqlInput(question);
isTextarea = FormUtils.isTextarea(this.props.question, FormUtils.resolveValue(answers[i])) || FormUtils.isSparqlInput(question) || FormUtils.isTurtleInput(question);
cls = Question._getAnswerClass(isTextarea);
row.push(<div key={'row-item-' + i} className={cls}>
<div className="row">
Expand Down
10 changes: 9 additions & 1 deletion src/components/answer/InputAnswer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const tokenTypes = {
class InputPropertiesResolver {

static _resolveInputType(question, value) {
if (FormUtils.isSparqlInput(question) || FormUtils.isTextarea(question, value)) {
if (FormUtils.isSparqlInput(question) || FormUtils.isTurtleInput(question) || FormUtils.isTextarea(question, value)) {
return 'textarea';
} else if (InputPropertiesResolver._isNumeric(question)) {
return 'number';
Expand Down Expand Up @@ -157,6 +157,14 @@ const InputAnswer = (props) => {
}
};
}
else if (props.turtle) {
console.log("TTL");
const yate = YATE.fromTextArea(e.target);
yate.setValue(value);
yate.on('change', () => {
props.onChange(yate.getValue());
});
}
}
}));
};
Expand Down

0 comments on commit d1dd2ef

Please sign in to comment.