mirror of https://github.com/abpframework/abp.git
committed by
GitHub
124 changed files with 15130 additions and 16543 deletions
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -1,23 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class BlogFeatureEnabledColumnRename : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.RenameColumn( |
|||
name: "Enabled", |
|||
table: "CmsBlogFeatures", |
|||
newName: "IsEnabled"); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.RenameColumn( |
|||
name: "IsEnabled", |
|||
table: "CmsBlogFeatures", |
|||
newName: "Enabled"); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,24 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class Page_Remove_Description : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "Description", |
|||
table: "CmsPages"); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<string>( |
|||
name: "Description", |
|||
table: "CmsPages", |
|||
type: "nvarchar(512)", |
|||
maxLength: 512, |
|||
nullable: true); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,109 +0,0 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class BlogPost_Author : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_CreatorId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_DeleterId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_LastModifierId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropIndex( |
|||
name: "IX_CmsBlogPosts_CreatorId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropIndex( |
|||
name: "IX_CmsBlogPosts_DeleterId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropIndex( |
|||
name: "IX_CmsBlogPosts_LastModifierId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.AddColumn<Guid>( |
|||
name: "AuthorId", |
|||
table: "CmsBlogPosts", |
|||
type: "uniqueidentifier", |
|||
nullable: false, |
|||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_CmsBlogPosts_AuthorId", |
|||
table: "CmsBlogPosts", |
|||
column: "AuthorId"); |
|||
|
|||
migrationBuilder.AddForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_AuthorId", |
|||
table: "CmsBlogPosts", |
|||
column: "AuthorId", |
|||
principalTable: "CmsUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_AuthorId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropIndex( |
|||
name: "IX_CmsBlogPosts_AuthorId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.DropColumn( |
|||
name: "AuthorId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_CmsBlogPosts_CreatorId", |
|||
table: "CmsBlogPosts", |
|||
column: "CreatorId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_CmsBlogPosts_DeleterId", |
|||
table: "CmsBlogPosts", |
|||
column: "DeleterId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_CmsBlogPosts_LastModifierId", |
|||
table: "CmsBlogPosts", |
|||
column: "LastModifierId"); |
|||
|
|||
migrationBuilder.AddForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_CreatorId", |
|||
table: "CmsBlogPosts", |
|||
column: "CreatorId", |
|||
principalTable: "CmsUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Restrict); |
|||
|
|||
migrationBuilder.AddForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_DeleterId", |
|||
table: "CmsBlogPosts", |
|||
column: "DeleterId", |
|||
principalTable: "CmsUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Restrict); |
|||
|
|||
migrationBuilder.AddForeignKey( |
|||
name: "FK_CmsBlogPosts_CmsUsers_LastModifierId", |
|||
table: "CmsBlogPosts", |
|||
column: "LastModifierId", |
|||
principalTable: "CmsUsers", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Restrict); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,25 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class Added_EntityType_to_Media : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<string>( |
|||
name: "EntityType", |
|||
table: "CmsMediaDescriptors", |
|||
type: "nvarchar(64)", |
|||
maxLength: 64, |
|||
nullable: false, |
|||
defaultValue: ""); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "EntityType", |
|||
table: "CmsMediaDescriptors"); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,24 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class Added_Content_To_BlogPost : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<string>( |
|||
name: "Content", |
|||
table: "CmsBlogPosts", |
|||
type: "nvarchar(max)", |
|||
maxLength: 2147483647, |
|||
nullable: true); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "Content", |
|||
table: "CmsBlogPosts"); |
|||
} |
|||
} |
|||
} |
|||
@ -1,24 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class Added_Content_To_Page : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<string>( |
|||
name: "Content", |
|||
table: "CmsPages", |
|||
type: "nvarchar(max)", |
|||
maxLength: 2147483647, |
|||
nullable: true); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "Content", |
|||
table: "CmsPages"); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,56 +0,0 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class BlogPost_CoverImage : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "CmsContents"); |
|||
|
|||
migrationBuilder.AddColumn<Guid>( |
|||
name: "CoverImageMediaId", |
|||
table: "CmsBlogPosts", |
|||
type: "uniqueidentifier", |
|||
nullable: true); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "CoverImageMediaId", |
|||
table: "CmsBlogPosts"); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "CmsContents", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
EntityId = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), |
|||
EntityType = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true), |
|||
Value = table.Column<string>(type: "nvarchar(max)", maxLength: 2147483647, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_CmsContents", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_CmsContents_TenantId_EntityType_EntityId", |
|||
table: "CmsContents", |
|||
columns: new[] { "TenantId", "EntityType", "EntityId" }); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -1,33 +0,0 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Volo.CmsKit.Migrations |
|||
{ |
|||
public partial class Page_StyleScript : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<string>( |
|||
name: "Script", |
|||
table: "CmsPages", |
|||
type: "nvarchar(max)", |
|||
nullable: true); |
|||
|
|||
migrationBuilder.AddColumn<string>( |
|||
name: "Style", |
|||
table: "CmsPages", |
|||
type: "nvarchar(max)", |
|||
nullable: true); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "Script", |
|||
table: "CmsPages"); |
|||
|
|||
migrationBuilder.DropColumn( |
|||
name: "Style", |
|||
table: "CmsPages"); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,36 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.CmsKit.Menus; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
public interface IMenuAdminAppService : IApplicationService |
|||
{ |
|||
Task<PagedResultDto<MenuWithDetailsDto>> GetListAsync(PagedAndSortedResultRequestDto input); |
|||
|
|||
Task<MenuWithDetailsDto> GetAsync(Guid id); |
|||
|
|||
Task<MenuWithDetailsDto> CreateAsync(MenuCreateInput input); |
|||
|
|||
Task<MenuWithDetailsDto> UpdateAsync(Guid menuId, MenuUpdateInput input); |
|||
|
|||
Task DeleteAsync(Guid menuId); |
|||
|
|||
Task<MenuItemDto> GetMenuItemAsync(Guid menuId, Guid menuItemId); |
|||
|
|||
Task<MenuItemDto> CreateMenuItemAsync(Guid menuId, MenuItemCreateInput input); |
|||
|
|||
Task<MenuItemDto> UpdateMenuItemAsync(Guid menuId, Guid menuItemId, MenuItemUpdateInput input); |
|||
|
|||
Task DeleteMenuItemAsync(Guid menuId, Guid menuItemId); |
|||
|
|||
Task MoveMenuItemAsync(Guid menuId, Guid menuItemId, MenuItemMoveInput input); |
|||
|
|||
Task UpdateMainMenuAsync(Guid menuId, UpdateMainMenuInput input); |
|||
|
|||
|
|||
Task<PagedResultDto<PageLookupDto>> GetPageLookupAsync(PageLookupInputDto input); |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
[Serializable] |
|||
public class MenuCreateInput |
|||
{ |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
[Serializable] |
|||
public class MenuItemCreateInput |
|||
{ |
|||
public Guid MenuId { get; set; } |
|||
|
|||
public Guid? ParentId { get; set; } |
|||
|
|||
[Required] |
|||
public string DisplayName { get; set; } |
|||
|
|||
public bool IsActive { get; set; } |
|||
|
|||
public string Url { get; set; } |
|||
|
|||
public string Icon { get; set; } |
|||
|
|||
public int Order { get; set; } |
|||
|
|||
public string Target { get; set; } |
|||
|
|||
public string ElementId { get; set; } |
|||
|
|||
public string CssClass { get; set; } |
|||
|
|||
public Guid? PageId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
[Serializable] |
|||
public class MenuItemMoveInput |
|||
{ |
|||
public Guid? NewParentId { get; set; } |
|||
|
|||
public int Position { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
[Serializable] |
|||
public class MenuItemUpdateInput |
|||
{ |
|||
[Required] |
|||
public string DisplayName { get; set; } |
|||
|
|||
public bool IsActive { get; set; } |
|||
|
|||
public string Url { get; set; } |
|||
|
|||
public string Icon { get; set; } |
|||
|
|||
public string Target { get; set; } |
|||
|
|||
public string ElementId { get; set; } |
|||
|
|||
public string CssClass { get; set; } |
|||
|
|||
public Guid? PageId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
[Serializable] |
|||
public class MenuUpdateInput |
|||
{ |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
public class PageLookupDto : EntityDto<Guid> |
|||
{ |
|||
public string Title { get; set; } |
|||
|
|||
public string Slug { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
[Serializable] |
|||
public class PageLookupInputDto: PagedAndSortedResultRequestDto |
|||
{ |
|||
public string Filter { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
[Serializable] |
|||
public class UpdateMainMenuInput |
|||
{ |
|||
public bool IsMainMenu { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,207 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Domain.Entities; |
|||
using Volo.Abp.GlobalFeatures; |
|||
using Volo.CmsKit.GlobalFeatures; |
|||
using Volo.CmsKit.Menus; |
|||
using Volo.CmsKit.Pages; |
|||
using Volo.CmsKit.Permissions; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
[RequiresGlobalFeature(typeof(MenuFeature))] |
|||
[Authorize(CmsKitAdminPermissions.Menus.Default)] |
|||
public class MenuAdminAppService : CmsKitAdminAppServiceBase, IMenuAdminAppService |
|||
{ |
|||
protected MenuManager MenuManager { get; } |
|||
protected IMenuRepository MenuRepository { get; } |
|||
protected IPageRepository PageRepository { get; } |
|||
|
|||
public MenuAdminAppService( |
|||
MenuManager menuManager, |
|||
IMenuRepository menuRepository, |
|||
IPageRepository pageRepository) |
|||
{ |
|||
MenuManager = menuManager; |
|||
MenuRepository = menuRepository; |
|||
PageRepository = pageRepository; |
|||
} |
|||
|
|||
public async Task<PagedResultDto<MenuWithDetailsDto>> GetListAsync(PagedAndSortedResultRequestDto input) |
|||
{ |
|||
var menus = await MenuRepository.GetPagedListAsync(input.SkipCount, input.MaxResultCount, input.Sorting); |
|||
|
|||
return new PagedResultDto<MenuWithDetailsDto>( |
|||
await MenuRepository.GetCountAsync(), |
|||
ObjectMapper.Map<List<Menu>, List<MenuWithDetailsDto>>(menus) |
|||
); |
|||
} |
|||
|
|||
public async Task<MenuWithDetailsDto> GetAsync(Guid id) |
|||
{ |
|||
var menu = await MenuRepository.GetAsync(id, includeDetails: true); |
|||
return ObjectMapper.Map<Menu, MenuWithDetailsDto>(menu); |
|||
} |
|||
|
|||
public async Task<MenuWithDetailsDto> GetSimpleAsync(Guid id) |
|||
{ |
|||
var menu = await MenuRepository.GetAsync(id, includeDetails: false); |
|||
return ObjectMapper.Map<Menu, MenuWithDetailsDto>(menu); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.Create)] |
|||
public async Task<MenuWithDetailsDto> CreateAsync(MenuCreateInput input) |
|||
{ |
|||
var menu = await MenuManager.CreateAsync(CurrentTenant.Id, input.Name); |
|||
|
|||
await MenuRepository.InsertAsync(menu); |
|||
|
|||
return ObjectMapper.Map<Menu, MenuWithDetailsDto>(menu); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
public async Task<MenuWithDetailsDto> UpdateAsync(Guid menuId, MenuUpdateInput input) |
|||
{ |
|||
var menu = await MenuRepository.GetAsync(menuId); |
|||
|
|||
menu.SetName(input.Name); |
|||
|
|||
await MenuRepository.UpdateAsync(menu); |
|||
|
|||
return ObjectMapper.Map<Menu, MenuWithDetailsDto>(menu); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.Delete)] |
|||
public virtual Task DeleteAsync(Guid menuId) |
|||
{ |
|||
return MenuRepository.DeleteAsync(menuId); |
|||
} |
|||
|
|||
public async Task<MenuItemDto> GetMenuItemAsync(Guid menuId, Guid menuItemId) |
|||
{ |
|||
var menu = await MenuRepository.GetAsync(menuId); |
|||
|
|||
var menuItem = menu.Items.FirstOrDefault(x => x.Id == menuItemId) |
|||
?? throw new EntityNotFoundException(typeof(MenuItem), menuItemId); |
|||
|
|||
return ObjectMapper.Map<MenuItem, MenuItemDto>(menuItem); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
public virtual async Task<MenuItemDto> CreateMenuItemAsync(Guid menuId, MenuItemCreateInput input) |
|||
{ |
|||
var menu = await MenuRepository.GetAsync(menuId, includeDetails: true); |
|||
|
|||
var menuItem = |
|||
new MenuItem( |
|||
GuidGenerator.Create(), |
|||
menuId, |
|||
input.DisplayName, |
|||
input.Url.IsNullOrEmpty() ? "#" : input.Url, |
|||
input.IsActive, |
|||
input.ParentId, |
|||
input.Icon, |
|||
input.Order, |
|||
input.Target, |
|||
input.ElementId, |
|||
input.CssClass); |
|||
|
|||
if (input.PageId.HasValue) |
|||
{ |
|||
var page = await PageRepository.GetAsync(input.PageId.Value); |
|||
MenuManager.SetPageUrl(menuItem, page); |
|||
} |
|||
|
|||
menu.Items.Add(menuItem); |
|||
|
|||
MenuManager.OrganizeTreeOrderForMenuItem(menu, menuItem); |
|||
|
|||
await MenuRepository.UpdateAsync(menu); |
|||
|
|||
return ObjectMapper.Map<MenuItem, MenuItemDto>(menuItem); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
public virtual async Task<MenuItemDto> UpdateMenuItemAsync(Guid menuId, Guid menuItemId, |
|||
MenuItemUpdateInput input) |
|||
{ |
|||
var menu = await MenuRepository.GetAsync(menuId, includeDetails: true); |
|||
|
|||
var menuItem = menu.Items.FirstOrDefault(x => x.Id == menuItemId) |
|||
?? throw new EntityNotFoundException(typeof(MenuItem), menuItemId); |
|||
|
|||
if (input.PageId.HasValue) |
|||
{ |
|||
MenuManager.SetPageUrl(menuItem, await PageRepository.GetAsync(input.PageId.Value)); |
|||
} |
|||
else |
|||
{ |
|||
menuItem.SetUrl(input.Url); |
|||
} |
|||
|
|||
menuItem.SetDisplayName(input.DisplayName); |
|||
menuItem.IsActive = input.IsActive; |
|||
menuItem.Icon = input.Icon; |
|||
menuItem.Target = input.Target; |
|||
menuItem.ElementId = input.ElementId; |
|||
menuItem.CssClass = input.CssClass; |
|||
|
|||
await MenuRepository.UpdateAsync(menu); |
|||
|
|||
return ObjectMapper.Map<MenuItem, MenuItemDto>(menuItem); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
public virtual async Task DeleteMenuItemAsync(Guid menuId, Guid menuItemId) |
|||
{ |
|||
var menu = await MenuRepository.GetAsync(menuId, includeDetails: true); |
|||
|
|||
var menuItem = menu.Items.FirstOrDefault(x => x.Id == menuItemId) |
|||
?? throw new EntityNotFoundException(typeof(MenuItem), menuItemId); |
|||
|
|||
menu.Items.Remove(menuItem); |
|||
|
|||
await MenuRepository.UpdateAsync(menu); |
|||
} |
|||
|
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
public virtual Task MoveMenuItemAsync(Guid menuId, Guid menuItemId, MenuItemMoveInput input) |
|||
{ |
|||
return MenuManager.MoveAsync(menuId, menuItemId, input.NewParentId, input.Position); |
|||
} |
|||
|
|||
public virtual async Task UpdateMainMenuAsync(Guid menuId, UpdateMainMenuInput input) |
|||
{ |
|||
if (input.IsMainMenu) |
|||
{ |
|||
await MenuManager.SetMainMenuAsync(menuId); |
|||
} |
|||
else |
|||
{ |
|||
await MenuManager.UnSetMainMenuAsync(menuId); |
|||
} |
|||
} |
|||
|
|||
public virtual async Task<PagedResultDto<PageLookupDto>> GetPageLookupAsync(PageLookupInputDto input) |
|||
{ |
|||
var count = await PageRepository.GetCountAsync(input.Filter); |
|||
|
|||
var pages = await PageRepository.GetListAsync( |
|||
input.Filter, |
|||
input.MaxResultCount, |
|||
input.SkipCount, |
|||
input.Sorting |
|||
); |
|||
|
|||
return new PagedResultDto<PageLookupDto>( |
|||
count, |
|||
ObjectMapper.Map<List<Page>, List<PageLookupDto>>(pages) |
|||
); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,123 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.GlobalFeatures; |
|||
using Volo.Abp.UI.Navigation; |
|||
using Volo.CmsKit.GlobalFeatures; |
|||
using Volo.CmsKit.Menus; |
|||
using Volo.CmsKit.Permissions; |
|||
|
|||
namespace Volo.CmsKit.Admin.Menus |
|||
{ |
|||
[RequiresGlobalFeature(typeof(MenuFeature))] |
|||
[RemoteService(Name = CmsKitAdminRemoteServiceConsts.RemoteServiceName)] |
|||
[Area("cms-kit")] |
|||
[Authorize(CmsKitAdminPermissions.Menus.Default)] |
|||
[Route("api/cms-kit-admin/menus")] |
|||
public class MenuAdminController : CmsKitAdminController, IMenuAdminAppService |
|||
{ |
|||
protected IMenuAdminAppService MenuAdminAppService { get; } |
|||
|
|||
public MenuAdminController(IMenuAdminAppService menuAdminAppService) |
|||
{ |
|||
MenuAdminAppService = menuAdminAppService; |
|||
} |
|||
|
|||
[HttpPost] |
|||
[Authorize(CmsKitAdminPermissions.Menus.Create)] |
|||
public Task<MenuWithDetailsDto> CreateAsync(MenuCreateInput input) |
|||
{ |
|||
return MenuAdminAppService.CreateAsync(input); |
|||
} |
|||
|
|||
[Route("{menuId}/menu-items/{menuItemId}")] |
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
[HttpGet] |
|||
public Task<MenuItemDto> GetMenuItemAsync(Guid menuId, Guid menuItemId) |
|||
{ |
|||
return MenuAdminAppService.GetMenuItemAsync(menuId, menuItemId); |
|||
} |
|||
|
|||
[Route("{menuId}/menu-items")] |
|||
[HttpPost] |
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
public Task<MenuItemDto> CreateMenuItemAsync(Guid menuId, MenuItemCreateInput input) |
|||
{ |
|||
return MenuAdminAppService.CreateMenuItemAsync(menuId, input); |
|||
} |
|||
|
|||
[Route("{menuId}")] |
|||
[HttpDelete] |
|||
[Authorize(CmsKitAdminPermissions.Menus.Delete)] |
|||
public Task DeleteAsync(Guid menuId) |
|||
{ |
|||
return MenuAdminAppService.DeleteAsync(menuId); |
|||
} |
|||
|
|||
[Route("{menuId}/menu-items/{menuItemId}")] |
|||
[HttpDelete] |
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
public Task DeleteMenuItemAsync(Guid menuId, Guid menuItemId) |
|||
{ |
|||
return MenuAdminAppService.DeleteMenuItemAsync(menuId, menuItemId); |
|||
} |
|||
|
|||
[Route("{menuId}")] |
|||
[HttpGet] |
|||
public Task<MenuWithDetailsDto> GetAsync(Guid menuId) |
|||
{ |
|||
return MenuAdminAppService.GetAsync(menuId); |
|||
} |
|||
|
|||
[HttpGet] |
|||
public Task<PagedResultDto<MenuWithDetailsDto>> GetListAsync(PagedAndSortedResultRequestDto input) |
|||
{ |
|||
return MenuAdminAppService.GetListAsync(input); |
|||
} |
|||
|
|||
[Route("{menuId}/menu-items/{menuItemId}/move")] |
|||
[HttpPut] |
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
public Task MoveMenuItemAsync(Guid menuId, Guid menuItemId, MenuItemMoveInput input) |
|||
{ |
|||
return MenuAdminAppService.MoveMenuItemAsync(menuId, menuItemId, input); |
|||
} |
|||
|
|||
[Route("{menuId}/main-menu")] |
|||
[HttpPut] |
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
public Task UpdateMainMenuAsync(Guid menuId, UpdateMainMenuInput input) |
|||
{ |
|||
return MenuAdminAppService.UpdateMainMenuAsync(menuId, input); |
|||
} |
|||
|
|||
[Route("{menuId}")] |
|||
[HttpPut] |
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
public Task<MenuWithDetailsDto> UpdateAsync(Guid menuId, MenuUpdateInput input) |
|||
{ |
|||
return MenuAdminAppService.UpdateAsync(menuId, input); |
|||
} |
|||
|
|||
[Route("{menuId}/menu-items/{menuItemId}")] |
|||
[HttpPut] |
|||
[Authorize(CmsKitAdminPermissions.Menus.Update)] |
|||
public Task<MenuItemDto> UpdateMenuItemAsync(Guid menuId, Guid menuItemId, MenuItemUpdateInput input) |
|||
{ |
|||
return MenuAdminAppService.UpdateMenuItemAsync(menuId, menuItemId, input); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("lookup/pages")] |
|||
public virtual Task<PagedResultDto<PageLookupDto>> GetPageLookupAsync([FromQuery]PageLookupInputDto input) |
|||
{ |
|||
return MenuAdminAppService.GetPageLookupAsync(input); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
@page |
|||
|
|||
@using Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus |
|||
@using Volo.CmsKit.Admin.Web.Pages |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|||
|
|||
@inherits CmsKitAdminPageBase |
|||
|
|||
@model CreateModalModel |
|||
|
|||
@{ |
|||
Layout = null; |
|||
} |
|||
|
|||
<abp-dynamic-form abp-model="ViewModel" asp-page="/CmsKit/Menus/CreateModal"> |
|||
<abp-modal> |
|||
<abp-modal-header title="@L["New"].Value"></abp-modal-header> |
|||
<abp-modal-body> |
|||
<abp-form-content /> |
|||
</abp-modal-body> |
|||
<abp-modal-footer buttons="@(AbpModalButtons.Cancel | AbpModalButtons.Save)"></abp-modal-footer> |
|||
</abp-modal> |
|||
</abp-dynamic-form> |
|||
@ -0,0 +1,44 @@ |
|||
using AutoMapper; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Validation; |
|||
using Volo.CmsKit.Admin.Menus; |
|||
using Volo.CmsKit.Menus; |
|||
|
|||
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus |
|||
{ |
|||
public class CreateModalModel : CmsKitAdminPageModel |
|||
{ |
|||
protected IMenuAdminAppService MenuAdminAppService { get; } |
|||
|
|||
[BindProperty] |
|||
public CreateMenuViewModel ViewModel { get; set; } |
|||
|
|||
public CreateModalModel(IMenuAdminAppService menuAdminAppService) |
|||
{ |
|||
MenuAdminAppService = menuAdminAppService; |
|||
} |
|||
|
|||
public async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
var input = ObjectMapper.Map<CreateMenuViewModel, MenuCreateInput>(ViewModel); |
|||
|
|||
await MenuAdminAppService.CreateAsync(input); |
|||
|
|||
return NoContent(); |
|||
} |
|||
|
|||
[AutoMap(typeof(MenuCreateInput), ReverseMap = true)] |
|||
public class CreateMenuViewModel |
|||
{ |
|||
[Required] |
|||
[DynamicMaxLength(typeof(MenuConsts), nameof(MenuConsts.MaxNameLength))] |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
@page |
|||
|
|||
@using Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus |
|||
@using Volo.CmsKit.Admin.Web.Pages |
|||
@using Volo.CmsKit.Admin.Web.Menus |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpPageToolbar |
|||
|
|||
@inherits CmsKitAdminPageBase |
|||
|
|||
@model IndexModel |
|||
|
|||
@{ |
|||
PageLayout.Content.Title = L["Menus"].Value; |
|||
PageLayout.Content.BreadCrumb.Add(L["Menu:CMS"].Value); |
|||
PageLayout.Content.MenuItemName = CmsKitAdminMenus.Menus.MenusMenu; |
|||
} |
|||
|
|||
@section scripts { |
|||
<abp-script-bundle> |
|||
<abp-script src="/Pages/CmsKit/Menus/index.js" /> |
|||
</abp-script-bundle> |
|||
} |
|||
|
|||
@section content_toolbar { |
|||
@await Component.InvokeAsync(typeof(AbpPageToolbarViewComponent), new { pageName = typeof(IndexModel).FullName }) |
|||
} |
|||
|
|||
<div id="CmsKitMenusWrapper"> |
|||
<abp-card> |
|||
<abp-card-body> |
|||
<abp-table striped-rows="true" id="MenusTable" class="nowrap"></abp-table> |
|||
</abp-card-body> |
|||
</abp-card> |
|||
</div> |
|||
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus |
|||
{ |
|||
public class IndexModel |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
@page |
|||
|
|||
@using Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems |
|||
@using Volo.CmsKit.Admin.Web.Pages |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|||
|
|||
@inherits CmsKitAdminPageBase |
|||
|
|||
@model CreateModalModel |
|||
|
|||
@{ |
|||
Layout = null; |
|||
} |
|||
|
|||
<form asp-page="/CmsKit/Menus/MenuItems/CreateModal"> |
|||
<abp-modal> |
|||
<abp-modal-header title="@L["New"].Value"></abp-modal-header> |
|||
<abp-modal-body> |
|||
|
|||
<abp-tabs tab-style="Tab"> |
|||
<abp-tab name="url" title="@L["Url"]"> |
|||
|
|||
<abp-input asp-for="ViewModel.Url"/> |
|||
|
|||
</abp-tab> |
|||
<abp-tab title="@L["Page"]"> |
|||
|
|||
<label asp-for="ViewModel.PageId"></label> |
|||
|
|||
<select class="form-control" asp-for="ViewModel.PageId"></select> |
|||
|
|||
<span asp-validation-for="ViewModel.PageId"></span> |
|||
</abp-tab> |
|||
|
|||
</abp-tabs> |
|||
<hr/> |
|||
<abp-input asp-for="ViewModel.MenuId"/> |
|||
<abp-input asp-for="ViewModel.ParentId"/> |
|||
<abp-input asp-for="ViewModel.DisplayName"/> |
|||
<abp-input asp-for="ViewModel.IsActive"/> |
|||
<abp-input asp-for="ViewModel.Icon"/> |
|||
<abp-input asp-for="ViewModel.Order"/> |
|||
<abp-input asp-for="ViewModel.Target"/> |
|||
<abp-input asp-for="ViewModel.ElementId"/> |
|||
<abp-input asp-for="ViewModel.CssClass"/> |
|||
</abp-modal-body> |
|||
<abp-modal-footer buttons="@(AbpModalButtons.Cancel | AbpModalButtons.Save)"></abp-modal-footer> |
|||
</abp-modal> |
|||
</form> |
|||
@ -0,0 +1,75 @@ |
|||
using AutoMapper; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; |
|||
using Volo.CmsKit.Admin.Menus; |
|||
|
|||
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems |
|||
{ |
|||
public class CreateModalModel : CmsKitAdminPageModel |
|||
{ |
|||
protected IMenuAdminAppService MenuAdminAppService { get; } |
|||
|
|||
[BindProperty] |
|||
public MenuItemCreateViewModel ViewModel { get; set; } |
|||
|
|||
public CreateModalModel(IMenuAdminAppService menuAdminAppService) |
|||
{ |
|||
MenuAdminAppService = menuAdminAppService; |
|||
ViewModel = new MenuItemCreateViewModel(); |
|||
} |
|||
|
|||
public virtual Task OnGetAsync(Guid menuId, Guid? parentId) |
|||
{ |
|||
ViewModel.MenuId = menuId; |
|||
ViewModel.ParentId = parentId; |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
public virtual async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
var input = ObjectMapper.Map<MenuItemCreateViewModel, MenuItemCreateInput>(ViewModel); |
|||
|
|||
var dto = await MenuAdminAppService.CreateMenuItemAsync(ViewModel.MenuId, input); |
|||
|
|||
return new OkObjectResult(dto); |
|||
} |
|||
|
|||
[AutoMap(typeof(MenuItemCreateInput), ReverseMap = true)] |
|||
public class MenuItemCreateViewModel |
|||
{ |
|||
[HiddenInput] |
|||
public Guid MenuId { get; set; } |
|||
|
|||
[HiddenInput] |
|||
public Guid? ParentId { get; set; } |
|||
|
|||
[Required] |
|||
public string DisplayName { get; set; } |
|||
|
|||
public bool IsActive { get; set; } = true; |
|||
|
|||
public string Url { get; set; } |
|||
|
|||
public Guid? PageId { get; set; } |
|||
|
|||
public string Icon { get; set; } |
|||
|
|||
[HiddenInput] |
|||
public int Order { get; set; } |
|||
|
|||
public string Target { get; set; } |
|||
|
|||
public string ElementId { get; set; } |
|||
|
|||
public string CssClass { get; set; } |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
@page |
|||
|
|||
@using Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems |
|||
@using Volo.CmsKit.Admin.Web.Pages |
|||
@using Volo.CmsKit.Admin.Web.Menus |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpPageToolbar |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Packages.JsTree |
|||
|
|||
@inherits CmsKitAdminPageBase |
|||
|
|||
@model IndexModel |
|||
|
|||
@{ |
|||
PageLayout.Content.Title = @Model.Menu.Name + " - " + L["MenuItems"].Value; |
|||
PageLayout.Content.BreadCrumb.Add(L["Menu:CMS"].Value); |
|||
PageLayout.Content.BreadCrumb.Add(L["Menus"].Value, "/Cms/Menus"); |
|||
PageLayout.Content.MenuItemName = CmsKitAdminMenus.Menus.MenusMenu; |
|||
} |
|||
|
|||
@section styles { |
|||
<abp-style-bundle name="@typeof(IndexModel).FullName"> |
|||
<abp-style type="typeof(JsTreeStyleContributor)"/> |
|||
<abp-script src="/Pages/CmsKit/Menus/MenuItems/index.css"/> |
|||
</abp-style-bundle> |
|||
} |
|||
|
|||
@section scripts { |
|||
<abp-script-bundle name="@typeof(IndexModel).FullName"> |
|||
<abp-style type="typeof(JsTreeScriptContributor)"/> |
|||
<abp-script src="/Pages/CmsKit/Menus/MenuItems/index.js"/> |
|||
<abp-script src="/Pages/CmsKit/Menus/MenuItems/createModal.js"/> |
|||
<abp-script src="/Pages/CmsKit/Menus/MenuItems/updateModal.js"/> |
|||
</abp-script-bundle> |
|||
} |
|||
|
|||
@section content_toolbar { |
|||
@await Component.InvokeAsync(typeof(AbpPageToolbarViewComponent), new {pageName = typeof(IndexModel).FullName}) |
|||
} |
|||
|
|||
<div id="CmsKitMenuItemsWrapper" data-menu-id="@Model.Id"> |
|||
<abp-card> |
|||
<abp-card-body> |
|||
<abp-card-title> |
|||
@Model.Menu.Name |
|||
</abp-card-title> |
|||
|
|||
<div id="MenuItemsEditTree"></div> |
|||
<div id="MenuItemsTreeEmptyInfo" class="text-muted">@L["NoMenuItems"]</div> |
|||
</abp-card-body> |
|||
</abp-card> |
|||
</div> |
|||
@ -0,0 +1,31 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.CmsKit.Admin.Menus; |
|||
using Volo.CmsKit.Menus; |
|||
|
|||
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems |
|||
{ |
|||
public class IndexModel : CmsKitAdminPageModel |
|||
{ |
|||
protected IMenuAdminAppService MenuAdminAppService { get; } |
|||
|
|||
[BindProperty(SupportsGet = true)] |
|||
public Guid Id { get; set; } |
|||
|
|||
public MenuWithDetailsDto Menu { get; protected set; } |
|||
|
|||
public IndexModel(IMenuAdminAppService menuAdminAppService) |
|||
{ |
|||
MenuAdminAppService = menuAdminAppService; |
|||
} |
|||
|
|||
public async Task OnGetAsync() |
|||
{ |
|||
Menu = await MenuAdminAppService.GetAsync(Id); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
@page |
|||
|
|||
@using Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems |
|||
@using Volo.CmsKit.Admin.Web.Pages |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|||
|
|||
@inherits CmsKitAdminPageBase |
|||
|
|||
@model UpdateModalModel |
|||
|
|||
@{ |
|||
Layout = null; |
|||
} |
|||
|
|||
<form asp-page="/CmsKit/Menus/MenuItems/UpdateModal"> |
|||
<abp-modal> |
|||
<abp-modal-header title="@L["New"].Value"></abp-modal-header> |
|||
<abp-modal-body> |
|||
<abp-input asp-for="MenuId"/> |
|||
<abp-input asp-for="Id"/> |
|||
|
|||
<abp-tabs tab-style="Tab"> |
|||
<abp-tab name="url" title="@L["Url"]"> |
|||
<abp-input asp-for="ViewModel.Url"/> |
|||
|
|||
</abp-tab> |
|||
<abp-tab title="@L["Page"]"> |
|||
|
|||
<label asp-for="ViewModel.PageId"></label> |
|||
|
|||
<select class="form-control" asp-for="ViewModel.PageId"></select> |
|||
</abp-tab> |
|||
|
|||
</abp-tabs> |
|||
|
|||
<hr/> |
|||
|
|||
<abp-input asp-for="ViewModel.DisplayName"/> |
|||
<abp-input asp-for="ViewModel.IsActive"/> |
|||
<abp-input asp-for="ViewModel.Icon"/> |
|||
<abp-input asp-for="ViewModel.Target"/> |
|||
<abp-input asp-for="ViewModel.ElementId"/> |
|||
<abp-input asp-for="ViewModel.CssClass"/> |
|||
</abp-modal-body> |
|||
<abp-modal-footer buttons="@(AbpModalButtons.Cancel | AbpModalButtons.Save)"></abp-modal-footer> |
|||
</abp-modal> |
|||
</form> |
|||
@ -0,0 +1,70 @@ |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Threading.Tasks; |
|||
using AutoMapper; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc.RazorPages; |
|||
using Volo.CmsKit.Admin.Menus; |
|||
using Volo.CmsKit.Menus; |
|||
|
|||
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus.MenuItems |
|||
{ |
|||
public class UpdateModalModel : CmsKitAdminPageModel |
|||
{ |
|||
protected IMenuAdminAppService MenuAdminAppService { get; } |
|||
|
|||
[BindProperty] |
|||
public MenuItemUpdateViewModel ViewModel { get; set; } |
|||
|
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public Guid MenuId { get; set; } |
|||
|
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public Guid Id { get; set; } |
|||
|
|||
public UpdateModalModel(IMenuAdminAppService menuAdminAppService) |
|||
{ |
|||
MenuAdminAppService = menuAdminAppService; |
|||
} |
|||
|
|||
public async Task OnGetAsync() |
|||
{ |
|||
var menuItemDto = await MenuAdminAppService.GetMenuItemAsync(MenuId, Id); |
|||
|
|||
ViewModel = ObjectMapper.Map<MenuItemDto, MenuItemUpdateViewModel>(menuItemDto); |
|||
} |
|||
|
|||
public async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
var input = ObjectMapper.Map<MenuItemUpdateViewModel, MenuItemUpdateInput>(ViewModel); |
|||
|
|||
var result = await MenuAdminAppService.UpdateMenuItemAsync(MenuId, Id, input); |
|||
|
|||
return new OkObjectResult(result); |
|||
} |
|||
|
|||
[AutoMap(typeof(MenuItemDto))] |
|||
[AutoMap(typeof(MenuItemUpdateInput), ReverseMap = true)] |
|||
public class MenuItemUpdateViewModel |
|||
{ |
|||
[Required] |
|||
public string DisplayName { get; set; } |
|||
|
|||
public bool IsActive { get; set; } |
|||
|
|||
public string Url { get; set; } |
|||
|
|||
public string Icon { get; set; } |
|||
|
|||
public string Target { get; set; } |
|||
|
|||
public string ElementId { get; set; } |
|||
|
|||
public string CssClass { get; set; } |
|||
|
|||
public Guid? PageId { get; set; } |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
var abp = abp || {}; |
|||
$(function () { |
|||
abp.modals.createMenuItem = function () { |
|||
|
|||
var initModal = function (publicApi, args) { |
|||
|
|||
var $pageId = $('#ViewModel_PageId'); |
|||
var $url = $('#ViewModel_Url'); |
|||
var $displayName = $('#ViewModel_DisplayName'); |
|||
var $pageIdClearButton = $('#url-tab'); |
|||
|
|||
initSelectPageId(); |
|||
|
|||
$pageId.on('change', function (params) { |
|||
$url.prop('disabled', $pageId.val()); |
|||
|
|||
if ($pageId.val()) |
|||
{ |
|||
if (!$displayName.val()){ |
|||
$displayName.val($pageId.text()); |
|||
} |
|||
} |
|||
}) |
|||
|
|||
$pageIdClearButton.click(function (){ |
|||
$pageId.val(''); |
|||
$pageId.trigger('change'); |
|||
}) |
|||
|
|||
function initSelectPageId() { |
|||
$pageId.data('autocompleteApiUrl', '/api/cms-kit-admin/menus/lookup/pages'); |
|||
$pageId.data('autocompleteDisplayProperty', 'title'); |
|||
$pageId.data('autocompleteValueProperty', 'id'); |
|||
$pageId.data('autocompleteItemsProperty', 'items'); |
|||
$pageId.data('autocompleteFilterParamName', 'filter'); |
|||
|
|||
abp.dom.initializers.initializeAutocompleteSelects($pageId); |
|||
} |
|||
}; |
|||
|
|||
return { |
|||
initModal: initModal |
|||
}; |
|||
}; |
|||
}); |
|||
@ -0,0 +1 @@ |
|||
.vakata-context { z-index:10052 !important; } |
|||
@ -0,0 +1,409 @@ |
|||
var _menuItem = {}; |
|||
$(function () { |
|||
var l = abp.localization.getResource("CmsKit"); |
|||
|
|||
var menuId = $('#CmsKitMenuItemsWrapper').data('menu-id'); |
|||
|
|||
var menuService = volo.cmsKit.admin.menus.menuAdmin; |
|||
|
|||
var createModal = new abp.ModalManager({ viewUrl: abp.appPath + 'CmsKit/Menus/MenuItems/CreateModal', modalClass: 'createMenuItem' }); |
|||
var updateModal = new abp.ModalManager({ viewUrl: abp.appPath + 'CmsKit/Menus/MenuItems/UpdateModal', modalClass: 'updateMenuItem'}); |
|||
|
|||
var menuTree = { |
|||
|
|||
$tree: $('#MenuItemsEditTree'), |
|||
|
|||
|
|||
$emptyInfo: $('#MenuItemsTreeEmptyInfo'), |
|||
|
|||
show: function () { |
|||
menuTree.$emptyInfo.hide(); |
|||
menuTree.$tree.show(); |
|||
}, |
|||
|
|||
hide: function () { |
|||
menuTree.$emptyInfo.show(); |
|||
menuTree.$tree.hide(); |
|||
}, |
|||
|
|||
itemCount: 0, |
|||
|
|||
setItemCount: function (itemCount) { |
|||
menuTree.itemCount = itemCount; |
|||
if (itemCount) { |
|||
menuTree.show(); |
|||
} else { |
|||
menuTree.hide(); |
|||
} |
|||
}, |
|||
|
|||
refreshItemCount: function () { |
|||
menuTree.setItemCount(menuTree.$tree.jstree('get_json').length); |
|||
}, |
|||
|
|||
selectedMenuItem: { |
|||
id: null, |
|||
displayName: null, |
|||
code: null, |
|||
|
|||
set: function (menuItemOnTree) { |
|||
if (!menuItemOnTree) { |
|||
menuTree.selectedMenuItem.id = null; |
|||
menuTree.selectedMenuItem.displayName = null; |
|||
menuTree.selectedMenuItem.IsActive = true; |
|||
menuTree.selectedMenuItem.Url = null; |
|||
menuTree.selectedMenuItem.Icon = null; |
|||
menuTree.selectedMenuItem.Order = 1; |
|||
menuTree.selectedMenuItem.Target = null; |
|||
menuTree.selectedMenuItem.ElementId = null; |
|||
menuTree.selectedMenuItem.CssClass = null; |
|||
menuTree.selectedMenuItem.PageId = null; |
|||
} else { |
|||
menuTree.selectedMenuItem.id = menuItemOnTree.id; |
|||
menuTree.selectedMenuItem.displayName = menuItemOnTree.original.displayName; |
|||
menuTree.selectedMenuItem.IsActive = menuItemOnTree.original.IsActive; |
|||
menuTree.selectedMenuItem.Url = menuItemOnTree.original.Url; |
|||
menuTree.selectedMenuItem.Icon = menuItemOnTree.original.Icon; |
|||
menuTree.selectedMenuItem.Order = menuItemOnTree.original.Order; |
|||
menuTree.selectedMenuItem.Target = menuItemOnTree.original.Target; |
|||
menuTree.selectedMenuItem.ElementId = menuItemOnTree.original.ElementId; |
|||
menuTree.selectedMenuItem.CssClass = menuItemOnTree.original.CssClass; |
|||
menuTree.selectedMenuItem.PageId = menuItemOnTree.original.PageId; |
|||
} |
|||
|
|||
_menuItem.checkbox.setSelectedItem({ |
|||
id: menuTree.selectedMenuItem.id, |
|||
displayName: menuTree.selectedMenuItem.displayName, |
|||
isActive: menuTree.selectedMenuItem.IsActive, |
|||
url: menuTree.selectedMenuItem.Url, |
|||
icon: menuTree.selectedMenuItem.Icon, |
|||
order: menuTree.selectedMenuItem.Order, |
|||
target: menuTree.selectedMenuItem.Target, |
|||
elementId: menuTree.selectedMenuItem.ElementId, |
|||
cssClass: menuTree.selectedMenuItem.CssClass, |
|||
pageId: menuTree.selectedMenuItem.PageId |
|||
}); |
|||
} |
|||
}, |
|||
|
|||
contextMenu: function (node) { |
|||
var items = { |
|||
edit: { |
|||
label: l('Edit'), |
|||
icon: 'fa fa-pencil', |
|||
_disabled: !abp.auth.isGranted('CmsKit.Menus.Update'), |
|||
action: function (data) { |
|||
var instance = $.jstree.reference(data.reference); |
|||
|
|||
updateModal.open({ |
|||
id: node.id, |
|||
menuId: menuId |
|||
}) |
|||
} |
|||
}, |
|||
|
|||
addSubMenuItem: { |
|||
label: l('AddSubMenuItem'), |
|||
icon: 'fa fa-plus', |
|||
_disabled: !abp.auth.isGranted('CmsKit.Menus.Update'), |
|||
action: function () { |
|||
menuTree.addItem(node.id); |
|||
} |
|||
}, |
|||
|
|||
'delete': { |
|||
label: l('Delete'), |
|||
icon: 'fa fa-remove', |
|||
_disabled: !abp.auth.isGranted('CmsKit.Menus.Update'), |
|||
action: function (data) { |
|||
var instance = $.jstree.reference(data.reference); |
|||
|
|||
abp.message.confirm( |
|||
l('MenuItemDeletionConfirmationMessage', node.original.displayName), |
|||
l('AreYouSure'), |
|||
function (isConfirmed) { |
|||
if (isConfirmed) { |
|||
menuService |
|||
.deleteMenuItem(menuId, node.id) |
|||
.done(function () { |
|||
instance.delete_node(node); |
|||
menuTree.refreshItemCount(); |
|||
}) |
|||
.fail(function (err) { |
|||
setTimeout(function () { |
|||
abp.message.error(err.message); |
|||
}, 500); |
|||
}); |
|||
} |
|||
} |
|||
) |
|||
} |
|||
} |
|||
} |
|||
return items; |
|||
}, |
|||
|
|||
addItem: function (parentId) { |
|||
var instance = $.jstree.reference(menuTree.$tree); |
|||
|
|||
createModal.open({ |
|||
menuId: menuId, |
|||
parentId: parentId, |
|||
}, function (newMenuItem) { |
|||
instance.create_node( |
|||
parentId ? instance.get_node(parentId) : '#', |
|||
{ |
|||
id: newMenuItem.id, |
|||
parent: newMenuItem.parentId ? newMenuItem.parentId : '#', |
|||
isActive: newMenuItem.isActive, |
|||
displayName: $.fn.dataTable.render.text().display(newMenuItem.displayName), |
|||
text: menuTree.generateTextOnTree(newMenuItem), |
|||
url: newMenuItem.url, |
|||
icon: newMenuItem.icon, |
|||
order: newMenuItem.order, |
|||
target: newMenuItem.target, |
|||
elementId: newMenuItem.elementId, |
|||
cssClass: newMenuItem.cssClass, |
|||
pageId: newMenuItem.pageId, |
|||
state: { |
|||
opened: true |
|||
} |
|||
}); |
|||
|
|||
menuTree.refreshItemCount(); |
|||
}); |
|||
}, |
|||
|
|||
generateTextOnTree: function (item) { |
|||
var itemClass = ' ou-text-no-members'; |
|||
return '<span title="' + item.displayName + '" class="ou-text text-dark' + itemClass + '" data-menuitem-id="' + item.id + '">' + |
|||
$.fn.dataTable.render.text().display(item.displayName) + |
|||
' <i class="fa fa-caret-down text-muted"></i></span > '; |
|||
}, |
|||
|
|||
getTreeDataFromServer: function (callback) { |
|||
menuService.get(menuId).done(function (result) { |
|||
var treeData = _.map(result.items, function (item) { |
|||
return { |
|||
id: item.id, |
|||
parent: item.parentId ? item.parentId : '#', |
|||
isActive: item.isActive, |
|||
displayName: $.fn.dataTable.render.text().display(item.displayName), |
|||
url: item.url, |
|||
icon: item.icon, |
|||
order: item.order, |
|||
target: item.target, |
|||
elementId: item.elementId, |
|||
cssClass: item.cssClass, |
|||
pageId: item.pageId, |
|||
text: menuTree.generateTextOnTree(item), |
|||
state: { |
|||
opened: true |
|||
} |
|||
}; |
|||
}); |
|||
|
|||
callback(treeData); |
|||
}); |
|||
}, |
|||
|
|||
init: function () { |
|||
menuTree.getTreeDataFromServer(function (treeData) { |
|||
|
|||
menuTree.setItemCount(treeData.length); |
|||
|
|||
menuTree.$tree |
|||
.on('changed.jstree', function (e, data) { |
|||
if (data.selected.length != 1) { |
|||
menuTree.selectedMenuItem.set(null); |
|||
} else { |
|||
var selectedNode = data.instance.get_node(data.selected[0]); |
|||
menuTree.selectedMenuItem.set(selectedNode); |
|||
} |
|||
}) |
|||
.on('move_node.jstree', function (e, data) { |
|||
|
|||
var parentNodeName = (!data.parent || data.parent == '#') |
|||
? l('Root') |
|||
: menuTree.$tree.jstree('get_node', data.parent).original.displayName; |
|||
|
|||
abp.message.confirm( |
|||
l('MenuItemMoveConfirmMessage', data.node.original.displayName, parentNodeName), |
|||
l('AreYouSure'), |
|||
function (isConfirmed) { |
|||
if (isConfirmed) { |
|||
menuService |
|||
.moveMenuItem(menuId, data.node.id, { |
|||
newParentId: data.parent === '#' ? null : data.parent, |
|||
position: data.position |
|||
}) |
|||
.done(function () { |
|||
menuTree.reload(); |
|||
}) |
|||
.fail(function (err) { |
|||
menuTree.$tree.jstree('refresh'); //rollback
|
|||
setTimeout(function () { |
|||
abp.message.error(err.message); |
|||
}, 500); |
|||
}); |
|||
} else { |
|||
menuTree.$tree.jstree('refresh'); //rollback
|
|||
} |
|||
} |
|||
); |
|||
}) |
|||
.jstree({ |
|||
'core': { |
|||
data: treeData, |
|||
multiple: false, |
|||
check_callback: function (operation, node, node_parent, node_position, more) { |
|||
return true; |
|||
} |
|||
}, |
|||
|
|||
contextmenu: { |
|||
items: menuTree.contextMenu, |
|||
'select_node': false |
|||
}, |
|||
|
|||
sort: function (node1, node2) { |
|||
if (this.get_node(node2).original.order < this.get_node(node1).original.order) { |
|||
return 1; |
|||
} |
|||
|
|||
return -1; |
|||
}, |
|||
|
|||
plugins: [ |
|||
'types', |
|||
'contextmenu', |
|||
'wholerow', |
|||
'sort', |
|||
'dnd' |
|||
] |
|||
}); |
|||
|
|||
$('button[name=CreateMenuItem]').click(function (e) { |
|||
e.preventDefault(); |
|||
createModal.open({menuId: menuId}); |
|||
}); |
|||
|
|||
createModal.onResult(function () { |
|||
menuTree.reload(); |
|||
}); |
|||
|
|||
updateModal.onResult(function (item) { |
|||
menuTree.reload(); |
|||
}); |
|||
|
|||
menuTree.$tree.on('click', '.ou-text .fa-caret-down', function (e) { |
|||
e.preventDefault(); |
|||
var id = $(this).closest('.ou-text').attr('data-menuitem-id'); |
|||
setTimeout(function () { |
|||
menuTree.$tree.jstree('show_contextmenu', id); |
|||
}, 100); |
|||
}); |
|||
}); |
|||
}, |
|||
|
|||
reload: function () { |
|||
menuTree.getTreeDataFromServer(function (treeData) { |
|||
menuTree.setItemCount(treeData.length); |
|||
menuTree.$tree.jstree(true).settings.core.data = treeData; |
|||
menuTree.$tree.jstree('refresh'); |
|||
}); |
|||
} |
|||
}; |
|||
|
|||
menuTree.init(); |
|||
|
|||
let selectedIds = []; |
|||
let selectedItem = {}; |
|||
let selectedCheckboxNames; |
|||
let selectAllHeaderTitle = '<div class="custom-checkbox custom-control no-height">' + |
|||
'<input type="checkbox" id="select_all" name="select-all" class="custom-control-input custom-selectbox" value="false" data-val="false">' + |
|||
'<label class="custom-control-label" for="select_all"></label></div>'; |
|||
|
|||
_menuItem.checkbox = { |
|||
initialize: function (selectedCbNames) { |
|||
selectedIds = []; |
|||
selectedCheckboxNames = selectedCbNames; |
|||
}, |
|||
getSelectedIds: function () { |
|||
return selectedIds; |
|||
}, |
|||
setSelectedItem: function (item) { |
|||
selectedItem = item; |
|||
}, |
|||
getSelectedItem: function () { |
|||
return selectedItem; |
|||
}, |
|||
getSelectAllHeaderTitle: function () { |
|||
return selectAllHeaderTitle; |
|||
} |
|||
}; |
|||
|
|||
$(document).on('click', '.custom-selectbox', function (el) { |
|||
el.stopPropagation(); |
|||
if (!$(el.target).is(':checkbox')) { |
|||
return; |
|||
} |
|||
|
|||
if ($(el.target).prop("checked") == true) { |
|||
checkAndAddAll(); |
|||
} else if ($(el.target).prop("checked") == false) { |
|||
uncheckAndRemoveAll(); |
|||
} |
|||
}); |
|||
|
|||
$(document).on('click', '.selectable', function (el) { |
|||
el.stopPropagation(); |
|||
selectDeselect(el); |
|||
}); |
|||
|
|||
const checkAndAddAll = function () { |
|||
$('table>tbody>').find('input[type="checkbox"]').prop("checked", true); |
|||
let selectedItems = $(`input[name="${selectedCheckboxNames}"]:checked`); |
|||
selectedIds = []; |
|||
for (var i = 0; typeof (selectedItems[i]) != 'undefined'; selectedIds.push(selectedItems[i++].getAttribute('id'))) ; |
|||
}; |
|||
|
|||
const uncheckAndRemoveAll = function () { |
|||
$('table>tbody>').find('input[type="checkbox"]').prop("checked", false); |
|||
selectedIds = []; |
|||
}; |
|||
|
|||
const addId = function (id) { |
|||
selectedIds.push(id); |
|||
}; |
|||
|
|||
const removeId = function (id) { |
|||
selectedIds = selectedIds.filter(function (e) { |
|||
return e !== id; |
|||
}); |
|||
}; |
|||
|
|||
const selectDeselect = function (el) { |
|||
$el = $(el); |
|||
if ($(el.target).is(':checkbox')) { |
|||
el.preventDefault(); |
|||
return; |
|||
} |
|||
|
|||
if (!$(el.target).is(':checkbox')) { |
|||
$el = $(el.target).parent().closest('tr').find('[type=checkbox]'); |
|||
|
|||
if ($el.prop("checked") == true) { |
|||
$el.prop("checked", false); |
|||
} else if ($el.prop("checked") == false) { |
|||
$el.prop("checked", true); |
|||
} |
|||
} |
|||
|
|||
if ($el.prop("checked") == true) { |
|||
addId($el.attr('id')); |
|||
} else if ($el.prop("checked") == false) { |
|||
removeId($el.attr('id')); |
|||
} |
|||
} |
|||
}); |
|||
@ -0,0 +1,46 @@ |
|||
var abp = abp || {}; |
|||
$(function () { |
|||
abp.modals.updateMenuItem = function () { |
|||
|
|||
var initModal = function (publicApi, args) { |
|||
|
|||
var $pageId = $('#ViewModel_PageId'); |
|||
var $url = $('#ViewModel_Url'); |
|||
var $displayName = $('#ViewModel_DisplayName'); |
|||
var $pageIdClearButton = $('#url-tab'); |
|||
|
|||
initSelectPageId(); |
|||
|
|||
$pageId.on('change', function (params) { |
|||
$url.prop('disabled', $pageId.val()); |
|||
|
|||
if ($pageId.val()) { |
|||
if (!$displayName.val()) { |
|||
$displayName.val($pageId.text()); |
|||
} |
|||
} |
|||
}) |
|||
|
|||
$pageId.trigger('change'); |
|||
|
|||
$pageIdClearButton.click(function () { |
|||
$pageId.val(''); |
|||
$pageId.trigger('change'); |
|||
}); |
|||
|
|||
function initSelectPageId() { |
|||
$pageId.data('autocompleteApiUrl', '/api/cms-kit-admin/menus/lookup/pages'); |
|||
$pageId.data('autocompleteDisplayProperty', 'title'); |
|||
$pageId.data('autocompleteValueProperty', 'id'); |
|||
$pageId.data('autocompleteItemsProperty', 'items'); |
|||
$pageId.data('autocompleteFilterParamName', 'filter'); |
|||
|
|||
abp.dom.initializers.initializeAutocompleteSelects($pageId); |
|||
} |
|||
}; |
|||
|
|||
return { |
|||
initModal: initModal |
|||
}; |
|||
}; |
|||
}); |
|||
@ -0,0 +1,23 @@ |
|||
@page |
|||
@using Volo.CmsKit.Admin.Web.Pages |
|||
@using Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|||
|
|||
@inherits CmsKitAdminPageBase |
|||
|
|||
@model UpdateModalModel |
|||
|
|||
@{ |
|||
Layout = null; |
|||
} |
|||
|
|||
<abp-dynamic-form abp-model="ViewModel" asp-page="/CmsKit/Menus/UpdateModal"> |
|||
<abp-modal> |
|||
<abp-modal-header title="@L["Edit"].Value"></abp-modal-header> |
|||
<abp-modal-body> |
|||
<abp-input asp-for="Id" /> |
|||
<abp-form-content /> |
|||
</abp-modal-body> |
|||
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer> |
|||
</abp-modal> |
|||
</abp-dynamic-form> |
|||
@ -0,0 +1,53 @@ |
|||
using AutoMapper; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Validation; |
|||
using Volo.CmsKit.Admin.Menus; |
|||
using Volo.CmsKit.Menus; |
|||
|
|||
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Menus |
|||
{ |
|||
public class UpdateModalModel : CmsKitAdminPageModel |
|||
{ |
|||
protected IMenuAdminAppService MenuAdminAppService { get; } |
|||
|
|||
[HiddenInput] |
|||
[BindProperty(SupportsGet = true)] |
|||
public Guid Id { get; set; } |
|||
|
|||
[BindProperty] |
|||
public UpdateMenuViewModel ViewModel { get; set; } |
|||
|
|||
public UpdateModalModel(IMenuAdminAppService menuAdminAppService) |
|||
{ |
|||
MenuAdminAppService = menuAdminAppService; |
|||
} |
|||
|
|||
public async Task OnGetAsync() |
|||
{ |
|||
var menu = await MenuAdminAppService.GetAsync(Id); |
|||
|
|||
ViewModel = ObjectMapper.Map<MenuWithDetailsDto, UpdateMenuViewModel>(menu); |
|||
} |
|||
|
|||
public async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
var input = ObjectMapper.Map<UpdateMenuViewModel, MenuUpdateInput>(ViewModel); |
|||
|
|||
await MenuAdminAppService.UpdateAsync(Id, input); |
|||
|
|||
return NoContent(); |
|||
} |
|||
|
|||
[AutoMap(typeof(MenuWithDetailsDto))] |
|||
[AutoMap(typeof(MenuUpdateInput), ReverseMap = true)] |
|||
public class UpdateMenuViewModel |
|||
{ |
|||
[Required] |
|||
[DynamicMaxLength(typeof(MenuConsts), nameof(MenuConsts.MaxNameLength))] |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
|
|||
@ -0,0 +1,118 @@ |
|||
$(function () { |
|||
var l = abp.localization.getResource("CmsKit"); |
|||
|
|||
var createModal = new abp.ModalManager(abp.appPath + "CmsKit/Menus/CreateModal"); |
|||
var updateModal = new abp.ModalManager(abp.appPath + "CmsKit/Menus/UpdateModal"); |
|||
|
|||
var menusService = volo.cmsKit.admin.menus.menuAdmin; |
|||
|
|||
var dataTable = $("#MenusTable").DataTable(abp.libs.datatables.normalizeConfiguration({ |
|||
processing: true, |
|||
serverSide: true, |
|||
paging: true, |
|||
searching: false, |
|||
scrollCollapse: true, |
|||
scrollX: true, |
|||
ordering: true, |
|||
order: [[1, "desc"]], |
|||
ajax: abp.libs.datatables.createAjax(menusService.getList), |
|||
columnDefs: [ |
|||
{ |
|||
title: l("Details"), |
|||
targets: 0, |
|||
rowAction: { |
|||
items: [ |
|||
{ |
|||
text: l('MenuItems'), |
|||
visible: abp.auth.isGranted('CmsKit.Menus.Update'), |
|||
action: function (data) { |
|||
location.href = "/Cms/Menus/" + data.record.id + "/menu-items" |
|||
} |
|||
}, |
|||
{ |
|||
text: l('MakeMainMenu'), |
|||
visible: function (data) { |
|||
return abp.auth.isGranted('CmsKit.Menus.Update') && !data.isMainMenu |
|||
}, |
|||
action: function (data) { |
|||
menusService |
|||
.updateMainMenu(data.record.id, {isMainMenu: true}) |
|||
.then(function () { |
|||
dataTable.ajax.reload(); |
|||
}); |
|||
} |
|||
}, |
|||
{ |
|||
text: l('UnMakeMainMenu'), |
|||
visible: function (data) { |
|||
return abp.auth.isGranted('CmsKit.Menus.Update') && data.isMainMenu |
|||
}, |
|||
action: function (data) { |
|||
menusService |
|||
.updateMainMenu(data.record.id, {isMainMenu: false}) |
|||
.then(function () { |
|||
dataTable.ajax.reload(); |
|||
}); |
|||
} |
|||
}, |
|||
{ |
|||
text: l('Edit'), |
|||
visible: abp.auth.isGranted('CmsKit.Menus.Update'), |
|||
action: function (data) { |
|||
updateModal.open({id: data.record.id}); |
|||
} |
|||
}, |
|||
{ |
|||
text: l('Delete'), |
|||
visible: abp.auth.isGranted('CmsKit.Menus.Delete'), |
|||
confirmMessage: function (data) { |
|||
return l("MenuDeletionConfirmationMessage", data.record.name) |
|||
}, |
|||
action: function (data) { |
|||
menusService |
|||
.delete(data.record.id) |
|||
.then(function () { |
|||
dataTable.ajax.reload(); |
|||
}); |
|||
} |
|||
} |
|||
] |
|||
} |
|||
}, |
|||
{ |
|||
title: l("Name"), |
|||
orderable: true, |
|||
data: "name", |
|||
render: function (data, val, record) { |
|||
|
|||
if (record.isMainMenu) { |
|||
return ( |
|||
data |
|||
+ |
|||
'<span class="badge badge-pill badge-info ml-1">' |
|||
+ |
|||
l("MainMenu") |
|||
+ |
|||
'</span>' |
|||
); |
|||
} else { |
|||
return data; |
|||
} |
|||
} |
|||
} |
|||
] |
|||
})); |
|||
|
|||
$('#AbpContentToolbar button[name=CreateMenu]').on('click', function (e) { |
|||
e.preventDefault(); |
|||
createModal.open(); |
|||
}); |
|||
|
|||
createModal.onResult(function () { |
|||
dataTable.ajax.reload(); |
|||
}); |
|||
|
|||
updateModal.onResult(function () { |
|||
dataTable.ajax.reload(); |
|||
}); |
|||
}); |
|||
@ -0,0 +1 @@ |
|||
|
|||
@ -0,0 +1,21 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace Volo.CmsKit.Menus |
|||
{ |
|||
public class MenuItemDto : AuditedEntityDto<Guid> |
|||
{ |
|||
public Guid MenuId { get; set; } |
|||
public Guid? ParentId { get; set; } |
|||
public string DisplayName { get; set; } |
|||
public bool IsActive { get; set; } |
|||
public string Url { get; set; } |
|||
public string Icon { get; set; } |
|||
public int Order { get; set; } |
|||
public string Target { get; set; } |
|||
public string ElementId { get; set; } |
|||
public string CssClass { get; set; } |
|||
public Guid? PageId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace Volo.CmsKit.Menus |
|||
{ |
|||
public class MenuWithDetailsDto : FullAuditedEntityDto<Guid> |
|||
{ |
|||
public string Name { get; set; } |
|||
|
|||
public bool IsMainMenu { get; set; } |
|||
|
|||
public List<MenuItemDto> Items { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp.GlobalFeatures; |
|||
|
|||
namespace Volo.CmsKit.GlobalFeatures |
|||
{ |
|||
[GlobalFeatureName(Name)] |
|||
public class MenuFeature : GlobalFeature |
|||
{ |
|||
public const string Name = "CmsKit.Menus"; |
|||
|
|||
internal MenuFeature( |
|||
[NotNull] GlobalCmsKitFeatures cmsKit) : base(cmsKit) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,22 +1,26 @@ |
|||
{ |
|||
"culture": "de-DE", |
|||
"texts": { |
|||
"PickYourReaction": "Wählen Sie Ihre Reaktion", |
|||
"YourComment": "Ihr Kommentar", |
|||
"YourReply": "Ihre Antwort", |
|||
"CommentAuthorizationExceptionMessage": "Diese Kommentare dürfen nicht öffentlich angezeigt werden.", |
|||
"Comments": "Kommentare", |
|||
"Send": "Senden", |
|||
"Delete": "Löschen", |
|||
"Reply": "Antworten", |
|||
"Update": "Aktualisieren", |
|||
"Edit": "Bearbeiten", |
|||
"LoginToAddComment": "Melden Sie sich an, um zu Kommentieren", |
|||
"LoginToRate": "Melden Sie sich an, um zu Bewerten", |
|||
"LoginToReply": "Melden Sie sich an, um zu Antworten", |
|||
"MessageDeletionConfirmationMessage": "Dieser Kommentar wird vollständig gelöscht.", |
|||
"CommentAuthorizationExceptionMessage": "Diese Kommentare dürfen nicht öffentlich angezeigt werden.", |
|||
"Undo": "Rüchkängig machen", |
|||
"Permission:Menus": "Menüverwaltung", |
|||
"Permission:Menus.Create": "Erstellen", |
|||
"Permission:Menus.Delete": "Löschen", |
|||
"Permission:Menus.Update": "Aktualisieren", |
|||
"PickYourReaction": "Wählen Sie Ihre Reaktion", |
|||
"RatingUndoMessage": "Ihre Bewertung wird rückgängig gemacht.", |
|||
"LoginToRate": "Melden Sie sich an, um zu Bewerten", |
|||
"Star": "Stern" |
|||
"Reply": "Antworten", |
|||
"Send": "Senden", |
|||
"Star": "Stern", |
|||
"Undo": "Rüchkängig machen", |
|||
"Update": "Aktualisieren", |
|||
"YourComment": "Ihr Kommentar", |
|||
"YourReply": "Ihre Antwort" |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.CmsKit.Menus |
|||
{ |
|||
public static class MenuConsts |
|||
{ |
|||
public static int MaxNameLength { get; set; } = 128; |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace Volo.CmsKit.Menus |
|||
{ |
|||
public static class MenuItemConsts |
|||
{ |
|||
public const int MaxDisplayNameLength = 64; |
|||
public const int MaxUrlLength = 1024; |
|||
} |
|||
} |
|||
@ -1,17 +1,26 @@ |
|||
namespace Volo.CmsKit.Pages |
|||
using System; |
|||
|
|||
namespace Volo.CmsKit.Pages |
|||
{ |
|||
public class PageConsts |
|||
{ |
|||
public const string EntityType = "Page"; |
|||
|
|||
|
|||
public static int MaxTitleLength { get; set; } = 256; |
|||
|
|||
|
|||
public static int MaxSlugLength { get; set; } = 256; |
|||
|
|||
public static int MaxContentLength { get; set; } = int.MaxValue; |
|||
|
|||
|
|||
public static int MaxScriptLength { get; set; } = int.MaxValue; |
|||
|
|||
|
|||
public static int MaxStyleLength { get; set; } = int.MaxValue; |
|||
|
|||
private static string _urlPrefix = "/pages/"; |
|||
public static string UrlPrefix |
|||
{ |
|||
get => _urlPrefix; |
|||
set => _urlPrefix = value.EnsureEndsWith('/').EnsureStartsWith('/'); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace Volo.CmsKit.Menus |
|||
{ |
|||
public interface IMenuRepository : IBasicRepository<Menu, Guid> |
|||
{ |
|||
Task<Menu> FindMainMenuAsync(bool includeDetails = true, CancellationToken cancellationToken = default); |
|||
|
|||
Task<List<Menu>> GetCurrentAndNextMainMenusAsync( |
|||
Guid nextMainMenuId, |
|||
bool includeDetails = true, |
|||
CancellationToken cancellationToken = default); |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
using JetBrains.Annotations; |
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace Volo.CmsKit.Menus |
|||
{ |
|||
public class Menu : FullAuditedAggregateRoot<Guid>, IMultiTenant |
|||
{ |
|||
public string Name { get; protected set; } |
|||
|
|||
public bool IsMainMenu { get; internal set; } |
|||
|
|||
public Guid? TenantId { get; protected set; } |
|||
|
|||
public ICollection<MenuItem> Items { get; protected set; } |
|||
|
|||
internal Menu(Guid id, Guid? tenantId, [NotNull] string name) : base(id) |
|||
{ |
|||
TenantId = tenantId; |
|||
SetName(name); |
|||
Items = new HashSet<MenuItem>(); |
|||
} |
|||
|
|||
public void SetName([NotNull] string name) |
|||
{ |
|||
Name = Check.NotNullOrEmpty(name, nameof(name), MenuConsts.MaxNameLength); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,87 @@ |
|||
using JetBrains.Annotations; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
|
|||
namespace Volo.CmsKit.Menus |
|||
{ |
|||
public class MenuItem : AuditedEntity<Guid> |
|||
{ |
|||
/// <summary>
|
|||
/// Parent <see cref="Menu"/> Id.
|
|||
/// </summary>
|
|||
public Guid MenuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Presents another <see cref="MenuItem"/> Id.
|
|||
/// If it's <see langword="null"/>, then it's a root menu item.
|
|||
/// </summary>
|
|||
public Guid? ParentId { get; set; } |
|||
|
|||
[NotNull] |
|||
public string DisplayName { get; protected set; } |
|||
|
|||
public bool IsActive { get; set; } |
|||
|
|||
[NotNull] |
|||
public string Url { get; protected set; } |
|||
|
|||
public string Icon { get; set; } |
|||
|
|||
public int Order { get; set; } |
|||
|
|||
public string Target { get; set; } |
|||
|
|||
public string ElementId { get; set; } |
|||
|
|||
public string CssClass { get; set; } |
|||
|
|||
public Guid? PageId { get; protected set; } |
|||
|
|||
|
|||
public MenuItem(Guid id, |
|||
Guid menuId, |
|||
[NotNull] string displayName, |
|||
[NotNull] string url, |
|||
bool isActive = true, |
|||
[CanBeNull] Guid? parentId = null, |
|||
[CanBeNull] string icon = null, |
|||
int order = 0, |
|||
[CanBeNull] string target = null, |
|||
[CanBeNull] string elementId = null, |
|||
[CanBeNull] string cssClass = null) |
|||
:base(id) |
|||
{ |
|||
MenuId = menuId; |
|||
SetDisplayName(displayName); |
|||
IsActive = isActive; |
|||
ParentId = parentId; |
|||
SetUrl(url); |
|||
Icon = icon; |
|||
Order = order; |
|||
Target = target; |
|||
ElementId = elementId; |
|||
CssClass = cssClass; |
|||
} |
|||
|
|||
public void SetDisplayName([NotNull] string displayName) |
|||
{ |
|||
DisplayName = Check.NotNullOrEmpty(displayName, nameof(displayName), MenuItemConsts.MaxDisplayNameLength); |
|||
} |
|||
|
|||
public void SetUrl([NotNull]string url) |
|||
{ |
|||
Url = Check.NotNullOrEmpty(url, nameof(url), MenuItemConsts.MaxUrlLength); |
|||
} |
|||
|
|||
internal void SetPageId(Guid pageId) |
|||
{ |
|||
PageId = pageId; |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue