Allow negative min and max for ScriptAccounts
All checks were successful
E2E Testing / test (push) Successful in 1m29s

This commit is contained in:
Sebastian Böckelmann 2024-03-19 10:39:47 +01:00
parent 7e672ec117
commit b488049c28
9 changed files with 91 additions and 122 deletions

View File

@ -1,13 +1,13 @@
<div *ngIf="scriptAccount != undefined">
<mat-form-field class="example-full-width">
<mat-label>MinValue</mat-label>
<input matInput [formControl]="minCtrl" type="number" (keypress)="onKeyPress($event)" (change)="onUpdateMinValue()">
<input matInput [formControl]="minCtrl" type="number" (change)="onUpdateMinValue($event)">
<mat-error *ngIf="minCtrl.hasError('required')">Please enter a valid number!</mat-error>
</mat-form-field>
<mat-form-field class="example-full-width">
<mat-label>MaxValue</mat-label>
<input matInput type="number" [formControl]="maxCtrl" (keypress)="onKeyPress($event)" (change)="onUpdateMaxValue()">
<input matInput type="number" [formControl]="maxCtrl" (change)="onUpdateMaxValue()">
<mat-error *ngIf="maxCtrl.hasError('required')">Please enter a valid number!</mat-error>
</mat-form-field>

View File

@ -22,8 +22,8 @@ export class MyErrorStateMatcher implements ErrorStateMatcher {
export class ScriptAccountEditorComponent implements OnInit{
@Input("scriptAccount") scriptAccount : ScriptAccount | undefined
minCtrl: FormControl = new FormControl(0, [Validators.required, Validators.pattern('^[0-9]*$')]);
maxCtrl: FormControl = new FormControl(100, [Validators.required, Validators.pattern('^[0-9]*$')]);
minCtrl: FormControl = new FormControl(0, [Validators.required, Validators.pattern('^[-]?[0-9]*$')]);
maxCtrl: FormControl = new FormControl(100, [Validators.required, Validators.pattern('^[-]?[0-9]*$')]);
matcher = new MyErrorStateMatcher();
constructor(private electronService: ElectronService) {
@ -33,15 +33,8 @@ export class ScriptAccountEditorComponent implements OnInit{
this.maxCtrl.setValue(this.scriptAccount!.maxValue);
}
onKeyPress(event: KeyboardEvent) {
const input = event.key;
const isDigit = /^\d+$/.test(input);
if (!isDigit) {
event.preventDefault();
}
}
onUpdateMinValue() {
onUpdateMinValue(event: Event) {
this.scriptAccount!.minValue = Number(this.minCtrl.value);
this.scriptAccount!.onModifyContent();
}

View File

@ -1,49 +0,0 @@
{
"componentName": "Weather",
"componentDescription": "",
"states": [
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": 0,
"maxValue": "50"
}
],
"stateLabel": "Sonnig",
"stateDescription": "Die Sonne scheint"
},
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": "50",
"maxValue": "75"
}
],
"stateLabel": "Wolkig",
"stateDescription": ""
}
],
"transitions": [
{
"scriptAccountActions": [
{
"changingValue": 10,
"scriptAccount": "Temperature"
}
],
"scriptAccountConditions": [
{
"scriptAccount": "Temperature",
"minValue": 0,
"maxValue": "10"
}
],
"startingState": "Sonnig",
"endingState": "Wolkig"
}
]
}

View File

@ -1,6 +0,0 @@
{
"componentName": "Parent Weather",
"componentDescription": "",
"states": [],
"transitions": []
}

View File

@ -1,49 +0,0 @@
{
"componentName": "Weather(Child)",
"componentDescription": "",
"states": [
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": 0,
"maxValue": "50"
}
],
"stateLabel": "Sonnig",
"stateDescription": "Die Sonne scheint"
},
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": "50",
"maxValue": "75"
}
],
"stateLabel": "Wolkig",
"stateDescription": ""
}
],
"transitions": [
{
"scriptAccountActions": [
{
"changingValue": 10,
"scriptAccount": "Temperature"
}
],
"scriptAccountConditions": [
{
"scriptAccount": "Temperature",
"minValue": 0,
"maxValue": "10"
}
],
"startingState": "Sonnig",
"endingState": "Wolkig"
}
]
}

View File

@ -1,4 +0,0 @@
{
"componentName": "Weather",
"componentDescription": ""
}

View File

@ -0,0 +1,80 @@
{
"componentName": "Weather",
"componentDescription": "A small Gamesystem about local weather events",
"states": [
{
"initial": false,
"conditions": [],
"stateLabel": "Sonne",
"stateDescription": ""
},
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": 0,
"maxValue": "30"
}
],
"stateLabel": "Regen",
"stateDescription": ""
},
{
"initial": false,
"conditions": [],
"stateLabel": "Wolke",
"stateDescription": ""
},
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": "-5",
"maxValue": 0
}
],
"stateLabel": "Schnee",
"stateDescription": ""
}
],
"transitions": [
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Sonne",
"endingState": "Wolke"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Wolke",
"endingState": "Sonne"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Wolke",
"endingState": "Regen"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Regen",
"endingState": "Wolke"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Wolke",
"endingState": "Schnee"
},
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Schnee",
"endingState": "Wolke"
}
]
}

View File

@ -0,0 +1,4 @@
{
"componentName": "Weathersystem",
"componentDescription": "Ein Wettersystem, dass sich aus normalem Wetter (Sonne, Regen, Wolke, Schnee, Sturm etc.) und zusätzlich den Jahreszeiten (Frühling, Sommer, Herbst, Winter, etc.) zusammensetzt."
}

View File

@ -1,6 +1,6 @@
{
"componentName": "Temperature",
"componentDescription": "",
"minValue": 0,
"maxValue": 100
"minValue": -50,
"maxValue": 70
}