diff --git a/src/app/public/components/archive-search/archive-search.component.spec.ts b/src/app/public/components/archive-search/archive-search.component.spec.ts index 3ffbe4791..5151eb469 100644 --- a/src/app/public/components/archive-search/archive-search.component.spec.ts +++ b/src/app/public/components/archive-search/archive-search.component.spec.ts @@ -124,6 +124,9 @@ describe('ArchiveSearchComponent', () => { component.onTagClick([new TagVO({ name: 'Tag1', tagId: 1 })]); - expect(component.searchByTag.emit).toHaveBeenCalledWith(1); + expect(component.searchByTag.emit).toHaveBeenCalledWith({ + tagId: 1, + tagName: 'Tag1', + }); }); }); diff --git a/src/app/public/components/archive-search/archive-search.component.ts b/src/app/public/components/archive-search/archive-search.component.ts index 515bf351a..812a42268 100644 --- a/src/app/public/components/archive-search/archive-search.component.ts +++ b/src/app/public/components/archive-search/archive-search.component.ts @@ -21,7 +21,10 @@ import { }) export class ArchiveSearchComponent implements OnInit { @Output() search = new EventEmitter(); - @Output() searchByTag = new EventEmitter(); + @Output() searchByTag = new EventEmitter<{ + tagId: number; + tagName: string; + }>(); public archive: ArchiveVO; private valueChangesSubscription: Subscription; @@ -127,7 +130,7 @@ export class ArchiveSearchComponent implements OnInit { public onTagClick(tag: TagVO[]): void { this.tag = tag; - this.searchByTag.emit(tag[0].tagId); + this.searchByTag.emit({ tagId: tag[0].tagId, tagName: tag[0].name }); this.valueChangesSubscription.unsubscribe(); this.searchForm.patchValue({ query: `tag:"${tag[0].name}"` }); diff --git a/src/app/public/components/public-archive/public-archive.component.spec.ts b/src/app/public/components/public-archive/public-archive.component.spec.ts index a3363de7d..b3c750121 100644 --- a/src/app/public/components/public-archive/public-archive.component.spec.ts +++ b/src/app/public/components/public-archive/public-archive.component.spec.ts @@ -6,6 +6,7 @@ import { of } from 'rxjs'; import { PublicProfileService } from '@public/services/public-profile/public-profile.service'; import { Router } from '@angular/router'; import { PublicArchiveComponent } from './public-archive.component'; +import { ArchiveVO } from '@models/index'; const publicProfileServiceMock = { publicRoot$: () => of({}), @@ -76,12 +77,12 @@ describe('PublicArchiveComponent', () => { const router = inject(Router); spyOn(router, 'navigate'); - instance.archive = { archiveId: '123' } as any; + instance.archive = new ArchiveVO({ archiveId: '123' }); - instance.onTagClick('example-tag'); + instance.onTagClick({ tagId: 'example-tag-id', tagName: 'tag-name' }); expect(router.navigate).toHaveBeenCalledWith( - ['search-tag', '123', 'example-tag'], + ['search-tag', '123', 'example-tag-id', 'tag-name'], { relativeTo: instance.route }, ); }); diff --git a/src/app/public/components/public-archive/public-archive.component.ts b/src/app/public/components/public-archive/public-archive.component.ts index 50104f51b..0d12e8428 100644 --- a/src/app/public/components/public-archive/public-archive.component.ts +++ b/src/app/public/components/public-archive/public-archive.component.ts @@ -122,10 +122,15 @@ export class PublicArchiveComponent implements OnInit, OnDestroy { this.showProfileInformation = !this.showProfileInformation; } - public onTagClick(tagName: string): void { + public onTagClick(tag): void { try { this.router.navigate( - ['search-tag', this.archive.archiveId, `${tagName}`], + [ + 'search-tag', + this.archive.archiveId, + `${tag.tagId}`, + `${tag.tagName}`, + ], { relativeTo: this.route, }, diff --git a/src/app/public/components/public-search-results/public-search-results.component.html b/src/app/public/components/public-search-results/public-search-results.component.html index c3340e055..ee2c96fed 100644 --- a/src/app/public/components/public-search-results/public-search-results.component.html +++ b/src/app/public/components/public-search-results/public-search-results.component.html @@ -4,7 +4,7 @@
Search results for - {{ query }} + {{ searchString }}
{ this.archivePath = ['/p/archive', params.publicArchiveNbr]; - + this.query = params.query ? params.query : ''; this.tags = params.tagId ? [new TagVO({ tagId: params.tagId })] : []; + this.searchString = this.query + ? this.query + : `Keyword: ${params.tagName}`; + this.searchSubscription = this.searchService .getResultsInPublicArchive(this.query, this.tags, params.archiveId) .subscribe((response) => { diff --git a/src/app/public/public.routes.ts b/src/app/public/public.routes.ts index 9434bf94a..2e0387634 100644 --- a/src/app/public/public.routes.ts +++ b/src/app/public/public.routes.ts @@ -49,7 +49,7 @@ export const routes: RoutesWithData = [ component: PublicSearchResultsComponent, }, { - path: 'search-tag/:archiveId/:tagId', + path: 'search-tag/:archiveId/:tagId/:tagName', component: PublicSearchResultsComponent, }, {