1
1
import React , { Component , PropTypes } from 'react' ;
2
2
import GlyphButton from '../common/GlyphButton.js' ;
3
3
import Alert from 'react-bootstrap/lib/Alert' ;
4
+ import Button from 'react-bootstrap/lib/Button'
4
5
import FormGroup from '../common/FormGroup' ;
5
6
import ArrayContainerItem from '../common/ArrayContainerItem' ;
6
7
@@ -51,8 +52,10 @@ class ArrayContainer extends Component {
51
52
} ;
52
53
53
54
buildGroupComponent = ( field ) => {
54
- let { componentFactory, layout } = this . props ;
55
-
55
+ let { componentFactory, layout, disabled } = this . props ;
56
+
57
+ field = field . map ( ( field ) => ( { ...field , disabled} ) ) ;
58
+
56
59
return componentFactory . buildGroupComponent ( {
57
60
component : layout . component ,
58
61
layout : layout ,
@@ -63,7 +66,7 @@ class ArrayContainer extends Component {
63
66
64
67
getComponents = ( ) => {
65
68
let { fields } = this . props ;
66
-
69
+
67
70
return fields . map ( ( field , index ) => (
68
71
< ArrayContainerItem key = { index } index = { index } onAction = { this . handleItemAction } >
69
72
{ this . buildGroupComponent ( field ) }
@@ -72,7 +75,7 @@ class ArrayContainer extends Component {
72
75
} ;
73
76
74
77
getAddBar = ( ) => {
75
- let { addText } = this . props ;
78
+ let { addText, disabled } = this . props ;
76
79
77
80
let text = addText ? addText : "Add" ;
78
81
let components = this . getComponents ( ) ;
@@ -81,7 +84,7 @@ class ArrayContainer extends Component {
81
84
return (
82
85
< div className = "add-bar" >
83
86
< span >
84
- < GlyphButton glyph = "plus" text = { text } bsSize = "small" onClick = { this . handleAdd } />
87
+ < GlyphButton glyph = "plus" text = { text } bsSize = "small" onClick = { this . handleAdd } disabled = { disabled } />
85
88
</ span >
86
89
</ div >
87
90
) ;
@@ -93,14 +96,15 @@ class ArrayContainer extends Component {
93
96
94
97
getAllComponents = ( ) => {
95
98
//TODO: We should replace a for button!
99
+ const { disabled } = this . props ;
96
100
let components = this . getComponents ( ) ;
97
101
98
102
if ( components . length ) {
99
103
return components ;
100
104
} else {
101
105
return (
102
106
< Alert bsStyle = "warning" >
103
- This array is empty. Consider < a onClick = { this . handleAdd } > adding a new item</ a > .
107
+ This array is empty. Consider < Button bsStyle = "link" disabled = { disabled } onClick = { this . handleAdd } > adding a new item</ Button > .
104
108
</ Alert >
105
109
) ;
106
110
}
0 commit comments