Skip to content

Commit

Permalink
Merge pull request #549 from MetaPhase-Consulting/fix/functional-bure…
Browse files Browse the repository at this point in the history
…aus-missing

Fix/functional bureaus missing TM-1402
  • Loading branch information
scott062 committed Nov 15, 2019
2 parents acf9a2e + ddc0264 commit 91232cc
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 31 deletions.
32 changes: 18 additions & 14 deletions src/Components/SearchFilters/BureauFilter/BureauFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class BureauFilter extends Component {
render() {
const { item, functionalBureaus } = this.props;
const regionalBureaus = item.data.slice().filter(b => b.is_regional);
const functionalBureaus$ = functionalBureaus.data.filter(b => !b.is_regional);
// sort the regional bureaus by their calculated label
const sortedRegionalBureuas = orderBy(regionalBureaus, e => getItemLabel(e));
return (
Expand Down Expand Up @@ -54,20 +55,23 @@ class BureauFilter extends Component {
</AccordionItem>
<AccordionItem className="accordion-content-small" id="functional-bureau-sub-accordion" title="Functional Bureaus" buttonClass="tm-nested-accordion-button">
{
functionalBureaus.data.filter(b => !b.isRegional).map(itemData => (
<CheckBox
_id={itemData.id} /* when we need the original id */
id={`checkbox-functional-bureau-${itemData.id}`}
key={`checkbox-functional-bureau-${itemData.id}`}
label={itemData.name}
title={itemData.name}
name={itemData.name}
value={itemData.isSelected || false}
code={itemData.id}
selectionRef={item.item.selectionRef}
onCheckBoxClick={this.onFunctionalBureauCheckBoxClick}
className="tm-checkbox-transparent"
/>))
functionalBureaus$.map((itemData) => {
const itemLabel = getItemLabel(itemData);
return (
<CheckBox
_id={itemData.id} /* when we need the original id */
id={`checkbox-functional-bureau-${itemData.id}`}
key={`checkbox-functional-bureau-${itemData.id}`}
label={itemLabel}
title={itemLabel}
name={itemLabel}
value={itemData.isSelected || false}
code={itemData.id}
selectionRef={item.item.selectionRef}
onCheckBoxClick={this.onFunctionalBureauCheckBoxClick}
className="tm-checkbox-transparent"
/>);
})
}
</AccordionItem>
</Accordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,6 @@ exports[`BureauFilterComponent matches snapshot 1`] = `
title="Functional Bureaus"
useIdClass={true}
>
<CheckBox
checkboxProps={Object {}}
className="tm-checkbox-transparent"
disabled={false}
id="checkbox-functional-bureau-undefined"
label="Name1"
labelSrOnly={false}
name="Name1"
onCheckBoxClick={[Function]}
selectionRef="bureau"
small={false}
title="Name1"
value={false}
/>
<CheckBox
checkboxProps={Object {}}
className="tm-checkbox-transparent"
Expand Down
5 changes: 4 additions & 1 deletion src/actions/filters/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { getPostName } from '../../utilities';
import { COMMON_PROPERTIES } from '../../Constants/EndpointParams';
import { checkFlag } from '../../flags';

const getUseAP = () => checkFlag('flags.available_positions');
// Attempt to map the non-numeric grade codes to a full description.
// If no match is found, return the unmodified code.
export function getCustomGradeDescription(gradeCode) {
Expand All @@ -23,6 +25,8 @@ export function getFilterCustomDescription(filterItem, filterItemObject) {
switch (filterItem.item.description) {
case 'region':
return `(${filterItemObject.short_description}) ${filterItemObject.long_description}`;
case 'functionalRegion':
return (getUseAP() ? `(${filterItemObject.short_description}) ${filterItemObject.long_description}` : false);
case 'skill':
return `${filterItemObject.description} (${filterItemObject.code})`;
case 'post':
Expand All @@ -39,7 +43,6 @@ export function getFilterCustomDescription(filterItem, filterItemObject) {
return getCustomGradeDescription(filterItemObject.code);
case 'postDiff':
case 'dangerPay':
case 'functionalRegion':
case 'bidSeason':
return filterItemObject.description;
default:
Expand Down
5 changes: 4 additions & 1 deletion src/actions/filters/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ describe('filter helpers', () => {
expect(getFilterCustomDescription(
{ item: { description: 'region' } }, { short_description: 't', long_description: 'test' }),
).toBe('(t) test');
expect(getFilterCustomDescription(
{ item: { description: 'functionalRegion' } }, { short_description: 't', long_description: 'test' }),
).toBeFalsy();
expect(getFilterCustomDescription(
{ item: { description: 'skill' } }, { description: 'test', code: 't' }),
).toBe('test (t)');
Expand All @@ -34,7 +37,7 @@ describe('filter helpers', () => {
expect(getFilterCustomDescription(
{ item: { description: 'language' } }, { formal_description: 'test', code: '1' }),
).toBe('test (1)');
['postDiff', 'dangerPay', 'functionalRegion', 'bidSeason'].forEach((f) => {
['postDiff', 'dangerPay', 'bidSeason'].forEach((f) => {
expect(getFilterCustomDescription(
{ item: { description: f } }, { description: 'test' }),
).toBe('test');
Expand Down
4 changes: 3 additions & 1 deletion src/reducers/filters/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const items =
sort: 100,
description: 'region',
endpoint: 'organization/?is_bureau=true&is_regional=true',
endpointAP: 'fsbid/reference/bureaus/?is_bureau=true&is_regional=true',
endpointAP: 'fsbid/reference/bureaus/?is_regional=true',
selectionRef: ENDPOINT_PARAMS.org,
text: 'Choose bureau',
choices: [
Expand All @@ -234,7 +234,9 @@ const items =
sort: 105,
description: 'functionalRegion',
endpoint: 'organization/group/',
endpointAP: 'fsbid/reference/bureaus/?is_regional=false',
selectionRef: ENDPOINT_PARAMS.functionalOrg,
selectionRefAP: ENDPOINT_PARAMS.org,
text: 'Choose functional bureau',
choices: [
],
Expand Down

0 comments on commit 91232cc

Please sign in to comment.