@@ -12,8 +12,8 @@ export default class SiteGroupRow extends React.Component {
12
12
this . state = {
13
13
PortalGroupName : props . group . PortalGroupName || "" ,
14
14
AuthenticationDomain : props . group . AuthenticationDomain ,
15
- Portals : JSON . parse ( JSON . stringify ( props . group . Portals ) ) || [ ] ,
16
- UnassignedSites : JSON . parse ( JSON . stringify ( props . unassignedSites || [ ] ) )
15
+ Portals : JSON . parse ( JSON . stringify ( props . group . Portals ) ) || [ ] ,
16
+ UnassignedSites : JSON . parse ( JSON . stringify ( props . unassignedSites || [ ] ) )
17
17
. filter ( ( site ) => site . PortalId !== this . props . group . MasterPortal . PortalId ) ,
18
18
errors : {
19
19
groupName : false ,
@@ -23,6 +23,10 @@ export default class SiteGroupRow extends React.Component {
23
23
this . submitted = false ;
24
24
}
25
25
26
+ componentWillReceiveProps ( newProps ) {
27
+ this . resetState ( newProps ) ;
28
+ }
29
+
26
30
clickOnPortal ( index , type ) {
27
31
if ( type === "assignedPortals" ) {
28
32
let p = JSON . parse ( JSON . stringify ( this . state . Portals ) ) ;
@@ -116,24 +120,24 @@ export default class SiteGroupRow extends React.Component {
116
120
this . props . onSave ( this . result ( ) ) ;
117
121
}
118
122
119
- resetState ( ) {
123
+ cancel ( ) {
124
+ this . resetState ( this . props ) ;
125
+ this . props . onCancelEditing ( ) ;
126
+ }
127
+
128
+ resetState ( props ) {
120
129
this . setState ( {
121
- PortalGroupName : this . props . group . PortalGroupName || "" ,
122
- AuthenticationDomain : this . props . group . AuthenticationDomain ,
123
- Portals : JSON . parse ( JSON . stringify ( this . props . group . Portals ) ) ,
124
- UnassignedSites : JSON . parse ( JSON . stringify ( this . props . unassignedSites ) ) ,
130
+ PortalGroupName : props . group . PortalGroupName || "" ,
131
+ AuthenticationDomain : props . group . AuthenticationDomain ,
132
+ Portals : JSON . parse ( JSON . stringify ( props . group . Portals ) ) ,
133
+ UnassignedSites : JSON . parse ( JSON . stringify ( props . unassignedSites ) ) ,
125
134
errors : {
126
135
groupName : false ,
127
136
authenticationDomain : false ,
128
137
} ,
129
138
} ) ;
130
139
}
131
140
132
- cancel ( ) {
133
- this . resetState ( ) ;
134
- this . props . onCancelEditing ( ) ;
135
- }
136
-
137
141
isValid ( ) {
138
142
let valid = true ;
139
143
if ( this . submitted ) {
@@ -169,7 +173,6 @@ export default class SiteGroupRow extends React.Component {
169
173
}
170
174
171
175
render ( ) {
172
-
173
176
return < div className = { "row " + this . props . isOpened } >
174
177
< div className = "rowHeader" >
175
178
< GridCell columnSize = { 45 } >
@@ -188,26 +191,28 @@ export default class SiteGroupRow extends React.Component {
188
191
< Collapse isOpened = { this . props . isOpened } >
189
192
< SiteGroupEditor
190
193
group = { this . props . group }
194
+ portalGroupName = { this . state . PortalGroupName }
195
+ authenticationDomain = { this . state . AuthenticationDomain }
196
+ errors = { this . state . errors }
197
+ unassignedSites = { this . state . UnassignedSites }
198
+ portals = { this . state . Portals }
199
+ isNew = { this . isNew ( ) }
191
200
onCancel = { ( ) => this . cancel ( ) }
192
201
onDeleteGroup = { ( group ) => this . props . onDeleteGroup ( ( group ) ) }
193
202
onSave = { ( ) => this . save ( ) }
194
203
onAuthenticationDomainChanged = { ( value ) => {
195
204
this . setState ( { AuthenticationDomain : value } ) ;
196
205
this . isValid ( ) ;
197
206
} }
198
- portalGroupName = { this . state . PortalGroupName }
199
- authenticationDomain = { this . state . AuthenticationDomain }
200
- errors = { this . state . errors }
201
- unassignedSites = { this . state . UnassignedSites }
202
207
onGroupNameChanged = { ( value ) => {
203
208
this . setState ( { PortalGroupName : value } ) ;
204
209
this . isValid ( ) ;
205
210
} }
206
- onClickOnPortal = { this . clickOnPortal }
207
- onMoveItemsLeft = { this . moveItemsLeft }
208
- onMoveItemsRight = { this . moveItemsRight }
209
- onMoveAll = { this . moveAll }
210
- isNew = { this . isNew ( ) }
211
+ onClickOnPortal = { ( i , t ) => this . clickOnPortal ( i , t ) }
212
+ onMoveItemsLeft = { ( ) => this . moveItemsLeft ( ) }
213
+ onMoveItemsRight = { ( ) => this . moveItemsRight ( ) }
214
+ onMoveAll = { ( d ) => this . moveAll ( d ) }
215
+
211
216
/>
212
217
</ Collapse >
213
218
</ div > ;
0 commit comments