From 6b9ef8f2f6ca7581e0a91b12d482e05bd3b034bd Mon Sep 17 00:00:00 2001 From: ketaki-deodhar <116035339+ketaki-deodhar@users.noreply.github.com> Date: Tue, 7 May 2024 16:42:23 -0700 Subject: [PATCH] 20989 - Exclude USA conditionally (#254) * 20989 - exclude USA conditionally * 20989 - update logic --- .../jurisdiction/Jurisdiction.stories.ts | 2 +- src/components/jurisdiction/Jurisdiction.vue | 23 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/components/jurisdiction/Jurisdiction.stories.ts b/src/components/jurisdiction/Jurisdiction.stories.ts index eda7e9de..ed8d6399 100644 --- a/src/components/jurisdiction/Jurisdiction.stories.ts +++ b/src/components/jurisdiction/Jurisdiction.stories.ts @@ -14,5 +14,5 @@ const Template = (args, { argTypes }) => ({ export const Default = Template.bind({}) Default['args'] = { - showUsJurisdictions: false + showUsaJurisdictions: false } diff --git a/src/components/jurisdiction/Jurisdiction.vue b/src/components/jurisdiction/Jurisdiction.vue index 4ca9e6e5..ad7e13d5 100644 --- a/src/components/jurisdiction/Jurisdiction.vue +++ b/src/components/jurisdiction/Jurisdiction.vue @@ -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 @@ -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({ @@ -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, @@ -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 {}