-
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.
Merge pull request #770 from rdmorganiser/refactor_options
Refactor options
- Loading branch information
Showing
45 changed files
with
638 additions
and
237 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -75,6 +75,10 @@ a { | |
color: #a94442; | ||
} | ||
} | ||
|
||
&.disabled { | ||
cursor: not-allowed; | ||
} | ||
} | ||
|
||
code { | ||
|
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,6 +1,92 @@ | ||
.flip { | ||
transform: rotate(180deg) scaleX(-1); | ||
} | ||
|
||
.w-100 { | ||
width: 100%; | ||
} | ||
.mt-0 { | ||
margin-top: 0; | ||
} | ||
.mt-5 { | ||
margin-top: 5px; | ||
} | ||
.mt-10 { | ||
margin-top: 10px; | ||
} | ||
.mt-20 { | ||
margin-top: 20px; | ||
} | ||
.mr-0 { | ||
margin-right: 0; | ||
} | ||
.mr-5 { | ||
margin-right: 5px; | ||
} | ||
.mr-10 { | ||
margin-right: 10px; | ||
} | ||
.mr-20 { | ||
margin-right: 20px; | ||
} | ||
.mb-0 { | ||
margin-bottom: 0; | ||
} | ||
.mb-5 { | ||
margin-bottom: 5px; | ||
} | ||
.mb-10 { | ||
margin-bottom: 10px; | ||
} | ||
.mb-20 { | ||
margin-bottom: 20px; | ||
} | ||
.ml-0 { | ||
margin-left: 0; | ||
} | ||
.ml-5 { | ||
margin-left: 5px; | ||
} | ||
.ml-10 { | ||
margin-left: 10px; | ||
} | ||
.ml-20 { | ||
margin-left: 20px; | ||
} | ||
|
||
.pt-0 { | ||
padding-top: 0; | ||
} | ||
.pt-10 { | ||
padding-top: 10px; | ||
} | ||
.pt-20 { | ||
padding-top: 20px; | ||
} | ||
.pr-0 { | ||
padding-right: 0; | ||
} | ||
.pr-10 { | ||
padding-right: 10px; | ||
} | ||
.pr-20 { | ||
padding-right: 20px; | ||
} | ||
.pb-0 { | ||
padding-bottom: 0; | ||
} | ||
.pb-10 { | ||
padding-bottom: 10px; | ||
} | ||
.pb-20 { | ||
padding-bottom: 20px; | ||
} | ||
.pl-0 { | ||
padding-left: 0; | ||
} | ||
.pl-10 { | ||
padding-left: 10px; | ||
} | ||
.pl-20 { | ||
padding-left: 20px; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import classNames from 'classnames' | ||
import isEmpty from 'lodash/isEmpty' | ||
import isNil from 'lodash/isNil' | ||
import get from 'lodash/get' | ||
|
||
import { getId, getLabel, getHelp } from 'rdmo/management/assets/js/utils/forms' | ||
|
||
const Radio = ({ config, element, field, options, onChange }) => { | ||
const id = getId(element, field), | ||
label = getLabel(config, element, field), | ||
help = getHelp(config, element, field), | ||
warnings = get(element, ['warnings', field]), | ||
errors = get(element, ['errors', field]) | ||
|
||
const className = classNames({ | ||
'form-group': true, | ||
'has-warning': !isEmpty(warnings), | ||
'has-error': !isEmpty(errors) | ||
}) | ||
|
||
const value = isNil(element[field]) ? '' : element[field] | ||
|
||
return ( | ||
<div className={className}> | ||
<label className="control-label" htmlFor={id}>{label}</label> | ||
|
||
<div> | ||
{ | ||
options.map((option, index) => ( | ||
<label key={index} className="radio-inline"> | ||
<input type="radio" name="inlineRadioOptions" disabled={element.read_only} | ||
checked={value === option.id} | ||
value={option.id} onChange={event => onChange(field, event.target.value)}/> | ||
<span>{option.text}</span> | ||
</label> | ||
)) | ||
} | ||
</div> | ||
|
||
{help && <p className="help-block">{help}</p>} | ||
|
||
{errors && <ul className="help-block list-unstyled"> | ||
{errors.map((error, index) => <li key={index}>{error}</li>)} | ||
</ul>} | ||
</div> | ||
) | ||
} | ||
|
||
Radio.propTypes = { | ||
config: PropTypes.object, | ||
element: PropTypes.object, | ||
field: PropTypes.string, | ||
options: PropTypes.array, | ||
onChange: PropTypes.func | ||
} | ||
|
||
export default Radio |
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.