File tree Expand file tree Collapse file tree 8 files changed +89
-93
lines changed
Templates/All-In-One-Template/MySpaProject/MySpaProject.WebMpa Expand file tree Collapse file tree 8 files changed +89
-93
lines changed Original file line number Diff line number Diff line change
1
+ using System . Web . Mvc ;
2
+ using Abp . Application . Navigation ;
3
+ using Abp . Localization ;
4
+ using MySpaProject . WebMpa . Models . Layout ;
5
+
6
+ namespace MySpaProject . WebMpa . Controllers
7
+ {
8
+ public class LayoutController : MySpaProjectControllerBase
9
+ {
10
+ private readonly IUserNavigationManager _userNavigationManager ;
11
+ private readonly ILocalizationManager _localizationManager ;
12
+
13
+ public LayoutController ( IUserNavigationManager userNavigationManager , ILocalizationManager localizationManager )
14
+ {
15
+ _userNavigationManager = userNavigationManager ;
16
+ _localizationManager = localizationManager ;
17
+ }
18
+
19
+ [ ChildActionOnly ]
20
+ public PartialViewResult TopMenu ( )
21
+ {
22
+ var model = new TopMenuViewModel
23
+ {
24
+ MainMenu = _userNavigationManager . GetMenu ( "MainMenu" , CurrentSession . UserId )
25
+ } ;
26
+
27
+ return PartialView ( "_TopMenu" , model ) ;
28
+ }
29
+
30
+ [ ChildActionOnly ]
31
+ public PartialViewResult LanguageSelection ( )
32
+ {
33
+ var model = new LanguageSelectionViewModel
34
+ {
35
+ CurrentLanguage = _localizationManager . CurrentLanguage ,
36
+ Languages = _localizationManager . GetAllLanguages ( )
37
+ } ;
38
+
39
+ return PartialView ( "_LanguageSelection" , model ) ;
40
+ }
41
+ }
42
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ using System . Collections . Generic ;
2
+ using Abp . Localization ;
3
+
4
+ namespace MySpaProject . WebMpa . Models . Layout
5
+ {
6
+ public class LanguageSelectionViewModel
7
+ {
8
+ public LanguageInfo CurrentLanguage { get ; set ; }
9
+
10
+ public IReadOnlyList < LanguageInfo > Languages { get ; set ; }
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ using Abp . Application . Navigation ;
2
+
3
+ namespace MySpaProject . WebMpa . Models . Layout
4
+ {
5
+ public class TopMenuViewModel
6
+ {
7
+ public UserMenu MainMenu { get ; set ; }
8
+ }
9
+ }
Original file line number Diff line number Diff line change 299
299
<Compile Include =" App_Start\RouteConfig.cs" />
300
300
<Compile Include =" Controllers\AboutController.cs" />
301
301
<Compile Include =" Controllers\HomeController.cs" />
302
+ <Compile Include =" Models\Layout\LanguageSelectionViewModel.cs" />
303
+ <Compile Include =" Controllers\LayoutController.cs" />
302
304
<Compile Include =" Controllers\MySpaProjectControllerBase.cs" />
303
305
<Compile Include =" Global.asax.cs" >
304
306
<DependentUpon >Global.asax</DependentUpon >
305
307
</Compile >
306
- <Compile Include =" Localization\ApplicationLanguageInfo .cs" />
308
+ <Compile Include =" Models\Layout\TopMenuViewModel .cs" />
307
309
<Compile Include =" Properties\AssemblyInfo.cs" />
308
310
<Compile Include =" Views\MySpaProjectWebViewPageBase.cs" />
309
311
</ItemGroup >
323
325
<DependentUpon >Web.config</DependentUpon >
324
326
</None >
325
327
</ItemGroup >
326
- <ItemGroup >
327
- <Folder Include =" Models\" />
328
- </ItemGroup >
328
+ <ItemGroup />
329
329
<ItemGroup >
330
330
<ProjectReference Include =" ..\MySpaProject.Application\MySpaProject.Application.csproj" >
331
331
<Project >{edf5d964-4c0f-4f19-b674-58a38a5e5401}</Project >
Original file line number Diff line number Diff line change 1
- @using MySpaProject .WebMpa .Localization
2
- @{
3
- var currentLanguage = ApplicationLanguageInfo .CurrentLanguage ;
4
- }
1
+ @model MySpaProject .WebMpa .Models .Layout .LanguageSelectionViewModel
5
2
<li class =" dropdown" >
6
3
<a href =" #" class =" dropdown-toggle" data-toggle =" dropdown" >
7
- <i class =" @currentLanguage.IconClass " ></i >
8
- <span >@currentLanguage .DisplayName </span >
4
+ <i class =" @Model.CurrentLanguage.Icon " ></i >
5
+ <span >@Model.CurrentLanguage .DisplayName </span >
9
6
<b class =" caret" ></b >
10
7
</a >
11
8
<ul class =" dropdown-menu" >
12
- @foreach ( var language in ApplicationLanguageInfo . SupportedLanguages . Values )
9
+ @foreach ( var language in Model . Languages )
13
10
{
14
- if (language != currentLanguage )
11
+ if (language . Name != Model . CurrentLanguage . Name )
15
12
{
16
- < li >< a href = " /AbpLocalization/ChangeCulture?cultureName=@(language.Name)&returnUrl=@(Request.Url)" >< i class = " @language.IconClass " >< / i > @language .DisplayName < / a >< / li >
13
+ < li >< a href = " /AbpLocalization/ChangeCulture?cultureName=@(language.Name)&returnUrl=@(Request.Url)" >< i class = " @language.Icon " >< / i > @language .DisplayName < / a >< / li >
17
14
}
18
15
}
19
16
</ul >
Original file line number Diff line number Diff line change 7
7
<span class =" icon-bar" ></span >
8
8
<span class =" icon-bar" ></span >
9
9
</button >
10
- <a class =" navbar-brand" href =" # " > MySpaProject! </a >
10
+ <a class =" navbar-brand" href =" ~/ " >< i class = " fa fa-cubes " ></ i > MySpaProject</a >
11
11
</div >
12
12
<div class =" collapse navbar-collapse" >
13
13
<ul class =" nav navbar-nav" >
14
- @Html.Partial( "_TopMenu ")
14
+ @Html.Action( "TopMenu", "Layout ")
15
15
</ul >
16
16
<ul class =" nav navbar-nav navbar-right" >
17
- @Html.Partial( "_LanguageSelection ")
17
+ @Html.Action( "LanguageSelection", "Layout ")
18
18
</ul >
19
19
</div >
20
20
</div >
Original file line number Diff line number Diff line change 1
- <li class =" @(ViewBag.CurrentPage == " Home " ? " active " : " " )" >
2
- <a href =" @Url.Action(" Index " , " Home " )" >@L( "HomePage")</a >
3
- </li >
4
- <li class =" @(ViewBag.CurrentPage == " About " ? " active " : " " )" >
5
- <a href =" @Url.Action(" Index " , " About " )" >@L( "About")</a >
6
- </li >
1
+ @model MySpaProject .WebMpa .Models .Layout .TopMenuViewModel
2
+ @foreach ( var menuItem in Model .MainMenu .Items )
3
+ {
4
+ <li class =" @(ViewBag.CurrentPage == menuItem.Name ? " active " : " " )" >
5
+ <a href =" @menuItem.Url" >
6
+ @if (! string .IsNullOrWhiteSpace (menuItem .Icon ))
7
+ {
8
+ <i class =" @menuItem.Icon" ></i >
9
+ }
10
+ @menuItem.DisplayName
11
+ </a >
12
+ </li >
13
+ }
You can’t perform that action at this time.
0 commit comments