diff --git a/client/src/app/forms/config/variant-submit/variant-submit.form.html b/client/src/app/forms/config/variant-submit/variant-submit.form.html index 554bee066..25336f5ec 100644 --- a/client/src/app/forms/config/variant-submit/variant-submit.form.html +++ b/client/src/app/forms/config/variant-submit/variant-submit.form.html @@ -15,16 +15,26 @@ + [nzDescription]="variantLink"> New Variant {{ variant.name }} added. - + View its details here. + + + Variant {{ variant.name }} already exists. + diff --git a/client/src/app/forms/config/variant-submit/variant-submit.form.ts b/client/src/app/forms/config/variant-submit/variant-submit.form.ts index 36b7df2e0..ab69985c6 100644 --- a/client/src/app/forms/config/variant-submit/variant-submit.form.ts +++ b/client/src/app/forms/config/variant-submit/variant-submit.form.ts @@ -9,11 +9,6 @@ import { CvcVariantSelectFieldOption } from '@app/forms/types/variant-select/var import { Maybe, Variant } from '@app/generated/civic.apollo' import { FormlyFieldConfig, FormlyFormOptions } from '@ngx-formly/core' import { BehaviorSubject } from 'rxjs' -import { - FormGene, - FormMolecularProfile, - FormVariant, -} from '@app/forms/forms.interfaces' import { NzFormLayoutType } from 'ng-zorro-antd/form' import { EntityFieldSubjectMap } from '@app/forms/states/base.state' import { Apollo, gql } from 'apollo-angular' @@ -29,18 +24,6 @@ type VariantSubmitState = { fields: EntityFieldSubjectMap } -// interface FormModel { -// fields: { -// gene: FormGene[] -// variant: FormVariant[] -// } -// } - -// export interface SelectedVariant { -// variantId: number -// molecularProfile: FormMolecularProfile -// } - @Component({ selector: 'cvc-variant-submit-form', templateUrl: './variant-submit.form.html', @@ -56,6 +39,7 @@ export class VariantSubmitForm { form: UntypedFormGroup config: FormlyFieldConfig[] layout: NzFormLayoutType = 'horizontal' + newlyCreated?: boolean finderState: VariantSubmitState = { formLayout: this.layout, @@ -101,6 +85,7 @@ export class VariantSubmitForm { showExtra: false, }, hideLabel: true, + isNewlyCreatedCallback: (isNew: boolean): void => {this.newlyCreated = isNew}, }, }, ], diff --git a/client/src/app/forms/types/variant-select/variant-quick-add/variant-quick-add.form.ts b/client/src/app/forms/types/variant-select/variant-quick-add/variant-quick-add.form.ts index 407482170..a8550e850 100644 --- a/client/src/app/forms/types/variant-select/variant-quick-add/variant-quick-add.form.ts +++ b/client/src/app/forms/types/variant-select/variant-quick-add/variant-quick-add.form.ts @@ -19,14 +19,12 @@ import { QuickAddVariantGQL, QuickAddVariantMutation, QuickAddVariantMutationVariables, - Variant, - VariantSelectTypeaheadFieldsFragment, } from '@app/generated/civic.apollo' import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy' -import { FormlyFieldConfig, FormlyFormOptions } from '@ngx-formly/core' +import { FormlyFieldConfig } from '@ngx-formly/core' import { NzFormLayoutType } from 'ng-zorro-antd/form' -import { BehaviorSubject, Observable, Subject } from 'rxjs' -import { CvcOrgSubmitButtonFieldConfig } from '../../org-submit-button/org-submit-button.type' +import { BehaviorSubject, Subject } from 'rxjs' +import { VariantIdWithCreationStatus } from '../variant-select.type' type VariantQuickAddModel = { name?: string @@ -62,7 +60,7 @@ export class CvcVariantQuickAddForm implements OnChanges { this.searchString$.next(str) } - @Output() cvcOnCreate = new EventEmitter() + @Output() cvcOnCreate = new EventEmitter() model: Partial form: UntypedFormGroup @@ -196,9 +194,7 @@ export class CvcVariantQuickAddForm implements OnChanges { this.formMessageDisplay$.next({ message: undefined }) setTimeout(() => { if (data && data.createVariant) { - const variant = data.createVariant - .variant as VariantSelectTypeaheadFieldsFragment - this.cvcOnCreate.next(variant.id) + this.cvcOnCreate.next({id: data.createVariant.variant.id, new: data.createVariant.new}) } }, 1000) } diff --git a/client/src/app/forms/types/variant-select/variant-select.type.html b/client/src/app/forms/types/variant-select/variant-select.type.html index 729f4603a..1d255236e 100644 --- a/client/src/app/forms/types/variant-select/variant-select.type.html +++ b/client/src/app/forms/types/variant-select/variant-select.type.html @@ -115,6 +115,6 @@ [cvcSearchString]="searchStr" [cvcGeneId]="onGeneId$ | ngrxPush" [cvcGeneName]="onGeneName$ | ngrxPush" - (cvcOnCreate)="onPopulate$.next($event)"> + (cvcOnCreate)="onSelectOrCreate($event)"> diff --git a/client/src/app/forms/types/variant-select/variant-select.type.ts b/client/src/app/forms/types/variant-select/variant-select.type.ts index 9fb12158f..93c4c4c4b 100644 --- a/client/src/app/forms/types/variant-select/variant-select.type.ts +++ b/client/src/app/forms/types/variant-select/variant-select.type.ts @@ -30,7 +30,6 @@ import { FormlyFieldConfig, FormlyFieldProps, } from '@ngx-formly/core' -import { Apollo } from 'apollo-angular' import { NzSelectOptionInterface } from 'ng-zorro-antd/select' import { BehaviorSubject, @@ -39,16 +38,19 @@ import { map, Observable, ReplaySubject, - startWith, Subject, scan, withLatestFrom, filter, take, } from 'rxjs' -import { tag } from 'rxjs-spy/operators' import mixin from 'ts-mixin-extended' +export interface VariantIdWithCreationStatus { + new: boolean + id: number +} + export type CvcVariantSelectFieldOption = Partial< FieldTypeConfig> > @@ -265,6 +267,13 @@ export class CvcVariantSelectField ) } + onSelectOrCreate(variant: VariantIdWithCreationStatus) { + this.onPopulate$.next(variant.id) + if(this.props.isNewlyCreatedCallback) { + this.props.isNewlyCreatedCallback(variant.new) + } + } + private onGeneId(gid: Maybe): void { this.selectedGeneId = gid // if field config indicates that a geneId is required, and none is provided,