mirror of https://github.com/abpframework/abp.git
5 changed files with 73 additions and 12 deletions
@ -0,0 +1,9 @@ |
|||
using System; |
|||
|
|||
namespace Volo.CmsKit.Admin.Contents; |
|||
|
|||
[Serializable] |
|||
public class ContentWidgetDto |
|||
{ |
|||
public string Key { get; set; } |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Volo.CmsKit.Admin.Contents; |
|||
public interface IContentAdminAppService : IApplicationService |
|||
{ |
|||
Task<ListResultDto<ContentWidgetDto>> GetWidgetsAsync(); |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.CmsKit.Contents; |
|||
|
|||
namespace Volo.CmsKit.Admin.Contents; |
|||
|
|||
public class ContentAdminAppService : CmsKitAdminAppServiceBase, IContentAdminAppService |
|||
{ |
|||
private readonly CmsKitContentWidgetOptions _options; |
|||
|
|||
public ContentAdminAppService(IOptions<CmsKitContentWidgetOptions> options) |
|||
{ |
|||
_options = options.Value; |
|||
} |
|||
|
|||
public Task<ListResultDto<ContentWidgetDto>> GetWidgetsAsync() |
|||
{ |
|||
var aa = _options.WidgetConfigs.ToList(); |
|||
return Task.FromResult(new ListResultDto<ContentWidgetDto>() |
|||
{ |
|||
Items = _options.WidgetConfigs |
|||
.Select(n => |
|||
new ContentWidgetDto |
|||
{ |
|||
Key = n.Key |
|||
|
|||
}).ToList() |
|||
}); |
|||
} |
|||
} |
|||
@ -1,30 +1,41 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc.Rendering; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
|||
using Volo.CmsKit.Admin.Contents; |
|||
|
|||
namespace Volo.CmsKit.Admin.Web.Pages.CmsKit.Contents; |
|||
|
|||
public class AddWidgetModal : AbpPageModel |
|||
{ |
|||
[BindProperty(SupportsGet = true)] |
|||
public Guid Id { get; set; } |
|||
protected IContentAdminAppService ContentAdminAppService { get; } |
|||
|
|||
[BindProperty(SupportsGet = true)] |
|||
public string Text { get; set; } |
|||
[BindProperty] |
|||
public ContentViewModel ViewModel { get; set; } |
|||
|
|||
|
|||
public AddWidgetModal() |
|||
public List<SelectListItem> Widgets { get; set; } = new(); |
|||
|
|||
public AddWidgetModal(IContentAdminAppService contentAdminAppService) |
|||
{ |
|||
ContentAdminAppService = contentAdminAppService; |
|||
} |
|||
|
|||
public async Task OnGetAsync() |
|||
{ |
|||
|
|||
Widgets = new List<SelectListItem>() { new("", "") }; |
|||
Widgets.AddRange((await ContentAdminAppService.GetWidgetsAsync()) |
|||
.Items |
|||
.Select(w => new SelectListItem(w.Key, w.Key)) |
|||
.ToList()); |
|||
} |
|||
|
|||
public async Task OnPostAsync() |
|||
public class ContentViewModel |
|||
{ |
|||
|
|||
[SelectItems(nameof(Widgets))] |
|||
public string Widget { get; set; } |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue