Fix form not able to be processed due to invalid values on multiplayer modes and actions

This commit is contained in:
Pat Hartl 2023-01-12 20:03:04 -06:00
parent 4afafacab0
commit 6939db7829
5 changed files with 15 additions and 8 deletions

View file

@ -23,16 +23,19 @@
@foreach (var action in Actions) @foreach (var action in Actions)
{ {
<tr> <tr>
<td><input @bind="action.Name" name="Game.Actions[@i].Name" class="form-control" placeholder="Play" /></td> <td><input @bind="action.Name" name="Game.Actions[@i].Name" class="form-control" placeholder="Play" /></td>
<td><input @bind="action.Path" name="Game.Actions[@i].Path" class="form-control" placeholder="Game.exe" /></td> <td><input @bind="action.Path" name="Game.Actions[@i].Path" class="form-control" placeholder="Game.exe" /></td>
<td><input @bind="action.Arguments" name="Game.Actions[@i].Arguments" class="form-control" placeholder="Launch Arguments" /></td> <td><input @bind="action.Arguments" name="Game.Actions[@i].Arguments" class="form-control" placeholder="Launch Arguments" /></td>
<td class="align-middle"> <td class="align-middle">
<div class="form-check form-switch form-check-inline mb-0"> <div class="form-check form-check-inline mb-0">
<input @bind="action.PrimaryAction" name="Game.Actions[@i].PrimaryAction" class="form-check-input" type="checkbox" /> <input name="Game.Actions[@i].PrimaryAction" class="form-check-input" type="checkbox" checked="@action.PrimaryAction" value="true" />
</div> </div>
</td> </td>
<td> <td>
<input name="Game.Actions[@i].Game.Id" type="hidden" value="@GameId" />
<div class="btn-list flex-nowrap justify-content-end"> <div class="btn-list flex-nowrap justify-content-end">
<button class="btn btn-ghost-danger btn-icon" @onclick="() => RemoveAction(i)" type="button"> <button class="btn btn-ghost-danger btn-icon" @onclick="() => RemoveAction(i)" type="button">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-x" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-x" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
@ -58,6 +61,7 @@
@code { @code {
[Parameter] public ICollection<Data.Models.Action> Actions { get; set; } [Parameter] public ICollection<Data.Models.Action> Actions { get; set; }
[Parameter] public Guid GameId { get; set; }
private void AddAction() private void AddAction()
{ {

View file

@ -37,6 +37,8 @@
<td><input @bind="multiplayerMode.MaxPlayers" name="Game.MultiplayerModes[@i].MaxPlayers" class="form-control" /></td> <td><input @bind="multiplayerMode.MaxPlayers" name="Game.MultiplayerModes[@i].MaxPlayers" class="form-control" /></td>
<td><input @bind="multiplayerMode.Description" name="Game.MultiplayerModes[@i].Description" class="form-control" /></td> <td><input @bind="multiplayerMode.Description" name="Game.MultiplayerModes[@i].Description" class="form-control" /></td>
<td> <td>
<input name="Game.MultiplayerModes[@i].Game.Id" type="hidden" value="@GameId" />
<div class="btn-list flex-nowrap justify-content-end"> <div class="btn-list flex-nowrap justify-content-end">
<button class="btn btn-ghost-danger btn-icon" @onclick="() => RemoveMode(i)" type="button"> <button class="btn btn-ghost-danger btn-icon" @onclick="() => RemoveMode(i)" type="button">
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-x" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-x" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
@ -62,6 +64,7 @@
@code { @code {
[Parameter] public ICollection<MultiplayerMode> MultiplayerModes { get; set; } [Parameter] public ICollection<MultiplayerMode> MultiplayerModes { get; set; }
[Parameter] public Guid GameId { get; set; }
private void AddMode() private void AddMode()
{ {

View file

@ -7,9 +7,9 @@ namespace LANCommander.Data.Models
public class Action : BaseModel public class Action : BaseModel
{ {
public string Name { get; set; } public string Name { get; set; }
public string Arguments { get; set; } public string? Arguments { get; set; }
public string Path { get; set; } public string? Path { get; set; }
public string WorkingDirectory { get; set; } public string? WorkingDirectory { get; set; }
public bool PrimaryAction { get; set; } public bool PrimaryAction { get; set; }
[JsonIgnore] [JsonIgnore]

View file

@ -9,7 +9,7 @@ namespace LANCommander.Data.Models
{ {
public MultiplayerType Type { get; set; } public MultiplayerType Type { get; set; }
public NetworkProtocol NetworkProtocol { get; set; } public NetworkProtocol NetworkProtocol { get; set; }
public string Description { get; set; } public string? Description { get; set; }
public int MinPlayers { get; set; } public int MinPlayers { get; set; }
public int MaxPlayers { get; set; } public int MaxPlayers { get; set; }
public int Spectators { get; set; } public int Spectators { get; set; }

View file

@ -84,13 +84,13 @@
<h3 class="card-title">Actions</h3> <h3 class="card-title">Actions</h3>
</div> </div>
<component type="typeof(ActionEditor)" render-mode="Server" param-Actions="Model.Game.Actions" /> <component type="typeof(ActionEditor)" render-mode="Server" param-Actions="Model.Game.Actions" param-GameId="Model.Game.Id" />
<div class="card-header"> <div class="card-header">
<h3 class="card-title">Multiplayer Modes</h3> <h3 class="card-title">Multiplayer Modes</h3>
</div> </div>
<component type="typeof(MultiplayerModeEditor)" render-mode="Server" param-MultiplayerModes="Model.Game.MultiplayerModes" /> <component type="typeof(MultiplayerModeEditor)" render-mode="Server" param-MultiplayerModes="Model.Game.MultiplayerModes" param-GameId="Model.Game.Id" />
<div class="card-footer"> <div class="card-footer">
<div class="d-flex"> <div class="d-flex">