Skip to content

Commit 380ba68

Browse files
author
Vikas Agarwal
committed
Merge branch 'dev' into feature/number_of_screens_valiation_802
* dev: Github issue#873, Manager does not get manager access immediately after joining the project -- Updated projectNonDirty state as well on every action that can update project
2 parents 3cc6607 + 5efbe9e commit 380ba68

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

src/projects/detail/components/EditProjectForm.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class EditProjectForm extends Component {
151151
*/
152152
handleChange(change) {
153153
// removed check for isChanged argument to fire the PROJECT_DIRTY event for every change in the form
154-
this.props.fireProjectDirty(change)
154+
this.props.fireProjectDirty(unflatten(change))
155155
}
156156

157157

src/projects/reducers/project.js

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ const initialState = {
2020
processingMembers: false,
2121
processingAttachments: false,
2222
error: false,
23-
project: {}
23+
project: {},
24+
projectNonDirty: {}
2425
}
2526

27+
// NOTE: We should always update projectNonDirty state whenever we update the project state
28+
2629
const parseErrorObj = (action) => {
2730
const data = action.payload.response.data.result
2831
return {
@@ -39,7 +42,8 @@ export const projectState = function (state=initialState, action) {
3942
case LOAD_PROJECT_PENDING:
4043
return Object.assign({}, state, {
4144
isLoading: true,
42-
project: null
45+
project: null,
46+
projectNonDirty: null
4347
})
4448

4549
case LOAD_PROJECT_SUCCESS:
@@ -53,7 +57,8 @@ export const projectState = function (state=initialState, action) {
5357
case CLEAR_LOADED_PROJECT:
5458
case GET_PROJECTS_SUCCESS:
5559
return Object.assign({}, state, {
56-
project: {}
60+
project: {},
61+
projectNonDirty: {}
5762
})
5863

5964
case LOAD_DIRECT_PROJECT_SUCCESS:
@@ -69,6 +74,18 @@ export const projectState = function (state=initialState, action) {
6974
plannedDuration: action.payload.plannedDuration,
7075
projectedDuration: action.payload.projectedDuration
7176
}}
77+
},
78+
projectNonDirty: {
79+
budget: { $set: {
80+
actualCost: action.payload.actualCost,
81+
projectedCost: action.payload.projectedCost,
82+
totalBudget: action.payload.totalBudget
83+
}},
84+
duration: { $set: {
85+
actualDuration: action.payload.actualDuration,
86+
plannedDuration: action.payload.plannedDuration,
87+
projectedDuration: action.payload.projectedDuration
88+
}}
7289
}
7390
})
7491

@@ -95,7 +112,8 @@ export const projectState = function (state=initialState, action) {
95112
return Object.assign({}, state, {
96113
processing: false,
97114
error: false,
98-
project: {}
115+
project: {},
116+
projectNonDirty: {}
99117
})
100118

101119
// Project attachments
@@ -109,15 +127,17 @@ export const projectState = function (state=initialState, action) {
109127
case ADD_PROJECT_ATTACHMENT_SUCCESS:
110128
return update(state, {
111129
processingAttachments: { $set : false },
112-
project: { attachments: { $push: [action.payload] } }
130+
project: { attachments: { $push: [action.payload] } },
131+
projectNonDirty: { attachments: { $push: [action.payload] } }
113132
})
114133

115134
case UPDATE_PROJECT_ATTACHMENT_SUCCESS: {
116135
// get index
117136
const idx = _.findIndex(state.project.attachments, a => a.id === action.payload.id)
118137
return update(state, {
119138
processingAttachments: { $set : false },
120-
project: { attachments: { $splice : [[idx, 1, action.payload]] } }
139+
project: { attachments: { $splice : [[idx, 1, action.payload]] } },
140+
projectNonDirty: { attachments: { $splice : [[idx, 1, action.payload]] } }
121141
})
122142
}
123143

@@ -127,7 +147,8 @@ export const projectState = function (state=initialState, action) {
127147
const idx = _.findIndex(state.project.attachments, a => a.id === action.payload)
128148
return update(state, {
129149
processing: { $set : false },
130-
project: { attachments: { $splice: [[idx, 1]] } }
150+
project: { attachments: { $splice: [[idx, 1]] } },
151+
projectNonDirty: { attachments: { $splice: [[idx, 1]] } }
131152
})
132153
}
133154

@@ -141,7 +162,8 @@ export const projectState = function (state=initialState, action) {
141162
case ADD_PROJECT_MEMBER_SUCCESS:
142163
return update (state, {
143164
processingMembers: { $set : false },
144-
project: { members: { $push: [action.payload] } }
165+
project: { members: { $push: [action.payload] } },
166+
projectNonDirty: { members: { $push: [action.payload] } }
145167
})
146168

147169
case UPDATE_PROJECT_MEMBER_SUCCESS: {
@@ -155,7 +177,8 @@ export const projectState = function (state=initialState, action) {
155177
updatedMembers.splice(idx, 1, action.payload)
156178
return update(state, {
157179
processingMembers: { $set : false },
158-
project: { members: { $set: updatedMembers } }
180+
project: { members: { $set: updatedMembers } },
181+
projectNonDirty: { members: { $set: updatedMembers } }
159182
})
160183
}
161184

@@ -164,7 +187,8 @@ export const projectState = function (state=initialState, action) {
164187
const idx = _.findIndex(state.project.members, a => a.id === action.payload)
165188
return update(state, {
166189
processingMembers: { $set : false },
167-
project: { members: { $splice: [[idx, 1]] } }
190+
project: { members: { $splice: [[idx, 1]] } },
191+
projectNonDirty: { members: { $splice: [[idx, 1]] } }
168192
})
169193
}
170194

0 commit comments

Comments
 (0)