@@ -2,7 +2,7 @@ import _ from 'lodash'
22import { unflatten } from 'flat'
33import React , { Component , PropTypes } from 'react'
44
5- import config , { findProductCategory } from '../../../config/projectWizard'
5+ import config , { findProductCategory , getProjectCreationTemplateField } from '../../../config/projectWizard'
66import Wizard from '../../../components/Wizard'
77import SelectProduct from './SelectProduct'
88import IncompleteProjectConfirmation from './IncompleteProjectConfirmation'
@@ -155,7 +155,7 @@ class ProjectWizard extends Component {
155155 const updateQuery = { }
156156 const detailsQuery = { products : [ product ] }
157157 // restore common fields from dirty project
158- this . restoreCommonDetails ( updateQuery , detailsQuery )
158+ this . restoreCommonDetails ( product , updateQuery , detailsQuery )
159159 updateQuery . details = { $set : detailsQuery }
160160 if ( projectType ) {
161161 updateQuery . type = { $set : projectType }
@@ -175,7 +175,7 @@ class ProjectWizard extends Component {
175175 *
176176 * Added for Github issue#1037
177177 */
178- restoreCommonDetails ( updateQuery , detailsQuery ) {
178+ restoreCommonDetails ( updatedProduct , updateQuery , detailsQuery ) {
179179 const name = _ . get ( this . state . dirtyProject , 'name' )
180180 // if name was already entered, restore it
181181 if ( name ) {
@@ -191,6 +191,44 @@ class ProjectWizard extends Component {
191191 if ( utm ) {
192192 detailsQuery . utm = { code : utm . code }
193193 }
194+ const appDefinitionQuery = { }
195+ const goal = _ . get ( this . state . dirtyProject , 'details.appDefinition.goal' )
196+ // finds the goal field from the updated product template
197+ const goalField = getProjectCreationTemplateField (
198+ updatedProduct ,
199+ 'appDefinition' ,
200+ 'questions' ,
201+ 'details.appDefinition.goal.value'
202+ )
203+ // if goal was already entered and updated product template has the field, restore it
204+ if ( goalField && goal ) {
205+ appDefinitionQuery . goal = goal
206+ }
207+ const users = _ . get ( this . state . dirtyProject , 'details.appDefinition.users' )
208+ // finds the users field from the target product template
209+ const usersField = getProjectCreationTemplateField (
210+ updatedProduct ,
211+ 'appDefinition' ,
212+ 'questions' ,
213+ 'details.appDefinition.users.value'
214+ )
215+ // if users was already entered and updated product template has the field, restore it
216+ if ( usersField && users ) {
217+ appDefinitionQuery . users = users
218+ }
219+ const notes = _ . get ( this . state . dirtyProject , 'details.appDefinition.notes' )
220+ // finds the notes field from the target product template
221+ const notesField = getProjectCreationTemplateField (
222+ updatedProduct ,
223+ 'appDefinition' ,
224+ 'notes' ,
225+ 'details.appDefinition.notes'
226+ )
227+ // if notes was already entered and updated product template has the field, restore it
228+ if ( notesField && notes ) {
229+ appDefinitionQuery . notes = notes
230+ }
231+ detailsQuery . appDefinition = appDefinitionQuery
194232 }
195233
196234 handleProjectChange ( change ) {
0 commit comments