issue-5-gamesystems #6

Merged
sebastian merged 24 commits from issue-5-gamesystems into main 2024-02-10 13:30:37 +01:00
3 changed files with 13 additions and 2 deletions
Showing only changes of commit 19cfe82905 - Show all commits

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"> <ng-container matColumnDef="delete">
<th mat-header-cell *matHeaderCellDef></th> <th mat-header-cell *matHeaderCellDef></th>
<td mat-cell *matCellDef="let state"> <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> </td>
</ng-container> </ng-container>

View File

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