Skip to content

Commit cfa0b2f

Browse files
author
vikasrohit
authored
Merge pull request #1305 from appirio-tech/feature/project-listing-updates#1268
Feature/project listing updates#1268
2 parents 376455e + 776bf86 commit cfa0b2f

File tree

6 files changed

+65
-41
lines changed

6 files changed

+65
-41
lines changed

src/components/ProjectInfo/ProjectInfo.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ProjectInfo extends Component {
2727
}
2828

2929
render() {
30-
const { project, currentMemberRole, duration, canDeleteProject } = this.props
30+
const { project, currentMemberRole, duration, canDeleteProject, onChangeStatus } = this.props
3131
const { showDeleteConfirm } = this.state
3232
return (
3333
<div className="project-info">
@@ -52,6 +52,7 @@ class ProjectInfo extends Component {
5252
currentMemberRole={currentMemberRole}
5353
duration={duration}
5454
descLinesCount={4}
55+
onChangeStatus={onChangeStatus}
5556
/>
5657
</div>
5758
)

src/components/ProjectInfo/ProjectInfo.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
background-color: $tc-white;
77
border-top-left-radius: 6px;
88
border-top-right-radius: 6px;
9-
padding: 4 * $base_unit;
109
@include tc-label-md;
1110

1211
.project-card-body {
12+
padding-left: 4 * $base_unit;
13+
padding-right: 4 * $base_unit;
1314
.project-description {
1415
max-height: 120px;
1516
min-height: 10px;
@@ -20,6 +21,9 @@
2021
.project-info-header {
2122
display:flex;
2223
fill: $tc-gray-50;
24+
padding-left: 4 * $base_unit;
25+
padding-right: 4 * $base_unit;
26+
padding-top: 4 * $base_unit;
2327
}
2428

2529
}

src/components/ProjectStatus/ProjectStatus.jsx

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React, { Component, PropTypes} from 'react'
1+
import React, { Component, PropTypes } from 'react'
22
import cn from 'classnames'
33
import { PROJECT_STATUS } from '../../config/constants'
44
import './ProjectStatus.scss'
55

66
export const enhanceDropdown = (CompositeComponent) => class extends Component {
77
constructor(props) {
88
super(props)
9-
this.state = { isOpen : false }
9+
this.state = { isOpen: false }
1010
this.handleClick = this.handleClick.bind(this)
1111
this.onSelect = this.onSelect.bind(this)
1212
this.onClickOutside = this.onClickOutside.bind(this)
@@ -19,13 +19,12 @@ export const enhanceDropdown = (CompositeComponent) => class extends Component {
1919

2020
document.dispatchEvent(dropdownClicked)
2121

22-
this.setState({ isOpen : !this.state.isOpen })
22+
this.setState({ isOpen: !this.state.isOpen })
2323
}
2424

2525
onSelect(value) {
2626
this.handleClick()
27-
28-
if (this.props.onChangeStatus) this.props.onChangeStatus(value)
27+
if (this.props.onSelect) this.props.onSelect(value)
2928
}
3029

3130
onClickOutside(evt) {
@@ -34,7 +33,7 @@ export const enhanceDropdown = (CompositeComponent) => class extends Component {
3433
console.log('onClickOutside')
3534

3635
do {
37-
if(currNode.className
36+
if (currNode.className
3837
&& currNode.className.indexOf
3938
&& currNode.className.indexOf('dropdown-wrap') > -1) {
4039
isDropdown = true
@@ -43,11 +42,11 @@ export const enhanceDropdown = (CompositeComponent) => class extends Component {
4342

4443
currNode = currNode.parentNode
4544

46-
if(!currNode)
45+
if (!currNode)
4746
break
48-
} while(currNode.tagName)
47+
} while (currNode.tagName)
4948

50-
if(!isDropdown) {
49+
if (!isDropdown) {
5150
this.setState({ isOpen: false })
5251
}
5352
}
@@ -75,9 +74,9 @@ export const enhanceDropdown = (CompositeComponent) => class extends Component {
7574
<div onClick={(e) => e.stopPropagation()} className="dropdown-wrap">
7675
<CompositeComponent
7776
{ ...this.props }
78-
isOpen={ isOpen }
79-
handleClick={ this.handleClick }
80-
onSelect={ this.onSelect }
77+
isOpen={isOpen}
78+
handleClick={this.handleClick}
79+
onSelect={this.onSelect}
8180
/>
8281
</div>
8382
)
@@ -86,32 +85,35 @@ export const enhanceDropdown = (CompositeComponent) => class extends Component {
8685

8786

8887
/*eslint-enable camelcase */
89-
const ProjectStatus = ({canEdit, isOpen, status, handleClick, onSelect, showText, withoutLabel, unifiedHeader=true }) => {
88+
const ProjectStatus = ({ canEdit, isOpen, status, handleClick, onSelect, showText, withoutLabel, unifiedHeader = true }) => {
9089
const selected = PROJECT_STATUS.filter((opt) => opt.value === status)[0]
9190
return (
9291
<div className="ProjectStatus">
93-
<div className={cn('status-header', 'ps-' + selected.value, {active: isOpen, editable : canEdit, 'unified-header' : unifiedHeader })} onClick={handleClick}>
92+
<div className={cn('status-header', 'ps-' + selected.value, { active: isOpen, editable: canEdit, 'unified-header': unifiedHeader })} onClick={handleClick}>
9493
<div className="status-icon"><i /></div>
95-
{showText && (<span className="status-label">{withoutLabel ? selected.fullName : selected.name}<i className="caret" /></span>) }
94+
{showText && (<span className="status-label">{withoutLabel ? selected.fullName : selected.name}<i className="caret" /></span>)}
95+
</div>
96+
{isOpen && canEdit && <div className="status-dropdown">
97+
<div className="status-header">Project Status</div>
98+
<ul>
99+
{
100+
PROJECT_STATUS.map((item) =>
101+
<li key={item.value}>
102+
<a
103+
href="javascript:"
104+
className={cn('status-option', 'ps-' + item.value, { active: item.value === status })}
105+
onClick={(e) => {
106+
onSelect(item.value, e)
107+
}}
108+
>
109+
<span className="status-icon"><i /></span>
110+
<span className="status-label">{item.name}</span>
111+
</a>
112+
</li>
113+
)
114+
}
115+
</ul>
96116
</div>
97-
{ isOpen && canEdit && <ul className="status-dropdown">
98-
{
99-
PROJECT_STATUS.map((item) =>
100-
<li key={item.value}>
101-
<a
102-
href="javascript:"
103-
className={cn('status-option', 'ps-' + item.value, {active: item.value === status})}
104-
onClick={(e) => {
105-
onSelect(item.value, e)
106-
}}
107-
>
108-
<span className="status-icon"><i/></span>
109-
<span className="status-label">{item.name}</span>
110-
</a>
111-
</li>
112-
)
113-
}
114-
</ul>
115117
}
116118
</div>
117119
)

src/components/ProjectStatus/ProjectStatus.scss

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ $status-height : 20px;
44
.ProjectStatus {
55
position: relative;
66
height: $status-height;
7-
87
.status-icon {
98
position: relative;
109
display: inline-block;
@@ -94,6 +93,7 @@ $status-height : 20px;
9493
}
9594
.caret {
9695
// content: '';
96+
z-index: 3;
9797
display: inline-block;
9898
width: 9px;
9999
height: 5px;
@@ -129,17 +129,29 @@ $status-height : 20px;
129129
margin-left: 10px;
130130
}
131131

132-
ul.status-dropdown {
132+
.status-dropdown {
133+
min-width: 110%;
133134
position: absolute;
134135
border-radius: $base-unit;
135136
box-shadow: 0 0 15px rgba(0, 0, 0, .25);
136137
padding: 10px 0;
137138
position: absolute;
138139
background: $tc-white;
139-
top: $status-height;
140+
top: -2*$base_unit;
140141
left: 0px;
141142
right: auto;
142143
z-index: 2;
144+
.status-header {
145+
@include roboto-medium;
146+
font-size: $tc-label-md;
147+
text-align: left;
148+
color: $tc-light-blue;
149+
line-height: 30px;
150+
padding-left: 20px;
151+
margin-bottom: 20px;
152+
white-space: nowrap;
153+
}
154+
143155
a.status-option {
144156
display: flex;
145157
@include roboto-medium;

src/projects/detail/containers/ProjectInfoContainer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class ProjectInfoContainer extends React.Component {
106106
duration={duration}
107107
canDeleteProject={canDeleteProject}
108108
onDeleteProject={this.onDeleteProject}
109+
onChangeStatus={this.onChangeStatus}
109110
/>
110111
<LinksMenu
111112
links={project.bookmarks || []}

src/projects/list/components/Projects/ProjectCardBody.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import { Link } from 'react-router-dom'
33
import TextTruncate from 'react-text-truncate'
44
import ProjectProgress from '../../../../components/ProjectProgress/ProjectProgress'
55
import ProjectStatus from '../../../../components/ProjectStatus/ProjectStatus'
6-
import { PROJECT_STATUS_ACTIVE } from '../../../../config/constants'
6+
import { PROJECT_STATUS_ACTIVE, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER } from '../../../../config/constants'
77
import './ProjectCardBody.scss'
8+
import _ from 'lodash'
89

9-
function ProjectCardBody({ project, duration, currentMemberRole, descLinesCount=8 }) {
10+
function ProjectCardBody({ project, duration, currentMemberRole, descLinesCount=8, onChangeStatus }) {
1011
if (!project) return null
12+
const canEdit = currentMemberRole
13+
&& _.indexOf([PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER], currentMemberRole) > -1
1114

1215
return (
1316
<div className="project-card-body">
@@ -25,8 +28,9 @@ function ProjectCardBody({ project, duration, currentMemberRole, descLinesCount=
2528
showText
2629
withoutLabel
2730
currentMemberRole={currentMemberRole}
28-
canEdit={false}
31+
canEdit={canEdit}
2932
unifiedHeader={false}
33+
onSelect={onChangeStatus}
3034
/>
3135
}
3236
{project.status === PROJECT_STATUS_ACTIVE &&

0 commit comments

Comments
 (0)