Delete States (only top-level simple-gamesystems)
Some checks failed
E2E Testing / test (push) Failing after 1m28s

This commit is contained in:
Sebastian Böckelmann 2024-02-10 11:48:58 +01:00
parent e7809df01f
commit 19cfe82905
3 changed files with 13 additions and 2 deletions

View File

@ -1 +1 @@
<app-simple-state-editor [states]="simpleGamesystem!.states"></app-simple-state-editor>
<app-simple-state-editor [states]="simpleGamesystem!.states" [gamesystem]="simpleGamesystem"></app-simple-state-editor>

View File

@ -48,7 +48,7 @@
<ng-container matColumnDef="delete">
<th mat-header-cell *matHeaderCellDef></th>
<td mat-cell *matCellDef="let state">
<button mat-icon-button color="warn"><mat-icon>delete</mat-icon></button>
<button mat-icon-button color="warn" (click)="deleteState(state)"><mat-icon>delete</mat-icon></button>
</td>
</ng-container>

View File

@ -3,6 +3,7 @@ import {SimpleState} from "../../../../game-model/gamesystems/SimpleState";
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";
@Component({
selector: 'app-simple-state-editor',
@ -19,6 +20,7 @@ import {MatSnackBar} from "@angular/material/snack-bar";
export class SimpleStateEditorComponent implements OnInit{
@Input() states: SimpleState[] = [];
@Input() gamesystem: SimpleGamesystem | undefined
dataSource = new MatTableDataSource();
displayedColumns = ["name", "initial", "edit", "delete"];
columnsToDisplayWithExpand = [...this.displayedColumns, 'expand'];
@ -57,4 +59,13 @@ export class SimpleStateEditorComponent implements OnInit{
}
return false;
}
deleteState(state: SimpleState) {
if(this.gamesystem == undefined || this.gamesystem.parentGamesystem == undefined) {
this.gamesystem?.removeState(state);
this.dataSource.data = this.gamesystem!.states
} else {
}
}
}