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 @@ -487,7 +487,9 @@ export namespace Search {
isDisease: boolean;
hasEHLD?: boolean;
hasReferenceEntity: boolean;
disease: boolean
disease: boolean;
deleted: boolean;
date: number;
}

export interface EntryResult {
Expand Down
28 changes: 26 additions & 2 deletions projects/website-angular/src/app/search/search.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,33 @@ <h2>{{ group.typeName }} ({{ group.entriesCount }})</h2>
@for (entry of group.entries; track entry.dbId) {
<div class="search-entry">
<div class="entry-header">
<a class="entry-name" [routerLink]="getDetailLink(entry)" [innerHTML]="entry.name"></a>
<span class="entry-id">{{ entry.stId }}</span>
@if (entry.deleted) {
<span>❌</span>
<span class="deleted" [innerHTML]="entry.stId"></span>
@if (entry.replacementStIds?.length) {
<a
[routerLink]="['/content/detail', entry.replacementStIds[0]]"
title="Go to replacement">
{{ entry.replacementStIds[0] }}
</a>
}

} @else {
<a class="entry-name"
[routerLink]="getDetailLink(entry)"
[innerHTML]="entry.name">
</a>
<span class="entry-id">{{ entry.stId }}</span>
}

</div>
@if (entry.deleted && entry.date) {
<div class="deleted-date">
<b>Deleted on</b>
{{ entry.date | date:'MMM d, y, h:mm:ss a' }}
</div>
}
@if (entry.species?.length) {
<div class="entry-species">
@for (sp of entry.species; track sp; let last = $last) {
Expand Down
6 changes: 6 additions & 0 deletions projects/website-angular/src/app/search/search.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ $border-radius: 8px;
align-items: flex-start;
}

.deleted {
text-decoration: line-through;
color: #555;
}


// Facet sidebar
.facet-sidebar {
width: 260px;
Expand Down
37 changes: 34 additions & 3 deletions projects/website-angular/src/app/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import {
SearchFilters,
FacetCount,
} from '../../services/search.service';
import { DatePipe } from '@angular/common';

@Component({
selector: 'app-search',
standalone: true,
imports: [PageLayoutComponent, TileComponent, RouterLink, SearchBarComponent, FormsModule],
imports: [PageLayoutComponent, TileComponent, RouterLink, SearchBarComponent, FormsModule, DatePipe],
templateUrl: './search.component.html',
styleUrl: './search.component.scss',
})
Expand Down Expand Up @@ -199,7 +200,26 @@ export class SearchComponent implements OnInit, OnDestroy, AfterViewInit {
this.hasNoResults = false;
} else {
// Successful API response - check if we have results
this.results = results as SearchResult;
const res = results as SearchResult;
const hasNonDeleted = res.results?.some(group =>
group.entries.some(e => !e.deleted)
);
res.results = res.results?.map(group => {
const entries = hasNonDeleted
? group.entries.filter(e => !e.deleted)
: group.entries;

return {
...group,
entries,
entriesCount: entries.length
};
}).filter(group => group.entries.length > 0) || [];
res.numberOfMatches = res.results.reduce(
(sum, g) => sum + g.entries.length,
0
);
this.results = res;
this.facets = facets;
this.totalPages = Math.ceil(((results as SearchResult).numberOfMatches || 0) / this.pageSize);
this.hasNoResults = ((results as SearchResult).numberOfMatches || 0) === 0;
Expand Down Expand Up @@ -233,7 +253,7 @@ export class SearchComponent implements OnInit, OnDestroy, AfterViewInit {

get allEntries(): SearchEntry[] {
if (!this.results?.results) return [];
return this.results.results.flatMap(g => g.entries);
return this.results.results.flatMap(g => this.filterDeletedEntries(g.entries));
}

toggleFacet(category: string, value: string): void {
Expand Down Expand Up @@ -272,6 +292,17 @@ export class SearchComponent implements OnInit, OnDestroy, AfterViewInit {
this.advancedMode = !this.advancedMode;
}

private filterDeletedEntries(entries: SearchEntry[]): SearchEntry[] {
if (!entries?.length) return [];

const nonDeleted = entries.filter(e => !e.deleted);
if (nonDeleted.length > 0) {
return nonDeleted;
}

return entries;
}

private updateQueryParams(params: Record<string, string | string[] | null>): void {
this.router.navigate([], {
relativeTo: this.route,
Expand Down
2 changes: 2 additions & 0 deletions projects/website-angular/src/services/search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export interface SearchEntry {
referenceIdentifier: string;
databaseName: string;
referenceURL: string;
deleted: boolean;
date: number;
}

export interface ResultGroup {
Expand Down