Skip to content

Commit

Permalink
mes-8441-searchEmptyInputBug (#975)
Browse files Browse the repository at this point in the history
* Fixed bug where an empty field could be searched

* Fixed bug where an numbers could be inputted into application reference
  • Loading branch information
RLCorp authored Dec 6, 2022
1 parent ecff356 commit 0b638cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/app/pages/test-results-search/test-results-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
<ion-row class="ion-padding-top">
<ion-col size="96">
<ion-input
*ngIf="searchBy !== 'appReference'"
id="test-result-search-{{searchBy}}-input"
[placeholder]="searchBy === 'appReference' ? 'Enter an application reference' : 'Enter a driver number'"
[placeholder]="'Enter a driver number'"
type="text"
class="ion-input-styling custom-font-size"
clearInput
Expand All @@ -51,14 +52,28 @@
(ionBlur)="setFocus(null)"
[value]="candidateInfo"
[ngClass]="{'input-focus': focusedElement === 'field'}"
(ionInput)="candidateInfoChanged($event.target.value)">
(ionChange)="candidateInfoChanged($event.target.value)">
</ion-input>
<ion-input
*ngIf="searchBy === 'appReference'"
id="test-result-search-{{searchBy}}-input"
[placeholder]="'Enter an application reference'"
type="text"
class="ion-input-styling custom-font-size"
clearInput
numbersOnly
(ionFocus)="setFocus('field')"
(ionBlur)="setFocus(null)"
[value]="candidateInfo"
[ngClass]="{'input-focus': focusedElement === 'field'}"
(ionChange)="candidateInfoChanged($event.target.value)">
</ion-input>
</ion-col>
</ion-row>
<ion-row class="ion-padding-top">
<ion-button
id="test-result-search-button"
[attr.disabled]="showSearchSpinner ? 'true' : null"
[attr.disabled]="showSearchSpinner ? 'true' : isEmpty(candidateInfo)"
class="mes-primary-button search-tests" (click)="searchTests()">
<h3 id="test-result-search-button-text">
<ion-icon name="search" class="search-icon"></ion-icon>
Expand Down
4 changes: 4 additions & 0 deletions src/app/pages/test-results-search/test-results-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,8 @@ export class TestResultsSearchPage extends BasePageComponent {
setFocus(focus: string): void {
this.focusedElement = focus;
}

isEmpty(input: string) {
return input === null || input.match(/^ *$/) !== null || input.trim() === '';
}
}

0 comments on commit 0b638cc

Please sign in to comment.