mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-03 18:48:40 +00:00
Implement checkboxes in slot settings to toggle various slot properties (#1063)
* Implement checkboxes in slot settings to toggle various slot properties * Fix UI inconsistencies in checkboxes * Update ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml Co-authored-by: Josh <josh@slendy.pw> * Update ProjectLighthouse.Servers.Website/Pages/SlotSettingsPage.cshtml Co-authored-by: Josh <josh@slendy.pw> * Fix missing end quote and add extra margin * Update SlotSettingsPage.cshtml.cs Resolve file conflict --------- Co-authored-by: Josh <josh@slendy.pw>
This commit is contained in:
parent
f059b20489
commit
8b8756e6de
2 changed files with 65 additions and 2 deletions
|
@ -60,6 +60,33 @@ function onSubmit(){
|
||||||
<label style="text-align: left" for="description">Description</label>
|
<label style="text-align: left" for="description">Description</label>
|
||||||
<textarea name="description" id="description" spellcheck="false" placeholder="Description">@HttpUtility.HtmlDecode(Model.Slot.Description)</textarea>
|
<textarea name="description" id="description" spellcheck="false" placeholder="Description">@HttpUtility.HtmlDecode(Model.Slot.Description)</textarea>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="ui divider"></div>
|
||||||
|
<label class="ui button @(Model.Slot.InitiallyLocked ? "selected" : "")" style="margin-bottom: 1em;" for="checkboxInitiallyLocked">
|
||||||
|
<i class="lock icon"></i>
|
||||||
|
Locked
|
||||||
|
<input type="checkbox" name="initiallyLocked" id="checkboxInitiallyLocked" style="margin-left: 5px;" onchange="onCheckboxChange(this)" @(Model.Slot.InitiallyLocked ? "checked" : "") value="true">
|
||||||
|
</label>
|
||||||
|
<label class="ui button @(Model.Slot.Shareable == 1 ? "selected" : "")" style="margin-bottom: 1em;" for="checkboxShareable">
|
||||||
|
<i class="check icon"></i>
|
||||||
|
Copyable
|
||||||
|
<input type="checkbox" name="shareable" id="checkboxShareable" style="margin-left: 5px;" onchange="onCheckboxChange(this)" @(Model.Slot.Shareable == 1 ? "checked" : "") value="1">
|
||||||
|
</label>
|
||||||
|
@if (Model.Slot.GameVersion != GameVersion.LittleBigPlanet1)
|
||||||
|
{
|
||||||
|
<label class="ui button @(Model.Slot.SubLevel ? "selected" : "")" style="margin-bottom: 1em;" for="checkboxSubLevel">
|
||||||
|
<i class="arrow circle down icon"></i>
|
||||||
|
Sub Level
|
||||||
|
<input type="checkbox" name="subLevel" id="checkboxSubLevel" style="margin-left: 5px;" onchange="onCheckboxChange(this)" @(Model.Slot.SubLevel ? "checked" : "") value="true">
|
||||||
|
</label>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<label class="ui button @(Model.Slot.Lbp1Only ? "selected" : "")" style="margin-bottom: 1em;" for="checkboxLbp1Only">
|
||||||
|
<i class="eye icon"></i>
|
||||||
|
LBP1 Only
|
||||||
|
<input type="checkbox" name="lbp1Only" id="checkboxLbp1Only" style="margin-left: 5px;" onchange="onCheckboxChange(this)" @(Model.Slot.Lbp1Only ? "checked" : "") value="true">
|
||||||
|
</label>
|
||||||
|
}
|
||||||
@if (Model.Slot.GameVersion != GameVersion.LittleBigPlanet1)
|
@if (Model.Slot.GameVersion != GameVersion.LittleBigPlanet1)
|
||||||
{
|
{
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
@ -106,6 +133,14 @@ function onSubmit(){
|
||||||
function onHoverStart(btn){
|
function onHoverStart(btn){
|
||||||
generateRandomSkew(btn);
|
generateRandomSkew(btn);
|
||||||
}
|
}
|
||||||
|
function onCheckboxChange(checkbox) {
|
||||||
|
const label = checkbox.parentElement;
|
||||||
|
if (checkbox.checked) {
|
||||||
|
label.classList.add('selected');
|
||||||
|
} else {
|
||||||
|
label.classList.remove('selected');
|
||||||
|
}
|
||||||
|
}
|
||||||
function generateRandomSkew(element){
|
function generateRandomSkew(element){
|
||||||
let rand = Math.random() * 6 - 3;
|
let rand = Math.random() * 6 - 3;
|
||||||
element.style.setProperty("--skew", "rotate(" + rand + "deg)");
|
element.style.setProperty("--skew", "rotate(" + rand + "deg)");
|
||||||
|
|
|
@ -5,6 +5,7 @@ using LBPUnion.ProjectLighthouse.Files;
|
||||||
using LBPUnion.ProjectLighthouse.Helpers;
|
using LBPUnion.ProjectLighthouse.Helpers;
|
||||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||||
|
using LBPUnion.ProjectLighthouse.Types.Users;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Filter;
|
using LBPUnion.ProjectLighthouse.Types.Filter;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
@ -18,7 +19,18 @@ public class SlotSettingsPage : BaseLayout
|
||||||
public SlotSettingsPage(DatabaseContext database) : base(database)
|
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);
|
this.Slot = await this.Database.Slots.FirstOrDefaultAsync(u => u.SlotId == slotId);
|
||||||
if (this.Slot == null) return this.NotFound();
|
if (this.Slot == null) return this.NotFound();
|
||||||
|
@ -56,6 +68,22 @@ public class SlotSettingsPage : BaseLayout
|
||||||
this.Slot.AuthorLabels = labels;
|
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
|
// ReSharper disable once InvertIf
|
||||||
if (this.Database.ChangeTracker.HasChanges())
|
if (this.Database.ChangeTracker.HasChanges())
|
||||||
{
|
{
|
||||||
|
@ -77,4 +105,4 @@ public class SlotSettingsPage : BaseLayout
|
||||||
|
|
||||||
return this.Page();
|
return this.Page();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue