Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow evidence and assertion tables to be filtered by status #1106

Merged
merged 1 commit into from
Aug 22, 2024
Merged
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 @@ -498,4 +498,44 @@
<span>Loading…</span>
</nz-tag>
<cvc-no-more-rows [cvcShowTag]="noMoreRows$ | ngrxPush"></cvc-no-more-rows>
<nz-filter-trigger
[(nzVisible)]="statusFilterVisible"
[nzDropdownMenu]="statusFilterMenu">
<span
nz-icon
nzType="filter"
nzTheme="fill"></span>
</nz-filter-trigger>
</ng-template>

<nz-dropdown-menu #statusFilterMenu>
<nz-radio-group
[(ngModel)]="statusInput"
(ngModelChange)="statusChanged()">
<label
nz-radio-button
[nzValue]="availableStatusFilters.NonRejected"
>Non-Rejected</label
>
<label
nz-radio-button
[nzValue]="availableStatusFilters.Accepted"
>Accepted</label
>
<label
nz-radio-button
[nzValue]="availableStatusFilters.Submitted"
>Submitted</label
>
<label
nz-radio-button
[nzValue]="availableStatusFilters.Rejected"
>Rejected</label
>
<label
nz-radio-button
[nzValue]="availableStatusFilters.All"
>All</label
>
</nz-radio-group>
</nz-dropdown-menu>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
EvidenceType,
Maybe,
PageInfo,
EvidenceLevel,
} from '@app/generated/civic.apollo'
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'
import { QueryRef } from 'apollo-angular'
Expand Down Expand Up @@ -118,6 +119,10 @@ export class CvcAssertionsTableComponent implements OnInit {
SignificanceInput: Maybe<EvidenceSignificance>
molecularProfileNameInput: Maybe<string>
ampLevelInput: Maybe<AmpLevel>
statusInput: Maybe<EvidenceStatusFilter> = EvidenceStatusFilter.NonRejected

availableStatusFilters = EvidenceStatusFilter
statusFilterVisible = false

sortColumns: typeof AssertionSortColumns = AssertionSortColumns

Expand All @@ -144,7 +149,7 @@ export class CvcAssertionsTableComponent implements OnInit {
phenotypeId: this.phenotypeId,
diseaseId: this.diseaseId,
therapyId: this.therapyId,
status: this.status,
status: this.status || EvidenceStatusFilter.NonRejected,
})

this.result$ = this.queryRef.valueChanges
Expand Down Expand Up @@ -255,6 +260,7 @@ export class CvcAssertionsTableComponent implements OnInit {
molecularProfileName: this.molecularProfileNameInput,
therapyName: this.therapyNameInput,
summary: this.summaryInput,
status: this.statusInput,
assertionType: this.assertionTypeInput
? this.assertionTypeInput
: undefined,
Expand All @@ -276,8 +282,16 @@ export class CvcAssertionsTableComponent implements OnInit {
this.loadedPages += 1
}

statusChanged() {
this.debouncedQuery.next()
this.statusFilterVisible = false
}

// virtual scroll helpers
trackByIndex(_: number, data: Maybe<AssertionBrowseFieldsFragment>): Maybe<number> {
trackByIndex(
_: number,
data: Maybe<AssertionBrowseFieldsFragment>
): Maybe<number> {
return data?.id
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { NzToolTipModule } from 'ng-zorro-antd/tooltip'
import { NzTypographyModule } from 'ng-zorro-antd/typography'
import { CvcAssertionsTagModule } from '../assertions-tag/assertions-tag.module'
import { CvcAssertionsTableComponent } from './assertions-table.component'
import { NzDropDownModule } from 'ng-zorro-antd/dropdown'
import { NzRadioModule } from 'ng-zorro-antd/radio'

@NgModule({
declarations: [CvcAssertionsTableComponent],
Expand All @@ -46,6 +48,8 @@ import { CvcAssertionsTableComponent } from './assertions-table.component'
NzTagModule,
NzToolTipModule,
NzTypographyModule,
NzDropDownModule,
NzRadioModule,

CvcAssertionsTagModule,
CvcAutoHeightCardModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,4 +644,44 @@
<span>Loading…</span>
</nz-tag>
<cvc-no-more-rows [cvcShowTag]="noMoreRows$ | ngrxPush"></cvc-no-more-rows>
<nz-filter-trigger
[(nzVisible)]="statusFilterVisible"
[nzDropdownMenu]="statusFilterMenu">
<span
nz-icon
nzType="filter"
nzTheme="fill"></span>
</nz-filter-trigger>
</ng-template>

<nz-dropdown-menu #statusFilterMenu>
<nz-radio-group
[(ngModel)]="statusInput"
(ngModelChange)="statusChanged()">
<label
nz-radio-button
[nzValue]="availableStatusFilters.NonRejected"
>Non-Rejected</label
>
<label
nz-radio-button
[nzValue]="availableStatusFilters.Accepted"
>Accepted</label
>
<label
nz-radio-button
[nzValue]="availableStatusFilters.Submitted"
>Submitted</label
>
<label
nz-radio-button
[nzValue]="availableStatusFilters.Rejected"
>Rejected</label
>
<label
nz-radio-button
[nzValue]="availableStatusFilters.All"
>All</label
>
</nz-radio-group>
</nz-dropdown-menu>
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface EvidenceTableUserFilters {
evidenceRatingInput?: Maybe<number>
molecularProfileNameInput?: Maybe<string>
geneSymbolInput?: Maybe<string>
statusInput?: Maybe<EvidenceStatusFilter>
}

@UntilDestroy()
Expand Down Expand Up @@ -126,11 +127,18 @@ export class CvcEvidenceTableComponent implements OnInit {
evidenceTypeInput: Maybe<EvidenceType>
molecularProfileNameInput: Maybe<string>
variantOriginInput: Maybe<VariantOrigin>
statusInput: Maybe<EvidenceStatusFilter> = EvidenceStatusFilter.NonRejected

availableStatusFilters = EvidenceStatusFilter
statusFilterVisible = false

sortColumns = EvidenceSortColumns
evidenceLevels = EvidenceLevel

constructor(private gql: EvidenceBrowseGQL, private cdr: ChangeDetectorRef) {
constructor(
private gql: EvidenceBrowseGQL,
private cdr: ChangeDetectorRef
) {
this.noMoreRows$ = new BehaviorSubject<boolean>(false)
this.scrollEvent$ = new BehaviorSubject<ScrollEvent>('stop')
this.sortChange$ = new Subject<SortDirectionEvent>()
Expand Down Expand Up @@ -160,7 +168,7 @@ export class CvcEvidenceTableComponent implements OnInit {
phenotypeId: this.phenotypeId,
rating: this.evidenceRatingInput ? this.evidenceRatingInput : undefined,
sourceId: this.sourceId,
status: this.status,
status: this.status || EvidenceStatusFilter.NonRejected,
userId: this.userId,
variantId: this.variantId,
molecularProfileId: this.molecularProfileId,
Expand Down Expand Up @@ -278,6 +286,7 @@ export class CvcEvidenceTableComponent implements OnInit {
diseaseName: this.diseaseNameInput,
therapyName: this.therapyNameInput,
description: this.descriptionInput,
status: this.statusInput,
evidenceLevel: this.evidenceLevelInput
? this.evidenceLevelInput
: undefined,
Expand All @@ -303,7 +312,15 @@ export class CvcEvidenceTableComponent implements OnInit {
this.cdr.detectChanges()
}

trackByIndex(_: number, data: Maybe<EvidenceGridFieldsFragment>): Maybe<number> {
statusChanged() {
this.filterChange$.next()
this.statusFilterVisible = false
}

trackByIndex(
_: number,
data: Maybe<EvidenceGridFieldsFragment>
): Maybe<number> {
return data?.id
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { NzToolTipModule } from 'ng-zorro-antd/tooltip'
import { NzTypographyModule } from 'ng-zorro-antd/typography'
import { CvcEvidenceTagModule } from '../evidence-tag/evidence-tag.module'
import { CvcEvidenceTableComponent } from './evidence-table.component'
import { NzDropDownModule } from 'ng-zorro-antd/dropdown'
import { NzRadioModule } from 'ng-zorro-antd/radio'

@NgModule({
declarations: [CvcEvidenceTableComponent],
Expand All @@ -49,6 +51,8 @@ import { CvcEvidenceTableComponent } from './evidence-table.component'
NzTagModule,
NzToolTipModule,
NzTypographyModule,
NzDropDownModule,
NzRadioModule,

CvcAutoHeightCardModule,
CvcAutoHeightTableModule,
Expand Down
1 change: 1 addition & 0 deletions client/src/app/generated/civic.apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,7 @@ export enum EvidenceStatus {
export enum EvidenceStatusFilter {
Accepted = 'ACCEPTED',
All = 'ALL',
NonRejected = 'NON_REJECTED',
Rejected = 'REJECTED',
Submitted = 'SUBMITTED'
}
Expand Down
1 change: 1 addition & 0 deletions client/src/app/generated/server.model.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3239,6 +3239,7 @@ enum EvidenceStatus {
enum EvidenceStatusFilter {
ACCEPTED
ALL
NON_REJECTED
REJECTED
SUBMITTED
}
Expand Down
6 changes: 6 additions & 0 deletions client/src/app/generated/server.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16764,6 +16764,12 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "NON_REJECTED",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "ALL",
"description": null,
Expand Down
9 changes: 5 additions & 4 deletions server/app/graphql/resolvers/top_level_assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,15 @@ def generate_select(field = nil)
scope.joins(:therapies).where('therapies.id = ?', value)
end
option(:status, type: Types::EvidenceStatusFilterType, description: "Filtering on the status of the assertion.") do |scope, value|
if value != 'ALL'
scope.unscope(where: :status).where(status: value)
else
if value == 'ALL'
scope.unscope(where: :status)
elsif value == 'NON_REJECTED'
scope.unscope(where: :status).where.not(status: 'rejected')
else
scope.unscope(where: :status).where(status: value)
end
end


option :sort_by, type: Types::BrowseTables::AssertionSortType, description: 'Columm and direction to sort evidence on.' do |scope, value|
case value.column
when 'DISEASE_NAME'
Expand Down
8 changes: 5 additions & 3 deletions server/app/graphql/resolvers/top_level_evidence_items.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ def generate_select(field = nil)
scope.where(rating: value)
end
option(:status, type: Types::EvidenceStatusFilterType, description: 'Filtering on the evidence status.') do |scope, value|
if value != 'ALL'
scope.unscope(where: :status).where(status: value)
else
if value == 'ALL'
scope.unscope(where: :status)
elsif value == 'NON_REJECTED'
scope.unscope(where: :status).where.not(status: 'rejected')
else
scope.unscope(where: :status).where(status: value)
end
end
option(:phenotype_id, type: GraphQL::Types::Int, description: 'Exact match filtering of the evidence items based on the internal CIViC phenotype id') do |scope, value|
Expand Down
1 change: 1 addition & 0 deletions server/app/graphql/types/evidence_status_filter_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class EvidenceStatusFilterType < Types::BaseEnum
value 'ACCEPTED', value: 'accepted'
value 'SUBMITTED', value: 'submitted'
value 'REJECTED', value: 'rejected'
value 'NON_REJECTED'
value 'ALL'
end
end
Loading