Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20989 - Exclude USA conditionally #254

Merged
merged 2 commits into from
May 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/components/jurisdiction/Jurisdiction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class Jurisdiction extends Vue {
separator: (jur.value === JurisdictionLocation.FD)
}))

// add USA jurisdictions (conditionally)
if (this.showUsJurisdictions) {
array.push({ isHeader: true, group: 1, text: 'United States' })
UsaJurisdiction
Expand All @@ -56,7 +57,7 @@ export default class Jurisdiction extends Vue {
// add in International jurisdictions (not including CA)
array.push({ isHeader: true, group: 2, text: 'International' })
IntlJurisdictions
.filter(jur => jur.value !== JurisdictionLocation.CA)
.filter(jur => !this.excludeJurisdictions(jur.value).includes(jur.value))
severinbeauvais marked this conversation as resolved.
Show resolved Hide resolved
.forEach(jur => array.push({
group: 2,
text: jur.text,
Expand All @@ -67,6 +68,23 @@ export default class Jurisdiction extends Vue {
return array
}

/**
* Always exclude CA
* Exclude USA when states are listed in the jurisdiction list based on showUsJurisdictions flag
*/
excludeJurisdictions (jurisdiction): Array<any> {
const excludedValues = []
if (jurisdiction === JurisdictionLocation.CA) {
excludedValues.push(JurisdictionLocation.CA)
}

if (this.showUsJurisdictions) {
JazzarKarim marked this conversation as resolved.
Show resolved Hide resolved
excludedValues.push(JurisdictionLocation.US)
}

return excludedValues
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa, this gets called for every item in the Intl list. And it does a lot of work.

Try something simpler.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you only need a simple conditional here that returns False if filter should exclude it, else True.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.


@Emit('change')
// eslint-disable-next-line @typescript-eslint/no-unused-vars
emitChangeEvent (jurisdiction: any): void {}
Expand Down
Loading