diff --git a/src/app/feature/submission/components/study-tab/study-tab.component.html b/src/app/feature/submission/components/study-tab/study-tab.component.html index e9caf02..b764dc5 100644 --- a/src/app/feature/submission/components/study-tab/study-tab.component.html +++ b/src/app/feature/submission/components/study-tab/study-tab.component.html @@ -103,6 +103,33 @@ + + Background EFO traits + + + {{bgEfoTrait.trait + ', ' + bgEfoTrait.shortForm}} + + + + + + + {{bgEfoTrait.trait + ', ' + bgEfoTrait.shortForm}} + + No results. + + + + @@ -271,6 +298,14 @@

Report may contain errors, please download and have a loo + + Background EFO + + N/A + {{row.background_efo_trait}} + + + Sumstats File diff --git a/src/app/feature/submission/components/study-tab/study-tab.component.ts b/src/app/feature/submission/components/study-tab/study-tab.component.ts index 7e9f40b..15e0e30 100644 --- a/src/app/feature/submission/components/study-tab/study-tab.component.ts +++ b/src/app/feature/submission/components/study-tab/study-tab.component.ts @@ -30,7 +30,7 @@ export class StudyTabComponent implements OnInit, AfterViewInit { dataSource: MatTableDataSource; resultsLength = 0; isLoadingResults = true; - displayedColumns: string[] = ['study_accession', 'study_tag', 'genotyping_technology', 'array_manufacturer', 'array_information', 'imputation', 'variant_count', 'statistical_model', 'study_description', 'disease_trait', 'efo', 'sumstats_file', 'cohort']; + displayedColumns: string[] = ['study_accession', 'study_tag', 'genotyping_technology', 'array_manufacturer', 'array_information', 'imputation', 'variant_count', 'statistical_model', 'study_description', 'disease_trait', 'efo', 'background_efo', 'sumstats_file', 'cohort']; @ViewChild(MatSort) sort: MatSort; @ViewChild(MatPaginator) paginator: MatPaginator; submissionId = this.route.snapshot.paramMap.get('id'); @@ -38,12 +38,16 @@ export class StudyTabComponent implements OnInit, AfterViewInit { separatorKeysCodes: number[] = [ENTER, COMMA]; traitCtrl = new FormControl(); efoTraitCtrl = new FormControl(); + bgEfoTraitCtrl = new FormControl(); reportedTraits: ReportedTrait[] = []; efoTraits: EfoTrait[] = []; + bgEfoTraits: EfoTrait[] = []; reportedTraitsDropdownItems: ReportedTrait[] = []; efoTraitsDropdownItems: EfoTrait[] = []; + bgEfoTraitsDropdownItems: EfoTrait[] = []; @ViewChild('reportedTraitInput') reportedTraitInput: ElementRef; @ViewChild('efoTraitInput') efoTraitInput: ElementRef; + @ViewChild('bgEfoTraitInput') bgEfoTraitInput: ElementRef; @ViewChild('sidenav') sidenav: MatSidenav; isLoadingSidenav: boolean; sidenavStudy: Study; @@ -151,10 +155,15 @@ export class StudyTabComponent implements OnInit, AfterViewInit { .subscribe(value => { for (const study of value) { study.efo_trait = ''; + study.background_efo_trait = ''; for (const efo of study.efoTraits) { study.efo_trait = study.efo_trait + efo.trait + ' | '; } study.efo_trait = study.efo_trait.substring(0, study.efo_trait.length - 3); + for (const efo of study.backgroundEfoTraits) { + study.background_efo_trait = study.background_efo_trait + efo.trait + ' | '; + } + study.background_efo_trait = study.background_efo_trait.substring(0, study.background_efo_trait.length - 3); } this.dataSource = new MatTableDataSource(value); }); @@ -188,6 +197,21 @@ export class StudyTabComponent implements OnInit, AfterViewInit { } }); }); + + fromEvent(this.bgEfoTraitInput.nativeElement, 'input').pipe() + .pipe(map((event: Event) => (event.target as HTMLInputElement).value)) + .pipe(debounceTime(1000)) + .pipe(distinctUntilChanged()) + .subscribe(data => { + this.efoTraitService.getTraits(50, 0, 'trait', 'asc', data).subscribe(value => { + if (value?._embedded?.efoTraits) { + this.bgEfoTraitsDropdownItems = value._embedded.efoTraits; + } + else { + this.bgEfoTraitsDropdownItems = []; + } + }); + }); } getSubmissionStudies() { @@ -214,6 +238,14 @@ export class StudyTabComponent implements OnInit, AfterViewInit { } } + removeBgEfo(trait: EfoTrait): void { + const index = this.bgEfoTraits.indexOf(trait); + + if (index >= 0) { + this.bgEfoTraits.splice (index, 1); + } + } + selected(event: MatAutocompleteSelectedEvent): void { this.reportedTraits[0] = event.option.value; this.reportedTraitInput.nativeElement.value = ''; @@ -228,6 +260,14 @@ export class StudyTabComponent implements OnInit, AfterViewInit { this.efoTraitCtrl.setValue(null); } + selectedBgEfo(event: MatAutocompleteSelectedEvent): void { + if (this.bgEfoTraits.indexOf(event.option.value) < 0) { + this.bgEfoTraits.push(event.option.value); + } + this.bgEfoTraitInput.nativeElement.value = ''; + this.bgEfoTraitCtrl.setValue(null); + } + openSidenav(id: string) { // open sidenav @@ -242,6 +282,7 @@ export class StudyTabComponent implements OnInit, AfterViewInit { this.reportedTraits[0] = this.sidenavStudy.diseaseTrait; } this.efoTraits = this.sidenavStudy.efoTraits; + this.bgEfoTraits = this.sidenavStudy.backgroundEfoTraits; this.isLoadingSidenav = false; }); } @@ -278,6 +319,18 @@ export class StudyTabComponent implements OnInit, AfterViewInit { }); } + + saveBgEfoTraits() { + this.isLoadingSidenav = true; + + this.submissionService.editBgEfoTraits(this.bgEfoTraits, this.submissionId, this.sidenavStudy) + .subscribe((v) => { + this.sidenavStudy = v; + this.isLoadingSidenav = false; + this.reloadStudies(); + }); + } + downloadBulkStudyMultiTraitUploadTemplate() { this.submissionService.downloadBulkStudyMultiTraitUploadTemplate().subscribe((response: any) => { @@ -319,10 +372,15 @@ export class StudyTabComponent implements OnInit, AfterViewInit { .subscribe(value => { for (const study of value._embedded.studies) { study.efo_trait = ''; + study.background_efo_trait = ''; for (const efo of study.efoTraits) { study.efo_trait = study.efo_trait + efo.trait + ' | '; } study.efo_trait = study.efo_trait.substring(0, study.efo_trait.length - 3); + for (const efo of study.backgroundEfoTraits) { + study.background_efo_trait = study.background_efo_trait + efo.trait + ' | '; + } + study.background_efo_trait = study.background_efo_trait.substring(0, study.background_efo_trait.length - 3); } this.isLoadingResults = false; this.dataSource = new MatTableDataSource(value._embedded.studies);