Skip to content

Commit

Permalink
Implement checkboxes in slot settings to toggle various slot properties
Browse files Browse the repository at this point in the history
  • Loading branch information
FeTetra committed Sep 22, 2024
1 parent 528ee8d commit 7839082
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
28 changes: 28 additions & 0 deletions ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,34 @@ function onSubmit(){
<label style="text-align: left" for="description">Description</label>
<textarea name="description" id="description" spellcheck="false" placeholder="Description">@HttpUtility.HtmlDecode(Model.Slot.Description)</textarea>
</div>
<div class="ui divider"></div>
<label class="ui red label" for="initiallyLocked">
<i class="lock icon"></i>
Locked
<input type="checkbox" name="initiallyLocked" id="initiallyLocked" style="margin-left: 5px;" @(Model.Slot.InitiallyLocked ? "checked" : "") value="true">
</label>
<label class="ui green label" for="shareable">
<i class="check icon"></i>
Copyable
<input type="checkbox" name="shareable" id="shareable" style="margin-left: 5px;" @(Model.Slot.Shareable == 1 ? "checked" : "") value="1">
</label>
@if (Model.Slot.GameVersion != GameVersion.LittleBigPlanet1)
{
<label class="ui blue label" for="subLevel">
<i class="arrow circle down icon"></i>
Sub Level
<input type="checkbox" name="subLevel" id="subLevel" style="margin-left: 5px;" @(Model.Slot.SubLevel ? "checked" : "") value="true">
</label>
}
else
{
<label class="ui yellow label" for="lbp1Only">
<i class="eye icon"></i>
LBP1 Only
<input type="checkbox" name="lbp1Only" id="lbp1Only" style="margin-left: 5px;" @(Model.Slot.Lbp1Only ? "checked" : "") value="true">
</label>
}
<div class="ui divider fitted hidden"></div>
@if (Model.Slot.GameVersion != GameVersion.LittleBigPlanet1)
{
<div class="field">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
using LBPUnion.ProjectLighthouse.Types.Users;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;

Expand All @@ -17,7 +18,18 @@ public class SlotSettingsPage : BaseLayout
public SlotSettingsPage(DatabaseContext database) : base(database)
{}

public async Task<IActionResult> OnPost([FromRoute] int slotId, [FromForm] string? avatar, [FromForm] string? name, [FromForm] string? description, string? labels)
public async Task<IActionResult> OnPost
(
[FromRoute] int slotId,
[FromForm] string? avatar,
[FromForm] string? name,
[FromForm] string? description,
[FromForm] string? labels,
[FromForm] bool initiallyLocked,
[FromForm] int shareable,
[FromForm] bool subLevel,
[FromForm] bool lbp1Only
)
{
this.Slot = await this.Database.Slots.FirstOrDefaultAsync(u => u.SlotId == slotId);
if (this.Slot == null) return this.NotFound();
Expand Down Expand Up @@ -55,6 +67,22 @@ public async Task<IActionResult> OnPost([FromRoute] int slotId, [FromForm] strin
this.Slot.AuthorLabels = labels;
}

if (this.Slot.InitiallyLocked != initiallyLocked) this.Slot.InitiallyLocked = initiallyLocked;

if (this.Slot.Shareable != shareable) this.Slot.Shareable = shareable;

if (this.Slot.SubLevel != subLevel)
{
if (this.Slot.GameVersion != GameVersion.LittleBigPlanet1)
this.Slot.SubLevel = subLevel;
}

if (this.Slot.Lbp1Only != lbp1Only)
{
if (this.Slot.GameVersion == GameVersion.LittleBigPlanet1)
this.Slot.Lbp1Only = lbp1Only;
}

// ReSharper disable once InvertIf
if (this.Database.ChangeTracker.HasChanges())
{
Expand Down

0 comments on commit 7839082

Please sign in to comment.