improve meta filter menu on profile

This commit is contained in:
RaidMax 2022-02-25 21:09:57 -06:00
parent b087d4c8de
commit de2e804b84
4 changed files with 20 additions and 25 deletions

View File

@ -20,6 +20,7 @@ namespace SharedLibraryCore.Interfaces
public enum MetaType public enum MetaType
{ {
All = -1,
Other, Other,
Information, Information,
AliasUpdate, AliasUpdate,

View File

@ -38,11 +38,12 @@ namespace WebfrontCore.ViewComponents
return View("_List", meta); return View("_List", meta);
} }
public static async Task<IEnumerable<IClientMeta>> GetClientMeta(IMetaService metaService, MetaType? metaType, EFClient.Permission level, ClientPaginationRequest request) public static async Task<IEnumerable<IClientMeta>> GetClientMeta(IMetaService metaService, MetaType? metaType,
EFClient.Permission level, ClientPaginationRequest request)
{ {
IEnumerable<IClientMeta> meta = null; IEnumerable<IClientMeta> meta = null;
if (metaType == null) // all types if (metaType is null or MetaType.All)
{ {
meta = await metaService.GetRuntimeMeta(request); meta = await metaService.GetRuntimeMeta(request);
} }

View File

@ -146,23 +146,23 @@
<partial name="Meta/_Information.cshtml" model="@Model.Meta"/> <partial name="Meta/_Information.cshtml" model="@Model.Meta"/>
</div> </div>
<div class="row border-bottom bg-dark"> <div class="row border-bottom">
<div class="d-md-flex flex-fill align-items-center bg-dark"> <div class="d-md-flex flex-fill">
<div class="text-center bg-dark p-2 pl-3 pr-4 text-muted" id="filter_meta_container_button"> <div class="bg-dark p-2 pl-3 pr-3 text-center text-muted border-0 align-self-stretch align-middle" id="filter_meta_container_button">
<span class="oi oi-sort-ascending"></span> <span class="text-primary" id="meta_filter_dropdown_icon">▼</span>
<a>@ViewBag.Localization["WEBFRONT_CLIENT_META_FILTER"]</a> <a>@ViewBag.Localization["WEBFRONT_CLIENT_META_FILTER"]</a>
</div> </div>
<div id="filter_meta_container" class="d-none d-md-flex flex-md-fill flex-md-wrap"> <div id="filter_meta_container" class="d-none d-md-flex flex-md-fill flex-md-wrap">
<a asp-action="ProfileAsync" asp-controller="Client" @{
class="nav-link p-2 pl-3 pr-3 text-center col-12 col-md-auto text-md-left @(!Model.MetaFilterType.HasValue ? "btn-primary text-white" : "text-muted")" const int defaultTabCount = 5;
asp-route-id="@Model.ClientId"> var metaTypes = Enum.GetValues(typeof(MetaType))
@ViewBag.Localization["META_TYPE_ALL_NAME"]
</a>
@{ var metaTypes = Enum.GetValues(typeof(MetaType))
.Cast<MetaType>() .Cast<MetaType>()
.Where(type => !ignoredMetaTypes.Contains(type)) .Where(type => !ignoredMetaTypes.Contains(type))
.ToList(); } .OrderByDescending(type => type == MetaType.All)
@foreach (var type in metaTypes.Take(4)) .ToList();
var selectedMeta = metaTypes.FirstOrDefault(meta => metaTypes.IndexOf(Model.MetaFilterType ?? MetaType.All) >= defaultTabCount && meta != MetaType.All && meta == Model.MetaFilterType);
}
@foreach (var type in metaTypes.Take(defaultTabCount - 1).Append(selectedMeta == MetaType.Other ? metaTypes[defaultTabCount - 1] : selectedMeta))
{ {
<a asp-action="ProfileAsync" asp-controller="Client" <a asp-action="ProfileAsync" asp-controller="Client"
class="meta-filter nav-link p-2 pl-3 pr-3 text-center @(Model.MetaFilterType.HasValue && Model.MetaFilterType.Value.ToString() == type.ToString() ? "btn-primary text-white" : "text-muted")" class="meta-filter nav-link p-2 pl-3 pr-3 text-center @(Model.MetaFilterType.HasValue && Model.MetaFilterType.Value.ToString() == type.ToString() ? "btn-primary text-white" : "text-muted")"
@ -172,9 +172,8 @@
@type.ToTranslatedName() @type.ToTranslatedName()
</a> </a>
} }
<a href="#" class="nav-link p-2 pl-3 pr-3 text-center text-muted d-none d-md-block" id="expand-meta-filters">...</a> <div class="d-md-none" id="additional_meta_filter">
<div class="d-block d-md-none" id="additional-meta-filter"> @foreach (var type in (selectedMeta == MetaType.Other ? metaTypes.Skip(defaultTabCount) : metaTypes.Skip(defaultTabCount).Append(metaTypes[defaultTabCount - 1])).Where(meta => selectedMeta == MetaType.Other || meta != selectedMeta))
@foreach (var type in metaTypes.Skip(4))
{ {
<a asp-action="ProfileAsync" asp-controller="Client" <a asp-action="ProfileAsync" asp-controller="Client"
class="meta-filter nav-link p-2 pl-3 pr-3 text-center @(Model.MetaFilterType.HasValue && Model.MetaFilterType.Value.ToString() == type.ToString() ? "btn-primary text-white" : "text-muted")" class="meta-filter nav-link p-2 pl-3 pr-3 text-center @(Model.MetaFilterType.HasValue && Model.MetaFilterType.Value.ToString() == type.ToString() ? "btn-primary text-white" : "text-muted")"

View File

@ -35,16 +35,10 @@
startAt = $('.loader-data-time').last().data('time'); startAt = $('.loader-data-time').last().data('time');
$('#filter_meta_container_button').click(function () { $('#filter_meta_container_button').click(function () {
$('#filter_meta_container').hide().removeClass('d-none').addClass('d-block').slideDown(); $('#filter_meta_container').removeClass('d-none').addClass('flex-md-column');
$('#additional-meta-filter').removeClass('d-md-none').addClass('d-flex').slideDown(); $('#additional_meta_filter').removeClass('d-md-none');
$('#expand-meta-filters').removeClass('d-md-block');
}); });
$('#expand-meta-filters').click(function () {
$('#additional-meta-filter').removeClass('d-md-none').addClass('d-flex').slideDown();
$('#expand-meta-filters').removeClass('d-md-block');
})
/* /*
* load context of chat * load context of chat
*/ */