From bfe500426fe4d249378b5678c38bfcf21b82d43f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 16 Feb 2024 19:54:36 +0100 Subject: [PATCH] Filter SimpleStates by StateLabel --- .../simple-state-editor.component.html | 4 ++++ .../simple-state-editor.component.ts | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html index f198dc9..1100328 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html @@ -1,5 +1,9 @@ + + Filter + + diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts index 76c5bef..3d4d1ed 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts @@ -4,6 +4,8 @@ import {MatTableDataSource} from "@angular/material/table"; import {animate, state, style, transition, trigger} from "@angular/animations"; import {MatSnackBar} from "@angular/material/snack-bar"; import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem"; +import {ProductState} from "../../../../game-model/gamesystems/ProductState"; +import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; @Component({ selector: 'app-simple-state-editor', @@ -21,7 +23,7 @@ export class SimpleStateEditorComponent implements OnInit{ @Input() states: SimpleState[] = []; @Input() gamesystem: SimpleGamesystem | undefined - dataSource = new MatTableDataSource(); + dataSource = new MatTableDataSource(); displayedColumns = ["name", "initial", "edit", "delete"]; columnsToDisplayWithExpand = [...this.displayedColumns, 'expand']; expandedElement: SimpleState | null = null; @@ -34,6 +36,9 @@ export class SimpleStateEditorComponent implements OnInit{ ngOnInit() { this.dataSource.data = this.states; + this.dataSource.filterPredicate = (data: SimpleState, filter: string) => { + return data.stateLabel.toLowerCase().includes(filter); + } } editState(state: SimpleState) { @@ -83,4 +88,9 @@ export class SimpleStateEditorComponent implements OnInit{ onStateChange() { this.gamesystem!.onModifyContent(); } + + applyFilter(event: KeyboardEvent) { + const filterValue = (event.target as HTMLInputElement).value; + this.dataSource.filter = filterValue.trim().toLowerCase(); + } }
Label