mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-17 07:12:32 +00:00
* Initial support for leaderboards and some refactoring * Start of UI redesign * Finish slot and user redesign, added deletion of comments, reviews, scores, and photos * Remove leftover debug print * Fix bug in permission check * Simplify sidebar code and add hearted and queued levels * Fix navbar scrolling on mobile and refactor SlotCardPartial
60 lines
No EOL
2.5 KiB
C#
60 lines
No EOL
2.5 KiB
C#
using LBPUnion.ProjectLighthouse.Levels;
|
|
using LBPUnion.ProjectLighthouse.PlayerData;
|
|
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
|
using Microsoft.AspNetCore.Html;
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Servers.Website.Extensions;
|
|
|
|
public static class PartialExtensions
|
|
{
|
|
|
|
public static ViewDataDictionary<T> WithLang<T>(this ViewDataDictionary<T> viewData, string language) => WithKeyValue(viewData, "Language", language);
|
|
|
|
public static ViewDataDictionary<T> WithTime<T>(this ViewDataDictionary<T> viewData, string timeZone) => WithKeyValue(viewData, "TimeZone", timeZone);
|
|
|
|
public static ViewDataDictionary<T> CanDelete<T>(this ViewDataDictionary<T> viewData, bool canDelete) => WithKeyValue(viewData, "CanDelete", canDelete);
|
|
|
|
private static ViewDataDictionary<T> WithKeyValue<T>(this ViewDataDictionary<T> viewData, string key, object? value)
|
|
{
|
|
try
|
|
{
|
|
return new ViewDataDictionary<T>(viewData)
|
|
{
|
|
{
|
|
key, value
|
|
},
|
|
};
|
|
}
|
|
catch
|
|
{
|
|
return viewData;
|
|
}
|
|
}
|
|
|
|
public static Task<IHtmlContent> ToLink<T>(this User user, IHtmlHelper<T> helper, ViewDataDictionary<T> viewData, string language, string timeZone = "", bool includeStatus = false)
|
|
=> helper.PartialAsync("Partials/Links/UserLinkPartial", user, viewData.WithLang(language).WithTime(timeZone).WithKeyValue("IncludeStatus", includeStatus));
|
|
|
|
public static Task<IHtmlContent> ToHtml<T>
|
|
(
|
|
this Slot slot,
|
|
IHtmlHelper<T> helper,
|
|
ViewDataDictionary<T> viewData,
|
|
User? user,
|
|
string callbackUrl,
|
|
string language = "",
|
|
string timeZone = "",
|
|
bool isMobile = false,
|
|
bool showLink = false,
|
|
bool isMini = false
|
|
) =>
|
|
helper.PartialAsync("Partials/SlotCardPartial", slot, viewData.WithLang(language).WithTime(timeZone)
|
|
.WithKeyValue("User", user)
|
|
.WithKeyValue("CallbackUrl", callbackUrl)
|
|
.WithKeyValue("ShowLink", showLink)
|
|
.WithKeyValue("IsMobile", isMobile));
|
|
|
|
public static Task<IHtmlContent> ToHtml<T>(this Photo photo, IHtmlHelper<T> helper, ViewDataDictionary<T> viewData, string language, string timeZone, bool canDelete = false)
|
|
=> helper.PartialAsync("Partials/PhotoPartial", photo, viewData.WithLang(language).WithTime(timeZone).CanDelete(canDelete));
|
|
} |