Refactoring (#314)
* Refactoring * Refactoring * Check for a valid email. * Fixed missing character. * Moved logic to the Utilities class. * Rename template .sql file * Modified null and empty string check. * Check for a valid email. * Fixed missing character. * Moved logic to the Utilities class. * Added Favicon support, Progressive Web App support, page title and url support, and private/public user registration options * Refactoring * Refactoring * Check for a valid email. * Moved logic to the Utilities class. Co-authored-by: Aubrey <aubrey.b@treskcow.tech> Co-authored-by: MIchael Atwood <matwood@dragonmastery.com> Co-authored-by: Shaun Walker <shaun.walker@siliqon.com>
This commit is contained in:
@ -39,6 +39,11 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private bool _visible = false;
|
||||
private bool _editmode = true;
|
||||
private bool _authorized = false;
|
||||
private string _iconSpan = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public string Header { get; set; } // required
|
||||
|
||||
@ -69,11 +74,6 @@
|
||||
[Parameter]
|
||||
public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon
|
||||
|
||||
bool _visible = false;
|
||||
bool _editmode = true;
|
||||
bool _authorized = false;
|
||||
string _iconSpan = "";
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Text))
|
||||
|
@ -15,6 +15,15 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private string _text = string.Empty;
|
||||
private string _url = string.Empty;
|
||||
private string _parameters = string.Empty;
|
||||
private string _classname = "btn btn-primary";
|
||||
private string _style = string.Empty;
|
||||
private bool _editmode = true;
|
||||
private bool _authorized = false;
|
||||
private string _iconSpan = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public string Action { get; set; } // required
|
||||
|
||||
@ -42,15 +51,6 @@
|
||||
[Parameter]
|
||||
public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon
|
||||
|
||||
string _text = "";
|
||||
string _url = "";
|
||||
string _parameters = "";
|
||||
string _classname = "btn btn-primary";
|
||||
string _style = "";
|
||||
bool _editmode = true;
|
||||
bool _authorized = false;
|
||||
string _iconSpan = "";
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
_text = Action;
|
||||
@ -90,14 +90,14 @@
|
||||
|
||||
private bool IsAuthorized()
|
||||
{
|
||||
bool authorized = false;
|
||||
var authorized = false;
|
||||
if (PageState.EditMode || !_editmode)
|
||||
{
|
||||
SecurityAccessLevel security = SecurityAccessLevel.Host;
|
||||
var security = SecurityAccessLevel.Host;
|
||||
if (Security == null)
|
||||
{
|
||||
string typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Action + ",");
|
||||
Type moduleType = Type.GetType(typename);
|
||||
var typename = ModuleState.ModuleType.Replace(Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0) + ",", Action + ",");
|
||||
var moduleType = Type.GetType(typename);
|
||||
if (moduleType != null)
|
||||
{
|
||||
var moduleobject = Activator.CreateInstance(moduleType);
|
||||
@ -113,6 +113,7 @@
|
||||
{
|
||||
security = Security.Value;
|
||||
}
|
||||
|
||||
switch (security)
|
||||
{
|
||||
case SecurityAccessLevel.Anonymous:
|
||||
@ -132,6 +133,7 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return authorized;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
@namespace Oqtane.Modules.Controls
|
||||
@inherits ModuleBase
|
||||
|
||||
@if (_text != "")
|
||||
@if (_text != string.Empty)
|
||||
{
|
||||
@((MarkupString)_text)
|
||||
}
|
||||
|
||||
@code {
|
||||
|
||||
private string _text = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public string CreatedBy { get; set; }
|
||||
|
||||
@ -31,50 +34,57 @@
|
||||
[Parameter]
|
||||
public string Style { get; set; }
|
||||
|
||||
string _text = "";
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
_text = "";
|
||||
_text = string.Empty;
|
||||
if (!String.IsNullOrEmpty(CreatedBy) || CreatedOn != null)
|
||||
{
|
||||
_text += "<p style=\"" + Style + "\">Created ";
|
||||
_text += "<p style=\string.Empty + Style + "\">Created ";
|
||||
|
||||
if (!String.IsNullOrEmpty(CreatedBy))
|
||||
{
|
||||
_text += " by <b>" + CreatedBy + "</b>";
|
||||
}
|
||||
|
||||
if (CreatedOn != null)
|
||||
{
|
||||
_text += " on <b>" + CreatedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||
}
|
||||
|
||||
_text += "</p>";
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(ModifiedBy) || ModifiedOn != null)
|
||||
{
|
||||
_text += "<p style=\"" + Style + "\">Last modified ";
|
||||
_text += "<p style=\string.Empty + Style + "\">Last modified ";
|
||||
|
||||
if (!String.IsNullOrEmpty(ModifiedBy))
|
||||
{
|
||||
_text += " by <b>" + ModifiedBy + "</b>";
|
||||
}
|
||||
|
||||
if (ModifiedOn != null)
|
||||
{
|
||||
_text += " on <b>" + ModifiedOn.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||
}
|
||||
|
||||
_text += "</p>";
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(DeletedBy) || DeletedOn.HasValue)
|
||||
{
|
||||
_text += "<p style=\"" + Style + "\">Deleted ";
|
||||
_text += "<p style=\string.Empty + Style + "\">Deleted ";
|
||||
|
||||
if (!String.IsNullOrEmpty(DeletedBy))
|
||||
{
|
||||
_text += " by <b>" + DeletedBy + "</b>";
|
||||
}
|
||||
|
||||
if (DeletedOn != null)
|
||||
{
|
||||
_text += " on <b>" + DeletedOn.Value.ToString("MMM dd yyyy HH:mm:ss") + "</b>";
|
||||
}
|
||||
|
||||
_text += "</p>";
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@
|
||||
@((MarkupString)_message)
|
||||
}
|
||||
</div>
|
||||
@if (_image != "")
|
||||
@if (_image != string.Empty)
|
||||
{
|
||||
<div class="col-auto">
|
||||
@((MarkupString)_image)
|
||||
@ -81,6 +81,21 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private string _id;
|
||||
private List<Folder> _folders;
|
||||
private int _folderid = -1;
|
||||
private List<File> _files = new List<File>();
|
||||
private int _fileid = -1;
|
||||
private bool _showfiles = true;
|
||||
private string _fileinputid = string.Empty;
|
||||
private string _progressinfoid = string.Empty;
|
||||
private string _progressbarid = string.Empty;
|
||||
private string _filter = "*";
|
||||
private bool _uploadmultiple = false;
|
||||
private bool _haseditpermission = false;
|
||||
private string _message = string.Empty;
|
||||
private string _image = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public string Folder { get; set; } // optional - for setting a specific folder by default
|
||||
|
||||
@ -99,21 +114,6 @@
|
||||
[Parameter]
|
||||
public string UploadMultiple { get; set; } // optional - enable multiple file uploads - default false
|
||||
|
||||
string _id;
|
||||
List<Folder> _folders;
|
||||
int _folderid = -1;
|
||||
List<File> _files = new List<File>();
|
||||
int _fileid = -1;
|
||||
bool _showfiles = true;
|
||||
string _fileinputid = "";
|
||||
string _progressinfoid = "";
|
||||
string _progressbarid = "";
|
||||
string _filter = "*";
|
||||
bool _uploadmultiple = false;
|
||||
bool _haseditpermission = false;
|
||||
string _message = "";
|
||||
string _image = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Folder))
|
||||
@ -205,13 +205,13 @@
|
||||
|
||||
private async Task FolderChanged(ChangeEventArgs e)
|
||||
{
|
||||
_message = "";
|
||||
_message = string.Empty;
|
||||
try
|
||||
{
|
||||
_folderid = int.Parse((string)e.Value);
|
||||
await GetFiles();
|
||||
_fileid = -1;
|
||||
_image = "";
|
||||
_image = string.Empty;
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -223,30 +223,31 @@
|
||||
|
||||
private async Task FileChanged(ChangeEventArgs e)
|
||||
{
|
||||
_message = "";
|
||||
_message = string.Empty;
|
||||
_fileid = int.Parse((string)e.Value);
|
||||
|
||||
await SetImage();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task SetImage()
|
||||
{
|
||||
_image = "";
|
||||
_image = string.Empty;
|
||||
if (_fileid != -1)
|
||||
{
|
||||
File file = await FileService.GetFileAsync(_fileid);
|
||||
if (file.ImageHeight != 0 && file.ImageWidth != 0)
|
||||
{
|
||||
int maxwidth = 200;
|
||||
int maxheight = 200;
|
||||
var maxwidth = 200;
|
||||
var maxheight = 200;
|
||||
|
||||
double ratioX = (double)maxwidth / (double)file.ImageWidth;
|
||||
double ratioY = (double)maxheight / (double)file.ImageHeight;
|
||||
double ratio = ratioX < ratioY ? ratioX : ratioY;
|
||||
var ratioX = (double)maxwidth / (double)file.ImageWidth;
|
||||
var ratioY = (double)maxheight / (double)file.ImageHeight;
|
||||
var ratio = ratioX < ratioY ? ratioX : ratioY;
|
||||
|
||||
_image = "<img src=\"" + ContentUrl(_fileid) + "\" alt=\"" + file.Name +
|
||||
"\" width=\"" + Convert.ToInt32(file.ImageWidth * ratio).ToString() +
|
||||
"\" height=\"" + Convert.ToInt32(file.ImageHeight * ratio).ToString() + "\" />";
|
||||
_image = "<img src=\string.Empty + ContentUrl(_fileid) + "\" alt=\string.Empty + file.Name +
|
||||
"\" width=\string.Empty + Convert.ToInt32(file.ImageWidth * ratio).ToString() +
|
||||
"\" height=\string.Empty + Convert.ToInt32(file.ImageHeight * ratio).ToString() + "\" />";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -254,7 +255,7 @@
|
||||
private async Task UploadFile()
|
||||
{
|
||||
var interop = new Interop(JsRuntime);
|
||||
string[] upload = await interop.GetFiles(_fileinputid);
|
||||
var upload = await interop.GetFiles(_fileinputid);
|
||||
if (upload.Length > 0)
|
||||
{
|
||||
try
|
||||
@ -268,14 +269,16 @@
|
||||
{
|
||||
result = await FileService.UploadFilesAsync(_folderid, upload, _id);
|
||||
}
|
||||
if (result == "")
|
||||
|
||||
if (result == string.Empty)
|
||||
{
|
||||
await logger.LogInformation("File Upload Succeeded {Files}", upload);
|
||||
_message = "<br /><div class=\"alert alert-success\" role=\"alert\">File Upload Succeeded</div>";
|
||||
await GetFiles();
|
||||
|
||||
if (upload.Length == 1)
|
||||
{
|
||||
File file = _files.Where(item => item.Name == upload[0]).FirstOrDefault();
|
||||
var file = _files.Where(item => item.Name == upload[0]).FirstOrDefault();
|
||||
if (file != null)
|
||||
{
|
||||
_fileid = file.FileId;
|
||||
@ -304,7 +307,8 @@
|
||||
|
||||
private async Task DeleteFile()
|
||||
{
|
||||
_message = "";
|
||||
_message = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
await FileService.DeleteFileAsync(_fileid);
|
||||
@ -322,9 +326,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
public int GetFileId()
|
||||
{
|
||||
return _fileid;
|
||||
}
|
||||
public int GetFileId() => _fileid;
|
||||
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ else
|
||||
}
|
||||
|
||||
@code {
|
||||
string _openLabel = "";
|
||||
string _closeLabel = "</label>";
|
||||
private string _openLabel = string.Empty;
|
||||
private string _closeLabel = "</label>";
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; } // required - the title of the label
|
||||
@ -31,12 +31,14 @@ else
|
||||
_openLabel = "<label";
|
||||
if (!string.IsNullOrEmpty(For))
|
||||
{
|
||||
_openLabel += " for=\"" + For + "\"";
|
||||
_openLabel += " for=\string.Empty + For + "\string.Empty;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Class))
|
||||
{
|
||||
_openLabel += " class=\"" + Class + "\"";
|
||||
_openLabel += " class=\string.Empty + Class + "\string.Empty;
|
||||
}
|
||||
|
||||
_openLabel += ">";
|
||||
}
|
||||
}
|
@ -8,15 +8,15 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private string _message = string.Empty;
|
||||
private string _classname = "alert alert-danger";
|
||||
|
||||
[Parameter]
|
||||
public string Message { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public MessageType Type { get; set; }
|
||||
|
||||
string _message = "";
|
||||
string _classname = "alert alert-danger";
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Message))
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
private string GetMessageType(MessageType type)
|
||||
{
|
||||
string classname = "";
|
||||
var classname = string.Empty;
|
||||
switch (type)
|
||||
{
|
||||
case MessageType.Success:
|
||||
@ -51,6 +51,7 @@
|
||||
classname = "alert alert-danger";
|
||||
break;
|
||||
}
|
||||
|
||||
return classname;
|
||||
}
|
||||
}
|
||||
|
@ -64,12 +64,12 @@
|
||||
</p>
|
||||
|
||||
@code {
|
||||
int _pages = 0;
|
||||
int _page = 1;
|
||||
int _maxItems;
|
||||
int _maxPages;
|
||||
int _startPage;
|
||||
int _endPage;
|
||||
private int _pages = 0;
|
||||
private int _page = 1;
|
||||
private int _maxItems;
|
||||
private int _maxPages;
|
||||
private int _startPage;
|
||||
private int _endPage;
|
||||
|
||||
[Parameter]
|
||||
public string Format { get; set; }
|
||||
@ -95,7 +95,7 @@
|
||||
[Parameter]
|
||||
public string Class { get; set; }
|
||||
|
||||
IEnumerable<TableItem> ItemList { get; set; }
|
||||
private IEnumerable<TableItem> ItemList { get; set; }
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
@ -103,6 +103,7 @@
|
||||
{
|
||||
Format = "Table";
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(Class))
|
||||
{
|
||||
if (Format == "Table")
|
||||
@ -114,6 +115,7 @@
|
||||
Class = "container";
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(PageSize))
|
||||
{
|
||||
_maxItems = 10;
|
||||
@ -122,6 +124,7 @@
|
||||
{
|
||||
_maxItems = int.Parse(PageSize);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(DisplayPages))
|
||||
{
|
||||
_maxPages = 5;
|
||||
@ -144,6 +147,7 @@
|
||||
{
|
||||
ItemList = Items.Skip((currentPage - 1) * _maxItems).Take(_maxItems);
|
||||
_page = currentPage;
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
@ -168,6 +172,7 @@
|
||||
{
|
||||
_endPage = _pages;
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
else if (direction == "back")
|
||||
@ -201,6 +206,7 @@
|
||||
_page -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateList(_page);
|
||||
}
|
||||
}
|
@ -74,6 +74,13 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private string _permissionnames = string.Empty;
|
||||
private List<Role> _roles;
|
||||
private List<PermissionString> _permissions;
|
||||
private List<User> _users = new List<User>();
|
||||
private string _username = string.Empty;
|
||||
private string _message = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public string EntityName { get; set; }
|
||||
|
||||
@ -83,13 +90,6 @@
|
||||
[Parameter]
|
||||
public string Permissions { get; set; }
|
||||
|
||||
string _permissionnames = "";
|
||||
List<Role> _roles;
|
||||
List<PermissionString> _permissions;
|
||||
List<User> _users = new List<User>();
|
||||
string _username = "";
|
||||
string _message = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (string.IsNullOrEmpty(PermissionNames))
|
||||
@ -105,6 +105,7 @@
|
||||
_roles.Insert(0, new Role { Name = Constants.AllUsersRole });
|
||||
|
||||
_permissions = new List<PermissionString>();
|
||||
|
||||
foreach (string permissionname in _permissionnames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
// initialize with admin role
|
||||
@ -120,13 +121,14 @@
|
||||
{
|
||||
_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))
|
||||
{
|
||||
if (user.Contains("]"))
|
||||
{
|
||||
int userid = int.Parse(user.Substring(0, user.IndexOf("]")));
|
||||
var userid = int.Parse(user.Substring(0, user.IndexOf("]")));
|
||||
if (_users.Where(item => item.UserId == userid).FirstOrDefault() == null)
|
||||
{
|
||||
_users.Add(await UserService.GetUserAsync(userid, ModuleState.SiteId));
|
||||
@ -158,16 +160,9 @@
|
||||
}
|
||||
|
||||
private bool GetPermissionDisabled(string roleName)
|
||||
{
|
||||
if (roleName == Constants.AdminRole)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
=> roleName == Constants.AdminRole
|
||||
? true
|
||||
: false;
|
||||
|
||||
private async Task AddUser()
|
||||
{
|
||||
@ -175,7 +170,7 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
User user = await UserService.GetUserAsync(_username, ModuleState.SiteId);
|
||||
var user = await UserService.GetUserAsync(_username, ModuleState.SiteId);
|
||||
if (user != null)
|
||||
{
|
||||
_users.Add(user);
|
||||
@ -186,16 +181,17 @@
|
||||
_message = "Username Does Not Exist";
|
||||
}
|
||||
}
|
||||
_username = "";
|
||||
|
||||
_username = string.Empty;
|
||||
}
|
||||
|
||||
private void PermissionChanged(bool? value, string permissionName, string securityId)
|
||||
{
|
||||
bool? selected = value;
|
||||
PermissionString permission = _permissions.Find(item => item.PermissionName == permissionName);
|
||||
var selected = value;
|
||||
var permission = _permissions.Find(item => item.PermissionName == permissionName);
|
||||
if (permission != null)
|
||||
{
|
||||
List<string> ids = permission.Permissions.Split(';').ToList();
|
||||
var ids = permission.Permissions.Split(';').ToList();
|
||||
|
||||
ids.Remove(securityId); // remove grant permission
|
||||
ids.Remove("!" + securityId); // remove deny permission
|
||||
@ -211,6 +207,7 @@
|
||||
case null:
|
||||
break; // permission not specified
|
||||
}
|
||||
|
||||
_permissions[_permissions.FindIndex(item => item.PermissionName == permissionName)].Permissions = string.Join(";", ids.ToArray());
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,12 @@
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private ElementReference _editorElement;
|
||||
private ElementReference _toolBar;
|
||||
private bool _filemanagervisible = false;
|
||||
private FileManager _fileManager;
|
||||
private string _message = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public RenderFragment ToolbarContent { get; set; }
|
||||
|
||||
@ -42,12 +48,6 @@
|
||||
[Parameter]
|
||||
public string DebugLevel { get; set; } = "info";
|
||||
|
||||
private ElementReference _editorElement;
|
||||
private ElementReference _toolBar;
|
||||
bool _filemanagervisible = false;
|
||||
FileManager _fileManager;
|
||||
string _message = "";
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
@ -102,14 +102,14 @@
|
||||
{
|
||||
if (_filemanagervisible)
|
||||
{
|
||||
int fileid = _fileManager.GetFileId();
|
||||
var fileid = _fileManager.GetFileId();
|
||||
if (fileid != -1)
|
||||
{
|
||||
await RichTextEditorInterop.InsertImage(
|
||||
JsRuntime,
|
||||
_editorElement, ContentUrl(fileid));
|
||||
_filemanagervisible = false;
|
||||
_message = "";
|
||||
_message = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -119,15 +119,17 @@
|
||||
else
|
||||
{
|
||||
_filemanagervisible = true;
|
||||
_message = "";
|
||||
_message = string.Empty;
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
public void CloseFileManager()
|
||||
{
|
||||
_filemanagervisible = false;
|
||||
_message = "";
|
||||
_message = string.Empty;
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
|
@ -16,12 +16,13 @@
|
||||
</CascadingValue>
|
||||
|
||||
@code {
|
||||
private List<TabPanel> _tabPanels = new List<TabPanel>();
|
||||
|
||||
// Next line is needed so we are able to add <TabPanel> components inside
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; }
|
||||
|
||||
public TabPanel ActiveTabPanel { get; set; }
|
||||
List<TabPanel> _tabPanels = new List<TabPanel>();
|
||||
|
||||
internal void AddTabPanel(TabPanel tabPanel)
|
||||
{
|
||||
@ -31,12 +32,12 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
string GetButtonClass(TabPanel tabPanel)
|
||||
{
|
||||
return tabPanel == ActiveTabPanel ? "btn-primary" : "btn-secondary";
|
||||
}
|
||||
private string GetButtonClass(TabPanel tabPanel)
|
||||
=> tabPanel == ActiveTabPanel
|
||||
? "btn-primary"
|
||||
: "btn-secondary";
|
||||
|
||||
void ActivateTabPanel(TabPanel tabPanel)
|
||||
private void ActivateTabPanel(TabPanel tabPanel)
|
||||
{
|
||||
ActiveTabPanel = tabPanel;
|
||||
}
|
||||
|
@ -3,6 +3,10 @@
|
||||
<img src="@_src" title="@_title" @onclick="SetValue" />
|
||||
|
||||
@code {
|
||||
private bool? _value = null;
|
||||
private string _title;
|
||||
private string _src = string.Empty;
|
||||
|
||||
[Parameter]
|
||||
public bool? Value { get; set; }
|
||||
|
||||
@ -12,10 +16,6 @@
|
||||
[Parameter]
|
||||
public Action<bool?> OnChange { get; set; }
|
||||
|
||||
bool? _value = null;
|
||||
string _title;
|
||||
string _src = "";
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_value = Value;
|
||||
@ -38,6 +38,7 @@
|
||||
_value = true;
|
||||
break;
|
||||
}
|
||||
|
||||
SetImage();
|
||||
OnChange(_value);
|
||||
}
|
||||
@ -57,9 +58,10 @@
|
||||
break;
|
||||
case null:
|
||||
_src = "images/null.png";
|
||||
_title = "";
|
||||
_title = string.Empty;
|
||||
break;
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user