diff --git a/src/atlasComponents/regionalFeatures/bsFeatures/receptor/ar/autoradiograph.component.ts b/src/atlasComponents/regionalFeatures/bsFeatures/receptor/ar/autoradiograph.component.ts index 867f18fb919b994d92a5c3516267571d60e7afb2..efd93a3b9e0441b325afad42b041f48b1a6b7d24 100644 --- a/src/atlasComponents/regionalFeatures/bsFeatures/receptor/ar/autoradiograph.component.ts +++ b/src/atlasComponents/regionalFeatures/bsFeatures/receptor/ar/autoradiograph.component.ts @@ -1,9 +1,15 @@ import { Component, Input, OnChanges } from "@angular/core"; import { BsFeatureReceptorBase } from "../base"; import { CONST } from 'common/constants' +import { TBSDetail } from "../type"; const { RECEPTOR_AR_CAPTION } = CONST +export function isAr(detail: TBSDetail, label: string){ + if (label) return !!detail.__data.__autoradiographs[label] + return !!detail.__data.__autoradiographs +} + @Component({ selector: 'bs-features-receptor-autoradiograph', templateUrl: './autoradiograph.template.html', diff --git a/src/atlasComponents/regionalFeatures/bsFeatures/receptor/entry/entry.component.ts b/src/atlasComponents/regionalFeatures/bsFeatures/receptor/entry/entry.component.ts index c7ddc98b3dfe499c26525c889e85133b591a95a3..7856a6ad7322c971c8afaef42181673255fa95ed 100644 --- a/src/atlasComponents/regionalFeatures/bsFeatures/receptor/entry/entry.component.ts +++ b/src/atlasComponents/regionalFeatures/bsFeatures/receptor/entry/entry.component.ts @@ -6,6 +6,7 @@ import { REGISTERED_FEATURE_INJECT_DATA } from "../../constants"; import { BsFeatureService, TFeatureCmpInput } from "../../service"; import { TBSDetail } from "../type"; import { ARIA_LABELS } from 'common/constants' +import { isPr } from "../profile/profile.component"; @Component({ selector: 'bs-features-receptor-entry', @@ -38,6 +39,10 @@ export class BsFeatureReceptorEntry extends BsRegionInputBase implements OnDestr shareReplay(1), ) + public hasPrAr$: Observable<boolean> = this.selectedReceptor$.pipe( + map(detail => detail.__files.some(f => isPr(f))), + ) + ngOnDestroy(){ while (this.sub.length > 0) this.sub.pop().unsubscribe() } diff --git a/src/atlasComponents/regionalFeatures/bsFeatures/receptor/entry/entry.template.html b/src/atlasComponents/regionalFeatures/bsFeatures/receptor/entry/entry.template.html index 5a6294e1fd7720dc85331a95f1f41e5ae547988e..813c489a6f2e2e054ed1019ebc36d5dc6ef2388c 100644 --- a/src/atlasComponents/regionalFeatures/bsFeatures/receptor/entry/entry.template.html +++ b/src/atlasComponents/regionalFeatures/bsFeatures/receptor/entry/entry.template.html @@ -15,30 +15,33 @@ [bsFeature]="selectedRec"> </bs-features-receptor-fingerprint> - <mat-divider></mat-divider> + <ng-template [ngIf]="hasPrAr$ | async"> + <mat-divider></mat-divider> - <mat-form-field class="mt-2 w-100"> - <mat-label> - Select a receptor - </mat-label> - <mat-select [(value)]="selectedReceptor"> - <mat-option - *ngFor="let receptorName of (allReceptors$ | async)" - [value]="receptorName"> - {{ receptorName }} - </mat-option> - </mat-select> - </mat-form-field> + <mat-form-field class="mt-2 w-100"> + <mat-label> + Select a receptor + </mat-label> + <mat-select [(value)]="selectedReceptor"> + <mat-option + *ngFor="let receptorName of (allReceptors$ | async)" + [value]="receptorName"> + {{ receptorName }} + </mat-option> + </mat-select> + </mat-form-field> + + <bs-features-receptor-profile + *ngIf="selectedReceptor" + [bsFeature]="selectedRec" + [bsLabel]="selectedReceptor"> + </bs-features-receptor-profile> + + <bs-features-receptor-autoradiograph + *ngIf="selectedReceptor" + [bsFeature]="selectedRec" + [bsLabel]="selectedReceptor"> + </bs-features-receptor-autoradiograph> + </ng-template> - <bs-features-receptor-profile - *ngIf="selectedReceptor" - [bsFeature]="selectedRec" - [bsLabel]="selectedReceptor"> - </bs-features-receptor-profile> - - <bs-features-receptor-autoradiograph - *ngIf="selectedReceptor" - [bsFeature]="selectedRec" - [bsLabel]="selectedReceptor"> - </bs-features-receptor-autoradiograph> </ng-container> diff --git a/src/atlasComponents/regionalFeatures/bsFeatures/receptor/profile/profile.component.ts b/src/atlasComponents/regionalFeatures/bsFeatures/receptor/profile/profile.component.ts index 02f9ef7fe87b2d4c967acf00097f4e16cfc2d7c8..6b33a73b4810c5828752a783b006b0dbb6928b94 100644 --- a/src/atlasComponents/regionalFeatures/bsFeatures/receptor/profile/profile.component.ts +++ b/src/atlasComponents/regionalFeatures/bsFeatures/receptor/profile/profile.component.ts @@ -4,6 +4,10 @@ import { BS_DARKTHEME } from "../../constants"; import { BsFeatureReceptorBase } from "../base"; import { CONST } from 'common/constants' +export function isPr(filename: string, label: string = ''){ + return filename.indexOf(`_pr_${label}`) >= 0 +} + const { RECEPTOR_PR_CAPTION } = CONST @Component({ @@ -43,7 +47,7 @@ export class BsFeatureReceptorProfile extends BsFeatureReceptorBase implements O } this.urls = this.bsFeature.__files - .filter(url => url.indexOf(`_pr_${this.bsLabel}`) >= 0) + .filter(url => isPr(url, this.bsLabel)) .map(url => { return { url } })