@@ -7,6 +7,36 @@ import FeaturePicker from './FeatureSelector/FeaturePicker'
77import { Formsy , Icons } from 'appirio-tech-react-components'
88
99import SpecSection from './SpecSection'
10+ import { HOC as hoc } from 'formsy-react'
11+
12+ const FeaturePickerModal = ( { project, isEdittable, showFeaturesDialog, hideFeaturesDialog, saveFeatures, setValue } ) => {
13+ const setFormValue = ( features , featureSeeAttached = false ) => {
14+ const featureObj = {
15+ value : features ,
16+ seeAttached : featureSeeAttached
17+ }
18+ setValue ( featureObj )
19+ saveFeatures ( features , featureSeeAttached )
20+ }
21+ return (
22+ < Modal
23+ isOpen = { showFeaturesDialog }
24+ className = "feature-selection-dialog"
25+ overlayClassName = "feature-selection-dialog-overlay"
26+ onRequestClose = { hideFeaturesDialog }
27+ >
28+ < FeaturePicker
29+ features = { _ . get ( project , 'details.appDefinition.features.value' , [ ] ) }
30+ isEdittable = { isEdittable } onSave = { setFormValue }
31+ />
32+ < div onClick = { hideFeaturesDialog } className = "feature-selection-dialog-close" >
33+ Save and close < Icons . XMarkIcon />
34+ </ div >
35+ </ Modal >
36+ )
37+ }
38+
39+ const FeaturePickerFormField = hoc ( FeaturePickerModal )
1040
1141class EditProjectForm extends Component {
1242
@@ -128,9 +158,9 @@ class EditProjectForm extends Component {
128158
129159 submit ( model ) {
130160 console . log ( 'submit' , this . isChanged ( ) )
131- if ( this . state . isFeaturesDirty ) {
132- model . details . appDefinition . features = this . state . project . details . appDefinition . features
133- }
161+ // if (this.state.isFeaturesDirty) {
162+ // model.details.appDefinition.features = this.state.project.details.appDefinition.features
163+ // }
134164 this . setState ( { isSaving : true } )
135165 this . props . submitHandler ( model )
136166 }
@@ -183,21 +213,16 @@ class EditProjectForm extends Component {
183213 onChange = { this . handleChange }
184214 >
185215 { sections . map ( renderSection ) }
186- </ Formsy . Form >
187- < Modal
188- isOpen = { this . state . showFeaturesDialog }
189- className = "feature-selection-dialog"
190- overlayClassName = "feature-selection-dialog-overlay"
191- onRequestClose = { this . hideFeaturesDialog }
192- >
193- < FeaturePicker
194- features = { _ . get ( project , 'details.appDefinition.features.value' , [ ] ) }
195- isEdittable = { isEdittable } onSave = { this . saveFeatures }
216+ < FeaturePickerFormField
217+ name = 'details.appDefinition.features'
218+ project = { project }
219+ isEdittable = { isEdittable }
220+ showFeaturesDialog = { this . state . showFeaturesDialog }
221+ hideFeaturesDialog = { this . hideFeaturesDialog }
222+ saveFeatures = { this . saveFeatures }
196223 />
197- < div onClick = { this . hideFeaturesDialog } className = "feature-selection-dialog-close" >
198- Save and close < Icons . XMarkIcon />
199- </ div >
200- </ Modal >
224+ </ Formsy . Form >
225+
201226 </ div >
202227 )
203228 }
0 commit comments