diff --git a/src/config/constants.js b/src/config/constants.js index df25f7c9e..f2efa6437 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -236,11 +236,6 @@ export const CREATE_PROJECT_PENDING = 'CREATE_PROJECT_PENDING' export const CREATE_PROJECT_SUCCESS = 'CREATE_PROJECT_SUCCESS' export const CREATE_PROJECT_FAILURE = 'CREATE_PROJECT_FAILURE' -export const CREATE_PROJECT_STAGE = 'CREATE_PROJECT_STAGE' -export const CREATE_PROJECT_STAGE_PENDING = 'CREATE_PROJECT_STAGE_PENDING' -export const CREATE_PROJECT_STAGE_SUCCESS = 'CREATE_PROJECT_STAGE_SUCCESS' -export const CREATE_PROJECT_STAGE_FAILURE = 'CREATE_PROJECT_STAGE_FAILURE' - export const UPDATE_PROJECT = 'UPDATE_PROJECT' export const UPDATE_PROJECT_PENDING = 'UPDATE_PROJECT_PENDING' export const UPDATE_PROJECT_SUCCESS = 'UPDATE_PROJECT_SUCCESS' @@ -1141,5 +1136,22 @@ export const MILESTONE_TYPE = { REPORTING: 'reporting', DELIVERABLE_REVIEW: 'deliverable-review', FINAL_DELIVERABLE_REVIEW: 'final-deliverable-review', - DELIVERABLE_FINAL_FIXES: 'deliverable-final-fixes' + DELIVERABLE_FINAL_FIXES: 'deliverable-final-fixes', + PHASE_SPECIFICATION:'phase-specification', + COMMUNITY_WORK: 'ommunity-work', + COMMUNITY_REVIEW: 'community-review', + GENERIC_WORK: 'generic-work', + CHECKPOINT_REVIEW: 'checkpoint-review', + ADD_LINKS: 'add-links', + FINAL_DESIGNS: 'final-designs', + FINAL_FIX: 'final-fix', + DELIVERY_DEV: 'delivery-dev', + DELIVERY_DESIGN: 'delivery-design', + DELIVERY: 'delivery' } + + +/** + * project template id + */ +export const PROJECT_TEMPLATE_ID = 166 diff --git a/src/projects/actions/project.js b/src/projects/actions/project.js index 4c2b2cdec..f1367e44f 100644 --- a/src/projects/actions/project.js +++ b/src/projects/actions/project.js @@ -30,7 +30,6 @@ import { LOAD_PROJECT, LOAD_PROJECT_MEMBER_INVITE, CREATE_PROJECT, - CREATE_PROJECT_STAGE, CLEAR_LOADED_PROJECT, UPDATE_PROJECT, DELETE_PROJECT, @@ -74,9 +73,6 @@ import { updateProductMilestone, updateProductTimeline } from './productsTimelines' -import { - getPhaseActualData, -} from '../../helpers/projectHelper' import { delay } from '../../helpers/utils' /** @@ -274,31 +270,6 @@ function createProductsTimelineAndMilestone(project) { } } -export function createProduct(project, productTemplate, phases, timelines) { - // get endDates + 1 day for all the phases if there are any phases - const phaseEndDatesPlusOne = (phases || []).map((phase) => { - const productId = _.get(phase, 'products[0].id', -1) - const timeline = _.get(timelines, `${productId}.timeline`, null) - - const phaseActualData = getPhaseActualData(phase, timeline) - - return phaseActualData.endDate.add(1, 'day') - }) - - const today = moment().hours(0).minutes(0).seconds(0).milliseconds(0) - const startDate = _.max([...phaseEndDatesPlusOne, today]) - - // assumes 10 days as default duration, ideally we could store it at template level - const endDate = moment(startDate).add((10 - 1), 'days') - - return (dispatch) => { - return dispatch({ - type: CREATE_PROJECT_STAGE, - payload: createProjectPhaseAndProduct(project, productTemplate, PHASE_STATUS_DRAFT, startDate, endDate) - }) - } -} - /** * Create phase and product for the project * diff --git a/src/projects/detail/components/CreatePhaseForm/CreatePhaseForm.jsx b/src/projects/detail/components/CreatePhaseForm/CreatePhaseForm.jsx index cf46b504c..e9869bffb 100644 --- a/src/projects/detail/components/CreatePhaseForm/CreatePhaseForm.jsx +++ b/src/projects/detail/components/CreatePhaseForm/CreatePhaseForm.jsx @@ -129,8 +129,8 @@ class CreatePhaseForm extends React.Component { _.forEach(apiMilestones, (m, index) => { m.status = 'reviewed' m.order = index + 1 + m.duration = moment(m.endDate).diff(moment(m.startDate), 'days') + 1 // TODO add mock data - m.duration = 1 m.hidden =false m.completedText = 'completed text' m.activeText = 'active text' diff --git a/src/projects/detail/components/timeline/CreateMilestoneForm/CreateMilestoneForm.jsx b/src/projects/detail/components/timeline/CreateMilestoneForm/CreateMilestoneForm.jsx index 9f850bd16..359ba7168 100644 --- a/src/projects/detail/components/timeline/CreateMilestoneForm/CreateMilestoneForm.jsx +++ b/src/projects/detail/components/timeline/CreateMilestoneForm/CreateMilestoneForm.jsx @@ -53,8 +53,8 @@ class CreateMilestoneForm extends React.Component { // TODO // mock data values.status = 'reviewed' + values.duration = moment(values.endDate).diff(moment(values.startDate), 'days') + 1 // TODO add mock data - values.duration = 1 values.hidden =false values.completedText = 'completed text' values.activeText = 'active text' @@ -64,6 +64,11 @@ class CreateMilestoneForm extends React.Component { values.blockedText = 'blocked text' onSubmit(values) } + + getOptionType(val) { + return _.find(MILESTONE_TYPE_OPTIONS, (v) => v.value === val).title + } + changeForm(values) { const { type, title, startDate, endDate } = this.state if (values['name'] !== title) { @@ -88,7 +93,7 @@ class CreateMilestoneForm extends React.Component { }) if (!title) { this.setState({ - title: values['type'] + title: this.getOptionType(values['type']) }) } } diff --git a/src/projects/detail/components/timeline/Milestone/Milestone.jsx b/src/projects/detail/components/timeline/Milestone/Milestone.jsx index a452e2bba..f3a2609c0 100644 --- a/src/projects/detail/components/timeline/Milestone/Milestone.jsx +++ b/src/projects/detail/components/timeline/Milestone/Milestone.jsx @@ -294,12 +294,13 @@ class Milestone extends React.Component { const isActualDateEditable = this.isActualStartDateEditable() const isCompletionDateEditable = this.isCompletionDateEditable() - const isFirstReportingType = index === 0 && milestone.type === MILESTONE_TYPE.REPORTING + const disableDelete = index === 0 && milestone.type === MILESTONE_TYPE.REPORTING + const disableType = index === 0 && milestone.type === MILESTONE_TYPE.REPORTING || milestone.status !== MILESTONE_STATUS.PLANNED const editForm = (