mirror of https://github.com/abpframework/abp
Merge pull request #905 from abpframework/Feature-management-modal
Feature management modalpull/926/head
commit
01094c8e3f
@ -0,0 +1,60 @@
|
||||
@page
|
||||
@using Microsoft.AspNetCore.Mvc.Localization
|
||||
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
|
||||
@using Volo.Abp.FeatureManagement.Localization
|
||||
@using Volo.Abp.Validation.StringValues
|
||||
@using Volo.Abp.FeatureManagement.Web.Pages.FeatureManagement
|
||||
@model FeatureManagementModal
|
||||
@inject IHtmlLocalizer<AbpFeatureManagementResource> L
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
<form method="post" asp-page="/FeatureManagement/FeatureManagementModal" data-script-class="abp.modals.FeatureManagement">
|
||||
<abp-modal size="Large">
|
||||
<abp-modal-header title="@(L["Features"].Value)"></abp-modal-header>
|
||||
<abp-modal-body class="ml-4">
|
||||
<input asp-for="@Model.ProviderKey" />
|
||||
<input asp-for="@Model.ProviderName" />
|
||||
@for (var i = 0; i < Model.FeatureListDto.Features.Count; i++)
|
||||
{
|
||||
var feature = Model.FeatureListDto.Features[i];
|
||||
<div class="mt-2" style="padding-left: @(feature.Depth * 20)px">
|
||||
|
||||
<spam class="mr-2">@feature.Name</spam>
|
||||
|
||||
<input type="text" name="Features[@i].Type" value="@feature.ValueType.Name" hidden />
|
||||
@if (feature.ValueType is FreeTextStringValueType)
|
||||
{
|
||||
<input type="text" name="Features[@i].Name" value="@feature.Name" hidden />
|
||||
<input type="text" name="Features[@i].Value" value="@feature.Value" />
|
||||
}
|
||||
@if (feature.ValueType is SelectionStringValueType)
|
||||
{
|
||||
<input type="text" name="Features[@i].Name" value="@feature.Name" hidden />
|
||||
<select name="Features[@i].Value">
|
||||
@foreach (var item in (feature.ValueType as SelectionStringValueType).ItemSource.Items)
|
||||
{
|
||||
if (item.Value == feature.Value)
|
||||
{
|
||||
<option value="@item.Value" selected="selected"> @L.GetString(item.DisplayText.Name) </option>
|
||||
}
|
||||
else
|
||||
{
|
||||
<option value="@item.Value"> @L.GetString(item.DisplayText.Name) </option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
}
|
||||
@if (feature.ValueType is ToggleStringValueType)
|
||||
{
|
||||
<input type="text" name="Features[@i].Name" value="@feature.Name" hidden />
|
||||
<input type="checkbox" class="FeatureValueCheckbox" name="Features[@i].BoolValue" value="@feature.Value"
|
||||
@Html.Raw(feature.Value == "True" ? "checked" : "") />
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</abp-modal-body>
|
||||
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer>
|
||||
</abp-modal>
|
||||
</form>
|
||||
|
@ -0,0 +1,75 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
|
||||
using Volo.Abp.Validation.StringValues;
|
||||
|
||||
namespace Volo.Abp.FeatureManagement.Web.Pages.FeatureManagement
|
||||
{
|
||||
public class FeatureManagementModal : AbpPageModel
|
||||
{
|
||||
[Required]
|
||||
[HiddenInput]
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public string ProviderName { get; set; }
|
||||
|
||||
[Required]
|
||||
[HiddenInput]
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public string ProviderKey { get; set; }
|
||||
|
||||
[BindProperty]
|
||||
public List<FeatureViewModel> Features { get; set; }
|
||||
|
||||
public FeatureListDto FeatureListDto { get; set; }
|
||||
|
||||
private readonly IFeatureAppService _featureAppService;
|
||||
|
||||
public FeatureManagementModal(IFeatureAppService featureAppService)
|
||||
{
|
||||
_featureAppService = featureAppService;
|
||||
}
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
FeatureListDto = await _featureAppService.GetAsync(ProviderName, ProviderKey);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
var features = new UpdateFeaturesDto
|
||||
{
|
||||
Features = Features.Select(f => new UpdateFeatureDto
|
||||
{
|
||||
Name = f.Name,
|
||||
Value = f.Type == nameof(ToggleStringValueType) ? f.BoolValue.ToString() : f.Value
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
await _featureAppService.UpdateAsync(ProviderName, ProviderKey, features);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
|
||||
public class ProviderInfoViewModel
|
||||
{
|
||||
public string ProviderName { get; set; }
|
||||
|
||||
public string ProviderKey { get; set; }
|
||||
}
|
||||
|
||||
public class FeatureViewModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Value { get; set; }
|
||||
|
||||
public bool BoolValue { get; set; }
|
||||
|
||||
public string Type { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue