Skip to content

Commit 86da385

Browse files
authored
29381 - rules and validation updates in name field (#857)
* fix: name input rules logic and add xpro validation - add validation/disable button in sub search modal * fix: correct defaultRules return order in name input component * fix: update search button logic and add xpro name validation - Update `isSearchBtnDisabled` logic for button disablement - Add `isValidXproName` getter for XPRO name length validation * chore: bump version to 5.8.6 and remove unused import in search component * fix: adjust max length validation for XPRO name flow - Use dynamic max length based on `isXproFlow` condition.
1 parent 51f92de commit 86da385

4 files changed

Lines changed: 48 additions & 4 deletions

File tree

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "name-request",
3-
"version": "5.8.5",
3+
"version": "5.8.6",
44
"private": true,
55
"appName": "Name Request UI",
66
"sbcName": "SBC Common Components",

app/src/components/dialogs/mras-search-info.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<div class="mt-1 mb-1 text-center">
3636
<v-btn
3737
class="search-btn"
38+
:disabled="isDisabled"
3839
@click="isNameSearch ? handleSubmit() : clearAndClose()"
3940
>
4041
{{ name ? 'Search' : 'Close' }}
@@ -50,6 +51,7 @@ import { Component, Vue } from 'vue-property-decorator'
5051
import { Action, Getter } from 'pinia-class'
5152
import { useStore } from '@/store'
5253
import { ActionBindingIF } from '@/interfaces/store-interfaces'
54+
import { MRAS_MIN_LENGTH, MRAS_MAX_LENGTH } from '@/components/new-request/constants'
5355
import NameInput from '@/components/new-request/name-input.vue'
5456
import { BAD_REQUEST, NOT_FOUND, SERVICE_UNAVAILABLE } from 'http-status-codes'
5557
@@ -64,6 +66,7 @@ export default class MrasSearchInfoDialog extends Vue {
6466
@Getter(useStore) getMrasSearchResultCode!: number
6567
@Getter(useStore) getName!: string
6668
@Getter(useStore) getMrasSearchInfoModalVisible!: boolean
69+
@Getter(useStore) isXproFlow!: boolean
6770
6871
@Action(useStore) setMrasSearchInfoModalVisible!: ActionBindingIF
6972
@Action(useStore) setName!: ActionBindingIF
@@ -125,6 +128,11 @@ export default class MrasSearchInfoDialog extends Vue {
125128
return this.getErrors
126129
}
127130
131+
get isDisabled (): boolean {
132+
return !!this.name && this.isXproFlow &&
133+
(!this.name || this.name.length < MRAS_MIN_LENGTH || this.name.length > MRAS_MAX_LENGTH)
134+
}
135+
128136
async handleSubmit (): Promise<void> {
129137
this.showModal = false
130138
if (this.name) await this.startAnalyzeName(null)

app/src/components/new-request/name-input.vue

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
:error-messages="message"
77
autocomplete="chrome-off"
88
:filled="!isReadOnly"
9-
:rules="(searchValue && isMrasSearch) ? mrasRules : defaultRules"
9+
:rules="getRules"
1010
:label="label"
1111
:class="{ 'read-only-mode': isReadOnly }"
1212
:disabled="isReadOnly"
@@ -66,6 +66,18 @@ export default class NameInput extends Vue {
6666
this.nameInputComponent = this.$refs['nameInputRef']
6767
}
6868
69+
get getRules (): any[] {
70+
if (this.searchValue) {
71+
if (this.isMrasSearch) {
72+
return this.mrasRules
73+
}
74+
if (this.isXproFlow) {
75+
return this.xproRules
76+
}
77+
}
78+
return this.defaultRules
79+
}
80+
6981
/** The array of validation rules for the MRAS corp num. */
7082
get mrasRules (): any[] {
7183
return [
@@ -75,6 +87,13 @@ export default class NameInput extends Vue {
7587
]
7688
}
7789
90+
get xproRules (): any[] {
91+
return [
92+
v => (!v || v.length >= MRAS_MIN_LENGTH) || `Must be at least ${MRAS_MIN_LENGTH} characters`,
93+
v => (!v || v.length <= MRAS_MAX_LENGTH) || `Cannot exceed ${MRAS_MAX_LENGTH} characters`
94+
]
95+
}
96+
7897
/** Local validator when input is a MRAS corp num. */
7998
get isCorpNumValid (): boolean {
8099
if (this.isMrasSearch) return this.nameInputComponent?.valid || false
@@ -114,7 +133,12 @@ export default class NameInput extends Vue {
114133
}
115134
116135
if (this.getErrors.includes('max_length')) {
117-
return ['Please enter a shorter name']
136+
let maxCharacters = DFLT_MAX_LENGTH
137+
if (this.isXproFlow) {
138+
maxCharacters = MRAS_MAX_LENGTH
139+
}
140+
141+
return [`Cannot exceed ${maxCharacters} characters`]
118142
}
119143
120144
const invalidDesignationMsg = checkInvalidDesignation(this.getEntityTypeCd, this.searchValue)

app/src/components/new-request/search.vue

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@
365365
id="search-name-btn"
366366
class="px-9"
367367
:class="{ 'mobile-btn' : isMobile }"
368-
:disabled="!corpNumValid"
368+
:disabled="isSearchBtnDisabled"
369369
@click="handleSubmit(true)"
370370
>
371371
<v-icon
@@ -424,6 +424,8 @@ import { Navigate } from '@/plugins'
424424
import { ActionBindingIF } from '@/interfaces/store-interfaces'
425425
import { Action, Getter } from 'pinia-class'
426426
import { useStore } from '@/store'
427+
import { MRAS_MIN_LENGTH, MRAS_MAX_LENGTH }
428+
from '@/components/new-request/constants'
427429
428430
/**
429431
* This is the component that displays the new NR menus and flows.
@@ -450,6 +452,7 @@ export default class Search extends Mixins(CommonMixin, NrAffiliationMixin, Sear
450452
@Getter(useStore) getIsLearBusiness!: boolean
451453
// @Getter(useStore) isRoleStaff!: boolean
452454
@Getter(useStore) getAuthorizedActions!: string[]
455+
@Getter(useStore) getName!: string
453456
454457
// Constant
455458
readonly colinLink = sessionStorage.getItem('CORPORATE_ONLINE_URL')
@@ -756,6 +759,15 @@ export default class Search extends Mixins(CommonMixin, NrAffiliationMixin, Sear
756759
return false
757760
}
758761
762+
get isValidXproName (): boolean {
763+
const name = this.getName
764+
return name.length >= MRAS_MIN_LENGTH && name.length <= MRAS_MAX_LENGTH
765+
}
766+
767+
get isSearchBtnDisabled (): boolean {
768+
return (this.getHasNoCorpNum && !this.isValidXproName) || (!this.getHasNoCorpNum && !this.corpNumValid)
769+
}
770+
759771
/**
760772
* If user is authenticated, create draft business and redirect to Dashboard.
761773
* If restoration/reinstatement selected, go to business dashboard.

0 commit comments

Comments
 (0)