From 3c7d0fda056454819f2afdaa0bdd3c640319981c Mon Sep 17 00:00:00 2001
From: Xiao Gui <xgui3783@gmail.com>
Date: Fri, 18 Mar 2022 14:16:07 +0100
Subject: [PATCH] bugfix: include util module bugfix: deep css chore: export
 default store

---
 .../sapiViews/core/rich/module.ts                |  2 ++
 .../autoradiography/autoradiography.style.css    |  5 -----
 src/extra_styles.css                             |  6 ++++++
 src/state/annotations/index.ts                   |  2 +-
 src/state/annotations/store.ts                   |  2 +-
 src/state/atlasAppearance/index.ts               |  2 +-
 src/state/atlasAppearance/store.ts               |  2 +-
 src/state/atlasSelection/store.ts                |  9 ++++++++-
 src/state/plugins/index.ts                       |  2 +-
 src/state/plugins/store.ts                       |  2 +-
 src/state/userInteraction/actions.ts             | 16 +---------------
 src/state/userInteraction/effects.ts             |  4 ++--
 src/state/userInteraction/index.ts               |  2 +-
 src/state/userInteraction/store.ts               |  2 +-
 src/state/userInterface/index.ts                 |  2 +-
 src/state/userInterface/store.ts                 |  4 ++--
 src/state/userPreference/index.ts                |  2 +-
 src/state/userPreference/store.ts                |  4 ++--
 .../viewerCmp/viewerCmp.component.ts             | 13 ++++++-------
 19 files changed, 39 insertions(+), 44 deletions(-)

diff --git a/src/atlasComponents/sapiViews/core/rich/module.ts b/src/atlasComponents/sapiViews/core/rich/module.ts
index ff6369902..90ce115ed 100644
--- a/src/atlasComponents/sapiViews/core/rich/module.ts
+++ b/src/atlasComponents/sapiViews/core/rich/module.ts
@@ -3,6 +3,7 @@ import { NgModule } from "@angular/core";
 import { ReactiveFormsModule } from "@angular/forms";
 import { SxplrFlatHierarchyModule } from "src/components/flatHierarchy";
 import { AngularMaterialModule } from "src/sharedModules";
+import { SapiViewsUtilModule } from "../../util";
 import { SapiViewsCoreRegionModule } from "../region";
 import { HighlightPipe } from "./regionsHierarchy/highlight.pipe";
 import { SapiViewsCoreRichRegionsHierarchy } from "./regionsHierarchy/regionsHierarchy.component";
@@ -15,6 +16,7 @@ import { SapiViewsCoreRichRegionListSearch } from "./regionsListSearch/regionLis
     ReactiveFormsModule,
     SapiViewsCoreRegionModule,
     SxplrFlatHierarchyModule,
+    SapiViewsUtilModule,
   ],
   declarations: [
     SapiViewsCoreRichRegionListSearch,
diff --git a/src/atlasComponents/sapiViews/features/receptors/autoradiography/autoradiography.style.css b/src/atlasComponents/sapiViews/features/receptors/autoradiography/autoradiography.style.css
index 833dd425a..e69de29bb 100644
--- a/src/atlasComponents/sapiViews/features/receptors/autoradiography/autoradiography.style.css
+++ b/src/atlasComponents/sapiViews/features/receptors/autoradiography/autoradiography.style.css
@@ -1,5 +0,0 @@
-:host >>> canvas
-{
-  max-width: 100%;
-  max-height: 100%;
-}
\ No newline at end of file
diff --git a/src/extra_styles.css b/src/extra_styles.css
index 4dc17c826..d7e99033c 100644
--- a/src/extra_styles.css
+++ b/src/extra_styles.css
@@ -871,3 +871,9 @@ quick-tour-unit svg
   stroke-linecap: round;
   stroke-linejoin: round;
 }
+
+sxplr-sapiviews-features-receptor-autoradiograph canvas
+{
+  max-width: 100%;
+  max-height: 100%;
+}
diff --git a/src/state/annotations/index.ts b/src/state/annotations/index.ts
index e044bea3d..4071cad11 100644
--- a/src/state/annotations/index.ts
+++ b/src/state/annotations/index.ts
@@ -1,4 +1,4 @@
 export { actions } from "./actions"
-export { Annotation, AnnotationState, reducer } from "./store"
+export { Annotation, AnnotationState, reducer, defaultState } from "./store"
 export { nameSpace } from "./const"
 export * as selectors from "./selectors"
\ No newline at end of file
diff --git a/src/state/annotations/store.ts b/src/state/annotations/store.ts
index 6278ac4e6..2cb8146bf 100644
--- a/src/state/annotations/store.ts
+++ b/src/state/annotations/store.ts
@@ -8,7 +8,7 @@ export type AnnotationState = {
   annotations: Annotation[]
 }
 
-const defaultState: AnnotationState = {
+export const defaultState: AnnotationState = {
   annotations: []
 }
 
diff --git a/src/state/atlasAppearance/index.ts b/src/state/atlasAppearance/index.ts
index 6d95a7d9c..53a3eef57 100644
--- a/src/state/atlasAppearance/index.ts
+++ b/src/state/atlasAppearance/index.ts
@@ -1,4 +1,4 @@
 export * as actions from "./action"
 export * as selectors from "./selector"
 export { nameSpace, ColorMapCustomLayer, CustomLayer, NgLayerCustomLayer } from "./const"
-export { reducer, AtlasAppearanceStore } from "./store"
\ No newline at end of file
+export { reducer, AtlasAppearanceStore, defaultState } from "./store"
\ No newline at end of file
diff --git a/src/state/atlasAppearance/store.ts b/src/state/atlasAppearance/store.ts
index 648104a70..6c060da26 100644
--- a/src/state/atlasAppearance/store.ts
+++ b/src/state/atlasAppearance/store.ts
@@ -9,7 +9,7 @@ export type AtlasAppearanceStore = {
   customLayers: CustomLayer[]
 }
 
-const defaultState: AtlasAppearanceStore = {
+export const defaultState: AtlasAppearanceStore = {
   octantRemoval: true,
   showDelineation: true,
   customLayers: []
diff --git a/src/state/atlasSelection/store.ts b/src/state/atlasSelection/store.ts
index d051a5475..11ac3f534 100644
--- a/src/state/atlasSelection/store.ts
+++ b/src/state/atlasSelection/store.ts
@@ -3,6 +3,12 @@ import { SapiAtlasModel, SapiParcellationModel, SapiRegionModel, SapiSpaceModel
 import * as actions from "./actions"
 import { ViewerMode, BreadCrumb } from "./const"
 
+function getRegionLabelIndex(atlas: SapiAtlasModel, tmpl: SapiSpaceModel, parc: SapiParcellationModel, region: SapiRegionModel) {
+  const lblIdx = Number(region?.hasAnnotation?.internalIdentifier)
+  if (isNaN(lblIdx)) return null
+  return lblIdx
+}
+
 export type AtlasSelectionState = {
   selectedAtlas: SapiAtlasModel
   selectedTemplate: SapiSpaceModel
@@ -87,9 +93,10 @@ const reducer = createReducer(
        * 
        * ignore
        */
+      const { selectedAtlas, selectedParcellation, selectedTemplate } = state
       if (
         !region.hasAnnotation?.visualizedIn
-        && region.hasAnnotation?.internalIdentifier === 'unknown'
+        && !getRegionLabelIndex(selectedAtlas, selectedTemplate, selectedParcellation, region)
       ) {
         return { ...state }
       }
diff --git a/src/state/plugins/index.ts b/src/state/plugins/index.ts
index 11548c69f..d7324fb27 100644
--- a/src/state/plugins/index.ts
+++ b/src/state/plugins/index.ts
@@ -1,5 +1,5 @@
 export * as selectors from "./selectors"
 export * as actions from "./actions"
-export { reducer, PluginStore } from "./store"
+export { reducer, PluginStore, defaultState } from "./store"
 export { Effects } from "./effects"
 export { nameSpace, INIT_MANIFEST_SRC } from "./const"
\ No newline at end of file
diff --git a/src/state/plugins/store.ts b/src/state/plugins/store.ts
index 0648d1fa6..83bb211ec 100644
--- a/src/state/plugins/store.ts
+++ b/src/state/plugins/store.ts
@@ -6,7 +6,7 @@ export type PluginStore = {
   initManifests: Record<string, string>
 }
 
-const defaultState: PluginStore = {
+export const defaultState: PluginStore = {
   initManifests: {}
 }
 
diff --git a/src/state/userInteraction/actions.ts b/src/state/userInteraction/actions.ts
index 2030f7344..d7b237184 100644
--- a/src/state/userInteraction/actions.ts
+++ b/src/state/userInteraction/actions.ts
@@ -1,22 +1,8 @@
 import { createAction, props } from "@ngrx/store"
 import { nameSpace } from "./const"
-import * as atlasSelection from "../atlasSelection"
-import { SapiRegionModel, SapiSpatialFeatureModel, SapiVolumeModel } from "src/atlasComponents/sapi"
-import * as userInterface from "../userInterface"
+import { SapiRegionModel } from "src/atlasComponents/sapi"
 import { SapiFeatureModel } from "src/atlasComponents/sapi/type"
 
-export const {
-  clearSelectedRegions,
-  clearStandAloneVolumes,
-  clearNonBaseParcLayer,
-} = atlasSelection.actions
-
-export const {
-  openSidePanel,
-  closeSidePanel,
-  expandSidePanelDetailView,
-} = userInterface.actions
-
 export const mouseOverAnnotations = createAction(
   `${nameSpace} mouseOverAnnotations`,
   props<{
diff --git a/src/state/userInteraction/effects.ts b/src/state/userInteraction/effects.ts
index ee8baa706..5d4986ad5 100644
--- a/src/state/userInteraction/effects.ts
+++ b/src/state/userInteraction/effects.ts
@@ -1,14 +1,14 @@
 import { Injectable } from "@angular/core";
 import { Actions, createEffect, ofType } from "@ngrx/effects";
-import * as actions from "./actions"
 import * as atlasSelectionActions from "../atlasSelection/actions"
+import * as userInterface from "../userInterface"
 import { mapTo } from "rxjs/operators";
 
 @Injectable()
 export class Effect {
   onStandAloneVolumesExistCloseMatDrawer = createEffect(() => this.action.pipe(
     ofType(atlasSelectionActions.clearStandAloneVolumes),
-    mapTo(actions.closeSidePanel())
+    mapTo(userInterface.actions.closeSidePanel())
   ))
 
   constructor(private action: Actions){
diff --git a/src/state/userInteraction/index.ts b/src/state/userInteraction/index.ts
index 4903f7b16..44d760341 100644
--- a/src/state/userInteraction/index.ts
+++ b/src/state/userInteraction/index.ts
@@ -2,4 +2,4 @@ export { Effect } from "./effects"
 export { nameSpace } from "./const"
 export * as actions from "./actions"
 export * as selectors from "./selectors"
-export { reducer, UserInteraction } from "./store"
\ No newline at end of file
+export { reducer, UserInteraction, defaultState } from "./store"
\ No newline at end of file
diff --git a/src/state/userInteraction/store.ts b/src/state/userInteraction/store.ts
index 0ce97c2ff..9d7368e8e 100644
--- a/src/state/userInteraction/store.ts
+++ b/src/state/userInteraction/store.ts
@@ -7,7 +7,7 @@ export type UserInteraction = {
   selectedFeature: SapiFeatureModel
 }
 
-const defaultState: UserInteraction = {
+export const defaultState: UserInteraction = {
   selectedFeature: null,
   mouseoverRegions: []
 }
diff --git a/src/state/userInterface/index.ts b/src/state/userInterface/index.ts
index 2329de3b3..382825ba3 100644
--- a/src/state/userInterface/index.ts
+++ b/src/state/userInterface/index.ts
@@ -1,5 +1,5 @@
 export * as actions from "./actions"
 export * as selectors from "./selectors"
 export { nameSpace, PanelMode } from "./const"
-export { reducer, UiStore } from "./store"
+export { reducer, UiStore, defaultState } from "./store"
 export { Effects } from "./effects"
diff --git a/src/state/userInterface/store.ts b/src/state/userInterface/store.ts
index 3fcea7d7e..cc854e820 100644
--- a/src/state/userInterface/store.ts
+++ b/src/state/userInterface/store.ts
@@ -9,7 +9,7 @@ export type UiStore = {
   showDelineation: boolean
 }
 
-const defaultStore: UiStore = {
+export const defaultState: UiStore = {
   panelMode: 'FOUR_PANEL',
   panelOrder: '0123',
   octantRemoval: false,
@@ -17,7 +17,7 @@ const defaultStore: UiStore = {
 }
 
 export const reducer = createReducer(
-  defaultStore,
+  defaultState,
   on(
     actions.setPanelMode,
     (state, { panelMode }) => {
diff --git a/src/state/userPreference/index.ts b/src/state/userPreference/index.ts
index e8e485b4d..1c7a493f7 100644
--- a/src/state/userPreference/index.ts
+++ b/src/state/userPreference/index.ts
@@ -1,4 +1,4 @@
-export { UserPreference, defaultUserPreferenceStore, reducer } from "./store"
+export { UserPreference, reducer, defaultState } from "./store"
 export { nameSpace } from "./const"
 export * as actions from "./actions"
 export * as selectors from "./selectors"
diff --git a/src/state/userPreference/store.ts b/src/state/userPreference/store.ts
index b80d510d8..dbf0be955 100644
--- a/src/state/userPreference/store.ts
+++ b/src/state/userPreference/store.ts
@@ -15,7 +15,7 @@ export type UserPreference = {
   agreeKgTos: boolean
 }
 
-export const defaultUserPreferenceStore: UserPreference = {
+export const defaultState: UserPreference = {
   useMobileUi: JSON.parse(localStorage.getItem(LOCAL_STORAGE_CONST.MOBILE_UI)),
   gpuLimit: Number(localStorage.getItem(LOCAL_STORAGE_CONST.GPU_LIMIT)) || defaultGpuLimit,
   useAnimation: !localStorage.getItem(LOCAL_STORAGE_CONST.ANIMATION),
@@ -26,7 +26,7 @@ export const defaultUserPreferenceStore: UserPreference = {
 }
 
 export const reducer = createReducer(
-  defaultUserPreferenceStore,
+  defaultState,
   on(
     actions.setAnimationFlag,
     (state, { flag }) => {
diff --git a/src/viewerModule/viewerCmp/viewerCmp.component.ts b/src/viewerModule/viewerCmp/viewerCmp.component.ts
index 02e48a907..de8f1abaf 100644
--- a/src/viewerModule/viewerCmp/viewerCmp.component.ts
+++ b/src/viewerModule/viewerCmp/viewerCmp.component.ts
@@ -11,8 +11,7 @@ import { ContextMenuService, TContextMenuReg } from "src/contextMenuModule";
 import { ComponentStore } from "../componentStore";
 import { DialogService } from "src/services/dialogService.service";
 import { SAPI, SapiRegionModel } from "src/atlasComponents/sapi";
-import { actions, fromRootStore } from "src/state/atlasSelection";
-import { atlasSelection, userInteraction } from "src/state";
+import { atlasSelection, userInteraction, } from "src/state";
 import { SapiSpatialFeatureModel, SapiFeatureModel, SapiParcellationModel } from "src/atlasComponents/sapi/type";
 
 type TCStoreViewerCmp = {
@@ -117,7 +116,7 @@ export class ViewerCmp implements OnDestroy {
   )
 
   public allAvailableParcellations$ = this.store$.pipe(
-    fromRootStore.allAvailParcs(this.sapi)
+    atlasSelection.fromRootStore.allAvailParcs(this.sapi)
   )
 
   public selectedRegions$ = this.store$.pipe(
@@ -318,13 +317,13 @@ export class ViewerCmp implements OnDestroy {
 
   public clearRoi(){
     this.store$.dispatch(
-      actions.clearSelectedRegions()
+      atlasSelection.actions.clearSelectedRegions()
     )
   }
 
   public selectRoi(roi: SapiRegionModel) {
     this.store$.dispatch(
-      actions.selectRegion({
+      atlasSelection.actions.selectRegion({
         region: roi
       })
     )
@@ -332,7 +331,7 @@ export class ViewerCmp implements OnDestroy {
 
   public exitSpecialViewMode(){
     this.store$.dispatch(
-      actions.clearViewerMode()
+      atlasSelection.actions.clearViewerMode()
     )
   }
 
@@ -376,7 +375,7 @@ export class ViewerCmp implements OnDestroy {
     if ((feat as SapiSpatialFeatureModel).location) {
       const feature = feat as SapiSpatialFeatureModel
       this.store$.dispatch(
-        actions.navigateTo({
+        atlasSelection.actions.navigateTo({
           navigation: {
             orientation: [0, 0, 0, 1],
             position: feature.location.center.coordinates.map(v => (v.unit as number) * 1e6)
-- 
GitLab