1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 14:10:04 +02:00

adding in functionality to determin current organisation when changing member role

This commit is contained in:
Alex Windett 2017-01-25 13:50:27 +00:00
parent f1cf0c4011
commit 1d2c322082
8 changed files with 40 additions and 17 deletions

View File

@ -13,7 +13,8 @@ const PeopleTable = (props) => {
handleRoleUpdate,
handleStatusTooltip,
people = [],
orgUI = {}
orgUI = {},
orgIndex
} = props;
const columns = [{
@ -49,6 +50,7 @@ const PeopleTable = (props) => {
handleRoleTooltip={handleRoleTooltip}
handleRoleUpdate={handleRoleUpdate}
membersRolesOptions={orgUI.members_roles}
orgIndex={orgIndex}
person={person}
personIndex={index}
toggledID={orgUI.member_role_tooltip}
@ -76,6 +78,7 @@ PeopleTable.propTypes = {
handleRoleTooltip: React.PropTypes.func,
handleRoleUpdate: React.PropTypes.func,
handleStatusTooltip: React.PropTypes.func,
orgIndex: React.PropTypes.number,
orgUI: React.PropTypes.object,
people: React.PropTypes.array,
};

View File

@ -54,7 +54,8 @@ const PersonRole = (props) => {
person,
personIndex,
handleRoleTooltip,
handleRoleUpdate
handleRoleUpdate,
orgIndex
} = props;
const toggled = toggledID;
@ -78,6 +79,7 @@ const PersonRole = (props) => {
? <Tooltip
handleSelect={handleOptionSelect}
options={membersRolesOptions}
orgIndex={orgIndex}
person={_person}
personIndex={personIndex}
/>
@ -90,6 +92,7 @@ PersonRole.propTypes = {
handleRoleTooltip: React.PropTypes.func,
handleRoleUpdate: React.PropTypes.func,
membersRolesOptions: React.PropTypes.array,
orgIndex: React.PropTypes.number,
person: React.PropTypes.object,
personIndex: React.PropTypes.number,
toggledID: React.PropTypes.oneOfType([

View File

@ -18,6 +18,7 @@ module.exports = ({
person = {},
personIndex,
options = [],
orgIndex,
}) => {
const _options = options.map( (option, i) => {
@ -28,7 +29,8 @@ module.exports = ({
status: person.status,
role: option
},
personIndex
personIndex,
orgIndex,
};
const _onClick = () => handleSelect(payload);
@ -59,6 +61,7 @@ module.exports = ({
module.exports.propTypes = {
handleSelect: React.PropTypes.func,
options: React.PropTypes.array,
orgIndex: React.PropTypes.number,
person: React.PropTypes.object,
personIndex: React.PropTypes.number,
};

View File

@ -12,7 +12,8 @@ const {
const {
peopleByOrgIdSelector,
orgUISelector,
membersSelector
orgIndexSelector,
membersSelector,
} = selectors;
const {
@ -36,6 +37,7 @@ const mapStateToProps = (state, {
}) => ({
people: peopleByOrgIdSelector(params.org)(state),
orgUI: orgUISelector(state),
orgIndex: orgIndexSelector(params.org)(state),
platformMembers: membersSelector(state)
});

View File

@ -48,9 +48,11 @@ module.exports = handleActions({
};
},
[handleRoleUpdate.toString()]: (state, action) => {
// TODO:
// Change "1" to org index. At the moment only updates
// "biz-tech"
const {
orgIndex,
person,
personIndex,
} = action.payload;
return {
...state,
@ -59,18 +61,18 @@ module.exports = handleActions({
member_role_tooltip: false
},
data: [
...state.data.slice(0, 1),
...state.data.slice(0, orgIndex),
{
...state.data[1],
...state.data[orgIndex],
members: [
...state.data[1].members.slice(0, action.payload.personIndex),
...state.data[orgIndex].members.slice(0, personIndex),
{
...action.payload.person
...person,
},
...state.data[1].members.slice(action.payload.personIndex + 1)
...state.data[orgIndex].members.slice(personIndex + 1)
]
},
...state.data.slice(1+1),
...state.data.slice(orgIndex + 1),
]
};
}

View File

@ -35,6 +35,11 @@ const orgById = (orgId) => createSelector(
(orgs) => find(orgs, ['id', orgId])
);
const orgIndexById = (orgId) => createSelector(
orgs,
(orgs) => orgs.map((o) => o.id).indexOf(orgId)
);
const serviceById = (serviceId) => createSelector(
[services],
(services) => find(services, ['id', serviceId])
@ -140,6 +145,7 @@ module.exports = {
orgByIdSelector: orgById,
orgsSelector: orgs,
orgUISelector: orgUI,
orgIndexSelector: orgIndexById,
servicesSelector: services,
serviceByIdSelector: serviceById,
orgSectionsSelector: orgSections,

View File

@ -19,7 +19,8 @@
},
"dependencies": {
"husky": "^0.11.9",
"license-to-fail": "^2.2.0"
"license-to-fail": "^2.2.0",
"lodash.findindex": "^4.6.0"
},
"devDependencies": {
"tap-xunit": "^1.4.0"

View File

@ -1,7 +1,5 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
abbrev@1:
version "1.0.9"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135"
@ -136,7 +134,7 @@ inflight@^1.0.4:
once "^1.3.0"
wrappy "1"
inherits@2, inherits@~2.0.1:
inherits@~2.0.1, inherits@2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
@ -190,6 +188,10 @@ license-to-fail@^2.2.0:
dependencies:
license-checker "^7.1.0"
lodash.findindex:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.findindex/-/lodash.findindex-4.6.0.tgz#a3245dee61fb9b6e0624b535125624bb69c11106"
lodash@^3.5.0:
version "3.10.1"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
@ -389,3 +391,4 @@ xmlbuilder@~4.1.0:
xtend@~4.0.0, xtend@~4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"