Condition Editor for StateConditions
All checks were successful
E2E Testing / test (push) Successful in 1m29s

This commit is contained in:
Sebastian Böckelmann 2024-02-18 17:50:08 +01:00
parent 8f45d18e40
commit 5dafce8a91
4 changed files with 25 additions and 1 deletions

View File

@ -0,0 +1,7 @@
.mat-column-edit, .mat-column-delete {
width: 32px;
}
table {
width: 100%;
}

View File

@ -1,4 +1,4 @@
<app-simple-state-editor [states]="simpleGamesystem!.states" [gamesystem]="simpleGamesystem" ></app-simple-state-editor> <app-simple-state-editor [states]="simpleGamesystem!.states" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-state-editor>
<div id="transition-editor"> <div id="transition-editor">
<app-simple-transition-editor [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-transition-editor> <app-simple-transition-editor [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-transition-editor>
</div> </div>

View File

@ -25,6 +25,11 @@
<mat-label>Description</mat-label> <mat-label>Description</mat-label>
<textarea matInput [(ngModel)]="element.stateDescription" rows="3" (ngModelChange)="onStateChange()"></textarea> <textarea matInput [(ngModel)]="element.stateDescription" rows="3" (ngModelChange)="onStateChange()"></textarea>
</mat-form-field> </mat-form-field>
<div class="long-form">
<app-scriptaccount-condition-editor [conditions]="element.conditions" [scriptAccounts]="scriptAccounts"
(onCreateCondition)="onCreateCondition(element, $event)" (onDeleteCondition)="deleteCondition(element, $event)"></app-scriptaccount-condition-editor>
</div>
</div> </div>
</td> </td>
</ng-container> </ng-container>

View File

@ -6,6 +6,8 @@ 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/states/ProductState"; import {ProductState} from "../../../../game-model/gamesystems/states/ProductState";
import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator"; import {LeafGamesystemCalculator} from "../../product-gamesystem-editor/LeafGamesystemCalculator";
import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount";
import {ScriptAccountCondition} from "../../../../game-model/gamesystems/conditions/ScriptAccountCondition";
@Component({ @Component({
selector: 'app-simple-state-editor', selector: 'app-simple-state-editor',
@ -23,6 +25,7 @@ export class SimpleStateEditorComponent implements OnInit{
@Input() states: SimpleState[] = []; @Input() states: SimpleState[] = [];
@Input() gamesystem: SimpleGamesystem | undefined @Input() gamesystem: SimpleGamesystem | undefined
@Input() scriptAccounts: ScriptAccount[] = []
dataSource = new MatTableDataSource<SimpleState>(); dataSource = new MatTableDataSource<SimpleState>();
displayedColumns = ["name", "initial", "edit", "delete"]; displayedColumns = ["name", "initial", "edit", "delete"];
columnsToDisplayWithExpand = [...this.displayedColumns, 'expand']; columnsToDisplayWithExpand = [...this.displayedColumns, 'expand'];
@ -93,4 +96,13 @@ export class SimpleStateEditorComponent implements OnInit{
const filterValue = (event.target as HTMLInputElement).value; const filterValue = (event.target as HTMLInputElement).value;
this.dataSource.filter = filterValue.trim().toLowerCase(); this.dataSource.filter = filterValue.trim().toLowerCase();
} }
onCreateCondition(state: SimpleState, condition: ScriptAccountCondition) {
state.addScriptAccountCondition(condition);
}
deleteCondition(state: SimpleState, condition: ScriptAccountCondition) {
state.removeScriptAccountCondition(condition.scriptAccount);
}
} }