Skip to content

Commit b837273

Browse files
author
vikasrohit
authored
Merge pull request #883 from appirio-tech/feature/features_change_no_reflected_without_save
Feature/features change no reflected without save
2 parents c84b030 + f0cad50 commit b837273

File tree

2 files changed

+44
-19
lines changed

2 files changed

+44
-19
lines changed

src/projects/detail/components/EditProjectForm.jsx

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,36 @@ import FeaturePicker from './FeatureSelector/FeaturePicker'
88
import { Formsy, Icons } from 'appirio-tech-react-components'
99

1010
import SpecSection from './SpecSection'
11+
import { HOC as hoc } from 'formsy-react'
12+
13+
const FeaturePickerModal = ({ project, isEdittable, showFeaturesDialog, hideFeaturesDialog, saveFeatures, setValue }) => {
14+
const setFormValue = (features, featureSeeAttached=false) => {
15+
const featureObj = {
16+
value: features,
17+
seeAttached: featureSeeAttached
18+
}
19+
setValue(featureObj)
20+
saveFeatures(features, featureSeeAttached)
21+
}
22+
return (
23+
<Modal
24+
isOpen={ showFeaturesDialog }
25+
className="feature-selection-dialog"
26+
overlayClassName="feature-selection-dialog-overlay"
27+
onRequestClose={ hideFeaturesDialog }
28+
>
29+
<FeaturePicker
30+
features={ _.get(project, 'details.appDefinition.features.value', []) }
31+
isEdittable={isEdittable} onSave={ setFormValue }
32+
/>
33+
<div onClick={ hideFeaturesDialog } className="feature-selection-dialog-close">
34+
Save and close <Icons.XMarkIcon />
35+
</div>
36+
</Modal>
37+
)
38+
}
39+
40+
const FeaturePickerFormField = hoc(FeaturePickerModal)
1141

1242
class EditProjectForm extends Component {
1343

@@ -135,10 +165,9 @@ class EditProjectForm extends Component {
135165
}
136166

137167
submit(model) {
138-
console.log('submit', this.isChanged())
139-
if (this.state.isFeaturesDirty) {
140-
model.details.appDefinition.features = this.state.project.details.appDefinition.features
141-
}
168+
// if (this.state.isFeaturesDirty) {
169+
// model.details.appDefinition.features = this.state.project.details.appDefinition.features
170+
// }
142171
this.setState({isSaving: true })
143172
this.props.submitHandler(model)
144173
}
@@ -192,21 +221,17 @@ class EditProjectForm extends Component {
192221
onChange={ this.handleChange }
193222
>
194223
{sections.map(renderSection)}
195-
</Formsy.Form>
196-
<Modal
197-
isOpen={ this.state.showFeaturesDialog }
198-
className="feature-selection-dialog"
199-
overlayClassName="feature-selection-dialog-overlay"
200-
onRequestClose={ this.hideFeaturesDialog }
201-
>
202-
<FeaturePicker
203-
features={ _.get(project, 'details.appDefinition.features.value', []) }
204-
isEdittable={isEdittable} onSave={ this.saveFeatures }
224+
<FeaturePickerFormField
225+
name='details.appDefinition.features'
226+
project={ project }
227+
isEdittable={ isEdittable }
228+
showFeaturesDialog={ this.state.showFeaturesDialog }
229+
hideFeaturesDialog={ this.hideFeaturesDialog }
230+
saveFeatures={ this.saveFeatures }
231+
value={ _.get(project, 'details.appDefinition.features', {})}
205232
/>
206-
<div onClick={ this.hideFeaturesDialog } className="feature-selection-dialog-close">
207-
Save and close <Icons.XMarkIcon />
208-
</div>
209-
</Modal>
233+
</Formsy.Form>
234+
210235
</div>
211236
)
212237
}

src/projects/reducers/project.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export const projectState = function (state=initialState, action) {
197197
project: _.mergeWith({}, state.project, action.payload, { isDirty : true},
198198
// customizer to override screens array with changed values
199199
(objValue, srcValue, key) => {
200-
if (key === 'screens') {
200+
if (key === 'screens' || key === 'features') {
201201
return srcValue// srcValue contains the changed values from action payload
202202
}
203203
}

0 commit comments

Comments
 (0)