Completed basic permission grant modal for user and role.

pull/208/head
Halil İbrahim Kalkan 7 years ago
parent ad418d057b
commit 6adddd5513

@ -18,6 +18,10 @@ namespace AbpDesk.EntityFrameworkCore
//Configures all dbcontextes to use Sql Server with calculated connection string
options.Configure(context =>
{
//TODO: Create an extension method to AbpDbContextConfigurationContext to use SqlServer in single line call! Example:
/* context.UseSqlServer(opional action to configure sqlserver)
* This internally makes the if below!
*/
if (context.ExistingConnection != null)
{
context.DbContextOptions.UseSqlServer(context.ExistingConnection);

@ -8,7 +8,9 @@ namespace Volo.Abp.Permissions.Web
public AbpPermissionsWebAutoMapperProfile()
{
CreateMap<PermissionGroupDto, PermissionManagementModal.PermissionGroupViewModel>();
CreateMap<PermissionGrantInfoDto, PermissionManagementModal.PermissionGrantInfoViewModel>();
CreateMap<ProviderInfoDto, PermissionManagementModal.ProviderInfoViewModel>();
}
}

@ -1,5 +1,6 @@
@page
@using Volo.Abp.Permissions.Web.Pages.AbpPermissions
@using Volo.Abp.Session
@model PermissionManagementModal
@{
Layout = null;
@ -21,8 +22,7 @@
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
@for (var i = 0; i < Model.Groups.Count; i++)
{
var normalizedGroupName = Model.Groups[i].Name.Replace(".", "_");
<a class="nav-link @(i == 0 ? "active" : "")" id="v-pills-tab-@normalizedGroupName" data-toggle="pill" href="#v-pills-@normalizedGroupName" role="tab" aria-controls="v-pills-@normalizedGroupName" aria-selected="false">@Model.Groups[i].DisplayName</a>
<a class="nav-link @(i == 0 ? "active" : "")" id="v-pills-tab-@Model.Groups[i].GetNormalizedGroupName()" data-toggle="pill" href="#v-pills-@Model.Groups[i].GetNormalizedGroupName()" role="tab" aria-controls="v-pills-@Model.Groups[i].GetNormalizedGroupName()" aria-selected="false">@Model.Groups[i].DisplayName</a>
}
</div>
</div>
@ -30,14 +30,13 @@
<div class="tab-content" id="v-pills-tabContent">
@for (var i = 0; i < Model.Groups.Count; i++)
{
var normalizedGroupName = Model.Groups[i].Name.Replace(".", "_");
<div class="tab-pane fade @(i == 0 ? "show active" : "")" id="v-pills-@normalizedGroupName" role="tabpanel" aria-labelledby="v-pills-tab-@normalizedGroupName">
<div class="tab-pane fade @(i == 0 ? "show active" : "")" id="v-pills-@Model.Groups[i].GetNormalizedGroupName()" role="tabpanel" aria-labelledby="v-pills-tab-@Model.Groups[i].GetNormalizedGroupName()">
@for (var j = 0; j < Model.Groups[i].Permissions.Count; j++)
{
<div class="form-check">
<label asp-for="@Model.Groups[i].Permissions[j].IsGranted" class="form-check-label">
<input asp-for="@Model.Groups[i].Permissions[j].IsGranted" class="form-check-input" />
@Model.Groups[i].Permissions[j].DisplayName
<input asp-for="@Model.Groups[i].Permissions[j].IsGranted" class="form-check-input" disabled="@Model.Groups[i].Permissions[j].IsDisabled(Model.ProviderName)" />
@Html.Raw(Model.Groups[i].Permissions[j].GetShownName(Model.ProviderName))
</label>
</div>
<input asp-for="@Model.Groups[i].Permissions[j].Name" />

@ -67,6 +67,11 @@ namespace Volo.Abp.Permissions.Web.Pages.AbpPermissions
public string DisplayName { get; set; }
public List<PermissionGrantInfoViewModel> Permissions { get; set; }
public string GetNormalizedGroupName()
{
return Name.Replace(".", "_");
}
}
public class PermissionGrantInfoViewModel
@ -82,6 +87,28 @@ namespace Volo.Abp.Permissions.Web.Pages.AbpPermissions
public bool IsGranted { get; set; }
public List<ProviderInfoViewModel> Providers { get; set; }
public bool IsDisabled(string currentProviderName)
{
return IsGranted && Providers.All(p => p.ProviderName != currentProviderName);
}
public string GetShownName(string currentProviderName)
{
if (!IsDisabled(currentProviderName))
{
return DisplayName;
}
return string.Format(
"{0} <span class=\"text-muted\">({1})</span>",
DisplayName,
Providers
.Where(p => p.ProviderName != currentProviderName)
.Select(p => p.ProviderName)
.JoinAsString(", ")
);
}
}
public class ProviderInfoViewModel

Loading…
Cancel
Save