mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-19 11:41:30 +00:00
Fix rendering issues with case creation page (#863)
This commit is contained in:
parent
027173b9c7
commit
1d89f7c548
2 changed files with 74 additions and 38 deletions
|
@ -2,6 +2,7 @@
|
|||
@using LBPUnion.ProjectLighthouse.Localization.StringLists
|
||||
@using LBPUnion.ProjectLighthouse.Servers.Website.Extensions
|
||||
@using LBPUnion.ProjectLighthouse.Types.Entities.Moderation
|
||||
@using LBPUnion.ProjectLighthouse.Types.Moderation.Cases
|
||||
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation.NewCasePage
|
||||
|
||||
@{
|
||||
|
@ -27,9 +28,18 @@
|
|||
<div>
|
||||
<b>Case Type:</b> @Model.Type.ToString()
|
||||
</div>
|
||||
<div>
|
||||
<b>Affected User:</b> <a href="/user/@Model.AffectedId">@Model.AffectedUser!.Username (id: @Model.AffectedId)</a>
|
||||
</div>
|
||||
@if (Model.Type.AffectsUser())
|
||||
{
|
||||
<div>
|
||||
<b>Affected User:</b> <a href="/user/@Model.AffectedId">@Model.AffectedUser!.Username (id: @Model.AffectedId)</a>
|
||||
</div>
|
||||
}
|
||||
else if (Model.Type.AffectsLevel())
|
||||
{
|
||||
<div>
|
||||
<b>Affected Level:</b> <a href="/user/@Model.AffectedId">@Model.AffectedSlot!.Name (id: @Model.AffectedId)</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="ui yellow segment">
|
||||
|
@ -50,36 +60,39 @@
|
|||
</button>
|
||||
</div>
|
||||
|
||||
<div class="ui blue segment">
|
||||
<details style="transition: max-height 0.25s ease-in-out;">
|
||||
<summary>Moderation history for user <a href="/user/@Model.AffectedId">@Model.AffectedUser!.Username</a></summary>
|
||||
<div class="ui list" style="padding-left: 1vh;">
|
||||
@if (Model.AffectedHistory.Count != 0)
|
||||
{
|
||||
@foreach (ModerationCaseEntity moderationCase in Model.AffectedHistory)
|
||||
@if (Model.Type.AffectsUser())
|
||||
{
|
||||
<div class="ui blue segment">
|
||||
<details style="transition: max-height 0.25s ease-in-out;">
|
||||
<summary>Moderation history for user <a href="/user/@Model.AffectedId">@Model.AffectedUser!.Username</a></summary>
|
||||
<div class="ui list" style="padding-left: 1vh;">
|
||||
@if (Model.AffectedHistory.Count != 0)
|
||||
{
|
||||
@foreach (ModerationCaseEntity moderationCase in Model.AffectedHistory)
|
||||
{
|
||||
<div class="item">
|
||||
<i class="@moderationCase.Type.GetCaseTypeIcon()"></i>
|
||||
<div class="content">
|
||||
<b>@moderationCase.Type.ToString()</b> by <a href="/user/@moderationCase.CreatorId">@moderationCase.CreatorUsername</a>
|
||||
on <b>@TimeZoneInfo.ConvertTime(moderationCase.CreatedAt, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt")</b>
|
||||
with reason <b>@(!string.IsNullOrWhiteSpace(moderationCase.Reason) ? moderationCase.Reason : "No reason provided")</b>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="item">
|
||||
<i class="@moderationCase.Type.GetCaseTypeIcon()"></i>
|
||||
<i class="ui icon check"></i>
|
||||
<div class="content">
|
||||
<b>@moderationCase.Type.ToString()</b> by <a href="/user/@moderationCase.CreatorId">@moderationCase.CreatorUsername</a>
|
||||
on <b>@TimeZoneInfo.ConvertTime(moderationCase.CreatedAt, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt")</b>
|
||||
with reason <b>@(!string.IsNullOrWhiteSpace(moderationCase.Reason) ? moderationCase.Reason : "No reason provided")</b>
|
||||
No moderation history found for user <a href="/user/@Model.AffectedId">@Model.AffectedUser!.Username</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="item">
|
||||
<i class="ui icon check"></i>
|
||||
<div class="content">
|
||||
No moderation history found for user <a href="/user/@Model.AffectedId">@Model.AffectedUser!.Username</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="ui red segment">
|
||||
<div style="margin-bottom: 1em;">
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Moderation.Cases;
|
||||
|
@ -18,6 +19,7 @@ public class NewCasePage : BaseLayout
|
|||
|
||||
public int AffectedId { get; set; }
|
||||
public UserEntity? AffectedUser { get; set; }
|
||||
public SlotEntity? AffectedSlot { get; set; }
|
||||
public List<ModerationCaseEntity> AffectedHistory { get; set; } = new();
|
||||
|
||||
public string? Error { get; private set; }
|
||||
|
@ -33,9 +35,18 @@ public class NewCasePage : BaseLayout
|
|||
this.Type = type.Value;
|
||||
|
||||
this.AffectedId = affectedId.Value;
|
||||
|
||||
this.AffectedUser = await this.Database.Users.FirstOrDefaultAsync(u => u.UserId == this.AffectedId);
|
||||
if (this.AffectedUser == null) return this.BadRequest();
|
||||
|
||||
if (this.Type.AffectsUser())
|
||||
{
|
||||
this.AffectedUser = await this.Database.Users.FirstOrDefaultAsync(u => u.UserId == this.AffectedId);
|
||||
if (this.AffectedUser == null) return this.BadRequest();
|
||||
}
|
||||
else if (this.Type.AffectsLevel())
|
||||
{
|
||||
this.AffectedSlot = await this.Database.Slots.FirstOrDefaultAsync(s => s.SlotId == this.AffectedId);
|
||||
if (this.AffectedSlot == null) return this.BadRequest();
|
||||
}
|
||||
else return this.BadRequest();
|
||||
|
||||
this.AffectedHistory = await this.Database.Cases.Where(c => c.AffectedId == this.AffectedId)
|
||||
.OrderByDescending(c => c.CreatedAt)
|
||||
|
@ -58,15 +69,27 @@ public class NewCasePage : BaseLayout
|
|||
// if id is invalid then return bad request
|
||||
if (!await type.Value.IsIdValid((int)affectedId, this.Database)) return this.BadRequest();
|
||||
|
||||
UserEntity? affectedUser =
|
||||
await this.Database.Users.FirstOrDefaultAsync(u => u.UserId == affectedId.Value);
|
||||
|
||||
if (affectedUser == null) return this.NotFound();
|
||||
|
||||
if (affectedUser.IsModerator)
|
||||
if (type.Value.AffectsUser())
|
||||
{
|
||||
this.Error = this.Translate(ErrorStrings.ActionNoPermission);
|
||||
return this.Page();
|
||||
UserEntity? affectedUser = await this.Database.Users.FirstOrDefaultAsync(u => u.UserId == affectedId.Value);
|
||||
if (affectedUser == null) return this.NotFound();
|
||||
|
||||
if (affectedUser.IsModerator)
|
||||
{
|
||||
this.Error = this.Translate(ErrorStrings.ActionNoPermission);
|
||||
|
||||
this.Type = type.Value;
|
||||
|
||||
this.AffectedId = affectedId.Value;
|
||||
|
||||
this.AffectedUser = affectedUser;
|
||||
|
||||
this.AffectedHistory = await this.Database.Cases.Where(c => c.AffectedId == this.AffectedId)
|
||||
.OrderByDescending(c => c.CreatedAt)
|
||||
.ToListAsync();
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
}
|
||||
|
||||
ModerationCaseEntity @case = new()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue