fixes to role management

This commit is contained in:
Shaun Walker 2020-03-24 16:56:01 -04:00
parent 32bc4bd13f
commit 20e481af3d
5 changed files with 19 additions and 44 deletions

View File

@ -6,37 +6,26 @@
<table class="table table-borderless"> <table class="table table-borderless">
<tr> <tr>
<td> <td>
<label class="control-label">Name: </label> <Label For="_name" Class="control-label" HelpText="Name Of The Role">Name: </Label>
</td> </td>
<td> <td>
<input class="form-control" @bind="@name" /> <input id="_name" class="form-control" @bind="@_name" />
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Description: </label> <Label For="_description" Class="control-label" HelpText="A Short Description Of The Role Which Describes Its Purpose">Description: </Label>
</td> </td>
<td> <td>
<textarea class="form-control" @bind="@description" rows="5"></textarea> <textarea id="_description" class="form-control" @bind="@_description" rows="5"></textarea>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label class="control-label">Auto Assigned? </label> <Label For="_isautoassigned" Class="control-label" HelpText="Indicates Whether Or Not New Users Are Automatically Assigned To This Role">Auto Assigned? </Label>
</td> </td>
<td> <td>
<select class="form-control" @bind="@isautoassigned"> <select id="_isautoassigned" class="form-control" @bind="@_isautoassigned">
<option value="True">Yes</option>
<option value="False">No</option>
</select>
</td>
</tr>
<tr>
<td>
<label class="control-label">System Role? </label>
</td>
<td>
<select class="form-control" @bind="@issystem">
<option value="True">Yes</option> <option value="True">Yes</option>
<option value="False">No</option> <option value="False">No</option>
</select> </select>
@ -49,19 +38,18 @@
@code { @code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
string name = ""; string _name = "";
string description = ""; string _description = "";
string isautoassigned = "False"; string _isautoassigned = "False";
string issystem = "False";
private async Task SaveRole() private async Task SaveRole()
{ {
Role role = new Role(); Role role = new Role();
role.SiteId = PageState.Page.SiteId; role.SiteId = PageState.Page.SiteId;
role.Name = name; role.Name = _name;
role.Description = description; role.Description = _description;
role.IsAutoAssigned = (isautoassigned == null ? false : Boolean.Parse(isautoassigned)); role.IsAutoAssigned = (_isautoassigned == null ? false : Boolean.Parse(_isautoassigned));
role.IsSystem = (issystem == null ? false : Boolean.Parse(issystem)); role.IsSystem = false;
try try
{ {

View File

@ -31,17 +31,6 @@
</select> </select>
</td> </td>
</tr> </tr>
<tr>
<td>
<Label For="_issystem" Class="control-label" HelpText="Indicates Whether Or Not This Is A System Role. System Roles Are Protected And Cannot Be Deleted.">System Role? </Label>
</td>
<td>
<select id="_issystem" class="form-control" @bind="@_issystem">
<option value="True">Yes</option>
<option value="False">No</option>
</select>
</td>
</tr>
</table> </table>
<button type="button" class="btn btn-success" @onclick="SaveRole">Save</button> <button type="button" class="btn btn-success" @onclick="SaveRole">Save</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink> <NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
@ -53,7 +42,6 @@
string _name = ""; string _name = "";
string _description = ""; string _description = "";
string _isautoassigned = "False"; string _isautoassigned = "False";
string _issystem = "False";
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -66,7 +54,6 @@
_name = role.Name; _name = role.Name;
_description = role.Description; _description = role.Description;
_isautoassigned = role.IsAutoAssigned.ToString(); _isautoassigned = role.IsAutoAssigned.ToString();
_issystem = role.IsSystem.ToString();
} }
} }
catch (Exception ex) catch (Exception ex)
@ -82,7 +69,7 @@
role.Name = _name; role.Name = _name;
role.Description = _description; role.Description = _description;
role.IsAutoAssigned = (_isautoassigned != null && Boolean.Parse(_isautoassigned)); role.IsAutoAssigned = (_isautoassigned != null && Boolean.Parse(_isautoassigned));
role.IsSystem = (_issystem != null && Boolean.Parse(_issystem)); role.IsSystem = false;
try try
{ {

View File

@ -17,8 +17,8 @@ else
<th>Name</th> <th>Name</th>
</Header> </Header>
<Row> <Row>
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.RoleId.ToString())" /></td> <td><ActionLink Action="Edit" Parameters="@($"id=" + context.RoleId.ToString())" Disabled="@(context.IsSystem)" /></td>
<td><ActionDialog Header="Delete Role" Message="@("Are You Sure You Wish To Delete The " + context.Name + " Role?")" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteRole(context))" /></td> <td><ActionDialog Header="Delete Role" Message="@("Are You Sure You Wish To Delete The " + context.Name + " Role?")" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteRole(context))" Disabled="@(context.IsSystem)" /></td>
<td>@context.Name</td> <td>@context.Name</td>
</Row> </Row>
</Pager> </Pager>

View File

@ -30,7 +30,7 @@
{ {
if (Disabled) if (Disabled)
{ {
<button class="@Class" disabled @onclick="DisplayModal">@Text</button> <button class="@Class" disabled>@Text</button>
} }
else else
{ {

View File

@ -6,7 +6,7 @@
{ {
if (Disabled) if (Disabled)
{ {
<NavLink class="@_classname" href="@_url" style="@_style" disabled>@((MarkupString)_iconSpan) @_text</NavLink> <button class="@_classname" style="@_style" disabled>@((MarkupString)_iconSpan) @_text</button>
} }
else else
{ {
@ -82,7 +82,7 @@
if (!string.IsNullOrEmpty(IconName)) if (!string.IsNullOrEmpty(IconName))
{ {
_iconSpan = $"<span class=\"oi oi-{IconName}\"></span>&nbsp;"; _iconSpan = $"<span class=\"oi oi-{IconName}\"></span>&nbsp;";
} }
_url = EditUrl(Action, _parameters); _url = EditUrl(Action, _parameters);
_authorized = IsAuthorized(); _authorized = IsAuthorized();