Implemented draft for toolbar feature

pull/279/head
Halil İbrahim Kalkan 7 years ago
parent 8fcc06eab9
commit 12a5ed8028

@ -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))
}
};
}
}
}

@ -1,6 +1,6 @@
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Views.Shared.Components.Theme.MainNavbar.Brand
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Views.Shared.Components.Theme.MainNavbar.Menu
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Views.Shared.Components.Theme.MainNavbar.Tools
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Views.Shared.Components.Theme.MainNavbar.Toolbar
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top" id="main-navbar">
@(await Component.InvokeAsync<MainNavbarBrandViewComponent>())
<button class="navbar-toggler" type="button" data-toggle="collapse"
@ -14,8 +14,7 @@
</ul>
<span id="main-navbar-tools">
@(await Component.InvokeAsync<MainNavbarToolsViewComponent>())
@(await Component.InvokeAsync<MainNavbarToolbarViewComponent>())
</span>
</div>
</nav>

@ -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);
}
}
}

@ -19,10 +19,6 @@
<EmbeddedResource Include="Views\**\*.cshtml" />
<EmbeddedResource Include="wwwroot\**\*.*" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Remove="Views\Shared\Components\Theme\MainNavbar\Tools\Default.cshtml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.csproj" />

@ -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));
}
}
}

@ -6,7 +6,6 @@ using Volo.Abp.DependencyInjection;
namespace Volo.Abp.UI.Navigation
{
//TODO: We can move Navigation to a dedicated dll, or to a Volo.Abp.Ui dll.
public class MenuManager : IMenuManager, ITransientDependency
{
private readonly NavigationOptions _options;

Loading…
Cancel
Save