-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add QuestionEraseValues component for checkboxes
- Loading branch information
1 parent
39c32c3
commit ccd3cd8
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
rdmo/projects/assets/js/interview/components/main/question/QuestionEraseValues.js
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,23 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
const QuestionEraseValues = ({ values, disabled, deleteValue }) => { | ||
const handleEraseValue = () => { | ||
values.forEach((value) => deleteValue(value)) | ||
} | ||
|
||
return !disabled && ( | ||
<button type="button" className="btn btn-link btn-erase-value" onClick={handleEraseValue} | ||
title={gettext('Erase input')}> | ||
<i className="fa fa-eraser fa-btn"></i> | ||
</button> | ||
) | ||
} | ||
|
||
QuestionEraseValues.propTypes = { | ||
values: PropTypes.array.isRequired, | ||
disabled: PropTypes.bool.isRequired, | ||
deleteValue: PropTypes.func.isRequired | ||
} | ||
|
||
export default QuestionEraseValues |
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