From 058c8b54f86aaa5f961b58c5e00769d3cd1f3fe1 Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Fri, 3 Mar 2023 14:16:43 +0100 Subject: [PATCH] chore: remove unused actions minor refactor: connectivity filter logic --- .../connectivity/excludeConnectivity.pipe.ts | 11 ++--- src/features/entry/entry.component.html | 40 +++++++++++-------- src/state/atlasSelection/actions.ts | 7 ---- src/state/atlasSelection/effects.ts | 18 --------- 4 files changed, 29 insertions(+), 47 deletions(-) diff --git a/src/features/connectivity/excludeConnectivity.pipe.ts b/src/features/connectivity/excludeConnectivity.pipe.ts index 829679fa1..736e5d56a 100644 --- a/src/features/connectivity/excludeConnectivity.pipe.ts +++ b/src/features/connectivity/excludeConnectivity.pipe.ts @@ -1,5 +1,8 @@ import { Pipe, PipeTransform } from "@angular/core" -import { Input } from "postcss" +import { PathReturn } from "src/atlasComponents/sapi/typeV3" +import { KeyValue } from "@angular/common" + +type DS = KeyValue<string, PathReturn<"/feature/_types">["items"]> @Pipe({ name: 'isConnectivity', @@ -7,9 +10,7 @@ import { Input } from "postcss" }) export class ExcludeConnectivityPipe implements PipeTransform { - public transform(datasets: any[], isConnectivity: boolean): any[] { - return datasets? isConnectivity? [datasets.find(d => d.key === 'connectivity')] - : datasets.filter(d => d.key !== 'connectivity') - : null + public transform(datasets: DS[], filterForConnectivityFlag: boolean): DS[] { + return (datasets || []).filter(d => (d.key === 'connectivity') === filterForConnectivityFlag) } } diff --git a/src/features/entry/entry.component.html b/src/features/entry/entry.component.html index b8e7b76ff..899e7a4d0 100644 --- a/src/features/entry/entry.component.html +++ b/src/features/entry/entry.component.html @@ -61,24 +61,30 @@ </div> </mat-expansion-panel> - <mat-expansion-panel sxplr-sapiviews-features-connectivity-check - #connectivityAccordion - *ngIf="(cateogryCollections$ | async | keyvalue | isConnectivity : true) as connectivity"> - <mat-expansion-panel-header> - <mat-panel-title> - {{ connectivity[0].key }} - </mat-panel-title> - </mat-expansion-panel-header> - <sxplr-features-connectivity-browser class="pe-all flex-shrink-1" - [region]="region" - [sxplr-features-connectivity-browser-atlas]="atlas | async" - [sxplr-features-connectivity-browser-template]="template" - [sxplr-features-connectivity-browser-parcellation]="parcellation" - [accordionExpanded]="connectivityAccordion.expanded" - [types]="connectivity[0].value"> - </sxplr-features-connectivity-browser> + <ng-template [ngIf]="cateogryCollections$ | async | keyvalue | isConnectivity : true" let-connectivity> + <ng-template ngFor [ngForOf]="connectivity" let-conn> + <mat-expansion-panel sxplr-sapiviews-features-connectivity-check + #connectivityAccordion + *ngIf="conn"> + <mat-expansion-panel-header> + <mat-panel-title> + {{ conn.key }} + </mat-panel-title> + </mat-expansion-panel-header> + + <sxplr-features-connectivity-browser class="pe-all flex-shrink-1" + [region]="region" + [sxplr-features-connectivity-browser-atlas]="atlas | async" + [sxplr-features-connectivity-browser-template]="template" + [sxplr-features-connectivity-browser-parcellation]="parcellation" + [accordionExpanded]="connectivityAccordion.expanded" + [types]="conn.value"> + </sxplr-features-connectivity-browser> + + </mat-expansion-panel> + </ng-template> + </ng-template> - </mat-expansion-panel> </mat-accordion> diff --git a/src/state/atlasSelection/actions.ts b/src/state/atlasSelection/actions.ts index 357b6b181..3634619d2 100644 --- a/src/state/atlasSelection/actions.ts +++ b/src/state/atlasSelection/actions.ts @@ -154,13 +154,6 @@ export const clearViewerMode = createAction( `${nameSpace} clearViewerMode`, ) -export const toggleRegionSelect = createAction( - `${nameSpace} toggleRegionSelect`, - props<{ - region: SxplrRegion - }>() -) - export const toggleRegionSelectById = createAction( `${nameSpace} toggleRegionSelectById`, props<{ diff --git a/src/state/atlasSelection/effects.ts b/src/state/atlasSelection/effects.ts index 5b1745e2a..1786b5cca 100644 --- a/src/state/atlasSelection/effects.ts +++ b/src/state/atlasSelection/effects.ts @@ -363,24 +363,6 @@ export class Effect { ) )) - onRegionToggleSelect = createEffect(() => this.action.pipe( - ofType(actions.toggleRegionSelect), - withLatestFrom( - this.store.pipe( - select(selectors.selectedRegions) - ) - ), - map(([ { region }, regions ]) => { - const selectedRegionsIndicies = regions.map(r => r["@id"]) - const roiIndex = selectedRegionsIndicies.indexOf(region["@id"]) - return actions.setSelectedRegions({ - regions: roiIndex >= 0 - ? [...regions.slice(0, roiIndex), ...regions.slice(roiIndex + 1)] - : [...regions, region] - }) - }) - )) - constructor( private action: Actions, private sapiSvc: SAPI, -- GitLab