Rename case properties, add dismissal button

This commit is contained in:
jvyden 2022-08-05 17:53:48 -04:00
commit 1996c1cdbb
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
7 changed files with 233 additions and 45 deletions

View file

@ -33,7 +33,7 @@ public class CasePage : BaseLayout
this.Cases = await this.Database.Cases
.OrderByDescending(c => c.CaseId)
.ToListAsync();
this.CaseCount = await this.Database.Cases.CountAsync(c => c.CaseDescription.Contains(this.SearchValue));
this.CaseCount = await this.Database.Cases.CountAsync(c => c.Description.Contains(this.SearchValue));
this.PageNumber = pageNumber;
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.CaseCount / ServerStatics.PageSize));

View file

@ -22,11 +22,11 @@ public class NewCasePage : BaseLayout
{
ModerationCase @case = new()
{
CaseType = (CaseType)type,
CaseDescription = description,
CaseExpires = expires,
CaseCreated = DateTime.Now,
CaseCreatorId = 1,
Type = (CaseType)type,
Description = description,
ExpiresAt = expires,
CreatedAt = DateTime.Now,
CreatorId = 1,
AffectedId = affectedId,
};

View file

@ -1,3 +1,4 @@
@using System.Diagnostics
@using LBPUnion.ProjectLighthouse
@using LBPUnion.ProjectLighthouse.Administration
@using LBPUnion.ProjectLighthouse.Configuration
@ -7,43 +8,59 @@
@{
Database database = new();
string color = Model.Expired ? "red" : "green";
string color = "blue";
if (Model.Expired) color = "yellow";
if (Model.Dismissed) color = "green";
}
<div class="ui @color segment">
<h2>Case #@Model.CaseId: @Model.CaseType</h2>
@if (Model.Expired)
<h2>Case #@Model.CaseId: @Model.Type</h2>
@if (Model.Dismissed)
{
Debug.Assert(Model.Dismisser != null);
Debug.Assert(Model.DismissedAt != null);
<h3 class="ui red header">
This case expired on @Model.CaseExpires!.Value.ToString("MM/dd/yyyy @ h:mm tt").
This case was dismissed by <a href="/user/@Model.Dismisser.UserId">@Model.Dismisser.Username</a> on @Model.DismissedAt.Value.ToString("MM/dd/yyyy @ h:mm tt").
</h3>
}
else if (Model.Expired)
{
<h3 class="ui red header">
This case expired on @Model.ExpiresAt!.Value.ToString("MM/dd/yyyy @ h:mm tt").
</h3>
}
<span>
Case created by <a href="/user/@Model.CaseCreator!.UserId">@Model.CaseCreator.Username</a>
on @Model.CaseCreated.ToString("MM/dd/yyyy @ h:mm tt")
Case created by <a href="/user/@Model.Creator!.UserId">@Model.Creator.Username</a>
on @Model.CreatedAt.ToString("MM/dd/yyyy @ h:mm tt")
</span><br>
@if (Model.CaseType.AffectsLevel())
@if (Model.Type.AffectsLevel())
{
Slot slot = await Model.GetSlotAsync(database);
<p><strong>Affected level:</strong> <a href="/slot/@slot.SlotId">@slot.Name</a></p>
}
else if (Model.CaseType.AffectsUser())
else if (Model.Type.AffectsUser())
{
User user = await Model.GetUserAsync(database);
<p><strong>Affected user:</strong> <a href="/user/@user.UserId">@user.Username</a></p>
}
@if (!string.IsNullOrWhiteSpace(Model.CaseDescription))
@if (!string.IsNullOrWhiteSpace(Model.Description))
{
<h3>Description</h3>
<pre>@Model.CaseDescription</pre>
<pre>@Model.Description</pre>
}
else
{
<b>No description was provided.</b>
}
<a href="/moderation/case/@Model.CaseId/expire"></a>
<a class="ui green small button" href="/moderation/case/@Model.CaseId/dismiss">
<i class="checkmark icon"></i>
<span>Dismiss</span>
</a>
</div>