From a4a0334ec08cccf931df8a07020c09383532ce07 Mon Sep 17 00:00:00 2001 From: Shaun Walker Date: Thu, 25 Jun 2020 09:31:21 -0400 Subject: [PATCH] added ModuleControlBase --- .../Modules/Controls/ActionDialog.razor | 4 +- .../Modules/Controls/ActionLink.razor | 13 ++-- .../Modules/Controls/AuditInfo.razor | 25 ++++--- .../Modules/Controls/FileManager.razor | 20 +++--- Oqtane.Client/Modules/Controls/Label.razor | 9 ++- .../Modules/Controls/ModuleMessage.razor | 5 +- Oqtane.Client/Modules/Controls/Pager.razor | 68 +++++++++---------- .../Modules/Controls/PermissionGrid.razor | 17 +++-- .../Modules/Controls/RichTextEditor.razor | 7 +- Oqtane.Client/Modules/Controls/Section.razor | 3 +- Oqtane.Client/Modules/Controls/TabPanel.razor | 3 +- Oqtane.Client/Modules/Controls/TabStrip.razor | 3 +- .../Modules/Controls/TriStateCheckBox.razor | 3 +- Oqtane.Client/Modules/ModuleControlBase.cs | 10 +++ 14 files changed, 94 insertions(+), 96 deletions(-) create mode 100644 Oqtane.Client/Modules/ModuleControlBase.cs diff --git a/Oqtane.Client/Modules/Controls/ActionDialog.razor b/Oqtane.Client/Modules/Controls/ActionDialog.razor index 076f1e9d..f016d997 100644 --- a/Oqtane.Client/Modules/Controls/ActionDialog.razor +++ b/Oqtane.Client/Modules/Controls/ActionDialog.razor @@ -1,6 +1,6 @@ @namespace Oqtane.Modules.Controls -@inherits ModuleBase -@attribute [OqtaneIgnore] +@inherits ModuleControlBase + @if (_visible) {
diff --git a/Oqtane.Client/Modules/Controls/ActionLink.razor b/Oqtane.Client/Modules/Controls/ActionLink.razor index 39782c08..8d6b6895 100644 --- a/Oqtane.Client/Modules/Controls/ActionLink.razor +++ b/Oqtane.Client/Modules/Controls/ActionLink.razor @@ -1,6 +1,5 @@ @namespace Oqtane.Modules.Controls -@inherits ModuleBase -@attribute [OqtaneIgnore] +@inherits ModuleControlBase @inject IUserService UserService @if (_authorized) @@ -51,7 +50,7 @@ [Parameter] public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon - + [Parameter] public bool IconOnly { get; set; } // optional - specifies only icon in link @@ -90,8 +89,8 @@ if (!string.IsNullOrEmpty(IconName)) { - _iconSpan = $"{(IconOnly?"":" ")}"; - + _iconSpan = $"{(IconOnly ? "" : " ")}"; + } _url = EditUrl(Action, _parameters); @@ -123,7 +122,7 @@ { security = Security.Value; } - + switch (security) { case SecurityAccessLevel.Anonymous: @@ -143,7 +142,7 @@ break; } } - + return authorized; } } diff --git a/Oqtane.Client/Modules/Controls/AuditInfo.razor b/Oqtane.Client/Modules/Controls/AuditInfo.razor index 7c081d3f..3022c49f 100644 --- a/Oqtane.Client/Modules/Controls/AuditInfo.razor +++ b/Oqtane.Client/Modules/Controls/AuditInfo.razor @@ -1,6 +1,5 @@ @namespace Oqtane.Modules.Controls -@inherits ModuleBase -@attribute [OqtaneIgnore] +@inherits ModuleControlBase @if (_text != string.Empty) { @@ -8,7 +7,7 @@ } @code { - + private string _text = string.Empty; [Parameter] @@ -22,7 +21,7 @@ [Parameter] public DateTime ModifiedOn { get; set; } - + [Parameter] public string DeletedBy { get; set; } @@ -41,51 +40,51 @@ if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn != null) { _text += "

Created "; - + if (!String.IsNullOrEmpty(CreatedBy)) { _text += " by " + CreatedBy + ""; } - + if (CreatedOn != null) { _text += " on " + CreatedOn.ToString("MMM dd yyyy HH:mm:ss") + ""; } - + _text += "

"; } if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn != null) { _text += "

Last modified "; - + if (!String.IsNullOrEmpty(ModifiedBy)) { _text += " by " + ModifiedBy + ""; } - + if (ModifiedOn != null) { _text += " on " + ModifiedOn.ToString("MMM dd yyyy HH:mm:ss") + ""; } - + _text += "

"; } if (!String.IsNullOrEmpty(DeletedBy) || DeletedOn.HasValue) { _text += "

Deleted "; - + if (!String.IsNullOrEmpty(DeletedBy)) { _text += " by " + DeletedBy + ""; } - + if (DeletedOn != null) { _text += " on " + DeletedOn.Value.ToString("MMM dd yyyy HH:mm:ss") + ""; } - + _text += "

"; } } diff --git a/Oqtane.Client/Modules/Controls/FileManager.razor b/Oqtane.Client/Modules/Controls/FileManager.razor index bfeb0d57..0762d5e9 100644 --- a/Oqtane.Client/Modules/Controls/FileManager.razor +++ b/Oqtane.Client/Modules/Controls/FileManager.razor @@ -1,7 +1,5 @@ @namespace Oqtane.Modules.Controls -@inherits ModuleBase - -@attribute [OqtaneIgnore] +@inherits ModuleControlBase @inject IFolderService FolderService @inject IFileService FileService @@ -56,11 +54,11 @@
@if (UploadMultiple) { - + } else { - + } @@ -134,7 +132,7 @@ if (!string.IsNullOrEmpty(Folder)) { - _folders = new List {new Folder {FolderId = -1, Name = Folder}}; + _folders = new List { new Folder { FolderId = -1, Name = Folder } }; FolderId = -1; } else @@ -163,7 +161,7 @@ await GetFiles(); - // create unique id for component + // create unique id for component _guid = Guid.NewGuid().ToString("N"); _fileinputid = _guid + "FileInput"; _progressinfoid = _guid + "ProgressInfo"; @@ -211,7 +209,7 @@ _message = string.Empty; try { - FolderId = int.Parse((string) e.Value); + FolderId = int.Parse((string)e.Value); await GetFiles(); FileId = -1; _image = string.Empty; @@ -227,7 +225,7 @@ private async Task FileChanged(ChangeEventArgs e) { _message = string.Empty; - FileId = int.Parse((string) e.Value); + FileId = int.Parse((string)e.Value); await SetImage(); StateHasChanged(); @@ -244,8 +242,8 @@ var maxwidth = 200; var maxheight = 200; - var ratioX = (double) maxwidth / (double) file.ImageWidth; - var ratioY = (double) maxheight / (double) file.ImageHeight; + var ratioX = (double)maxwidth / (double)file.ImageWidth; + var ratioY = (double)maxheight / (double)file.ImageHeight; var ratio = ratioX < ratioY ? ratioX : ratioY; _image = "\"" - @if(Format == "Table") + @if (Format == "Table") { - - - @Header - - +
+ + @Header + + + @foreach (var item in ItemList) + { + @Row(item) + @if (Detail != null) + { + @Detail(item) + } + } + +
+ } + @if (Format == "Grid") + { +
+
@Header
@foreach (var item in ItemList) { - @Row(item) +
@Row(item)
@if (Detail != null) { - @Detail(item) +
@Detail(item)
} } - - - } - @if(Format == "Grid") - { -
-
@Header
- @foreach (var item in ItemList) - { -
@Row(item)
- @if (Detail != null) - { -
@Detail(item)
- } - } -
+
}
@if (_page > _maxPages) @@ -44,7 +42,7 @@ } @if (_endPage > 1) { - + @for (int i = _startPage; i <= _endPage; i++) { var pager = i; @@ -105,7 +103,7 @@ { Format = "Table"; } - + if (string.IsNullOrEmpty(Class)) { if (Format == "Table") @@ -117,7 +115,7 @@ Class = "container"; } } - + if (string.IsNullOrEmpty(PageSize)) { _maxItems = 10; @@ -126,7 +124,7 @@ { _maxItems = int.Parse(PageSize); } - + if (string.IsNullOrEmpty(DisplayPages)) { _maxPages = 5; @@ -149,7 +147,7 @@ { ItemList = Items.Skip((currentPage - 1) * _maxItems).Take(_maxItems); _page = currentPage; - + StateHasChanged(); } @@ -174,7 +172,7 @@ { _endPage = _pages; } - + StateHasChanged(); } else if (direction == "back") @@ -208,7 +206,7 @@ _page -= 1; } } - + UpdateList(_page); } } diff --git a/Oqtane.Client/Modules/Controls/PermissionGrid.razor b/Oqtane.Client/Modules/Controls/PermissionGrid.razor index 951f0502..630a652b 100644 --- a/Oqtane.Client/Modules/Controls/PermissionGrid.razor +++ b/Oqtane.Client/Modules/Controls/PermissionGrid.razor @@ -1,6 +1,5 @@ @namespace Oqtane.Modules.Controls -@inherits ModuleBase -@attribute [OqtaneIgnore] +@inherits ModuleControlBase @inject IRoleService RoleService @inject IUserService UserService @@ -39,7 +38,7 @@ User @foreach (PermissionString permission in _permissions) { - @permission.PermissionName + @permission.PermissionName } @@ -48,7 +47,7 @@ { string userid = "[" + user.UserId.ToString() + "]"; - @user.DisplayName + @user.DisplayName @foreach (PermissionString permission in _permissions) { var p = permission; @@ -107,13 +106,13 @@ _roles.Insert(0, new Role { Name = Constants.AllUsersRole }); _permissions = new List(); - + foreach (string permissionname in _permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { // initialize with admin role _permissions.Add(new PermissionString { PermissionName = permissionname, Permissions = Constants.AdminRole }); } - + if (!string.IsNullOrEmpty(Permissions)) { // populate permissions @@ -123,7 +122,7 @@ { _permissions[_permissions.FindIndex(item => item.PermissionName == permissionstring.PermissionName)].Permissions = permissionstring.Permissions; } - + if (permissionstring.Permissions.Contains("[")) { foreach (string user in permissionstring.Permissions.Split(new char[] { '[' }, StringSplitOptions.RemoveEmptyEntries)) @@ -183,7 +182,7 @@ _message = "Username Does Not Exist"; } } - + _username = string.Empty; } @@ -209,7 +208,7 @@ case null: break; // permission not specified } - + _permissions[_permissions.FindIndex(item => item.PermissionName == permissionName)].Permissions = string.Join(";", ids.ToArray()); } } diff --git a/Oqtane.Client/Modules/Controls/RichTextEditor.razor b/Oqtane.Client/Modules/Controls/RichTextEditor.razor index 28888050..5eeb17a2 100644 --- a/Oqtane.Client/Modules/Controls/RichTextEditor.razor +++ b/Oqtane.Client/Modules/Controls/RichTextEditor.razor @@ -1,6 +1,5 @@ @namespace Oqtane.Modules.Controls -@inherits ModuleBase -@attribute [OqtaneIgnore] +@inherits ModuleControlBase
@@ -108,12 +107,12 @@ public string DebugLevel { get; set; } = "info"; public override List Resources => new List() - { +{ 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-interop.js" } }; - + protected override void OnInitialized() { _content = Content; // raw HTML diff --git a/Oqtane.Client/Modules/Controls/Section.razor b/Oqtane.Client/Modules/Controls/Section.razor index f21a7e17..02fab969 100644 --- a/Oqtane.Client/Modules/Controls/Section.razor +++ b/Oqtane.Client/Modules/Controls/Section.razor @@ -1,6 +1,5 @@ @namespace Oqtane.Modules.Controls -@inherits ModuleBase -@attribute [OqtaneIgnore] +@inherits ModuleControlBase
diff --git a/Oqtane.Client/Modules/Controls/TabPanel.razor b/Oqtane.Client/Modules/Controls/TabPanel.razor index bd89ab59..9f04dc5f 100644 --- a/Oqtane.Client/Modules/Controls/TabPanel.razor +++ b/Oqtane.Client/Modules/Controls/TabPanel.razor @@ -1,6 +1,5 @@ @namespace Oqtane.Modules.Controls -@inherits ModuleBase -@attribute [OqtaneIgnore] +@inherits ModuleControlBase @if (Name == Parent.ActiveTab) { diff --git a/Oqtane.Client/Modules/Controls/TabStrip.razor b/Oqtane.Client/Modules/Controls/TabStrip.razor index ee6a6c82..cc58376f 100644 --- a/Oqtane.Client/Modules/Controls/TabStrip.razor +++ b/Oqtane.Client/Modules/Controls/TabStrip.razor @@ -1,6 +1,5 @@ @namespace Oqtane.Modules.Controls -@inherits ModuleBase -@attribute [OqtaneIgnore] +@inherits ModuleControlBase
diff --git a/Oqtane.Client/Modules/Controls/TriStateCheckBox.razor b/Oqtane.Client/Modules/Controls/TriStateCheckBox.razor index 3c056d87..845db70b 100644 --- a/Oqtane.Client/Modules/Controls/TriStateCheckBox.razor +++ b/Oqtane.Client/Modules/Controls/TriStateCheckBox.razor @@ -1,4 +1,5 @@ @namespace Oqtane.Modules.Controls +@inherits ModuleControlBase @@ -38,7 +39,7 @@ _value = true; break; } - + SetImage(); OnChange(_value); } diff --git a/Oqtane.Client/Modules/ModuleControlBase.cs b/Oqtane.Client/Modules/ModuleControlBase.cs new file mode 100644 index 00000000..d245d97c --- /dev/null +++ b/Oqtane.Client/Modules/ModuleControlBase.cs @@ -0,0 +1,10 @@ +using Oqtane.Shared; + +namespace Oqtane.Modules +{ + [OqtaneIgnore] + public abstract class ModuleControlBase : ModuleBase + { + + } +}