@@ -3,7 +3,6 @@ import moment from 'moment'
33import { flatten , unflatten } from 'flat'
44import { getProjectById ,
55 createProject as createProjectAPI ,
6- createProjectWithStatus as createProjectWithStatusAPI ,
76 updateProject as updateProjectAPI ,
87 deleteProject as deleteProjectAPI ,
98 deleteProjectPhase as deleteProjectPhaseAPI ,
@@ -275,16 +274,16 @@ function createProductsTimelineAndMilestone(project) {
275274 * Create phase and product for the project
276275 *
277276 * @param {Object } project project
278- * @param {Object } projectTemplate project template
277+ * @param {Object } productTemplate product template
279278 * @param {String } status (optional) project/phase status
280279 *
281280 * @return {Promise } project
282281 */
283- export function createProjectPhaseAndProduct ( project , projectTemplate , status = PHASE_STATUS_DRAFT , startDate , endDate ) {
282+ export function createProjectPhaseAndProduct ( project , productTemplate , status = PHASE_STATUS_DRAFT , startDate , endDate ) {
284283 const param = {
285284 status,
286- name : projectTemplate . name ,
287- productTemplateId : projectTemplate . id
285+ name : productTemplate . name ,
286+ productTemplateId : productTemplate . id
288287 }
289288 if ( startDate ) {
290289 param [ 'startDate' ] = startDate . format ( 'YYYY-MM-DD' )
@@ -309,16 +308,16 @@ export function createProjectPhaseAndProduct(project, projectTemplate, status =
309308 * Create phase and product and milestones for the project
310309 *
311310 * @param {Object } project project
312- * @param {Object } projectTemplate project template
311+ * @param {Object } productTemplate product template
313312 * @param {String } status (optional) project/phase status
314313 * @param {Object } startDate phase startDate
315314 * @param {Object } endDate phase endDate
316315 * @param {Array } milestones milestones
317316 *
318317 * @return {Promise } project
319318 */
320- function createPhaseAndMilestonesRequest ( project , projectTemplate , status = PHASE_STATUS_DRAFT , startDate , endDate , milestones ) {
321- return createProjectPhaseAndProduct ( project , projectTemplate , status , startDate , endDate ) . then ( ( { timeline, phase, project, product} ) => {
319+ function createPhaseAndMilestonesRequest ( project , productTemplate , status = PHASE_STATUS_DRAFT , startDate , endDate , milestones ) {
320+ return createProjectPhaseAndProduct ( project , productTemplate , status , startDate , endDate ) . then ( ( { timeline, phase, project, product} ) => {
322321 // we have to add delay before creating milestones in newly created timeline
323322 // to make sure timeline is created in ES, otherwise it may happen that we would try to add milestones
324323 // into timeline before timeline existent in ES
@@ -332,12 +331,11 @@ function createPhaseAndMilestonesRequest(project, projectTemplate, status = PHAS
332331 } )
333332}
334333
335-
336- export function createPhaseAndMilestones ( project , projectTemplate , status , startDate , endDate , milestones ) {
334+ export function createPhaseAndMilestones ( project , productTemplate , status , startDate , endDate , milestones ) {
337335 return ( dispatch , getState ) => {
338336 return dispatch ( {
339337 type : CREATE_PROJECT_PHASE_TIMELINE_MILESTONES ,
340- payload : createPhaseAndMilestonesRequest ( project , projectTemplate , status , startDate , endDate , milestones )
338+ payload : createPhaseAndMilestonesRequest ( project , productTemplate , status , startDate , endDate , milestones )
341339 } ) . then ( ( ) => {
342340 const state = getState ( )
343341 const project = state . projectState . project
@@ -555,19 +553,6 @@ export function updateProduct(projectId, phaseId, productId, updatedProps) {
555553 }
556554}
557555
558- export function createProjectWithStatus ( newProject , status , projectTemplate ) {
559- return ( dispatch ) => {
560- return dispatch ( {
561- type : CREATE_PROJECT ,
562- payload : createProjectWithStatusAPI ( newProject , status )
563- . then ( ( project ) => {
564- return createProjectPhaseAndProduct ( project , projectTemplate , status )
565- . then ( ( ) => project )
566- } )
567- } )
568- }
569- }
570-
571556export function deleteProject ( newProject ) {
572557 return ( dispatch ) => {
573558 return dispatch ( {
0 commit comments