-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Widgets again and add units to interview
- Loading branch information
1 parent
a256fca
commit 31c949e
Showing
23 changed files
with
568 additions
and
425 deletions.
There are no files selected for viewing
9 changes: 6 additions & 3 deletions
9
rdmo/projects/assets/js/interview/components/main/question/QuestionDefault.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 |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
const QuestionDefault = ({ isDefault }) => { | ||
return isDefault && ( | ||
import { isDefaultValue } from '../../../utils/value' | ||
|
||
const QuestionDefault = ({ question, value }) => { | ||
return isDefaultValue(question, value) && ( | ||
<div className="badge badge-default" title={gettext('This is a default answer that can be customized.')}> | ||
{gettext('Default')} | ||
</div> | ||
) | ||
} | ||
|
||
QuestionDefault.propTypes = { | ||
isDefault: PropTypes.bool.isRequired | ||
question: PropTypes.object.isRequired, | ||
value: PropTypes.object.isRequired | ||
} | ||
|
||
export default QuestionDefault |
33 changes: 33 additions & 0 deletions
33
rdmo/projects/assets/js/interview/components/main/question/QuestionUnit.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,33 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { isUndefined } from 'lodash' | ||
|
||
const QuestionUnit = ({ question, inputValue }) => { | ||
return (question.unit || !isUndefined(inputValue)) && ( | ||
<div className="unit"> | ||
{ | ||
!isUndefined(inputValue) && ( | ||
<> | ||
<span>{inputValue}</span> | ||
{' '} | ||
</> | ||
) | ||
} | ||
{ | ||
question.unit && !isUndefined(inputValue) && (' ') | ||
} | ||
{ | ||
question.unit && ( | ||
<span title={gettext('The unit for this answer.')}>{question.unit}</span> | ||
) | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
QuestionUnit.propTypes = { | ||
question: PropTypes.object.isRequired, | ||
inputValue: PropTypes.string, | ||
} | ||
|
||
export default QuestionUnit |
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
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
Oops, something went wrong.