Skip to content

Commit 6d22f96

Browse files
authored
Merge pull request #3372 from PrakashDurlabhji/dev
f2f avoid draft status
2 parents c17402f + 082333a commit 6d22f96

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

src/components/ProjectStatus/editableProjectStatus.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
PROJECT_STATUS_ACTIVE,
1111
PROJECT_STATUS_COMPLETED,
1212
PROJECT_STATUS_CANCELLED,
13-
TOOLTIP_DEFAULT_DELAY
13+
TOOLTIP_DEFAULT_DELAY,
14+
PROJECT_STATUS_DRAFT
1415
} from '../../config/constants'
1516
import CarretDownNormal9px from '../../assets/icons/arrow-9px-carret-down-normal.svg'
1617

@@ -63,7 +64,7 @@ const hocStatusDropdown = (CompositeComponent, statusList, projectCanBeActive) =
6364
<div className="status-header">Project Status</div>
6465
<ul>
6566
{
66-
activestatusList.sort((a, b) => a.dropDownOrder > b.dropDownOrder).map((item) =>
67+
activestatusList.sort((a, b) => a.order - b.order).map((item) =>
6768
item.toolTipMessage ? (
6869
<Tooltip key={item.value} theme="light" tooltipDelay={TOOLTIP_DEFAULT_DELAY}>
6970
<div className="tooltip-target">
@@ -121,6 +122,7 @@ const editableProjectStatus = (CompositeComponent) => class extends Component {
121122
this.showStatusChangeDialog = this.showStatusChangeDialog.bind(this)
122123
this.changeStatus = this.changeStatus.bind(this)
123124
this.handleReasonUpdate = this.handleReasonUpdate.bind(this)
125+
this.getProjectStatusDropdownValues = this.getProjectStatusDropdownValues.bind(this)
124126
}
125127

126128
componentWillReceiveProps() {
@@ -158,12 +160,20 @@ const editableProjectStatus = (CompositeComponent) => class extends Component {
158160
this.setState({ statusChangeReason : _.get(reason, 'value') })
159161
}
160162

163+
getProjectStatusDropdownValues(status) {
164+
if (status === PROJECT_STATUS_DRAFT) {
165+
return [{color: 'gray', name: 'Draft', fullName: 'Project is in draft', value: PROJECT_STATUS_DRAFT, order: 2, dropDownOrder: 1 }].concat(PROJECT_STATUS)
166+
}
167+
return PROJECT_STATUS
168+
}
169+
161170
render() {
162171
const { showStatusChangeDialog, newStatus, statusChangeReason } = this.state
163-
const { canEdit, projectCanBeActive } = this.props
172+
const { canEdit, projectCanBeActive, status } = this.props
173+
const PROJECT_STATUS_VALUES = this.getProjectStatusDropdownValues(status)
164174
const StatusDropdown = canEdit
165-
? enhanceDropdown(hocStatusDropdown(CompositeComponent, PROJECT_STATUS, projectCanBeActive))
166-
: hocStatusDropdown(CompositeComponent, PROJECT_STATUS, projectCanBeActive)
175+
? enhanceDropdown(hocStatusDropdown(CompositeComponent, PROJECT_STATUS_VALUES, projectCanBeActive))
176+
: hocStatusDropdown(CompositeComponent, PROJECT_STATUS_VALUES, projectCanBeActive)
167177
return (
168178
<div className={cn('EditableProjectStatus', {'modal-active': showStatusChangeDialog})}>
169179
<div className="modal-overlay" onClick={ this.hideStatusChangeDialog }/>
@@ -190,7 +200,11 @@ editableProjectStatus.propTypes = {
190200
/**
191201
* Boolean flag to control if project status can be switched to active.
192202
*/
193-
projectCanBeActive: PropTypes.bool
203+
projectCanBeActive: PropTypes.bool,
204+
/**
205+
* String representing project status
206+
*/
207+
status: PropTypes.string
194208
}
195209

196210
export default editableProjectStatus

src/config/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ export const PHASE_STATUS_CANCELLED = 'cancelled'
566566
export const PHASE_STATUS_PAUSED = 'paused'
567567

568568
export const PROJECT_STATUS = [
569-
{color: 'gray', name: 'Draft', fullName: 'Project is in draft', value: PROJECT_STATUS_DRAFT, order: 2, dropDownOrder: 1 },
569+
// {color: 'gray', name: 'Draft', fullName: 'Project is in draft', value: PROJECT_STATUS_DRAFT, order: 2, dropDownOrder: 1 },
570570
{color: 'gray', name: 'In review', fullName: 'Project is in review', value: PROJECT_STATUS_IN_REVIEW, order: 3, dropDownOrder: 2 },
571571
{color: 'gray', name: 'Reviewed', fullName: 'Project is reviewed', value: PROJECT_STATUS_REVIEWED, order: 4, dropDownOrder: 3 },
572572
{color: 'green', name: 'Active', fullName: 'Project is active', value: PROJECT_STATUS_ACTIVE, order: 1, dropDownOrder: 4 },

src/projects/actions/project.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import {
6060
SCOPE_CHANGE_REQ_STATUS_APPROVED,
6161
SCOPE_CHANGE_REQ_STATUS_REJECTED,
6262
SCOPE_CHANGE_REQ_STATUS_CANCELED,
63+
PHASE_STATUS_DRAFT,
6364
} from '../../config/constants'
6465
import {
6566
updateProductMilestone,
@@ -275,7 +276,7 @@ export function createProduct(project, productTemplate, phases, timelines) {
275276
return (dispatch) => {
276277
return dispatch({
277278
type: CREATE_PROJECT_STAGE,
278-
payload: createProjectPhaseAndProduct(project, productTemplate, PROJECT_STATUS_DRAFT, startDate, endDate)
279+
payload: createProjectPhaseAndProduct(project, productTemplate, PHASE_STATUS_DRAFT, startDate, endDate)
279280
})
280281
}
281282
}
@@ -289,7 +290,7 @@ export function createProduct(project, productTemplate, phases, timelines) {
289290
*
290291
* @return {Promise} project
291292
*/
292-
export function createProjectPhaseAndProduct(project, projectTemplate, status = PROJECT_STATUS_DRAFT, startDate, endDate) {
293+
export function createProjectPhaseAndProduct(project, projectTemplate, status = PHASE_STATUS_DRAFT, startDate, endDate) {
293294
const param = {
294295
status,
295296
name: projectTemplate.name,

0 commit comments

Comments
 (0)