mirror of https://github.com/abpframework/abp.git
12 changed files with 107 additions and 11 deletions
@ -0,0 +1,20 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Views.Shared.Components.Theme.MainNavbar.Toolbar.Items.UserMenu; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars |
|||
{ |
|||
public class ToolbarManager : IToolbarManager, ITransientDependency |
|||
{ |
|||
public async Task<Toolbar> GetAsync(string name) |
|||
{ |
|||
return new Toolbar(name) |
|||
{ |
|||
Items = |
|||
{ |
|||
new ToolbarItem(typeof(UserMenuViewComponent)) |
|||
} |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars |
|||
@model Toolbar |
|||
@foreach (var toolbarItem in Model.Items) |
|||
{ |
|||
<text>@(await Component.InvokeAsync(toolbarItem.ComponentType))</text> |
|||
} |
|||
@ -1,12 +1,12 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Views.Shared.Components.Theme.MainNavbar.Tools |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Views.Shared.Components.Theme.MainNavbar.Toolbar.Items.UserMenu |
|||
{ |
|||
public class MainNavbarToolsViewComponent : AbpViewComponent |
|||
public class UserMenuViewComponent : AbpViewComponent |
|||
{ |
|||
public IViewComponentResult Invoke() |
|||
{ |
|||
return View("~/Views/Shared/Components/Theme/MainNavbar/Tools/Default.cshtml"); |
|||
return View("~/Views/Shared/Components/Theme/MainNavbar/Toolbar/Items/UserMenu/Default.cshtml"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Views.Shared.Components.Theme.MainNavbar.Toolbar |
|||
{ |
|||
public class MainNavbarToolbarViewComponent : AbpViewComponent |
|||
{ |
|||
private readonly IToolbarManager _toolbarManager; |
|||
|
|||
public MainNavbarToolbarViewComponent(IToolbarManager toolbarManager) |
|||
{ |
|||
_toolbarManager = toolbarManager; |
|||
} |
|||
|
|||
public async Task<IViewComponentResult> InvokeAsync() |
|||
{ |
|||
var toolbar = await _toolbarManager.GetAsync(StandardToolbars.Main); |
|||
return View("~/Views/Shared/Components/Theme/MainNavbar/Toolbar/Default.cshtml", toolbar); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars |
|||
{ |
|||
public interface IToolbarManager |
|||
{ |
|||
Task<Toolbar> GetAsync(string name); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars |
|||
{ |
|||
public static class StandardToolbars |
|||
{ |
|||
public const string Main = "Main"; |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System.Collections.Generic; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars |
|||
{ |
|||
public class Toolbar |
|||
{ |
|||
public string Name { get; } |
|||
|
|||
public List<ToolbarItem> Items { get; } |
|||
|
|||
public Toolbar([NotNull] string name) |
|||
{ |
|||
Name = Check.NotNull(name, nameof(name)); |
|||
Items = new List<ToolbarItem>(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars |
|||
{ |
|||
public class ToolbarItem |
|||
{ |
|||
public Type ComponentType |
|||
{ |
|||
get => _componentType; |
|||
set => _componentType = Check.NotNull(value, nameof(value)); |
|||
} |
|||
private Type _componentType; |
|||
|
|||
public ToolbarItem([NotNull] Type componentType) |
|||
{ |
|||
ComponentType = Check.NotNull(componentType, nameof(componentType)); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue