improve confirm dialog
This commit is contained in:
parent
d5031a052a
commit
f59ec7bdac
|
@ -17,7 +17,7 @@ else
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ConfirmationDialog Header="Delete File" Message="@("Are You Sure You Wish To Delete " + context + "?")" Action="Delete" Class="btn btn-danger" OnClick="@(async () => await DeleteFile(context))" /></td>
|
<td><ActionDialog Header="Delete File" Message="@("Are You Sure You Wish To Delete " + context + "?")" Action="Delete" Class="btn btn-danger" OnClick="@(async () => await DeleteFile(context))" /></td>
|
||||||
<td><a href="@(uri.Scheme + "://" + uri.Authority + "/" + PageState.Site.SiteRootPath + context)" target="_new">@context</a></td>
|
<td><a href="@(uri.Scheme + "://" + uri.Authority + "/" + PageState.Site.SiteRootPath + context)" target="_new">@context</a></td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<ActionLink Action="Add" Text="Add Profile" Control="Edit" />
|
<ActionLink Action="Add" Security="SecurityAccessLevel.Admin" Text="Add Profile" />
|
||||||
|
|
||||||
<Pager Items="@Profiles">
|
<Pager Items="@Profiles">
|
||||||
<Header>
|
<Header>
|
||||||
|
@ -18,7 +18,7 @@ else
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ProfileId.ToString())" /></td>
|
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.ProfileId.ToString())" /></td>
|
||||||
<td><ConfirmationDialog Header="Delete Profile" Message="@("Are You Sure You Wish To Delete " + context.Name + "?")" Action="Delete" Class="btn btn-danger" OnClick="@(async () => await DeleteProfile(context.ProfileId))" /></td>
|
<td><ActionDialog Header="Delete Profile" Message="@("Are You Sure You Wish To Delete " + context.Name + "?")" Action="Delete" Class="btn btn-danger" OnClick="@(async () => await DeleteProfile(context.ProfileId))" /></td>
|
||||||
<td>@context.Name</td>
|
<td>@context.Name</td>
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
|
|
123
Oqtane.Client/Modules/Controls/ActionDialog.razor
Normal file
123
Oqtane.Client/Modules/Controls/ActionDialog.razor
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
@namespace Oqtane.Modules.Controls
|
||||||
|
@inherits ModuleBase
|
||||||
|
|
||||||
|
@if (visible)
|
||||||
|
{
|
||||||
|
<div class="app-admin-modal">
|
||||||
|
<div class="modal" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">@Header</h5>
|
||||||
|
<button type="button" class="close" @onclick="DisplayModal" aria-label="Close">×</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>@Message</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="@Class" @onclick="Confirm">@Action</button>
|
||||||
|
<button type="button" class="btn btn-secondary" @onclick="DisplayModal">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@if (authorized)
|
||||||
|
{
|
||||||
|
<button class="@Class" @onclick="DisplayModal">@Action</button>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string Header { get; set; } // required
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Message { get; set; } // required
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Action { get; set; } // defaults to Ok if not specified
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public SecurityAccessLevel? Security { get; set; } // optional - can be used to explicitly specify SecurityAccessLevel
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Class { get; set; } // optional
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public Action OnClick { get; set; } // required - executes a method in the calling component
|
||||||
|
|
||||||
|
bool visible = false;
|
||||||
|
bool authorized = false;
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Action))
|
||||||
|
{
|
||||||
|
Action = "Ok";
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(Class))
|
||||||
|
{
|
||||||
|
Class = "btn btn-success";
|
||||||
|
}
|
||||||
|
authorized = IsAuthorized();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsAuthorized()
|
||||||
|
{
|
||||||
|
bool authorized = false;
|
||||||
|
if (PageState.EditMode)
|
||||||
|
{
|
||||||
|
SecurityAccessLevel security = SecurityAccessLevel.Host;
|
||||||
|
if (Security == null)
|
||||||
|
{
|
||||||
|
string typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Action + ",");
|
||||||
|
Type moduleType = Type.GetType(typename);
|
||||||
|
if (moduleType != null)
|
||||||
|
{
|
||||||
|
var moduleobject = Activator.CreateInstance(moduleType);
|
||||||
|
security = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
security = SecurityAccessLevel.Anonymous; // occurs when an action does not have a corresponding module control
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
security = Security.Value;
|
||||||
|
}
|
||||||
|
switch (security)
|
||||||
|
{
|
||||||
|
case SecurityAccessLevel.Anonymous:
|
||||||
|
authorized = true;
|
||||||
|
break;
|
||||||
|
case SecurityAccessLevel.View:
|
||||||
|
authorized = UserSecurity.IsAuthorized(PageState.User, "View", ModuleState.Permissions);
|
||||||
|
break;
|
||||||
|
case SecurityAccessLevel.Edit:
|
||||||
|
authorized = UserSecurity.IsAuthorized(PageState.User, "Edit", ModuleState.Permissions);
|
||||||
|
break;
|
||||||
|
case SecurityAccessLevel.Admin:
|
||||||
|
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.AdminRole);
|
||||||
|
break;
|
||||||
|
case SecurityAccessLevel.Host:
|
||||||
|
authorized = UserSecurity.IsAuthorized(PageState.User, Constants.HostRole);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return authorized;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisplayModal()
|
||||||
|
{
|
||||||
|
visible = !visible;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Confirm()
|
||||||
|
{
|
||||||
|
DisplayModal();
|
||||||
|
OnClick();
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,7 +9,10 @@
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Action { get; set; }
|
public string Action { get; set; } // required
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public SecurityAccessLevel? Security { get; set; } // optional - can be used to explicitly specify SecurityAccessLevel
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Text { get; set; } // optional - defaults to Action if not specified
|
public string Text { get; set; } // optional - defaults to Action if not specified
|
||||||
|
@ -23,9 +26,6 @@
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Style { get; set; } // optional
|
public string Style { get; set; } // optional
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public string Control { get; set; } // optional - can be used to explicitly link an Action to a Module Control
|
|
||||||
|
|
||||||
string text = "";
|
string text = "";
|
||||||
string url = "";
|
string url = "";
|
||||||
string parameters = "";
|
string parameters = "";
|
||||||
|
@ -57,24 +57,35 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
url = EditUrl(Action, parameters);
|
url = EditUrl(Action, parameters);
|
||||||
|
authorized = IsAuthorized();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsAuthorized()
|
||||||
|
{
|
||||||
|
bool authorized = false;
|
||||||
if (PageState.EditMode)
|
if (PageState.EditMode)
|
||||||
{
|
{
|
||||||
string typename;
|
SecurityAccessLevel security = SecurityAccessLevel.Host;
|
||||||
if (string.IsNullOrEmpty(Control))
|
if (Security == null)
|
||||||
{
|
{
|
||||||
typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Action + ",");
|
string typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Action + ",");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Control + ",");
|
|
||||||
}
|
|
||||||
Type moduleType = Type.GetType(typename);
|
Type moduleType = Type.GetType(typename);
|
||||||
if (moduleType != null)
|
if (moduleType != null)
|
||||||
{
|
{
|
||||||
var moduleobject = Activator.CreateInstance(moduleType);
|
var moduleobject = Activator.CreateInstance(moduleType);
|
||||||
SecurityAccessLevel SecurityAccessLevel = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
security = (SecurityAccessLevel)moduleType.GetProperty("SecurityAccessLevel").GetValue(moduleobject, null);
|
||||||
switch (SecurityAccessLevel)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
security = SecurityAccessLevel.Anonymous; // occurs when an action does not have a corresponding module control
|
||||||
|
Class = "btn btn-warning"; // alert developer of missing module comtrol
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
security = Security.Value;
|
||||||
|
}
|
||||||
|
switch (security)
|
||||||
{
|
{
|
||||||
case SecurityAccessLevel.Anonymous:
|
case SecurityAccessLevel.Anonymous:
|
||||||
authorized = true;
|
authorized = true;
|
||||||
|
@ -93,15 +104,6 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
return authorized;
|
||||||
{
|
|
||||||
authorized = true; // occurs when an action does not have a corresponding module control
|
|
||||||
classname = "btn btn-warning"; // alert developer of missing module comtrol
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
authorized = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,69 +0,0 @@
|
||||||
@namespace Oqtane.Modules.Controls
|
|
||||||
@inherits ModuleBase
|
|
||||||
|
|
||||||
@if (visible)
|
|
||||||
{
|
|
||||||
<div class="app-admin-modal">
|
|
||||||
<div class="modal" tabindex="-1" role="dialog">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title">@Header</h5>
|
|
||||||
<button type="button" class="close" @onclick="DisplayModal" aria-label="Close">×</button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<p>@Message</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="@Class" @onclick="Confirm">@Action</button>
|
|
||||||
<button type="button" class="btn btn-secondary" @onclick="DisplayModal">Cancel</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
<button class="@Class" @onclick="DisplayModal">@Action</button>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
[Parameter]
|
|
||||||
public string Header { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public string Message { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public string Action { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public string Class { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public Action OnClick { get; set; }
|
|
||||||
|
|
||||||
bool visible = false;
|
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(Action))
|
|
||||||
{
|
|
||||||
Action = "Ok";
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(Class))
|
|
||||||
{
|
|
||||||
Class = "btn btn-success";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DisplayModal()
|
|
||||||
{
|
|
||||||
visible = !visible;
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Confirm()
|
|
||||||
{
|
|
||||||
DisplayModal();
|
|
||||||
OnClick();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,9 @@
|
||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@typeparam TableItem
|
@typeparam TableItem
|
||||||
|
|
||||||
<p align="center">
|
<p>
|
||||||
|
@if(Format == "Table")
|
||||||
|
{
|
||||||
<table class="table table-borderless">
|
<table class="table table-borderless">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>@Header</tr>
|
<tr>@Header</tr>
|
||||||
|
@ -14,7 +16,18 @@
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div>
|
}
|
||||||
|
@if(Format == "Grid")
|
||||||
|
{
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">@Header</div>
|
||||||
|
@foreach (var item in ItemList)
|
||||||
|
{
|
||||||
|
<div class="row">@Row(item)</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<div class="mx-auto text-center">
|
||||||
@if (Page > MaxPages)
|
@if (Page > MaxPages)
|
||||||
{
|
{
|
||||||
<button class="btn btn-secondary" @onclick=@(async () => SetPagerSize("back"))><span class="oi oi-media-skip-backward" title="back" aria-hidden="true"></span></button>
|
<button class="btn btn-secondary" @onclick=@(async () => SetPagerSize("back"))><span class="oi oi-media-skip-backward" title="back" aria-hidden="true"></span></button>
|
||||||
|
@ -50,6 +63,9 @@
|
||||||
int StartPage;
|
int StartPage;
|
||||||
int EndPage;
|
int EndPage;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Format { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public RenderFragment Header { get; set; }
|
public RenderFragment Header { get; set; }
|
||||||
|
|
||||||
|
@ -69,6 +85,10 @@
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(Format))
|
||||||
|
{
|
||||||
|
Format = "Table";
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(PageSize))
|
if (string.IsNullOrEmpty(PageSize))
|
||||||
{
|
{
|
||||||
MaxItems = 10;
|
MaxItems = 10;
|
||||||
|
|
|
@ -50,7 +50,6 @@ namespace Oqtane.Infrastructure
|
||||||
case ".dll":
|
case ".dll":
|
||||||
entry.ExtractToFile(Path.Combine(binfolder, filename), true);
|
entry.ExtractToFile(Path.Combine(binfolder, filename), true);
|
||||||
break;
|
break;
|
||||||
case ".nuspec":
|
|
||||||
case ".png":
|
case ".png":
|
||||||
case ".jpg":
|
case ".jpg":
|
||||||
case ".jpeg":
|
case ".jpeg":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user