Skip to content

Commit

Permalink
show matrix error message
Browse files Browse the repository at this point in the history
  • Loading branch information
broncha committed Jul 29, 2021
1 parent f644762 commit a48e69b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/MatrixColumnCellComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ module.exports = MatrixColumnCellComponent = function () {

return R('td', {
className: className
}, elem);
}, elem, this.props.invalid && this.props.invalidMessage !== null ? R('small', {
style: {
color: '#C43B1D'
}
}, this.props.invalidMessage) : void 0);
}
}]);
return MatrixColumnCellComponent;
Expand All @@ -241,6 +245,8 @@ module.exports = MatrixColumnCellComponent = function () {
// Called with new answer of cell
invalid: PropTypes.bool,
// True if invalid
invalidMessage: PropTypes.string,
// Validation message
schema: PropTypes.object.isRequired // Schema to use, including form

};
Expand Down
1 change: 1 addition & 0 deletions lib/answers/MatrixAnswerComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ module.exports = MatrixAnswerComponent = function () {
answer: cellAnswer,
onAnswerChange: this.handleCellChange.bind(null, item, column),
invalid: invalid != null,
invalidMessage: invalid || null,
schema: this.props.schema
});
}
Expand Down
3 changes: 3 additions & 0 deletions src/MatrixColumnCellComponent.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = class MatrixColumnCellComponent extends React.Component
answer: PropTypes.object # Answer of the cell
onAnswerChange: PropTypes.func.isRequired # Called with new answer of cell
invalid: PropTypes.bool # True if invalid
invalidMessage: PropTypes.string # Validation message
schema: PropTypes.object.isRequired # Schema to use, including form

@contextTypes:
Expand Down Expand Up @@ -102,3 +103,5 @@ module.exports = class MatrixColumnCellComponent extends React.Component

return R 'td', className: className,
elem
if @props.invalid and @props.invalidMessage != null
R 'small', style: {color: '#C43B1D'}, @props.invalidMessage
1 change: 1 addition & 0 deletions src/answers/MatrixAnswerComponent.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ module.exports = class MatrixAnswerComponent extends React.Component
answer: cellAnswer
onAnswerChange: @handleCellChange.bind(null, item, column)
invalid: invalid?
invalidMessage: invalid or null
schema: @props.schema

renderItem: (item, index) ->
Expand Down

0 comments on commit a48e69b

Please sign in to comment.