Skip to content
Snippets Groups Projects
Commit 96dda16a authored by Xiao Gui's avatar Xiao Gui
Browse files

chore: hide profile and AR when not available

parent 57e5d002
No related branches found
No related tags found
No related merge requests found
import { Component, Input, OnChanges } from "@angular/core"; import { Component, Input, OnChanges } from "@angular/core";
import { BsFeatureReceptorBase } from "../base"; import { BsFeatureReceptorBase } from "../base";
import { CONST } from 'common/constants' import { CONST } from 'common/constants'
import { TBSDetail } from "../type";
const { RECEPTOR_AR_CAPTION } = CONST const { RECEPTOR_AR_CAPTION } = CONST
export function isAr(detail: TBSDetail, label: string){
if (label) return !!detail.__data.__autoradiographs[label]
return !!detail.__data.__autoradiographs
}
@Component({ @Component({
selector: 'bs-features-receptor-autoradiograph', selector: 'bs-features-receptor-autoradiograph',
templateUrl: './autoradiograph.template.html', templateUrl: './autoradiograph.template.html',
......
...@@ -6,6 +6,7 @@ import { REGISTERED_FEATURE_INJECT_DATA } from "../../constants"; ...@@ -6,6 +6,7 @@ import { REGISTERED_FEATURE_INJECT_DATA } from "../../constants";
import { BsFeatureService, TFeatureCmpInput } from "../../service"; import { BsFeatureService, TFeatureCmpInput } from "../../service";
import { TBSDetail } from "../type"; import { TBSDetail } from "../type";
import { ARIA_LABELS } from 'common/constants' import { ARIA_LABELS } from 'common/constants'
import { isPr } from "../profile/profile.component";
@Component({ @Component({
selector: 'bs-features-receptor-entry', selector: 'bs-features-receptor-entry',
...@@ -38,6 +39,10 @@ export class BsFeatureReceptorEntry extends BsRegionInputBase implements OnDestr ...@@ -38,6 +39,10 @@ export class BsFeatureReceptorEntry extends BsRegionInputBase implements OnDestr
shareReplay(1), shareReplay(1),
) )
public hasPrAr$: Observable<boolean> = this.selectedReceptor$.pipe(
map(detail => detail.__files.some(f => isPr(f))),
)
ngOnDestroy(){ ngOnDestroy(){
while (this.sub.length > 0) this.sub.pop().unsubscribe() while (this.sub.length > 0) this.sub.pop().unsubscribe()
} }
......
...@@ -15,30 +15,33 @@ ...@@ -15,30 +15,33 @@
[bsFeature]="selectedRec"> [bsFeature]="selectedRec">
</bs-features-receptor-fingerprint> </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-form-field class="mt-2 w-100">
<mat-label> <mat-label>
Select a receptor Select a receptor
</mat-label> </mat-label>
<mat-select [(value)]="selectedReceptor"> <mat-select [(value)]="selectedReceptor">
<mat-option <mat-option
*ngFor="let receptorName of (allReceptors$ | async)" *ngFor="let receptorName of (allReceptors$ | async)"
[value]="receptorName"> [value]="receptorName">
{{ receptorName }} {{ receptorName }}
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </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> </ng-container>
...@@ -4,6 +4,10 @@ import { BS_DARKTHEME } from "../../constants"; ...@@ -4,6 +4,10 @@ import { BS_DARKTHEME } from "../../constants";
import { BsFeatureReceptorBase } from "../base"; import { BsFeatureReceptorBase } from "../base";
import { CONST } from 'common/constants' import { CONST } from 'common/constants'
export function isPr(filename: string, label: string = ''){
return filename.indexOf(`_pr_${label}`) >= 0
}
const { RECEPTOR_PR_CAPTION } = CONST const { RECEPTOR_PR_CAPTION } = CONST
@Component({ @Component({
...@@ -43,7 +47,7 @@ export class BsFeatureReceptorProfile extends BsFeatureReceptorBase implements O ...@@ -43,7 +47,7 @@ export class BsFeatureReceptorProfile extends BsFeatureReceptorBase implements O
} }
this.urls = this.bsFeature.__files this.urls = this.bsFeature.__files
.filter(url => url.indexOf(`_pr_${this.bsLabel}`) >= 0) .filter(url => isPr(url, this.bsLabel))
.map(url => { .map(url => {
return { url } return { url }
}) })
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment