Skip to content

Commit

Permalink
Render organization names instead of counts in assignment cell
Browse files Browse the repository at this point in the history
  • Loading branch information
cKellyDesign committed Oct 17, 2019
1 parent ca3836c commit 1d6bb9d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
17 changes: 14 additions & 3 deletions src/containers/forms/AssignTeamTableCell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import organizationsReducer, {
reducerName as organizationsReducerName,
} from '../../../store/ducks/opensrp/organizations';
import { getButtonId, getFormName } from './helpers';
import './style.css';

reducerRegistry.register(assignmentReducerName, assignmentReducer);
reducerRegistry.register(organizationsReducerName, organizationsReducer);
Expand Down Expand Up @@ -95,10 +96,20 @@ const AssignTeamTableCell = (props: AssignTeamCellProps) => {
target: getButtonId(jurisdictionId),
};

const assignedOrganizations = assignments
.map(
(a: Assignment) =>
organizationsById &&
organizationsById[a.organization] &&
organizationsById[a.organization].name
)
.filter(org => !!org)
.join(', ');

return (
<div onClick={stopPropagationAndPreventDefault}>
<span style={{ paddingRight: '2rem' }} className="assignment-count-text">
{`${assignments.length} ${TEAMS_ASSIGNED}`}
<div onClick={stopPropagationAndPreventDefault} className="assignment-cell">
<span className="assignment-label" title={`${assignments.length} ${TEAMS_ASSIGNED}`}>
{assignedOrganizations}
</span>
{assignButton || <AssignTeamButton {...assignTeamButtonProps} />}
{assignPopover || <AssignTeamPopover {...assignTeamPopoverProps} />}
Expand Down
7 changes: 7 additions & 0 deletions src/containers/forms/AssignTeamTableCell/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.assignment-cell .assignment-label {
text-overflow: ellipsis;
white-space: nowrap;
max-width: calc(100% - 120px);
display: inline-block;
overflow: hidden;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ exports[`/containers/forms/AssignTeamTableCell renders correctly: AssignTeamButt

exports[`/containers/forms/AssignTeamTableCell renders correctly: Team Count Text 1`] = `
<span
className="assignment-count-text"
style={
Object {
"paddingRight": "2rem",
}
}
>
0 Teams Assigned
</span>
className="assignment-label"
title="0 Teams Assigned"
/>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ describe('/containers/forms/AssignTeamTableCell', () => {
expect(toJson(wrapper.find('button#plan-assignment-outpost-number-one'))).toMatchSnapshot(
'AssignTeamButton'
);
expect(toJson(wrapper.find('span.assignment-count-text'))).toMatchSnapshot('Team Count Text');
expect(toJson(wrapper.find('span.assignment-label'))).toMatchSnapshot('Team Count Text');
});
});

0 comments on commit 1d6bb9d

Please sign in to comment.