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 { 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',
......
......@@ -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()
}
......
......@@ -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>
......@@ -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 }
})
......
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