From 8b0e745beabd71d349ee460d89b18ba66ab0c06f Mon Sep 17 00:00:00 2001 From: Alex Windett Date: Wed, 25 Jan 2017 16:06:18 +0000 Subject: [PATCH] implimenting assinging status update to team memember --- .../src/components/people-list/table/index.js | 4 +++ .../people-list/table/person-role.js | 1 + .../people-list/table/person-status.js | 26 +++++++++++++-- .../components/people-list/table/tooltip.js | 5 ++- frontend/src/containers/org/people.js | 5 ++- frontend/src/state/actions.js | 3 +- frontend/src/state/reducers/orgs.js | 33 ++++++++++++++++++- 7 files changed, 71 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/people-list/table/index.js b/frontend/src/components/people-list/table/index.js index 53fb9dbf..44c6f692 100644 --- a/frontend/src/components/people-list/table/index.js +++ b/frontend/src/components/people-list/table/index.js @@ -12,6 +12,7 @@ const PeopleTable = (props) => { handleRoleTooltip, handleRoleUpdate, handleStatusTooltip, + handleStatusUpdate, people = [], orgUI = {}, orgIndex @@ -38,7 +39,9 @@ const PeopleTable = (props) => { const status = (person) => ( { options={membersRolesOptions} orgIndex={orgIndex} person={_person} + personAttr="role" personIndex={personIndex} /> : null } diff --git a/frontend/src/components/people-list/table/person-status.js b/frontend/src/components/people-list/table/person-status.js index 4aa1929a..d73a4b01 100644 --- a/frontend/src/components/people-list/table/person-status.js +++ b/frontend/src/components/people-list/table/person-status.js @@ -49,14 +49,26 @@ const PlainButton = styled.button` const PersonStatus = (props) => { const { - handleStatusTooltip, toggledID, membersStatusOptions, person, + personIndex, + handleStatusTooltip, + handleStatusUpdate, + orgIndex } = props; const toggled = toggledID; const handleClick = () => handleStatusTooltip(person.uuid); + const handleOptionSelect = (updatedMember) => + handleStatusUpdate(updatedMember); + + // Only send relevent info as props + const _person = { + uuid: person.uuid, + status: person.status, + role: person.role + }; return ( @@ -65,7 +77,14 @@ const PersonStatus = (props) => { { toggledID === person.uuid - ? + ? : null } ); @@ -73,8 +92,11 @@ const PersonStatus = (props) => { PersonStatus.propTypes = { handleStatusTooltip: React.PropTypes.func, + handleStatusUpdate: React.PropTypes.func, membersStatusOptions: React.PropTypes.array, + orgIndex: React.PropTypes.number, person: React.PropTypes.object, + personIndex: React.PropTypes.number, toggledID: React.PropTypes.oneOfType([ React.PropTypes.string, React.PropTypes.bool, diff --git a/frontend/src/components/people-list/table/tooltip.js b/frontend/src/components/people-list/table/tooltip.js index a24fd3a5..0d6b270c 100644 --- a/frontend/src/components/people-list/table/tooltip.js +++ b/frontend/src/components/people-list/table/tooltip.js @@ -16,6 +16,7 @@ const arrowPosition = { module.exports = ({ handleSelect, person = {}, + personAttr, personIndex, options = [], orgIndex, @@ -27,7 +28,8 @@ module.exports = ({ person: { uuid: person.uuid, status: person.status, - role: option + role: person.role, + [`${personAttr}`]: option }, personIndex, orgIndex, @@ -63,5 +65,6 @@ module.exports.propTypes = { options: React.PropTypes.array, orgIndex: React.PropTypes.number, person: React.PropTypes.object, + personAttr: React.PropTypes.string, personIndex: React.PropTypes.number, }; \ No newline at end of file diff --git a/frontend/src/containers/org/people.js b/frontend/src/containers/org/people.js index c7707fb6..074470ec 100644 --- a/frontend/src/containers/org/people.js +++ b/frontend/src/containers/org/people.js @@ -20,7 +20,8 @@ const { handleInviteToggle, handlePeopleRoleTooltip, handlePeopleStatusTooltip, - handleRoleUpdate + handleRoleUpdate, + handleStatusUpdate, } = actions; const People = (props) => { @@ -47,6 +48,8 @@ const mapDispatchToProps = (dispatch) => ({ handleRoleTooltip: (id) => dispatch(handlePeopleRoleTooltip(id)), handleRoleUpdate: (updatedMember) => dispatch(handleRoleUpdate(updatedMember)), + handleStatusUpdate: (updatedMember) => + dispatch(handleStatusUpdate(updatedMember)), }); module.exports = connect( diff --git a/frontend/src/state/actions.js b/frontend/src/state/actions.js index 0ee97f57..e67159e7 100644 --- a/frontend/src/state/actions.js +++ b/frontend/src/state/actions.js @@ -22,5 +22,6 @@ module.exports = { createAction(`${APP}/HANDLE_PERSON_STATUS_TOOLTIP`), handlePeopleRoleTooltip: createAction(`${APP}/HANDLE_PERSON_ROLE_TOOLTIP`), - handleRoleUpdate: createAction(`${APP}/HANDLE_PERSON_ROLE_UPDATE`), + handleMemberUpdate: createAction(`${APP}/HANDLE_PERSON_ROLE_UPDATE`), + handleStatusUpdate: createAction(`${APP}/HANDLE_PERSON_STATUS_UPDATE`), }; diff --git a/frontend/src/state/reducers/orgs.js b/frontend/src/state/reducers/orgs.js index dce5f5bb..f98e7fd3 100644 --- a/frontend/src/state/reducers/orgs.js +++ b/frontend/src/state/reducers/orgs.js @@ -10,7 +10,8 @@ const { handleInviteToggle, handlePeopleRoleTooltip, handlePeopleStatusTooltip, - handleRoleUpdate + handleRoleUpdate, + handleStatusUpdate, } = actions; module.exports = handleActions({ @@ -75,5 +76,35 @@ module.exports = handleActions({ ...state.data.slice(orgIndex + 1), ] }; + }, + [handleStatusUpdate.toString()]: (state, action) => { + const { + orgIndex, + person, + personIndex, + } = action.payload; + + return { + ...state, + ui: { + ...state.ui, + member_status_tooltip: false, + member_role_tooltip: false + }, + data: [ + ...state.data.slice(0, orgIndex), + { + ...state.data[orgIndex], + members: [ + ...state.data[orgIndex].members.slice(0, personIndex), + { + ...person, + }, + ...state.data[orgIndex].members.slice(personIndex + 1) + ] + }, + ...state.data.slice(orgIndex + 1), + ] + }; } }, {});