From 8c7e2ae78c8f7213d83849115488c3520e1c312c Mon Sep 17 00:00:00 2001
From: Xiao Gui <xgui3783@gmail.com>
Date: Fri, 14 Jul 2023 11:59:59 +0200
Subject: [PATCH] fix: region selectable fix: remove exmpt lbl on voi

---
 docs/releases/v2.12.3.md                      |  6 +++
 mkdocs.yml                                    |  1 +
 package.json                                  |  2 +-
 src/atlasComponents/sapi/sapi.service.ts      |  2 +-
 .../sapiViews/core/region/module.ts           |  2 +
 .../regionsHierarchy.component.ts             |  9 +++--
 .../regionsHierarchy.template.html            |  6 ++-
 .../treeView/treeView.template.html           |  6 ++-
 src/features/guards.ts                        |  7 +---
 .../viewerCmp/viewerCmp.component.ts          | 39 ++++++++++++++++---
 .../viewerCmp/viewerCmp.template.html         |  1 +
 11 files changed, 61 insertions(+), 20 deletions(-)
 create mode 100644 docs/releases/v2.12.3.md

diff --git a/docs/releases/v2.12.3.md b/docs/releases/v2.12.3.md
new file mode 100644
index 000000000..fb6c01665
--- /dev/null
+++ b/docs/releases/v2.12.3.md
@@ -0,0 +1,6 @@
+# v2.12.3
+
+## Bugfix
+
+- Visually distinguish regions that are mapped in a space to those that are not
+- Remove experimental flag to VOI
diff --git a/mkdocs.yml b/mkdocs.yml
index 3b54fefc8..46599c968 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -33,6 +33,7 @@ nav:
     - Fetching datasets: 'advanced/datasets.md'
     - Display non-atlas volumes: 'advanced/otherVolumes.md'
   - Release notes:
+    - v2.12.3: 'releases/v2.12.3.md'
     - v2.12.2: 'releases/v2.12.2.md'
     - v2.12.1: 'releases/v2.12.1.md'
     - v2.12.0: 'releases/v2.12.0.md'
diff --git a/package.json b/package.json
index 5746b8bb3..9a950eda8 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "siibra-explorer",
-  "version": "2.12.2",
+  "version": "2.12.3",
   "description": "siibra-explorer - explore brain atlases. Based on humanbrainproject/nehuba & google/neuroglancer. Built with angular",
   "scripts": {
     "lint": "eslint src --ext .ts",
diff --git a/src/atlasComponents/sapi/sapi.service.ts b/src/atlasComponents/sapi/sapi.service.ts
index 50db12384..1faa428f1 100644
--- a/src/atlasComponents/sapi/sapi.service.ts
+++ b/src/atlasComponents/sapi/sapi.service.ts
@@ -461,7 +461,7 @@ export class SAPI{
     )
   }
 
-  private async getLabelledMap(parcellation: SxplrParcellation, template: SxplrTemplate) {
+  async getLabelledMap(parcellation: SxplrParcellation, template: SxplrTemplate) {
     // No need to retrieve sapi object, since we know @id maps to id
     return await this.v3Get("/map", {
       query: {
diff --git a/src/atlasComponents/sapiViews/core/region/module.ts b/src/atlasComponents/sapiViews/core/region/module.ts
index 6e9140d0b..dc8a97117 100644
--- a/src/atlasComponents/sapiViews/core/region/module.ts
+++ b/src/atlasComponents/sapiViews/core/region/module.ts
@@ -10,6 +10,7 @@ import { SapiViewsUtilModule } from "../../util/module";
 import { SapiViewsCoreRegionRegionListItem } from "./region/listItem/region.listItem.component";
 import { SapiViewsCoreRegionRegionBase } from "./region/region.base.directive";
 import { SapiViewsCoreRegionRegionRich } from "./region/rich/region.rich.component";
+import { MatTooltipModule } from "@angular/material/tooltip";
 
 @NgModule({
   imports: [
@@ -21,6 +22,7 @@ import { SapiViewsCoreRegionRegionRich } from "./region/rich/region.rich.compone
     StrictLocalModule,
     FeatureModule,
     ReadmoreModule,
+    MatTooltipModule,
   ],
   declarations: [
     SapiViewsCoreRegionRegionListItem,
diff --git a/src/atlasComponents/sapiViews/core/rich/regionsHierarchy/regionsHierarchy.component.ts b/src/atlasComponents/sapiViews/core/rich/regionsHierarchy/regionsHierarchy.component.ts
index ac272bc82..0c85164a9 100644
--- a/src/atlasComponents/sapiViews/core/rich/regionsHierarchy/regionsHierarchy.component.ts
+++ b/src/atlasComponents/sapiViews/core/rich/regionsHierarchy/regionsHierarchy.component.ts
@@ -20,6 +20,7 @@ const filterByRegexPipe = new FilterByRegexPipe()
 })
 
 export class SapiViewsCoreRichRegionsHierarchy {
+  TXT_CANNOT_BE_SELECTED = "Not mapped in this template space."
 
   static IsParent(region: SxplrRegion, parentRegion: SxplrRegion): boolean {
     return region.parentIds.some(id => parentRegion.id === id)
@@ -36,6 +37,9 @@ export class SapiViewsCoreRichRegionsHierarchy {
     )
   }
 
+  @Input('sxplr-sapiviews-core-rich-regionshierarchy-label-mapped-region-names')
+  labelMappedRegionNames: string[] = []
+
   @Input('sxplr-sapiviews-core-rich-regionshierarchy-accent-regions')
   accentedRegions: SxplrRegion[] = []
 
@@ -100,10 +104,9 @@ export class SapiViewsCoreRichRegionsHierarchy {
   
   onNodeClick({node: roi, event }: {node: SxplrRegion, event: MouseEvent}){
     /**
-     * only allow leave nodes to be selectable for now
+     * Only allow the regions that are labelled mapped to be selected.
      */
-    const children = this._regions.filter(r => this.isParent(r, roi))
-    if (children.length > 0) {
+    if (!this.labelMappedRegionNames.includes(roi.name)) {
       return
     }
     if (event.ctrlKey) {
diff --git a/src/atlasComponents/sapiViews/core/rich/regionsHierarchy/regionsHierarchy.template.html b/src/atlasComponents/sapiViews/core/rich/regionsHierarchy/regionsHierarchy.template.html
index 762ae45d8..fe58b7efc 100644
--- a/src/atlasComponents/sapiViews/core/rich/regionsHierarchy/regionsHierarchy.template.html
+++ b/src/atlasComponents/sapiViews/core/rich/regionsHierarchy/regionsHierarchy.template.html
@@ -14,10 +14,12 @@
 
 </mat-form-field>
 
-<ng-template #tmplRef let-region>
+<ng-template #tmplRef let-region let-last="last">
   <div class="mat-body sxplr-d-flex sxplr-align-items-center sxplr-h-100 region-tmpl"
+    [matTooltip]="last && !labelMappedRegionNames.includes(region.name) ? TXT_CANNOT_BE_SELECTED : null"
     [ngClass]="{
-      'sxplr-custom-cmp accent': accentedRegions | includes : region
+      'sxplr-custom-cmp accent': accentedRegions | includes : region,
+      'muted-7': !labelMappedRegionNames.includes(region.name)
     }"
     [innerHTML]="region.name | hightlightPipe : searchTerm">
   </div>
diff --git a/src/components/flatHierarchy/treeView/treeView.template.html b/src/components/flatHierarchy/treeView/treeView.template.html
index 730cd04b0..7ecb9798a 100644
--- a/src/components/flatHierarchy/treeView/treeView.template.html
+++ b/src/components/flatHierarchy/treeView/treeView.template.html
@@ -23,7 +23,8 @@
     <ng-template
       [ngTemplateOutlet]="phTmpl"
       [ngTemplateOutletContext]="{
-        $implicit: node
+        $implicit: node,
+        last: !node.expandable
       }">
     </ng-template>
 
@@ -51,7 +52,8 @@
       <ng-template
         [ngTemplateOutlet]="renderNodeTmplRef"
         [ngTemplateOutletContext]="{
-          $implicit: node.node
+          $implicit: node.node,
+          last: !node.expandable
         }">
       </ng-template>
     </div>
diff --git a/src/features/guards.ts b/src/features/guards.ts
index fefbc7a0b..eff1ea272 100644
--- a/src/features/guards.ts
+++ b/src/features/guards.ts
@@ -8,11 +8,6 @@ export function isVoiData(feature: unknown): feature is VoiFeature {
   return !!feature['bbox']
 }
 
-export function notQuiteRight(feature: unknown): string[] {
-  if (feature['name'].includes("Cellular level 3D reconstructed volumes at 1µm resolution")) {
-    return [
-      "This volume is currently not displayed correctly. We are working to restore the functionality."
-    ]
-  }
+export function notQuiteRight(_feature: unknown): string[] {
   return []
 }
diff --git a/src/viewerModule/viewerCmp/viewerCmp.component.ts b/src/viewerModule/viewerCmp/viewerCmp.component.ts
index 75f18fd1e..8a5ed8f0a 100644
--- a/src/viewerModule/viewerCmp/viewerCmp.component.ts
+++ b/src/viewerModule/viewerCmp/viewerCmp.component.ts
@@ -1,7 +1,7 @@
 import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, TemplateRef, ViewChild } from "@angular/core";
 import { select, Store } from "@ngrx/store";
-import { combineLatest, Observable, Subscription } from "rxjs";
-import { debounceTime, map, shareReplay } from "rxjs/operators";
+import { combineLatest, Observable, of, Subscription } from "rxjs";
+import { debounceTime, map, shareReplay, switchMap } from "rxjs/operators";
 import { CONST, ARIA_LABELS, QUICKTOUR_DESC } from 'common/constants'
 import { animate, state, style, transition, trigger } from "@angular/animations";
 import { IQuickTourData } from "src/ui/quickTour";
@@ -139,15 +139,41 @@ export class ViewerCmp implements OnDestroy {
     select(atlasSelection.selectors.relevantSelectedPoint)
   )
 
-  public view$ = combineLatest([
+  #currentMap$ = combineLatest([
+    this.#templateSelected$,
+    this.#parcellationSelected$
+  ]).pipe(
+    switchMap(([tmpl, parc]) => tmpl && parc ? this.sapi.getLabelledMap(parc, tmpl) : of(null))
+  )
+
+
+  #view0$ = combineLatest([
     this.#selectedRegions$,
     this.#viewerMode$,
     this.#selectedFeature$,
     this.#selectedPoint$,
     this.#templateSelected$,
-    this.#parcellationSelected$
+    this.#parcellationSelected$,
   ]).pipe(
-    map(([ selectedRegions, viewerMode, selectedFeature, selectedPoint, selectedTemplate, selectedParcellation ]) => {
+    map(([ selectedRegions, viewerMode, selectedFeature, selectedPoint, selectedTemplate, selectedParcellation ]) => ({
+      selectedRegions, viewerMode, selectedFeature, selectedPoint, selectedTemplate, selectedParcellation
+    }))
+  )
+
+  #view1$ = combineLatest([
+    this.#currentMap$,
+  ]).pipe(
+    map(( [ currentMap ] ) => ({
+      currentMap
+    }))
+  )
+
+  public view$ = combineLatest([
+    this.#view0$,
+    this.#view1$,
+  ]).pipe(
+    map(([v0, v1]) => ({ ...v0, ...v1 })),
+    map(({ selectedRegions, viewerMode, selectedFeature, selectedPoint, selectedTemplate, selectedParcellation, currentMap }) => {
       let spatialObjectTitle: string
       let spatialObjectSubtitle: string
       if (selectedPoint) {
@@ -162,6 +188,8 @@ export class ViewerCmp implements OnDestroy {
       if (!!selectedTemplate) {
         spatialObjectSubtitle = selectedTemplate.name
       }
+
+      const labelMappedRegionNames = currentMap && Object.keys(currentMap.indices) || []
       return {
         viewerMode,
         selectedRegions,
@@ -169,6 +197,7 @@ export class ViewerCmp implements OnDestroy {
         selectedPoint,
         selectedTemplate,
         selectedParcellation,
+        labelMappedRegionNames,
 
         /**
          * Selected Spatial Object
diff --git a/src/viewerModule/viewerCmp/viewerCmp.template.html b/src/viewerModule/viewerCmp/viewerCmp.template.html
index 459fb19e8..283145b65 100644
--- a/src/viewerModule/viewerCmp/viewerCmp.template.html
+++ b/src/viewerModule/viewerCmp/viewerCmp.template.html
@@ -540,6 +540,7 @@
       <sxplr-sapiviews-core-rich-regionshierarchy
         class="sxplr-w-100 sxplr-flex-var"
         [sxplr-sapiviews-core-rich-regionshierarchy-regions]="allAvailableRegions$ | async"
+        [sxplr-sapiviews-core-rich-regionshierarchy-label-mapped-region-names]="view.labelMappedRegionNames"
         [sxplr-sapiviews-core-rich-regionshierarchy-accent-regions]="view.selectedRegions"
         (sxplr-sapiviews-core-rich-regionshierarchy-region-select)="selectRoi($event)"
         (sxplr-sapiviews-core-rich-regionshierarchy-region-toggle)="toggleRoi($event)"
-- 
GitLab