Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
acoffman committed Jan 31, 2024
2 parents 6931228 + 18fd79c commit 756c5c6
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,13 @@ const formFieldConfig: FormlyFieldConfig[] = [
type: 'direction-select',
props: {
required: true,
formMode: 'revise',
},
},
{
key: 'significance',
type: 'significance-select',
props: {
required: true,
formMode: 'revise',
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ import { CvcDirectionSelectFieldOptions } from '@app/forms/types/direction-selec
import { CvcDiseaseSelectFieldOptions } from '@app/forms/types/disease-select/disease-select.type'
import { CvcInteractionSelectFieldOptions } from '@app/forms/types/interaction-select/interaction-select.type'
import { CvcLevelSelectFieldOptions } from '@app/forms/types/level-select/level-select.type'
import { CvcMolecularProfileSelectFieldConfig } from '@app/forms/types/molecular-profile-select/molecular-profile-select.type'
import { CvcOrgSubmitButtonFieldConfig } from '@app/forms/types/org-submit-button/org-submit-button.type'
import { CvcOriginSelectFieldOptions } from '@app/forms/types/origin-select/origin-select.type'
import { CvcPhenotypeSelectFieldOptions } from '@app/forms/types/phenotype-select/phenotype-select.type'
import { CvcRatingFieldOptions } from '@app/forms/types/rating/rating.type'
import { CvcSignificanceSelectFieldOptions } from '@app/forms/types/significance-select/significance-select.type'
import {
CvcSourceSelectFieldConfig,
CvcSourceSelectFieldOptions,
} from '@app/forms/types/source-select/source-select.type'
import { CvcSourceSelectFieldConfig } from '@app/forms/types/source-select/source-select.type'
import { CvcTherapySelectFieldOptions } from '@app/forms/types/therapy-select/therapy-select.type'
import { CvcEntityTypeSelectFieldConfig } from '@app/forms/types/type-select/type-select.type'
import assignFieldConfigDefaultValues from '@app/forms/utilities/assign-field-default-values'
Expand All @@ -22,7 +18,6 @@ import { CvcFormRowWrapperProps } from '@app/forms/wrappers/form-row/form-row.wr
import { FormlyFieldConfig } from '@ngx-formly/core'

const formFieldConfig: FormlyFieldConfig[] = [
// form-layout wrapper embeds the form in an nz-grid row, allowing the form to be placed adjacent to other controls or page elements. Currently, it provides a toggleable dev panel. Could be used to add a preview of the entity being added/edited, or more extensive feedback like lists of similar entities, etc.
{
wrappers: ['form-layout'],
props: <CvcFormLayoutWrapperProps>{
Expand Down Expand Up @@ -87,15 +82,13 @@ const formFieldConfig: FormlyFieldConfig[] = [
type: 'direction-select',
props: {
required: true,
formMode: 'revise',
},
},
<CvcSignificanceSelectFieldOptions>{
key: 'significance',
type: 'significance-select',
props: {
required: true,
formMode: 'revise',
},
},
<CvcDiseaseSelectFieldOptions>{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class CvcEvidenceReviseForm implements OnInit, AfterViewInit, OnDestroy {
this.form = new UntypedFormGroup({})
this.fields = evidenceReviseFields
this.state = new EvidenceState()
this.state.formMode = 'revise'
this.options = { formState: this.state }
this.reviseEvidenceMutator = new MutatorWithState(networkErrorService)
}
Expand Down
39 changes: 17 additions & 22 deletions client/src/app/forms/config/evidence-submit/evidence-submit.form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ export class CvcEvidenceSubmitForm implements OnDestroy, AfterViewInit, OnInit {
selectedSourceId?: number
selectedMpId?: number

countQueryRef?: QueryRef<ExistingEvidenceCountQuery, ExistingEvidenceCountQueryVariables>
curatedQueryRef?: QueryRef<FullyCuratedSourceQuery, FullyCuratedSourceQueryVariables>
countQueryRef?: QueryRef<
ExistingEvidenceCountQuery,
ExistingEvidenceCountQueryVariables
>
curatedQueryRef?: QueryRef<
FullyCuratedSourceQuery,
FullyCuratedSourceQueryVariables
>
existingEvidenceId?: number
routeSub: Subscription

Expand All @@ -90,39 +96,28 @@ export class CvcEvidenceSubmitForm implements OnDestroy, AfterViewInit, OnInit {
this.routeSub = this.route.queryParams.subscribe((params) => {
if (params.existingEvidenceId) {
this.existingEvidenceId = +params.existingEvidenceId

let direction = this.getFieldConfig('direction-select')
if (direction) {
direction.props!.formMode = 'clone'
}
let significance = this.getFieldConfig('significance-select')
if (significance) {
significance.props!.formMode = 'clone'
}
this.state.formMode = 'clone'
} else {
this.model = { fields: {} }
}
})
}

getFieldConfig(fieldKey: string) {
return this.fields?.[0].fieldGroup
?.find((f) => f.key === 'fields')
?.fieldGroup?.find((f) => f.type === fieldKey)
}

ngOnInit(): void {
this.countQueryRef = this.existingEvidenceGQL.watch({molecularProfileId: 0, sourceId: 0})
this.curatedQueryRef = this.fullyCuratedSourceGQL.watch({sourceId: 0})
this.countQueryRef = this.existingEvidenceGQL.watch({
molecularProfileId: 0,
sourceId: 0,
})
this.curatedQueryRef = this.fullyCuratedSourceGQL.watch({ sourceId: 0 })

this.existingEvidenceCount$ = this.countQueryRef?.valueChanges.pipe(
map((c) => c.data?.evidenceItems?.totalCount),
filter(isNonNulled),
untilDestroyed(this)
)
this.fullyCuratedSource$ = this.curatedQueryRef?.valueChanges.pipe(
map(c => c.data?.source?.fullyCurated),
untilDestroyed(this)
map((c) => c.data?.source?.fullyCurated),
untilDestroyed(this)
)
}

Expand Down Expand Up @@ -188,7 +183,7 @@ export class CvcEvidenceSubmitForm implements OnDestroy, AfterViewInit, OnInit {
}

if (newModel.fields.sourceId) {
if(newModel.fields.sourceId != this.selectedSourceId) {
if (newModel.fields.sourceId != this.selectedSourceId) {
this.selectedSourceId = newModel.fields.sourceId
this.curatedQueryRef?.refetch({ sourceId: this.selectedSourceId })
}
Expand Down
8 changes: 5 additions & 3 deletions client/src/app/forms/states/base.state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
formatEvidenceEnum,
} from '@app/core/utilities/enum-formatters/format-evidence-enum'
import { formatEvidenceEnum } from '@app/core/utilities/enum-formatters/format-evidence-enum'
import {
AssertionSignificance,
AssertionDirection,
Expand All @@ -22,6 +20,8 @@ export type EntitySignificance = EvidenceSignificance | AssertionSignificance

export type EntityDirection = EvidenceDirection | AssertionDirection

export type CvcFormMode = 'revise' | 'add' | 'clone'

export type ValidEntity = {
entityType: EntityType
significance: EntitySignificance[]
Expand Down Expand Up @@ -52,6 +52,7 @@ export type NoStateFormOptions = { formState: { formLayout: NzFormLayoutType } }
export interface IEntityState {
formReady$: Subject<boolean>
formLayout: NzFormLayoutType
formMode: CvcFormMode
validStates: Map<EntityType, ValidEntity>
getTypeOptions: () => EntityType[]
getSignificanceOptions: (et: EntityType) => EntitySignificance[]
Expand All @@ -77,6 +78,7 @@ export interface IEntityState {
class BaseState implements IEntityState {
formReady$ = new Subject<boolean>()
formLayout: NzFormLayoutType = 'vertical'
formMode: CvcFormMode = 'add'
fields: EntityFieldSubjectMap
enums: EntityFieldSubjectMap
options: EntityFieldSubjectMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export interface CvcDirectionSelectFieldProps extends FormlyFieldProps {
requireTypePromptFn: (entityName: string) => string
tooltip?: string
extraType?: CvcFormFieldExtraType
formMode: 'revise' | 'add' | 'clone'
}

export interface CvcDirectionSelectFieldConfig
Expand Down Expand Up @@ -164,7 +163,6 @@ export class CvcDirectionSelectField
`Select ${entityType ? entityType + ' ' : ''}${entityName} Direction`,
requireTypePromptFn: (entityName: string) =>
`Select ${entityName} Type to select its Direction`,
formMode: 'add',
},
}

Expand Down Expand Up @@ -246,7 +244,10 @@ export class CvcDirectionSelectField
this.onEntityType$ = this.state.fields[etName]
// if new entityType received, reset field, then based on entityType value, toggle disabled state, update placeholder
this.onEntityType$
.pipe(skip(this.props.formMode === 'add' ? 0 : 1), untilDestroyed(this))
.pipe(
skip(this.options.formState.formMode === 'add' ? 0 : 1),
untilDestroyed(this)
)
.subscribe((et: Maybe<CvcInputEnum>) => {
if (!et) {
this.props.disabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ interface CvcSignificanceSelectFieldProps extends FormlyFieldProps {
tooltip?: string
description?: string
extraType?: CvcFormFieldExtraType
formMode: 'revise' | 'add' | 'clone'
}

export interface CvcSignificanceSelectFieldConfig
Expand Down Expand Up @@ -170,7 +169,6 @@ export class CvcSignificanceSelectField
requireTypePromptFn: (entityName: string) =>
`Select ${entityName} Type to select its Significance`,
tooltip: 'Clinical impact of the variant',
formMode: 'add',
},
}

Expand Down Expand Up @@ -247,7 +245,10 @@ export class CvcSignificanceSelectField
this.onTypeSelect$ = this.state.fields[etName]
// if new entityType received, reset field, then based on entityType value, toggle disabled state, update placeholder
this.onTypeSelect$
.pipe(skip(this.props.formMode === 'add' ? 0 : 1), untilDestroyed(this))
.pipe(
skip(this.options.formState.formMode === 'add' ? 0 : 1),
untilDestroyed(this)
)
.subscribe((et: Maybe<CvcInputEnum>) => {
if (!et) {
this.props.disabled = true
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/forms/utilities/variant-to-model-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function variantFormModelToReviseInput(
let clinvarHelper = (ids: string[]): ClinvarInput => {
if (ids[0] == 'NONE FOUND') {
return { noneFound: true }
} else if (ids[0] == 'NA') {
} else if (ids[0] == 'N/A') {
return { notApplicable: true }
} else {
return { ids: ids.map((id) => +id) }
Expand Down

0 comments on commit 756c5c6

Please sign in to comment.