diff --git a/src/ui/databrowserModule/databrowser.module.ts b/src/ui/databrowserModule/databrowser.module.ts index 1e7469cda4a142ce4e759870e9c6e7cb76b5cf9b..aa37e7e3e6f16a07d1ac358e9ecf9ad882d45a0f 100644 --- a/src/ui/databrowserModule/databrowser.module.ts +++ b/src/ui/databrowserModule/databrowser.module.ts @@ -32,6 +32,8 @@ import { GetKgSchemaIdFromFullIdPipe } from "./util/getKgSchemaIdFromFullId.pipe import { PreviewFileIconPipe } from "./preview/previewFileIcon.pipe"; import { PreviewFileTypePipe } from "./preview/previewFileType.pipe"; import { SingleDatasetListView } from "./singleDataset/listView/singleDatasetListView.component"; +import { AppendFilerModalityPipe } from "./util/appendFilterModality.pipe"; +import { ResetCounterModalityPipe } from "./util/resetCounterModality.pipe"; @NgModule({ imports:[ @@ -69,7 +71,9 @@ import { SingleDatasetListView } from "./singleDataset/listView/singleDatasetLis RegionBackgroundToRgbPipe, GetKgSchemaIdFromFullIdPipe, PreviewFileIconPipe, - PreviewFileTypePipe + PreviewFileTypePipe, + AppendFilerModalityPipe, + ResetCounterModalityPipe ], exports:[ DataBrowser, diff --git a/src/ui/databrowserModule/databrowser/databrowser.component.ts b/src/ui/databrowserModule/databrowser/databrowser.component.ts index 5cbf3849ed694d796a4cfa7c2b2eb51611a9f880..f7fcc13e7c0ba71b1f0b636b09d0436e2e282ba5 100644 --- a/src/ui/databrowserModule/databrowser/databrowser.component.ts +++ b/src/ui/databrowserModule/databrowser/databrowser.component.ts @@ -71,7 +71,7 @@ export class DataBrowser implements OnChanges, OnDestroy,OnInit{ ) } - ngOnChanges(changes){ + ngOnChanges(){ this.regions = this.regions.map(r => { /** @@ -111,7 +111,6 @@ export class DataBrowser implements OnChanges, OnDestroy,OnInit{ .finally(() => { this.fetchingFlag = false this.dataentriesUpdated.emit(this.dataentries) - this.resetFilters() this.cdr.markForCheck() }) diff --git a/src/ui/databrowserModule/databrowser/databrowser.template.html b/src/ui/databrowserModule/databrowser/databrowser.template.html index 522980dc8b50ea317853eb0a373d706e44e1b9a7..10147fe43734cc11d061f4b8a7cf0d627565dc96 100644 --- a/src/ui/databrowserModule/databrowser/databrowser.template.html +++ b/src/ui/databrowserModule/databrowser/databrowser.template.html @@ -143,7 +143,7 @@ <modality-picker iav-stop="click" class="w-100" - [countedDataM]="countedDataM" + [countedDataM]="visibleCountedDataM | resetcounterModalityPipe | appendFilterModalityPipe : [countedDataM]" (modalityFilterEmitter)="handleModalityFilterEvent($event)" #modalityPickerCmp> diff --git a/src/ui/databrowserModule/modalityPicker/modalityPicker.template.html b/src/ui/databrowserModule/modalityPicker/modalityPicker.template.html index c5a19766ab57bf553be1a5cb6365fa86b73f1f88..0a84ce45d7ab03555da2fac132545f2f7747ad59 100644 --- a/src/ui/databrowserModule/modalityPicker/modalityPicker.template.html +++ b/src/ui/databrowserModule/modalityPicker/modalityPicker.template.html @@ -1,6 +1,7 @@ <mat-checkbox [checked]="datamodality.visible" (change)="toggleModality(datamodality)" + [ngClass]="{'muted': datamodality.occurance === 0}" *ngFor="let datamodality of countedDataM"> {{ datamodality.name }} <span class="text-muted">({{ datamodality.occurance }})</span> </mat-checkbox> \ No newline at end of file diff --git a/src/ui/databrowserModule/util/appendFilterModality.pipe.ts b/src/ui/databrowserModule/util/appendFilterModality.pipe.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef7e740c2ebd398729d6fe9797deb7e4e11b9e99 --- /dev/null +++ b/src/ui/databrowserModule/util/appendFilterModality.pipe.ts @@ -0,0 +1,24 @@ +import { Pipe, PipeTransform } from "@angular/core"; +import { CountedDataModality } from "../databrowser.service"; + +@Pipe({ + name: 'appendFilterModalityPipe' +}) + +export class AppendFilerModalityPipe implements PipeTransform{ + public transform(root: CountedDataModality[], appending: CountedDataModality[][]): CountedDataModality[]{ + let returnArr:CountedDataModality[] = [...root] + for (const mods of appending){ + for (const mod of mods){ + // preserve the visibility + const { visible } = returnArr.find(({ name }) => name === mod.name) || mod + returnArr = returnArr.filter(({ name }) => name !== mod.name) + returnArr = returnArr.concat({ + ...mod, + visible + }) + } + } + return returnArr + } +} \ No newline at end of file diff --git a/src/ui/databrowserModule/util/resetCounterModality.pipe.ts b/src/ui/databrowserModule/util/resetCounterModality.pipe.ts new file mode 100644 index 0000000000000000000000000000000000000000..8f65af67ebc15bf25a02ef0fa05342d5a6ec068b --- /dev/null +++ b/src/ui/databrowserModule/util/resetCounterModality.pipe.ts @@ -0,0 +1,17 @@ +import { Pipe, PipeTransform } from "@angular/core"; +import { CountedDataModality } from "../databrowser.service"; + +@Pipe({ + name: 'resetcounterModalityPipe' +}) + +export class ResetCounterModalityPipe implements PipeTransform{ + public transform(inc: CountedDataModality[]):CountedDataModality[]{ + return inc.map(({ occurance, ...rest }) => { + return { + occurance: 0, + ...rest + } + }) + } +} \ No newline at end of file