Fix action and multiplayer mode editors not linking to games properly and now creating fields with correct index
This commit is contained in:
parent
6939db7829
commit
1a6dff63b2
6 changed files with 22 additions and 10 deletions
|
@ -23,6 +23,7 @@
|
|||
|
||||
@foreach (var action in Actions)
|
||||
{
|
||||
var index = i;
|
||||
|
||||
<tr>
|
||||
<td><input @bind="action.Name" name="Game.Actions[@i].Name" class="form-control" placeholder="Play" /></td>
|
||||
|
@ -34,10 +35,11 @@
|
|||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<input name="Game.Actions[@i].Game.Id" type="hidden" value="@GameId" />
|
||||
<input name="Game.Actions[@i].Id" type="hidden" value="@action.Id" />
|
||||
<input name="Game.Actions[@i].GameId" type="hidden" value="@GameId" />
|
||||
|
||||
<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(index)" 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">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<line x1="18" y1="6" x2="6" y2="18"></line>
|
||||
|
@ -47,6 +49,8 @@
|
|||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
i++;
|
||||
}
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
@foreach (var multiplayerMode in MultiplayerModes)
|
||||
{
|
||||
var index = i;
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<select @bind="multiplayerMode.Type" name="Game.MultiplayerModes[@i].Type" class="form-control">
|
||||
|
@ -37,10 +39,10 @@
|
|||
<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 name="Game.MultiplayerModes[@i].Game.Id" type="hidden" value="@GameId" />
|
||||
<input name="Game.Actions[@i].GameId" type="hidden" value="@GameId" />
|
||||
|
||||
<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(index)" 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">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<line x1="18" y1="6" x2="6" y2="18"></line>
|
||||
|
@ -50,6 +52,8 @@
|
|||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
i++;
|
||||
}
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
|
|
|
@ -12,7 +12,10 @@ namespace LANCommander.Data.Models
|
|||
public string? WorkingDirectory { get; set; }
|
||||
public bool PrimaryAction { get; set; }
|
||||
|
||||
public Guid GameId { get; set; }
|
||||
[JsonIgnore]
|
||||
public virtual Game Game { get; set; }
|
||||
[ForeignKey(nameof(GameId))]
|
||||
[InverseProperty("Actions")]
|
||||
public virtual Game? Game { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,10 @@ namespace LANCommander.Data.Models
|
|||
public int MinPlayers { get; set; }
|
||||
public int MaxPlayers { get; set; }
|
||||
public int Spectators { get; set; }
|
||||
|
||||
public Guid? GameId { get; set; }
|
||||
[JsonIgnore]
|
||||
public virtual Game Game { get; set; }
|
||||
[ForeignKey(nameof(GameId))]
|
||||
[InverseProperty("MultiplayerModes")]
|
||||
public virtual Game? Game { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,6 @@ builder.Services.AddAuthentication(options =>
|
|||
builder.Services.AddControllersWithViews().AddJsonOptions(x =>
|
||||
{
|
||||
x.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
|
||||
x.JsonSerializerOptions.MaxDepth = 3;
|
||||
});
|
||||
builder.Services.AddServerSideBlazor();
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
},
|
||||
onInitialize: function () {
|
||||
for (let option of Object.keys(this.options)) {
|
||||
if (option.selected) {
|
||||
this.$input.siblings('select').append(`<option value="${option.value}" selected>${option.text}</option>`);
|
||||
if (this.options[option].selected) {
|
||||
this.$input.siblings('select').append(`<option value="${this.options[option].value}" selected>${this.options[option].text}</option>`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue