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
14 changes: 6 additions & 8 deletions ui/src/app/collection/collection-skill-search.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe("CollectionSkillSearchComponent", () => {

it("getApiSearch should return canned search", () => {
// Arrange
component.multiplePagesSelected = true
component.selectAllChecked = true
const search = "testQueryString"
component.searchForm.setValue({search})

Expand All @@ -204,14 +204,12 @@ describe("CollectionSkillSearchComponent", () => {

it("getApiSearch should return specified search", () => {
// Arrange
component.multiplePagesSelected = false
const skill = createMockSkillSummary()

// Act
const result = component.getApiSearch(skill)
component.selectAllChecked = false
component.selectedSkills = [createMockSkillSummary("1")]
const result = component.selectedUuids()

// Assert
expect(result).toEqual(new ApiSearch({ uuids: [ skill.uuid ] } ))
expect(result).toEqual(component.getApiSearch()?.uuids)
})

it("handleSelectAll should be correct", () => {
Expand All @@ -222,7 +220,7 @@ describe("CollectionSkillSearchComponent", () => {
// Act
component.handleSelectAll(true)
// Assert
expect(component.multiplePagesSelected).toBeTrue()
expect(component.selectAllChecked).toBeTrue()

// Arrange
component.results = new PaginatedSkills([], 5)
Expand Down
7 changes: 2 additions & 5 deletions ui/src/app/collection/collection-skill-search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class CollectionSkillSearchComponent extends SkillsListComponent implemen
if (result) {
this.toastService.hideBlockingLoader()
const isWorkspace = this.collection?.status === PublishStatus.Workspace
const baseMessage = `You added ${selectedCount} RSD${selectedCount ? "s" : ""} to the`
const baseMessage = `You added ${this.selectAllChecked ? this.totalCount : this.size} RSD${selectedCount ? "s" : ""} to the`
const message = ` ${baseMessage} ${this.collectionOrWorkspace(false)} ${ isWorkspace ? "" : this.collection?.name}.`
this.toastService.showToast("Success!", message)
}
Expand All @@ -135,10 +135,7 @@ export class CollectionSkillSearchComponent extends SkillsListComponent implemen
}

getApiSearch(skill?: ApiSkillSummary): ApiSearch | undefined {
return (this.multiplePagesSelected) ? new ApiSearch({query: this.searchQuery}) : super.getApiSearch(skill)
return this.selectAllChecked ? new ApiSearch({query: this.searchQuery}) : new ApiSearch({uuids: this.selectedUuids()})
}

handleSelectAll(selectAllChecked: boolean): void {
this.multiplePagesSelected = this.totalPageCount > 1
}
}