From de2e804b8408e932a6f3407293956c8f5fa03058 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Fri, 25 Feb 2022 21:09:57 -0600 Subject: [PATCH] improve meta filter menu on profile --- SharedLibraryCore/Interfaces/IClientMeta.cs | 1 + .../ProfileMetaListViewComponent.cs | 5 ++-- .../Views/Client/Profile/Index.cshtml | 29 +++++++++---------- WebfrontCore/wwwroot/js/profile.js | 10 ++----- 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/SharedLibraryCore/Interfaces/IClientMeta.cs b/SharedLibraryCore/Interfaces/IClientMeta.cs index 1b3ed0a41..479ba70ae 100644 --- a/SharedLibraryCore/Interfaces/IClientMeta.cs +++ b/SharedLibraryCore/Interfaces/IClientMeta.cs @@ -20,6 +20,7 @@ namespace SharedLibraryCore.Interfaces public enum MetaType { + All = -1, Other, Information, AliasUpdate, diff --git a/WebfrontCore/ViewComponents/ProfileMetaListViewComponent.cs b/WebfrontCore/ViewComponents/ProfileMetaListViewComponent.cs index db7fc7c7d..5314960bd 100644 --- a/WebfrontCore/ViewComponents/ProfileMetaListViewComponent.cs +++ b/WebfrontCore/ViewComponents/ProfileMetaListViewComponent.cs @@ -38,11 +38,12 @@ namespace WebfrontCore.ViewComponents return View("_List", meta); } - public static async Task> GetClientMeta(IMetaService metaService, MetaType? metaType, EFClient.Permission level, ClientPaginationRequest request) + public static async Task> GetClientMeta(IMetaService metaService, MetaType? metaType, + EFClient.Permission level, ClientPaginationRequest request) { IEnumerable meta = null; - if (metaType == null) // all types + if (metaType is null or MetaType.All) { meta = await metaService.GetRuntimeMeta(request); } diff --git a/WebfrontCore/Views/Client/Profile/Index.cshtml b/WebfrontCore/Views/Client/Profile/Index.cshtml index 7721ae408..90397bd96 100644 --- a/WebfrontCore/Views/Client/Profile/Index.cshtml +++ b/WebfrontCore/Views/Client/Profile/Index.cshtml @@ -146,23 +146,23 @@ -
-
-
- +
+
+
- - @ViewBag.Localization["META_TYPE_ALL_NAME"] - - @{ var metaTypes = Enum.GetValues(typeof(MetaType)) + @{ + const int defaultTabCount = 5; + var metaTypes = Enum.GetValues(typeof(MetaType)) .Cast() .Where(type => !ignoredMetaTypes.Contains(type)) - .ToList(); } - @foreach (var type in metaTypes.Take(4)) + .OrderByDescending(type => type == MetaType.All) + .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)) { } - ... -
- @foreach (var type in metaTypes.Skip(4)) +
+ @foreach (var type in (selectedMeta == MetaType.Other ? metaTypes.Skip(defaultTabCount) : metaTypes.Skip(defaultTabCount).Append(metaTypes[defaultTabCount - 1])).Where(meta => selectedMeta == MetaType.Other || meta != selectedMeta)) {