Skip to content

Commit 503c720

Browse files
authored
Merge pull request #4224 from yoution/feature/generic-phases-with-new-milestone-types
fix: fix additional issues
2 parents 0ab7c15 + a20f692 commit 503c720

File tree

10 files changed

+49
-109
lines changed

10 files changed

+49
-109
lines changed

src/config/constants.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,6 @@ export const CREATE_PROJECT_PENDING = 'CREATE_PROJECT_PENDING'
236236
export const CREATE_PROJECT_SUCCESS = 'CREATE_PROJECT_SUCCESS'
237237
export const CREATE_PROJECT_FAILURE = 'CREATE_PROJECT_FAILURE'
238238

239-
export const CREATE_PROJECT_STAGE = 'CREATE_PROJECT_STAGE'
240-
export const CREATE_PROJECT_STAGE_PENDING = 'CREATE_PROJECT_STAGE_PENDING'
241-
export const CREATE_PROJECT_STAGE_SUCCESS = 'CREATE_PROJECT_STAGE_SUCCESS'
242-
export const CREATE_PROJECT_STAGE_FAILURE = 'CREATE_PROJECT_STAGE_FAILURE'
243-
244239
export const UPDATE_PROJECT = 'UPDATE_PROJECT'
245240
export const UPDATE_PROJECT_PENDING = 'UPDATE_PROJECT_PENDING'
246241
export const UPDATE_PROJECT_SUCCESS = 'UPDATE_PROJECT_SUCCESS'
@@ -1141,5 +1136,22 @@ export const MILESTONE_TYPE = {
11411136
REPORTING: 'reporting',
11421137
DELIVERABLE_REVIEW: 'deliverable-review',
11431138
FINAL_DELIVERABLE_REVIEW: 'final-deliverable-review',
1144-
DELIVERABLE_FINAL_FIXES: 'deliverable-final-fixes'
1139+
DELIVERABLE_FINAL_FIXES: 'deliverable-final-fixes',
1140+
PHASE_SPECIFICATION:'phase-specification',
1141+
COMMUNITY_WORK: 'ommunity-work',
1142+
COMMUNITY_REVIEW: 'community-review',
1143+
GENERIC_WORK: 'generic-work',
1144+
CHECKPOINT_REVIEW: 'checkpoint-review',
1145+
ADD_LINKS: 'add-links',
1146+
FINAL_DESIGNS: 'final-designs',
1147+
FINAL_FIX: 'final-fix',
1148+
DELIVERY_DEV: 'delivery-dev',
1149+
DELIVERY_DESIGN: 'delivery-design',
1150+
DELIVERY: 'delivery'
11451151
}
1152+
1153+
1154+
/**
1155+
* project template id
1156+
*/
1157+
export const PROJECT_TEMPLATE_ID = 166

src/projects/actions/project.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
LOAD_PROJECT,
3131
LOAD_PROJECT_MEMBER_INVITE,
3232
CREATE_PROJECT,
33-
CREATE_PROJECT_STAGE,
3433
CLEAR_LOADED_PROJECT,
3534
UPDATE_PROJECT,
3635
DELETE_PROJECT,
@@ -74,9 +73,6 @@ import {
7473
updateProductMilestone,
7574
updateProductTimeline
7675
} from './productsTimelines'
77-
import {
78-
getPhaseActualData,
79-
} from '../../helpers/projectHelper'
8076
import { delay } from '../../helpers/utils'
8177

8278
/**
@@ -274,31 +270,6 @@ function createProductsTimelineAndMilestone(project) {
274270
}
275271
}
276272

277-
export function createProduct(project, productTemplate, phases, timelines) {
278-
// get endDates + 1 day for all the phases if there are any phases
279-
const phaseEndDatesPlusOne = (phases || []).map((phase) => {
280-
const productId = _.get(phase, 'products[0].id', -1)
281-
const timeline = _.get(timelines, `${productId}.timeline`, null)
282-
283-
const phaseActualData = getPhaseActualData(phase, timeline)
284-
285-
return phaseActualData.endDate.add(1, 'day')
286-
})
287-
288-
const today = moment().hours(0).minutes(0).seconds(0).milliseconds(0)
289-
const startDate = _.max([...phaseEndDatesPlusOne, today])
290-
291-
// assumes 10 days as default duration, ideally we could store it at template level
292-
const endDate = moment(startDate).add((10 - 1), 'days')
293-
294-
return (dispatch) => {
295-
return dispatch({
296-
type: CREATE_PROJECT_STAGE,
297-
payload: createProjectPhaseAndProduct(project, productTemplate, PHASE_STATUS_DRAFT, startDate, endDate)
298-
})
299-
}
300-
}
301-
302273
/**
303274
* Create phase and product for the project
304275
*

src/projects/detail/components/CreatePhaseForm/CreatePhaseForm.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ class CreatePhaseForm extends React.Component {
129129
_.forEach(apiMilestones, (m, index) => {
130130
m.status = 'reviewed'
131131
m.order = index + 1
132+
m.duration = moment(m.endDate).diff(moment(m.startDate), 'days') + 1
132133
// TODO add mock data
133-
m.duration = 1
134134
m.hidden =false
135135
m.completedText = 'completed text'
136136
m.activeText = 'active text'

src/projects/detail/components/timeline/CreateMilestoneForm/CreateMilestoneForm.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class CreateMilestoneForm extends React.Component {
5353
// TODO
5454
// mock data
5555
values.status = 'reviewed'
56+
values.duration = moment(values.endDate).diff(moment(values.startDate), 'days') + 1
5657
// TODO add mock data
57-
values.duration = 1
5858
values.hidden =false
5959
values.completedText = 'completed text'
6060
values.activeText = 'active text'
@@ -64,6 +64,11 @@ class CreateMilestoneForm extends React.Component {
6464
values.blockedText = 'blocked text'
6565
onSubmit(values)
6666
}
67+
68+
getOptionType(val) {
69+
return _.find(MILESTONE_TYPE_OPTIONS, (v) => v.value === val).title
70+
}
71+
6772
changeForm(values) {
6873
const { type, title, startDate, endDate } = this.state
6974
if (values['name'] !== title) {
@@ -88,7 +93,7 @@ class CreateMilestoneForm extends React.Component {
8893
})
8994
if (!title) {
9095
this.setState({
91-
title: values['type']
96+
title: this.getOptionType(values['type'])
9297
})
9398
}
9499
}

src/projects/detail/components/timeline/Milestone/Milestone.jsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,13 @@ class Milestone extends React.Component {
294294
const isActualDateEditable = this.isActualStartDateEditable()
295295
const isCompletionDateEditable = this.isCompletionDateEditable()
296296

297-
const isFirstReportingType = index === 0 && milestone.type === MILESTONE_TYPE.REPORTING
297+
const disableDelete = index === 0 && milestone.type === MILESTONE_TYPE.REPORTING
298+
const disableType = index === 0 && milestone.type === MILESTONE_TYPE.REPORTING || milestone.status !== MILESTONE_STATUS.PLANNED
298299

299300
const editForm = (
300301
<Form
301302
fields={[
302-
isFirstReportingType ?
303+
disableType ?
303304
{
304305
label: 'Type',
305306
disabled: true,
@@ -491,7 +492,7 @@ class Milestone extends React.Component {
491492

492493
{isEditing && !isUpdating && (
493494
<div styleName="edit-form">
494-
{isFirstReportingType ? null: <i onClick={this.onDeleteClick} title="trash"><TrashIcon /></i> }
495+
{disableDelete ? null: <i onClick={this.onDeleteClick} title="trash"><TrashIcon /></i> }
495496
{editForm}
496497
</div>
497498
)}
@@ -519,7 +520,7 @@ class Milestone extends React.Component {
519520

520521
{isUpdating && <DotIndicator><LoadingIndicator /></DotIndicator>}
521522

522-
{!isEditing && !isUpdating && milestone.type === 'phase-specification' && (
523+
{!isEditing && !isUpdating && milestone.type === MILESTONE_TYPE.PHASE_SPECIFICATION && (
523524
<MilestoneTypePhaseSpecification
524525
milestone={milestone}
525526
updateMilestoneContent={this.updateMilestoneContent}
@@ -529,7 +530,7 @@ class Milestone extends React.Component {
529530
/>
530531
)}
531532

532-
{!isEditing && !isUpdating && (milestone.type === 'community-work' || milestone.type === 'community-review' || milestone.type === 'generic-work') && (
533+
{!isEditing && !isUpdating && (milestone.type === MILESTONE_TYPE.COMMUNITY_WORK || milestone.type === MILESTONE_TYPE.COMMUNITY_REVIEW || milestone.type === MILESTONE_TYPE.GENERIC_WORK) && (
533534
<MilestoneTypeProgress
534535
milestone={milestone}
535536
updateMilestoneContent={this.updateMilestoneContent}
@@ -539,7 +540,7 @@ class Milestone extends React.Component {
539540
/>
540541
)}
541542

542-
{!isEditing && !isUpdating && milestone.type === 'checkpoint-review' && (
543+
{!isEditing && !isUpdating && milestone.type === MILESTONE_TYPE.CHECKPOINT_REVIEW && (
543544
<MilestoneTypeCheckpointReview
544545
milestone={milestone}
545546
updateMilestoneContent={this.updateMilestoneContent}
@@ -549,7 +550,7 @@ class Milestone extends React.Component {
549550
/>
550551
)}
551552

552-
{!isEditing && !isUpdating && milestone.type === 'add-links' && (
553+
{!isEditing && !isUpdating && milestone.type === MILESTONE_TYPE.ADD_LINKS && (
553554
<MilestoneTypeAddLinks
554555
milestone={milestone}
555556
updateMilestoneContent={this.updateMilestoneContent}
@@ -559,7 +560,7 @@ class Milestone extends React.Component {
559560
/>
560561
)}
561562

562-
{!isEditing && !isUpdating && milestone.type === 'final-designs' && (
563+
{!isEditing && !isUpdating && milestone.type === MILESTONE_TYPE.FINAL_DESIGNS && (
563564
<MilestoneTypeFinalDesigns
564565
milestone={milestone}
565566
updateMilestoneContent={this.updateMilestoneContent}
@@ -569,7 +570,7 @@ class Milestone extends React.Component {
569570
/>
570571
)}
571572

572-
{!isEditing && !isUpdating && milestone.type === 'final-fix' && (
573+
{!isEditing && !isUpdating && milestone.type === MILESTONE_TYPE.FINAL_FIX && (
573574
<MilestoneTypeFinalFixes
574575
milestone={milestone}
575576
updateMilestoneContent={this.updateMilestoneContent}
@@ -584,11 +585,11 @@ class Milestone extends React.Component {
584585
!isEditing &&
585586
!isUpdating &&
586587
(
587-
milestone.type === 'delivery-dev' ||
588-
milestone.type === 'delivery-design' ||
588+
milestone.type === MILESTONE_TYPE.DELIVERY_DEV ||
589+
milestone.type === MILESTONE_TYPE.DELIVERY_DESIGN ||
589590
// TODO this is a temporary fallback for already created milestones in DEV backend
590591
// this is just to keep already created milestones working and can be removed when we don't touch such projects anymore
591-
milestone.type === 'delivery'
592+
milestone.type === MILESTONE_TYPE.DELIVERY
592593
) &&
593594
(
594595
<MilestoneTypeDelivery

src/projects/detail/components/timeline/createMilestoneForm/CreateMilestoneForm.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class CreateMilestoneForm extends React.Component {
5353
// TODO
5454
// mock data
5555
values.status = 'reviewed'
56+
values.duration = moment(values.endDate).diff(moment(values.startDate), 'days') + 1
5657
// TODO add mock data
57-
values.duration = 1
5858
values.hidden =false
5959
values.completedText = 'completed text'
6060
values.activeText = 'active text'
@@ -64,6 +64,11 @@ class CreateMilestoneForm extends React.Component {
6464
values.blockedText = 'blocked text'
6565
onSubmit(values)
6666
}
67+
68+
getOptionType(val) {
69+
return _.find(MILESTONE_TYPE_OPTIONS, (v) => v.value === val).title
70+
}
71+
6772
changeForm(values) {
6873
const { type, title, startDate, endDate } = this.state
6974
if (values['name'] !== title) {
@@ -88,7 +93,7 @@ class CreateMilestoneForm extends React.Component {
8893
})
8994
if (!title) {
9095
this.setState({
91-
title: values['type']
96+
title: this.getOptionType(values['type'])
9297
})
9398
}
9499
}

src/projects/detail/containers/DashboardContainer.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import {
6060
PHASE_STATUS_DRAFT,
6161
SCREEN_BREAKPOINT_MD,
6262
CODER_BOT_USERID,
63+
PROJECT_TEMPLATE_ID,
6364
} from '../../../config/constants'
6465

6566
const SYSTEM_USER = {
@@ -119,7 +120,7 @@ class DashboardContainer extends React.Component {
119120

120121
const projectTemplate = {
121122
name: phase.title,
122-
id:166,
123+
id: PROJECT_TEMPLATE_ID,
123124
}
124125

125126
createPhaseAndMilestones(project, projectTemplate, type, phase.startDate, phase.endDate, milestones)

src/projects/reducers/productsTimelines.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
SUBMIT_FINAL_FIXES_REQUEST_PENDING,
2727
SUBMIT_FINAL_FIXES_REQUEST_SUCCESS,
2828
SUBMIT_FINAL_FIXES_REQUEST_FAILURE,
29-
CREATE_PROJECT_STAGE_SUCCESS,
3029
} from '../../config/constants'
3130
import update from 'react-addons-update'
3231

@@ -201,31 +200,6 @@ export const productsTimelines = (state=initialState, action) => {
201200
})
202201
)
203202

204-
205-
case CREATE_PROJECT_STAGE_SUCCESS: {
206-
const timeline = payload.timeline
207-
const product = payload.product
208-
209-
// if there is timeline for the product
210-
if (timeline) {
211-
// sort milestones by order as server doesn't do it
212-
timeline.milestones = _.sortBy(timeline.milestones, 'order')
213-
}
214-
215-
if (timeline && product) {
216-
return update(state, {
217-
[product.id]: {
218-
$set: {
219-
isLoading: false,
220-
timeline,
221-
error: false
222-
}
223-
}
224-
})
225-
}
226-
return state
227-
}
228-
229203
case LOAD_PRODUCT_TIMELINE_WITH_MILESTONES_SUCCESS: {
230204
const timeline = payload
231205

src/projects/reducers/project.js

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
CREATE_PROJECT_PHASE_TIMELINE_MILESTONES_PENDING, CREATE_PROJECT_PHASE_TIMELINE_MILESTONES_SUCCESS, CREATE_PROJECT_PHASE_TIMELINE_MILESTONES_FAILURE,
33
LOAD_PROJECT_PENDING, LOAD_PROJECT_SUCCESS, LOAD_PROJECT_MEMBER_INVITE_PENDING, LOAD_PROJECT_MEMBER_INVITE_SUCCESS, LOAD_PROJECT_FAILURE,
4-
CREATE_PROJECT_PENDING, CREATE_PROJECT_SUCCESS, CREATE_PROJECT_FAILURE, CREATE_PROJECT_STAGE_PENDING, CREATE_PROJECT_STAGE_SUCCESS, CREATE_PROJECT_STAGE_FAILURE, CLEAR_LOADED_PROJECT,
4+
CREATE_PROJECT_PENDING, CREATE_PROJECT_SUCCESS, CREATE_PROJECT_FAILURE, CLEAR_LOADED_PROJECT,
55
UPDATE_PROJECT_PENDING, UPDATE_PROJECT_SUCCESS, UPDATE_PROJECT_FAILURE,
66
DELETE_PROJECT_PENDING, DELETE_PROJECT_SUCCESS, DELETE_PROJECT_FAILURE,
77
ADD_PROJECT_ATTACHMENT_PENDING, ADD_PROJECT_ATTACHMENT_SUCCESS, ADD_PROJECT_ATTACHMENT_FAILURE,
@@ -327,25 +327,6 @@ export const projectState = function (state=initialState, action) {
327327
})
328328
}
329329

330-
case CREATE_PROJECT_STAGE_SUCCESS: {
331-
// as we additionally loaded products to the phase object we have to keep them
332-
// note that we keep them as they are without creation a new copy
333-
const phase = {
334-
...action.payload.phase,
335-
products: [action.payload.product]
336-
}
337-
const phaseNonDirty = {
338-
// for non-dirty version we make sure that dont' have the same objects with phase
339-
..._.cloneDeep(action.payload.phase),
340-
products: [_.cloneDeep(action.payload.product)]
341-
}
342-
return update(state, {
343-
processing: { $set: false },
344-
phases: { $push: [phase] },
345-
phasesNonDirty: { $push: [phaseNonDirty] }
346-
})
347-
}
348-
349330
case UPDATE_PHASE_SUCCESS: {
350331
// as we additionally loaded products to the phase object we have to keep them
351332
// note that we keep them as they are without creation a new copy
@@ -477,7 +458,6 @@ export const projectState = function (state=initialState, action) {
477458
}
478459

479460
// Create & Edit project
480-
case CREATE_PROJECT_STAGE_PENDING:
481461
case CREATE_PROJECT_PENDING:
482462
case DELETE_PROJECT_PENDING:
483463
case UPDATE_PROJECT_PENDING:
@@ -885,7 +865,6 @@ export const projectState = function (state=initialState, action) {
885865
}
886866

887867
case LOAD_PROJECT_FAILURE:
888-
case CREATE_PROJECT_STAGE_FAILURE:
889868
case CREATE_PROJECT_FAILURE:
890869
case DELETE_PROJECT_FAILURE:
891870
case UPDATE_PROJECT_FAILURE:

src/reducers/alerts.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
// bulk phase and milestones
66
CREATE_PROJECT_PHASE_TIMELINE_MILESTONES_SUCCESS,
77
// Project
8-
CREATE_PROJECT_STAGE_SUCCESS,
98
CREATE_PROJECT_SUCCESS, CREATE_PROJECT_FAILURE,
109
UPDATE_PROJECT_SUCCESS, UPDATE_PROJECT_FAILURE,
1110
DELETE_PROJECT_SUCCESS, DELETE_PROJECT_FAILURE,
@@ -88,13 +87,6 @@ export default function(state = {}, action) {
8887
Alert.success('Project phase created.')
8988
return state
9089
}
91-
case CREATE_PROJECT_STAGE_SUCCESS: {
92-
93-
//delay time for reload stage list of project after creating state
94-
setTimeout(() => { Alert.success('Added New Stage To Project') }, 2000)
95-
96-
return state
97-
}
9890

9991
case DELETE_PROJECT_PHASE_SUCCESS: {
10092
Alert.success('Project phase deleted.')

0 commit comments

Comments
 (0)