Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
</span>
<span class="m-buttonText-x-text">{{labelFor(r)}}<span class="t-visuallyHidden">, </span></span>
</button>
<!-- Save as new button if not perfect match -->
<button class="m-buttonText" type="button" *ngIf="allowSaveNew && !isExactMatchFound()" (click)="selectSearchValue()" [disabled]="false">
<span class="m-buttonText-x-icon">Save new: {{ labelFor(searchControlResultValue) }} (Enter)</span>
</button>
</div>

<!-- Empty results -->
Expand All @@ -81,6 +85,9 @@
<p class="m-selectMenu-x-message">
<span class="m-selectMenu-x-messageText">No Results</span>
</p>
<button class="m-buttonText" type="button" *ngIf="allowSaveNew" (click)="selectSearchValue()" [disabled]="false">
<span class="m-buttonText-x-icon">Save new: {{ labelFor(searchControlResultValue) }} (Enter)</span>
</button>
</div>
</ng-template>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,13 @@ describe("AbstractFormFieldSearchMultiSelectComponent", () => {
return true
})()).toEqual(true)
})

it("exact match detection works", () => {
component.results = []
component.searchControlValue = "abc";
expect(component.isExactMatchFound()).toEqual(false)

component.results = [{value:'abc'}]
expect(component.isExactMatchFound()).toEqual(true)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export abstract class AbstractFormFieldSearchMultiSelect<TValue>
return false
}

isExactMatchFound(): boolean {
if (!this.searchControlResultValue) return false
return !!(this.results?.find((r: TValue) => this.areSearchResultsEqual(r, this.searchControlResultValue as TValue)))
}

selectResult(result: TValue): void {
if (this.isSearchResultType(result) && !this.isResultSelected(result)){
let selected: TValue[] = this.controlValue ?? []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export abstract class AbstractFormFieldSearchSelect<TSearch, TValue>
extends AbstractFormField<TValue|null> implements OnInit, OnDestroy {

@Input() createNonExisting = false
@Input() allowSaveNew: boolean = false

searchControl: FormControl = new FormControl("")

Expand Down Expand Up @@ -59,6 +60,11 @@ export abstract class AbstractFormFieldSearchSelect<TSearch, TValue>
return this.searchControlValue.length <= 0
}

isExactMatchFound(): boolean {
if (!this.searchControlResultValue) return false
return !!(this.results?.find((r: TSearch) => this.areSearchResultsEqual(r, this.searchControlResultValue as TSearch)))
}

get searchControlValue(): string {
return this.searchControl.value?.trim() ?? ""
}
Expand All @@ -73,7 +79,7 @@ export abstract class AbstractFormFieldSearchSelect<TSearch, TValue>
const searchResult = this.searchResultFromString(this.searchControlValue)

if (searchResult) {
const existingResult =this.results?.find((r: TSearch) => this.areSearchResultsEqual(r, searchResult))
const existingResult = this.results?.find((r: TSearch) => this.areSearchResultsEqual(r, searchResult))
return existingResult ?? (this.createNonExisting) ? searchResult : undefined
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
<button class="m-buttonText" *ngFor="let r of results" type="button" (click)="onSearchResultClicked(r)">
<span class="m-buttonText-x-text">{{labelFor(r)}}</span>
</button>
<button class="m-buttonText" type="button" *ngIf="allowSaveNew && !isExactMatchFound()" (click)="selectSearchValue()" [disabled]="false">
<span class="m-buttonText-x-icon">Save new: {{ labelFor(searchControlResultValue) }} (Enter)</span>
</button>
</div>

<!-- Empty results -->
Expand All @@ -65,6 +68,9 @@
<p class="m-selectMenu-x-message">
<span class="m-selectMenu-x-messageText">No Results</span>
</p>
<button class="m-buttonText" type="button" *ngIf="allowSaveNew" (click)="selectSearchValue()" [disabled]="false">
<span class="m-buttonText-x-icon">Save new: {{ labelFor(searchControlResultValue) }} (Enter)</span>
</button>
</div>
</ng-template>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,13 @@ describe("AbstractFormFieldSearchSingleSelectComponent", () => {
return true
})()).toEqual(true)
})

it("exact match detection works", () => {
component.results = []
component.searchControlValue = "abc";
expect(component.isExactMatchFound()).toEqual(false)

component.results = [{value:'abc'}]
expect(component.isExactMatchFound()).toEqual(true)
})
})
6 changes: 6 additions & 0 deletions ui/src/app/richskill/form/rich-skill-form.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ <h3 class="m-iconTitle">
[errorMessage]="authorErrorMessage"
[keywordType]="keywordType.Author"
[createNonExisting]="true"
[allowSaveNew]="true"
></app-form-field-keyword-search-multi-select>
</div>

Expand Down Expand Up @@ -74,6 +75,7 @@ <h3 class="m-iconTitle">
helpMessage="Industry-recognized, general terms that represents a broad group of related RSDs."
[keywordType]="keywordType.Category"
[createNonExisting]="true"
[allowSaveNew]="true"
></app-form-field-keyword-search-multi-select>
</div>

Expand All @@ -87,6 +89,7 @@ <h3 class="m-iconTitle">
errorMessage="Keywords are required"
[keywordType]="keywordType.Keyword"
[createNonExisting]="true"
[allowSaveNew]="true"
></app-form-field-keyword-search-multi-select>
</div>

Expand All @@ -99,6 +102,7 @@ <h3 class="m-iconTitle">
helpMessage="Names of professional standards that define skill mastery, sourced from industry-recognized frameworks."
[keywordType]="keywordType.Standard"
[createNonExisting]="true"
[allowSaveNew]="true"
></app-form-field-keyword-search-multi-select>
</div>

Expand All @@ -111,6 +115,7 @@ <h3 class="m-iconTitle">
helpMessage="Related academic and professional certifications that support career advancement."
[keywordType]="keywordType.Certification"
[createNonExisting]="true"
[allowSaveNew]="true"
></app-form-field-keyword-search-multi-select>
</div>

Expand All @@ -133,6 +138,7 @@ <h3 class="m-iconTitle">
helpMessage="Employers who require this skill for a given job. Employers are not visible in the public view of an RSD."
[keywordType]="keywordType.Employer"
[createNonExisting]="true"
[allowSaveNew]="true"
></app-form-field-keyword-search-multi-select>
</div>

Expand Down