Skip to content

Commit

Permalink
fixes silverstripe#5941, fixes readonly missing readonly box, fix pop…
Browse files Browse the repository at this point in the history
…over documentation, fixes readonly mode SingleSelectField
  • Loading branch information
Christopher Joe committed Sep 5, 2016
1 parent fc27c53 commit 6489067
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
10 changes: 8 additions & 2 deletions admin/client/src/components/FieldHolder/FieldHolder.js
Expand Up @@ -11,10 +11,16 @@ function fieldHolder(Field) {

// The extraClass property is defined on both the holder and element
// for legacy reasons (same behaviour as PHP rendering)
const classNames = ['form-group field', this.props.extraClass].join(' ');
const classNames = [
'form-group field',
this.props.extraClass,
];
if (this.props.readOnly) {
classNames.push('readonly');
}

return (
<div className={classNames} id={this.props.holder_id}>
<div className={classNames.join(' ')} id={this.props.holder_id}>
{labelText &&
<label className="form__field-label" htmlFor={this.props.id}>
{labelText}
Expand Down
3 changes: 1 addition & 2 deletions admin/client/src/components/FormAction/FormAction.js
Expand Up @@ -11,8 +11,7 @@ class FormAction extends SilverStripeComponent {
render() {
return (
<button {...this.getButtonProps()}>
{this.getLoadingIcon()}
{this.props.title}
{this.getLoadingIcon() || this.props.title}
</button>
);
}
Expand Down
2 changes: 1 addition & 1 deletion admin/client/src/components/PopoverField/README.md
Expand Up @@ -16,7 +16,7 @@ Position to place this popover compared to the activation button. Options are:

Can be provided within a `data` object passed to this component.

## popoverTitle
### popoverTitle

This title will be used as the header in the popup.

Expand Down
Expand Up @@ -14,7 +14,7 @@ class SingleSelectField extends SilverStripeComponent {
render() {
let field = null;
if (this.props.readOnly) {
field = this.getReadonlyField;
field = this.getReadonlyField();
} else {
field = this.getSelectField();
}
Expand All @@ -28,9 +28,10 @@ class SingleSelectField extends SilverStripeComponent {
* @returns ReactComponent
*/
getReadonlyField() {
let label = this.props.source.find((item) => item.value === this.props.value);
let label = this.props.source
&& this.props.source.find((item) => item.value === this.props.value);

label = label !== undefined
label = typeof label === 'string'
? label
: this.props.value;

Expand Down

0 comments on commit 6489067

Please sign in to comment.