Filter SimpleStates by StateLabel
All checks were successful
E2E Testing / test (push) Successful in 1m32s
All checks were successful
E2E Testing / test (push) Successful in 1m32s
This commit is contained in:
parent
41452f0b9d
commit
bfe500426f
@ -1,5 +1,9 @@
|
|||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
|
<mat-form-field appearance="fill" class="long-form">
|
||||||
|
<mat-label>Filter</mat-label>
|
||||||
|
<input matInput (keyup)="applyFilter($event)" placeholder="Filter" #input>
|
||||||
|
</mat-form-field>
|
||||||
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" multiTemplateDataRows>
|
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" multiTemplateDataRows>
|
||||||
<ng-container matColumnDef="name">
|
<ng-container matColumnDef="name">
|
||||||
<th mat-header-cell *matHeaderCellDef>Label</th>
|
<th mat-header-cell *matHeaderCellDef>Label</th>
|
||||||
|
@ -4,6 +4,8 @@ import {MatTableDataSource} from "@angular/material/table";
|
|||||||
import {animate, state, style, transition, trigger} from "@angular/animations";
|
import {animate, state, style, transition, trigger} from "@angular/animations";
|
||||||
import {MatSnackBar} from "@angular/material/snack-bar";
|
import {MatSnackBar} from "@angular/material/snack-bar";
|
||||||
import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem";
|
import {SimpleGamesystem} from "../../../../game-model/gamesystems/SimpleGamesystem";
|
||||||
|
import {ProductState} from "../../../../game-model/gamesystems/ProductState";
|
||||||
|
import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-simple-state-editor',
|
selector: 'app-simple-state-editor',
|
||||||
@ -21,7 +23,7 @@ export class SimpleStateEditorComponent implements OnInit{
|
|||||||
|
|
||||||
@Input() states: SimpleState[] = [];
|
@Input() states: SimpleState[] = [];
|
||||||
@Input() gamesystem: SimpleGamesystem | undefined
|
@Input() gamesystem: SimpleGamesystem | undefined
|
||||||
dataSource = new MatTableDataSource();
|
dataSource = new MatTableDataSource<SimpleState>();
|
||||||
displayedColumns = ["name", "initial", "edit", "delete"];
|
displayedColumns = ["name", "initial", "edit", "delete"];
|
||||||
columnsToDisplayWithExpand = [...this.displayedColumns, 'expand'];
|
columnsToDisplayWithExpand = [...this.displayedColumns, 'expand'];
|
||||||
expandedElement: SimpleState | null = null;
|
expandedElement: SimpleState | null = null;
|
||||||
@ -34,6 +36,9 @@ export class SimpleStateEditorComponent implements OnInit{
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.dataSource.data = this.states;
|
this.dataSource.data = this.states;
|
||||||
|
this.dataSource.filterPredicate = (data: SimpleState, filter: string) => {
|
||||||
|
return data.stateLabel.toLowerCase().includes(filter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editState(state: SimpleState) {
|
editState(state: SimpleState) {
|
||||||
@ -83,4 +88,9 @@ export class SimpleStateEditorComponent implements OnInit{
|
|||||||
onStateChange() {
|
onStateChange() {
|
||||||
this.gamesystem!.onModifyContent();
|
this.gamesystem!.onModifyContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applyFilter(event: KeyboardEvent) {
|
||||||
|
const filterValue = (event.target as HTMLInputElement).value;
|
||||||
|
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user