Skip to content

Commit ad91061

Browse files
committed
1 parent 39121fc commit ad91061

File tree

7 files changed

+50
-68
lines changed

7 files changed

+50
-68
lines changed

src/api/projects.js

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -77,53 +77,6 @@ export function getProjectById(projectId) {
7777
export function getProjectPhases(projectId, query = {}) {
7878
const params = _.mapValues(query, (param) => encodeURIComponent(param))
7979

80-
// const mockaData = [{
81-
// "products":[{"updatedBy":40152856,"actualPrice":0,"phaseId":8730,"billingAccountId":null,"templateId":176,"type":"generic-product","createdAt":"2021-08-05T20:38:08.587Z","createdBy":40152856,"estimatedPrice":0,"name":"Generic Product","details":{},"id":8794,"directProjectId":null,"projectId":18162,"updatedAt":"2021-08-05T20:38:08.588Z"}],
82-
// "budget":0,
83-
// "createdAt":"2021-08-05T20:38:08.575Z",
84-
// "createdBy":40152856,
85-
// "details":{},
86-
// "duration":null,
87-
// "endDate":"2021-08-12T00:00:00.000Z",
88-
// "id":8730,
89-
// "name":"a1",
90-
// "description":null,
91-
// "progress":0,
92-
// "projectId":18162,
93-
// "spentBudget":0,
94-
// "startDate":"2021-08-09T00:00:00.000Z",
95-
// // "status":"in_review",
96-
// "status":"reviewed",
97-
// "updatedAt":"2021-08-06T03:06:39.277Z",
98-
// "updatedBy":40152856,
99-
// // "approvals": [{id: 0, decision: "approve", comment: ""}],
100-
// "approvals": [{id: 0, decision: "reject", comment: "rej"}],
101-
// "members":[]},
102-
103-
// {"products":[{"updatedBy":40152856,"actualPrice":0,"phaseId":8730,"billingAccountId":null,"templateId":176,"type":"generic-product","createdAt":"2021-08-05T20:38:08.587Z","createdBy":40152856,"estimatedPrice":0,"name":"Generic Product","details":{},"id":8794,"directProjectId":null,"projectId":18162,"updatedAt":"2021-08-05T20:38:08.588Z"}],
104-
// "budget":0,
105-
// "createdAt":"2021-08-05T20:38:08.575Z",
106-
// "createdBy":40152856,
107-
// "details":{},
108-
// "duration":null,
109-
// "endDate":"2021-08-12T00:00:00.000Z",
110-
// "id":8730,
111-
// "name":"a2",
112-
// "description":null,
113-
// "progress":0,
114-
// "projectId":18162,
115-
// "spentBudget":0,
116-
// "startDate":"2021-08-09T00:00:00.000Z",
117-
// // "status":"in_review",
118-
// "status":"reviewed",
119-
// "updatedAt":"2021-08-06T03:06:39.277Z",
120-
// "updatedBy":40152856,
121-
// // "approvals": [{id: 0, decision: "approve", comment: ""}],
122-
// "approvals": [{id: 0, decision: "reject", comment: "rej1"}],
123-
// "members":[]},
124-
// ]
125-
// return Promise.resolve(mockaData)
126-
12780
return axios.get(`${PROJECTS_API_URL}/v5/projects/${projectId}/phases`, { params })
12881
.then(resp => {console.log('resp.data', query, resp.data); return resp.data})
12982
}

src/projects/detail/components/SimplePlan/ManageMilestones/ManageMilestones.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,13 @@ class ManageMilestones extends React.Component {
258258
} = this.props
259259

260260
// const isNeedApproval = project.status === PROJECT_STATUS_IN_REVIEW
261-
const canShowApproval = isCustomer
261+
const isNeedApproval = !milestones.filter(ms => ms.selected === true).find(ms => !(ms.status === PHASE_STATUS_IN_REVIEW))
262+
const canShowApproval = isCustomer && isNeedApproval
262263

263264
const canEdit = (isUpdatable || canShowApproval) && this.getSelectCount() > 0
264265
const disableDeleteAction = this.getSelectCount() > 1
266+
const canShowSelectionStatus = canEdit || (isCustomer && this.getSelectCount() > 0)
267+
265268
return (
266269
<div>
267270
<div styleName="toolbar">
@@ -272,7 +275,7 @@ class ManageMilestones extends React.Component {
272275
<IconGnattView />
273276
</button>
274277
<div styleName="separator" /> */}
275-
{this.getSelectCount() > 0 ? <div styleName="unselect-bottom" onClick={this.onUnselectAll}>
278+
{(this.getSelectCount() > 0 || canShowSelectionStatus)? <div styleName="unselect-bottom" onClick={this.onUnselectAll}>
276279
<IconUnselect /> {this.getSelectCount()} PROJECT(S) SELECTED
277280
</div>: null }
278281
{ canEdit ? (() => canShowApproval ?
@@ -326,13 +329,13 @@ class ManageMilestones extends React.Component {
326329
<col style={{ width: '11%' }} />{/* END DATE */}
327330
<col style={{ width: '10%' }} />{/* STATUS */}
328331
<col style={{ width: '13%' }} />{/* COPILOTS */}
329-
{(isUpdatable || canShowApproval) && (<col style={{ width: '64px' }} />)}{/* ACTION */}
332+
{(isUpdatable || isCustomer) && (<col style={{ width: '64px' }} />)}{/* ACTION */}
330333
</colgroup>
331334
<thead>
332335
<MilestoneHeaderRow
333336
milestones={milestones}
334337
onChangeMilestones={onChangeMilestones}
335-
isUpdatable={isUpdatable || canShowApproval}
338+
isUpdatable={isUpdatable || isCustomer}
336339
/>
337340
</thead>
338341
<tbody>

src/projects/detail/components/SimplePlan/components/MilestoneApprovalButton/MilestoneApprovalButton.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
@import "../../../../../../styles/variables";
22

33
.icon-button {
4-
height: 14px;
4+
height: 24px;
55
padding: 0 !important;
66
border: 0 !important;
77
svg {
8-
width: 14px;
9-
height: 14px;
8+
width: 24px;
9+
height: 24px;
1010
}
1111
}
1212

src/projects/detail/components/SimplePlan/components/MilestoneRow/MilestoneRow.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,21 +353,21 @@ function MilestoneRow({
353353
</td>
354354
)}
355355
{
356-
showApproval && (
356+
isCustomer && (
357357
<td styleName="action">
358-
<div styleName="inline-menu">
359-
<MilestoneApprovalButton
358+
<div styleName="inline-menu approve">
359+
{showApproval && <MilestoneApprovalButton
360360
type={'approve'}
361361
onClick={() => {
362362
onApprove({type: 'approve', item: milestone})
363363
}}
364-
/>
365-
<MilestoneApprovalButton
364+
/>}
365+
{ showApproval && <MilestoneApprovalButton
366366
type="reject"
367367
onClick={(v) => {
368368
onApprove({type: 'reject', comment: v, item: milestone})
369369
}}
370-
/>
370+
/>}
371371
</div>
372372
</td>
373373
)

src/projects/detail/components/SimplePlan/components/MilestoneRow/MilestoneRow.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
button {
158158
color: black;
159159
}
160+
160161
svg {
161162
width: 14px;
162163
height: 14px;
@@ -165,5 +166,12 @@
165166
fill: currentColor
166167
}
167168
}
169+
170+
&.approve {
171+
172+
> *:not(:last-child) {
173+
margin-right: 5px;
174+
}
175+
}
168176
}
169177
}

src/projects/detail/components/SimplePlan/components/MilestonesApprovalNotification/MilestonesApprovalNotification.jsx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,45 @@ class MilestonesApprovalNotification extends React.Component {
2323
open: false,
2424
show: true,
2525
}
26+
27+
this.findLatest = this.findLatest.bind(this)
28+
}
29+
30+
findLatest(approvals) {
31+
let d = null;
32+
let maxIndex = 0;
33+
for(let index = 0; index < approvals.length; index ++) {
34+
const tmp = new Date(approvals[index].createdAt)
35+
if(!d) {
36+
d = tmp;
37+
continue;
38+
}
39+
if(d < tmp) {
40+
d = tmp;
41+
maxIndex = index;
42+
}
43+
}
44+
return approvals[maxIndex] || {};
2645
}
2746

2847
render() {
2948
const { milestones } = this.props
3049

3150
console.log('milestones', milestones)
51+
3252
const inReviews = milestones.find(
3353
(ms) => ms.status === PHASE_STATUS_IN_REVIEW
3454
)
3555
const revieweds = milestones.filter(
3656
(ms) => ms.status === PHASE_STATUS_REVIEWED
37-
)
57+
).map( ms => {ms.currentApproval = this.findLatest(ms.approvals); return ms})
3858

3959
const showAllApproved =
4060
!inReviews && revieweds.length > 0 &&
4161
!revieweds.find(
4262
(rd) =>
4363
!!(
44-
rd.approvals && rd.approvals[0].decision !== PHASE_APPROVAL_APPROVE
64+
rd.approvals && rd.currentApproval.decision !== PHASE_APPROVAL_APPROVE
4565
)
4666
)
4767

@@ -55,13 +75,13 @@ class MilestonesApprovalNotification extends React.Component {
5575
// group item pre-definition
5676
const toPush = { items: null, comment: null }
5777

58-
if (ms.approvals[0].decision === PHASE_APPROVAL_REJECT) {
59-
(toPush.items = [ms]), (toPush.comment = ms.approvals[0].comment)
78+
if (ms.currentApproval.decision === PHASE_APPROVAL_REJECT) {
79+
(toPush.items = [ms]), (toPush.comment = ms.currentApproval.comment)
6080
}
6181
revieweds.slice(index + 1).forEach((ms2, index2) => {
6282
if (
63-
ms2.approvals[0].decision === PHASE_APPROVAL_REJECT &&
64-
ms.approvals[0].comment === ms2.approvals[0].comment
83+
ms2.currentApproval.decision === PHASE_APPROVAL_REJECT &&
84+
ms.currentApproval.comment === ms2.currentApproval.comment
6585
) {
6686
toPush.items.push(ms2)
6787
skip.push(index2 + index + 1)

src/projects/detail/containers/DashboardContainer.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ class DashboardContainer extends React.Component {
155155
const reqs = []
156156
milestones.forEach( ms => {
157157
reqs.push(
158-
// executePhaseApproval(ms.projectId, ms.id, {decision: type, comment, startDate: ms.startDate, expectedEndDate: ms.endDate})
159158
executePhaseApproval(ms.projectId, ms.id, {decision: type, comment})
160-
// executePhaseApproval(ms.projectId, ms.id, {decision: 'reject', comment: 'rej'})
161159
)
162160
console.log('type-comment', type, comment, ms)
163161
})

0 commit comments

Comments
 (0)