mirror of https://github.com/abpframework/abp.git
45 changed files with 484 additions and 43 deletions
@ -1,8 +1,13 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Volo.CmsKit.Admin.Blogs; |
|||
|
|||
public interface IBlogAdminAppService : ICrudAppService<BlogDto, Guid, BlogGetListInput, CreateBlogDto, UpdateBlogDto> |
|||
{ |
|||
Task<ListResultDto<BlogDto>> GetAllListAsync(); |
|||
|
|||
Task MoveAllBlogPostsAsync(Guid blogId, Guid? assignToBlogId); |
|||
} |
|||
|
|||
@ -0,0 +1,59 @@ |
|||
@page |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal |
|||
@using Volo.CmsKit.Admin.Web.Pages.CmsKit.Blogs |
|||
@using Volo.CmsKit.Localization |
|||
@model DeleteBlogModal |
|||
@inject IHtmlLocalizer<CmsKitResource> L |
|||
@{ |
|||
Layout = null; |
|||
} |
|||
|
|||
<form method="post" asp-page="/CmsKit/Blogs/DeleteBlogModal" autocomplete="off"> |
|||
@{ |
|||
var deleteAllClicked = "checked"; |
|||
var deleteButtonDisabled = ""; |
|||
<abp-modal> |
|||
<abp-modal-header title="@L["AreYouSure"].Value"></abp-modal-header> |
|||
<abp-modal-body> |
|||
|
|||
<abp-input asp-for="Blog.Id" type="hidden"></abp-input> |
|||
|
|||
<p class="fw-bold">@L.GetString("BlogDeletionConfirmationMessage", Model.Blog.Name).Value</p> |
|||
|
|||
@if (Model.Blog.BlogPostCount > 0) |
|||
{ |
|||
<p class="mt-2">@L.GetString("ChooseAnActionForBlog", Model.Blog.BlogPostCount).Value</p> |
|||
|
|||
|
|||
if (Model.Blog.OtherBlogs.Any()) |
|||
{ |
|||
deleteAllClicked = ""; |
|||
deleteButtonDisabled = "disabled"; |
|||
<div class="form-check"> |
|||
<input class="form-check-input" type="radio" checked name="assign" id="assign"> |
|||
<label class="form-check-label" for="assign">@L["AssignBlogPostsToOtherBlog"].Value</label> |
|||
</div> |
|||
<select name="Blog.AssignToBlogId" id="Blog_AssignToBlogId" class="form-select mt-2"> |
|||
<option value="" selected>@L["SelectAnBlogToAssign"].Value</option> |
|||
@foreach (var blog in Model.Blog.OtherBlogs) |
|||
{ |
|||
<option value="@blog.Key">@blog.Value</option> |
|||
} |
|||
</select> |
|||
} |
|||
|
|||
<div class="form-check mt-2"> |
|||
<input class="form-check-input" type="radio" @deleteAllClicked name="assign" id="deleteAll"> |
|||
<label class="form-check-label" for="deleteAll">@L["DeleteAllBlogPostsOfThisBlog"].Value</label> |
|||
</div> |
|||
} |
|||
</abp-modal-body> |
|||
<abp-modal-footer> |
|||
<button class="btn btn-outline-danger" data-bs-dismiss="modal" type="button">@L["Cancel"]</button> |
|||
<button class="btn btn-danger" @deleteButtonDisabled type="submit"><i class="fa fa-trash"></i> <span>@L["Delete"]</span></button> |
|||
</abp-modal-footer> |
|||
</abp-modal> |
|||
} |
|||
|
|||
</form> |
|||
@ -0,0 +1,57 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc.RazorPages; |
|||
using Volo.Abp.ObjectExtending; |
|||
using Volo.CmsKit.Admin.Blogs; |
|||
|
|||
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Blogs; |
|||
|
|||
public class DeleteBlogModal : CmsKitAdminPageModel |
|||
{ |
|||
[BindProperty] |
|||
public BlogInfoModel Blog { get; set; } |
|||
|
|||
protected IBlogAdminAppService BlogAdminAppService { get; } |
|||
|
|||
public DeleteBlogModal(IBlogAdminAppService blogAdminAppService) |
|||
{ |
|||
BlogAdminAppService = blogAdminAppService; |
|||
} |
|||
|
|||
public virtual async Task OnGetAsync(Guid id) |
|||
{ |
|||
var blog = await BlogAdminAppService.GetAsync(id); |
|||
var allBlogs = await BlogAdminAppService.GetAllListAsync(); |
|||
|
|||
Blog = new BlogInfoModel |
|||
{ |
|||
Id = blog.Id, |
|||
Name = blog.Name, |
|||
BlogPostCount = blog.BlogPostCount, |
|||
OtherBlogs = allBlogs.Items.Where(b => b.Id != blog.Id).Select(e => new KeyValuePair<Guid, string>(e.Id, e.Name)).ToList() |
|||
}; |
|||
} |
|||
|
|||
public virtual async Task<IActionResult> OnPostAsync() |
|||
{ |
|||
await BlogAdminAppService.MoveAllBlogPostsAsync(Blog.Id, Blog.AssignToBlogId); |
|||
await BlogAdminAppService.DeleteAsync(Blog.Id); |
|||
return NoContent(); |
|||
} |
|||
|
|||
public class BlogInfoModel : ExtensibleObject |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
public int BlogPostCount { get; set; } |
|||
|
|||
public List<KeyValuePair<Guid, string>> OtherBlogs { get; set; } |
|||
|
|||
public Guid? AssignToBlogId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
namespace Volo.CmsKit.Blogs; |
|||
|
|||
public class BlogWithBlogPostCount |
|||
{ |
|||
public Blog Blog { get; set; } |
|||
|
|||
public int BlogPostCount { get; set; } |
|||
|
|||
public BlogWithBlogPostCount(Blog blog, int blogPostCount) |
|||
{ |
|||
Blog = blog; |
|||
BlogPostCount = blogPostCount; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue