Skip to content

Commit

Permalink
20989 - Exclude USA conditionally (#254)
Browse files Browse the repository at this point in the history
* 20989 - exclude USA conditionally

* 20989 - update logic
  • Loading branch information
ketaki-deodhar authored May 7, 2024
1 parent 4ad1897 commit 6b9ef8f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/jurisdiction/Jurisdiction.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ const Template = (args, { argTypes }) => ({

export const Default = Template.bind({})
Default['args'] = {
showUsJurisdictions: false
showUsaJurisdictions: false
}
23 changes: 20 additions & 3 deletions src/components/jurisdiction/Jurisdiction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class Jurisdiction extends Vue {
// props
@Prop({ default: 'Select the home jurisdiction' }) readonly label!: string
@Prop() readonly errorMessages!: string
@Prop({ default: false }) readonly showUsJurisdictions!: boolean
@Prop({ default: false }) readonly showUsaJurisdictions!: boolean
// variables
jurisdiction = null
Expand All @@ -42,7 +42,8 @@ export default class Jurisdiction extends Vue {
separator: (jur.value === JurisdictionLocation.FD)
}))
if (this.showUsJurisdictions) {
// add USA jurisdictions (conditionally)
if (this.showUsaJurisdictions) {
array.push({ isHeader: true, group: 1, text: 'United States' })
UsaJurisdiction
.forEach(jur => array.push({
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))
.forEach(jur => array.push({
group: 2,
text: jur.text,
Expand All @@ -67,6 +68,22 @@ export default class Jurisdiction extends Vue {
return array
}
/**
* Always exclude CA
* Exclude USA when states are listed in the jurisdiction list based on showUsaJurisdictions flag
*/
excludeJurisdictions (jurisdiction): boolean {
if (jurisdiction === JurisdictionLocation.CA) {
return false
}
if (this.showUsaJurisdictions && (jurisdiction === JurisdictionLocation.US)) {
return false
}
return true
}
@Emit('change')
// eslint-disable-next-line @typescript-eslint/no-unused-vars
emitChangeEvent (jurisdiction: any): void {}
Expand Down

0 comments on commit 6b9ef8f

Please sign in to comment.