added ModuleControlBase

This commit is contained in:
Shaun Walker 2020-06-25 09:31:21 -04:00
parent fa15a5e44b
commit a4a0334ec0
14 changed files with 94 additions and 96 deletions

View File

@ -1,6 +1,6 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleControlBase
@attribute [OqtaneIgnore]
@if (_visible) @if (_visible)
{ {
<div class="app-admin-modal"> <div class="app-admin-modal">

View File

@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleControlBase
@attribute [OqtaneIgnore]
@inject IUserService UserService @inject IUserService UserService
@if (_authorized) @if (_authorized)
@ -51,7 +50,7 @@
[Parameter] [Parameter]
public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon
[Parameter] [Parameter]
public bool IconOnly { get; set; } // optional - specifies only icon in link public bool IconOnly { get; set; } // optional - specifies only icon in link
@ -90,8 +89,8 @@
if (!string.IsNullOrEmpty(IconName)) if (!string.IsNullOrEmpty(IconName))
{ {
_iconSpan = $"<span class=\"oi oi-{IconName}\"></span>{(IconOnly?"":"&nbsp")}"; _iconSpan = $"<span class=\"oi oi-{IconName}\"></span>{(IconOnly ? "" : "&nbsp")}";
} }
_url = EditUrl(Action, _parameters); _url = EditUrl(Action, _parameters);
@ -123,7 +122,7 @@
{ {
security = Security.Value; security = Security.Value;
} }
switch (security) switch (security)
{ {
case SecurityAccessLevel.Anonymous: case SecurityAccessLevel.Anonymous:
@ -143,7 +142,7 @@
break; break;
} }
} }
return authorized; return authorized;
} }
} }

View File

@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleControlBase
@attribute [OqtaneIgnore]
@if (_text != string.Empty) @if (_text != string.Empty)
{ {
@ -8,7 +7,7 @@
} }
@code { @code {
private string _text = string.Empty; private string _text = string.Empty;
[Parameter] [Parameter]
@ -22,7 +21,7 @@
[Parameter] [Parameter]
public DateTime ModifiedOn { get; set; } public DateTime ModifiedOn { get; set; }
[Parameter] [Parameter]
public string DeletedBy { get; set; } public string DeletedBy { get; set; }
@ -41,51 +40,51 @@
if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn != null) if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn != null)
{ {
_text += "<p style=\"" + Style + "\">Created "; _text += "<p style=\"" + Style + "\">Created ";
if (!String.IsNullOrEmpty(CreatedBy)) if (!String.IsNullOrEmpty(CreatedBy))
{ {
_text += " by <b>" + CreatedBy + "</b>"; _text += " by <b>" + CreatedBy + "</b>";
} }
if (CreatedOn != null) if (CreatedOn != null)
{ {
_text += " on <b>" + CreatedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>"; _text += " on <b>" + CreatedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
} }
_text += "</p>"; _text += "</p>";
} }
if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn != null) if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn != null)
{ {
_text += "<p style=\"" + Style + "\">Last modified "; _text += "<p style=\"" + Style + "\">Last modified ";
if (!String.IsNullOrEmpty(ModifiedBy)) if (!String.IsNullOrEmpty(ModifiedBy))
{ {
_text += " by <b>" + ModifiedBy + "</b>"; _text += " by <b>" + ModifiedBy + "</b>";
} }
if (ModifiedOn != null) if (ModifiedOn != null)
{ {
_text += " on <b>" + ModifiedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>"; _text += " on <b>" + ModifiedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
} }
_text += "</p>"; _text += "</p>";
} }
if (!String.IsNullOrEmpty(DeletedBy) || DeletedOn.HasValue) if (!String.IsNullOrEmpty(DeletedBy) || DeletedOn.HasValue)
{ {
_text += "<p style=\"" + Style + "\">Deleted "; _text += "<p style=\"" + Style + "\">Deleted ";
if (!String.IsNullOrEmpty(DeletedBy)) if (!String.IsNullOrEmpty(DeletedBy))
{ {
_text += " by <b>" + DeletedBy + "</b>"; _text += " by <b>" + DeletedBy + "</b>";
} }
if (DeletedOn != null) if (DeletedOn != null)
{ {
_text += " on <b>" + DeletedOn.Value.ToString("MMM dd yyyy HH:mm:ss") + "</b>"; _text += " on <b>" + DeletedOn.Value.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
} }
_text += "</p>"; _text += "</p>";
} }
} }

View File

@ -1,7 +1,5 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleControlBase
@attribute [OqtaneIgnore]
@inject IFolderService FolderService @inject IFolderService FolderService
@inject IFileService FileService @inject IFileService FileService
@ -56,11 +54,11 @@
<div> <div>
@if (UploadMultiple) @if (UploadMultiple)
{ {
<input type="file" id="@_fileinputid" name="file" accept="@_filter" multiple/> <input type="file" id="@_fileinputid" name="file" accept="@_filter" multiple />
} }
else else
{ {
<input type="file" id="@_fileinputid" name="file" accept="@_filter"/> <input type="file" id="@_fileinputid" name="file" accept="@_filter" />
} }
<span id="@_progressinfoid"></span><progress id="@_progressbarid" style="width: 150px; visibility: hidden;"></progress> <span id="@_progressinfoid"></span><progress id="@_progressbarid" style="width: 150px; visibility: hidden;"></progress>
<span class="float-right"> <span class="float-right">
@ -134,7 +132,7 @@
if (!string.IsNullOrEmpty(Folder)) if (!string.IsNullOrEmpty(Folder))
{ {
_folders = new List<Folder> {new Folder {FolderId = -1, Name = Folder}}; _folders = new List<Folder> { new Folder { FolderId = -1, Name = Folder } };
FolderId = -1; FolderId = -1;
} }
else else
@ -163,7 +161,7 @@
await GetFiles(); await GetFiles();
// create unique id for component // create unique id for component
_guid = Guid.NewGuid().ToString("N"); _guid = Guid.NewGuid().ToString("N");
_fileinputid = _guid + "FileInput"; _fileinputid = _guid + "FileInput";
_progressinfoid = _guid + "ProgressInfo"; _progressinfoid = _guid + "ProgressInfo";
@ -211,7 +209,7 @@
_message = string.Empty; _message = string.Empty;
try try
{ {
FolderId = int.Parse((string) e.Value); FolderId = int.Parse((string)e.Value);
await GetFiles(); await GetFiles();
FileId = -1; FileId = -1;
_image = string.Empty; _image = string.Empty;
@ -227,7 +225,7 @@
private async Task FileChanged(ChangeEventArgs e) private async Task FileChanged(ChangeEventArgs e)
{ {
_message = string.Empty; _message = string.Empty;
FileId = int.Parse((string) e.Value); FileId = int.Parse((string)e.Value);
await SetImage(); await SetImage();
StateHasChanged(); StateHasChanged();
@ -244,8 +242,8 @@
var maxwidth = 200; var maxwidth = 200;
var maxheight = 200; var maxheight = 200;
var ratioX = (double) maxwidth / (double) file.ImageWidth; var ratioX = (double)maxwidth / (double)file.ImageWidth;
var ratioY = (double) maxheight / (double) file.ImageHeight; var ratioY = (double)maxheight / (double)file.ImageHeight;
var ratio = ratioX < ratioY ? ratioX : ratioY; var ratio = ratioX < ratioY ? ratioX : ratioY;
_image = "<img src=\"" + ContentUrl(FileId) + "\" alt=\"" + file.Name + _image = "<img src=\"" + ContentUrl(FileId) + "\" alt=\"" + file.Name +

View File

@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleControlBase
@attribute [OqtaneIgnore]
@if (!string.IsNullOrEmpty(HelpText)) @if (!string.IsNullOrEmpty(HelpText))
{ {
@ -16,7 +15,7 @@ else
private string _closeLabel = "</label>"; private string _closeLabel = "</label>";
[Parameter] [Parameter]
public RenderFragment ChildContent { get; set; } public RenderFragment ChildContent { get; set; }
[Parameter] [Parameter]
public string For { get; set; } // optional - the id of the associated input control for accessibility public string For { get; set; } // optional - the id of the associated input control for accessibility
@ -34,12 +33,12 @@ else
{ {
_openLabel += " for=\"" + For + "\""; _openLabel += " for=\"" + For + "\"";
} }
if (!string.IsNullOrEmpty(Class)) if (!string.IsNullOrEmpty(Class))
{ {
_openLabel += " class=\"" + Class + "\""; _openLabel += " class=\"" + Class + "\"";
} }
_openLabel += ">"; _openLabel += ">";
} }
} }

View File

@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleControlBase
@attribute [OqtaneIgnore]
@if (!string.IsNullOrEmpty(_message)) @if (!string.IsNullOrEmpty(_message))
{ {
@ -52,7 +51,7 @@
classname = "alert alert-danger"; classname = "alert alert-danger";
break; break;
} }
return classname; return classname;
} }
} }

View File

@ -1,41 +1,39 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleControlBase
@attribute [OqtaneIgnore] @typeparam TableItem
@typeparam TableItem
<p> <p>
@if(Format == "Table") @if (Format == "Table")
{ {
<table class="@Class"> <table class="@Class">
<thead> <thead>
<tr>@Header</tr> <tr>@Header</tr>
</thead> </thead>
<tbody> <tbody>
@foreach (var item in ItemList)
{
<tr>@Row(item)</tr>
@if (Detail != null)
{
<tr>@Detail(item)</tr>
}
}
</tbody>
</table>
}
@if (Format == "Grid")
{
<div class="@Class">
<div class="row">@Header</div>
@foreach (var item in ItemList) @foreach (var item in ItemList)
{ {
<tr>@Row(item)</tr> <div class="row">@Row(item)</div>
@if (Detail != null) @if (Detail != null)
{ {
<tr>@Detail(item)</tr> <div class="row">@Detail(item)</div>
} }
} }
</tbody> </div>
</table>
}
@if(Format == "Grid")
{
<div class="@Class">
<div class="row">@Header</div>
@foreach (var item in ItemList)
{
<div class="row">@Row(item)</div>
@if (Detail != null)
{
<div class="row">@Detail(item)</div>
}
}
</div>
} }
<div class="mx-auto text-center"> <div class="mx-auto text-center">
@if (_page > _maxPages) @if (_page > _maxPages)
@ -44,7 +42,7 @@
} }
@if (_endPage > 1) @if (_endPage > 1)
{ {
<button class="btn btn-secondary" @onclick=@(async () => NavigateToPage("previous"))><span class="oi oi-chevron-left" title="previous" aria-hidden="true"></span></button> <button class="btn btn-secondary" @onclick=@(async () => NavigateToPage("previous"))><span class="oi oi-chevron-left" title="previous" aria-hidden="true"></span></button>
@for (int i = _startPage; i <= _endPage; i++) @for (int i = _startPage; i <= _endPage; i++)
{ {
var pager = i; var pager = i;
@ -105,7 +103,7 @@
{ {
Format = "Table"; Format = "Table";
} }
if (string.IsNullOrEmpty(Class)) if (string.IsNullOrEmpty(Class))
{ {
if (Format == "Table") if (Format == "Table")
@ -117,7 +115,7 @@
Class = "container"; Class = "container";
} }
} }
if (string.IsNullOrEmpty(PageSize)) if (string.IsNullOrEmpty(PageSize))
{ {
_maxItems = 10; _maxItems = 10;
@ -126,7 +124,7 @@
{ {
_maxItems = int.Parse(PageSize); _maxItems = int.Parse(PageSize);
} }
if (string.IsNullOrEmpty(DisplayPages)) if (string.IsNullOrEmpty(DisplayPages))
{ {
_maxPages = 5; _maxPages = 5;
@ -149,7 +147,7 @@
{ {
ItemList = Items.Skip((currentPage - 1) * _maxItems).Take(_maxItems); ItemList = Items.Skip((currentPage - 1) * _maxItems).Take(_maxItems);
_page = currentPage; _page = currentPage;
StateHasChanged(); StateHasChanged();
} }
@ -174,7 +172,7 @@
{ {
_endPage = _pages; _endPage = _pages;
} }
StateHasChanged(); StateHasChanged();
} }
else if (direction == "back") else if (direction == "back")
@ -208,7 +206,7 @@
_page -= 1; _page -= 1;
} }
} }
UpdateList(_page); UpdateList(_page);
} }
} }

View File

@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleControlBase
@attribute [OqtaneIgnore]
@inject IRoleService RoleService @inject IRoleService RoleService
@inject IUserService UserService @inject IUserService UserService
@ -39,7 +38,7 @@
<th scope="col">User</th> <th scope="col">User</th>
@foreach (PermissionString permission in _permissions) @foreach (PermissionString permission in _permissions)
{ {
<th style="text-align: center; width: 1px;">@permission.PermissionName</th> <th style="text-align: center; width: 1px;">@permission.PermissionName</th>
} }
</tr> </tr>
</thead> </thead>
@ -48,7 +47,7 @@
{ {
string userid = "[" + user.UserId.ToString() + "]"; string userid = "[" + user.UserId.ToString() + "]";
<tr> <tr>
<td >@user.DisplayName</td> <td>@user.DisplayName</td>
@foreach (PermissionString permission in _permissions) @foreach (PermissionString permission in _permissions)
{ {
var p = permission; var p = permission;
@ -107,13 +106,13 @@
_roles.Insert(0, new Role { Name = Constants.AllUsersRole }); _roles.Insert(0, new Role { Name = Constants.AllUsersRole });
_permissions = new List<PermissionString>(); _permissions = new List<PermissionString>();
foreach (string permissionname in _permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string permissionname in _permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
{ {
// initialize with admin role // initialize with admin role
_permissions.Add(new PermissionString { PermissionName = permissionname, Permissions = Constants.AdminRole }); _permissions.Add(new PermissionString { PermissionName = permissionname, Permissions = Constants.AdminRole });
} }
if (!string.IsNullOrEmpty(Permissions)) if (!string.IsNullOrEmpty(Permissions))
{ {
// populate permissions // populate permissions
@ -123,7 +122,7 @@
{ {
_permissions[_permissions.FindIndex(item => item.PermissionName == permissionstring.PermissionName)].Permissions = permissionstring.Permissions; _permissions[_permissions.FindIndex(item => item.PermissionName == permissionstring.PermissionName)].Permissions = permissionstring.Permissions;
} }
if (permissionstring.Permissions.Contains("[")) if (permissionstring.Permissions.Contains("["))
{ {
foreach (string user in permissionstring.Permissions.Split(new char[] { '[' }, StringSplitOptions.RemoveEmptyEntries)) foreach (string user in permissionstring.Permissions.Split(new char[] { '[' }, StringSplitOptions.RemoveEmptyEntries))
@ -183,7 +182,7 @@
_message = "Username Does Not Exist"; _message = "Username Does Not Exist";
} }
} }
_username = string.Empty; _username = string.Empty;
} }
@ -209,7 +208,7 @@
case null: case null:
break; // permission not specified break; // permission not specified
} }
_permissions[_permissions.FindIndex(item => item.PermissionName == permissionName)].Permissions = string.Join(";", ids.ToArray()); _permissions[_permissions.FindIndex(item => item.PermissionName == permissionName)].Permissions = string.Join(";", ids.ToArray());
} }
} }

View File

@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleControlBase
@attribute [OqtaneIgnore]
<div class="row" style="margin-bottom: 50px;"> <div class="row" style="margin-bottom: 50px;">
<div class="col"> <div class="col">
@ -108,12 +107,12 @@
public string DebugLevel { get; set; } = "info"; public string DebugLevel { get; set; } = "info";
public override List<Resource> Resources => new List<Resource>() public override List<Resource> Resources => new List<Resource>()
{ {
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill1.3.6.min.js" }, new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill1.3.6.min.js" },
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-blot-formatter.min.js" }, new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-blot-formatter.min.js" },
new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-interop.js" } new Resource { ResourceType = ResourceType.Script, Bundle = "Quill", Url = "js/quill-interop.js" }
}; };
protected override void OnInitialized() protected override void OnInitialized()
{ {
_content = Content; // raw HTML _content = Content; // raw HTML

View File

@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleControlBase
@attribute [OqtaneIgnore]
<div class="d-flex"> <div class="d-flex">
<div> <div>

View File

@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleControlBase
@attribute [OqtaneIgnore]
@if (Name == Parent.ActiveTab) @if (Name == Parent.ActiveTab)
{ {

View File

@ -1,6 +1,5 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleBase @inherits ModuleControlBase
@attribute [OqtaneIgnore]
<CascadingValue Value="this"> <CascadingValue Value="this">
<div class="container-fluid"> <div class="container-fluid">

View File

@ -1,4 +1,5 @@
@namespace Oqtane.Modules.Controls @namespace Oqtane.Modules.Controls
@inherits ModuleControlBase
<img src="@_src" title="@_title" @onclick="SetValue" /> <img src="@_src" title="@_title" @onclick="SetValue" />
@ -38,7 +39,7 @@
_value = true; _value = true;
break; break;
} }
SetImage(); SetImage();
OnChange(_value); OnChange(_value);
} }

View File

@ -0,0 +1,10 @@
using Oqtane.Shared;
namespace Oqtane.Modules
{
[OqtaneIgnore]
public abstract class ModuleControlBase : ModuleBase
{
}
}