From 2a9e8f66d4ff0ee9e92d85b0ebd895656d7b8e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Fri, 14 Jun 2024 21:48:28 +0200 Subject: [PATCH] #448 - Refactor main menu. Separate implementation for top menu and bottom menu. --- .config/dotnet-tools.json | 12 ++ .../Bootstrap/BootstrapTask.cs | 2 +- .../Layouts/BottomMenu.razor | 75 +++++++++ .../Layouts/BottomMenu.razor.cs | 2 + src/Money.Blazor.Host/Layouts/Layout.razor | 2 +- src/Money.Blazor.Host/Layouts/MainMenu.razor | 120 +++++++------- .../Layouts/MainMenu.razor.cs | 24 ++- .../Layouts/MainMenuLink.razor | 5 +- src/Money.Blazor.Host/Layouts/UserInfo.razor | 72 +++----- .../Layouts/UserInfo.razor.cs | 7 +- .../MenuItems/MenuItemService.cs | 86 +++++++++- .../MenuItems/Models/MenuItemModel.cs | 21 ++- .../Models/Queries/ListMainMenuItem.cs | 19 +++ .../Money.Blazor.Host.csproj | 8 + .../webcompilerconfiguration.json | 22 +++ src/Money.Blazor.Host/wwwroot/css/site.css | 154 +++++++++--------- .../wwwroot/css/site.min.css | 2 +- src/Money.Blazor.Host/wwwroot/css/site.scss | 68 +------- 18 files changed, 425 insertions(+), 276 deletions(-) create mode 100644 .config/dotnet-tools.json create mode 100644 src/Money.Blazor.Host/MenuItems/Models/Queries/ListMainMenuItem.cs create mode 100644 src/Money.Blazor.Host/webcompilerconfiguration.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 00000000..66623acc --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "excubo.webcompiler": { + "version": "3.8.15", + "commands": [ + "webcompiler" + ] + } + } +} \ No newline at end of file diff --git a/src/Money.Blazor.Host/Bootstrap/BootstrapTask.cs b/src/Money.Blazor.Host/Bootstrap/BootstrapTask.cs index fbd6f554..4f7f5d4f 100644 --- a/src/Money.Blazor.Host/Bootstrap/BootstrapTask.cs +++ b/src/Money.Blazor.Host/Bootstrap/BootstrapTask.cs @@ -86,7 +86,7 @@ public void Initialize() .AddTransient() .AddTransient() .AddSingleton() - .AddSingleton() + .AddTransient() .AddSingleton() .AddTransient() .AddTransient() diff --git a/src/Money.Blazor.Host/Layouts/BottomMenu.razor b/src/Money.Blazor.Host/Layouts/BottomMenu.razor index c4730782..1ad5d051 100644 --- a/src/Money.Blazor.Host/Layouts/BottomMenu.razor +++ b/src/Money.Blazor.Host/Layouts/BottomMenu.razor @@ -17,6 +17,15 @@ } + else if (item.Text == "Main menu") + { + + } else { + +
+ @if (MainMenu != null) + { +
+ @foreach (var item in MainMenu.Views) + @MainMenuItem(item) + @foreach (var item in MainMenu.More.Where(i => i.Text != "About")) + @MainMenuItem(item) +
+
+
+ @foreach (var item in MainMenu.User) + @MainMenuItem(item) +
+ } +
+ } + +@code +{ + RenderFragment MainMenuItem(MenuItemModel item) + { + var isLogout = item.Text == "Logout"; + return + @
+ @if (item.Url != null) + { + + + + + @item.Text + + + + } + else + { + + } +
+ ; + } +} \ No newline at end of file diff --git a/src/Money.Blazor.Host/Layouts/BottomMenu.razor.cs b/src/Money.Blazor.Host/Layouts/BottomMenu.razor.cs index 66ae9e87..ea9f09b8 100644 --- a/src/Money.Blazor.Host/Layouts/BottomMenu.razor.cs +++ b/src/Money.Blazor.Host/Layouts/BottomMenu.razor.cs @@ -32,6 +32,7 @@ public partial class BottomMenu : IDisposable, protected Interop Interop { get; set; } protected List Items { get; set; } + protected MainMenuItems MainMenu { get; set; } protected async override Task OnInitializedAsync() { @@ -39,6 +40,7 @@ protected async override Task OnInitializedAsync() await base.OnInitializedAsync(); await LoadAsync(); + MainMenu = await Queries.QueryAsync(new ListMainMenuItem()); } public void Dispose() diff --git a/src/Money.Blazor.Host/Layouts/Layout.razor b/src/Money.Blazor.Host/Layouts/Layout.razor index cbc45685..4884cec4 100644 --- a/src/Money.Blazor.Host/Layouts/Layout.razor +++ b/src/Money.Blazor.Host/Layouts/Layout.razor @@ -2,7 +2,7 @@ @inject Navigator Navigator
-