Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
✨ [PRTL-1612] add count in title in all cases (#2066)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jephuff authored and alex-wilmer committed Oct 30, 2017
1 parent f875246 commit 01eab0b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
13 changes: 9 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"memoizee": "0.4.5",
"moment": "2.17.1",
"oncogrid": "2.0.1",
"pluralize": "7.0.0",
"prop-types": "15.5.10",
"query-string": "4.3.4",
"queue": "4.2.1",
Expand Down
16 changes: 7 additions & 9 deletions src/packages/@ncigdc/components/SetActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import AppendSetModal from '@ncigdc/components/Modals/AppendSetModal';
import RemoveSetModal from '@ncigdc/components/Modals/RemoveSetModal';
import DropdownItem from '@ncigdc/uikit/DropdownItem';
import { theme } from '@ncigdc/theme';
import pluralize from '@ncigdc/utils/pluralize';

const enhance = compose(
connect(({ sets }) => ({ sets })),
Expand All @@ -34,7 +35,7 @@ export default enhance(
}) => {
const titleType = type.replace(/^./, m => m.toUpperCase());
const total = selectedIds.length || props.total || 0;
const displayType = `${type}${total > 1 ? 's' : ''}`;
const countAndType = pluralize(titleType, total, true);
const filters = selectedIds.length
? { op: 'in', content: { field, value: selectedIds } }
: props.filters;
Expand Down Expand Up @@ -63,19 +64,16 @@ export default enhance(
},
}}
>
{total.toLocaleString()} {displayType}
{countAndType}
</DropdownItem>
<DropdownItem
style={{ lineHeight: '1.5', cursor: 'pointer' }}
onClick={() => {
dispatch(
setModal(
<SaveSetModal
title={
selectedIds.length
? `Save ${total.toLocaleString()} ${displayType} as new set`
: `Save ${titleType} Set`
}
title={`Save ${countAndType} as New Set`}
total={total}
filters={filters}
type={type}
CreateSetButton={CreateSetButton}
Expand All @@ -94,7 +92,7 @@ export default enhance(
setModal(
<AppendSetModal
field={field}
title={`Add ${total.toLocaleString()} ${displayType} to existing set`}
title={`Add ${countAndType} to Existing Set`}
filters={filters}
type={type}
CreateSetButton={CreateSetButton}
Expand All @@ -113,7 +111,7 @@ export default enhance(
setModal(
<RemoveSetModal
field={field}
title={`Remove ${total.toLocaleString()} ${displayType} from existing set`}
title={`Remove ${countAndType} from Existing Set`}
filters={filters}
type={type}
RemoveFromSetButton={RemoveFromSetButton}
Expand Down
3 changes: 3 additions & 0 deletions src/packages/@ncigdc/utils/pluralize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import pluralize from 'pluralize';
export default (word = '', count = 0, inclusive) =>
`${inclusive ? `${count.toLocaleString()} ` : ''}${pluralize(word, count)}`;

0 comments on commit 01eab0b

Please sign in to comment.