Assorted enhancements
This commit is contained in:
		@ -350,7 +350,7 @@ else
 | 
			
		||||
            var localizationCookieValue = CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture));
 | 
			
		||||
            await interop.SetCookie(CookieRequestCultureProvider.DefaultCookieName, localizationCookieValue, 360);
 | 
			
		||||
 | 
			
		||||
            NavigationManager.NavigateTo(NavigationManager.Uri, forceLoad: true);
 | 
			
		||||
            NavigationManager.NavigateTo(NavigationManager.Uri, true);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -152,13 +152,11 @@
 | 
			
		||||
                <div class="container">
 | 
			
		||||
                    <div class="row mb-1 align-items-center">
 | 
			
		||||
                        <PermissionGrid EntityName="@EntityNames.Page" Permissions="@_permissions" @ref="_permissionGrid" />
 | 
			
		||||
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        </TabPanel>
 | 
			
		||||
        <TabPanel Name="PageModules" ResourceKey="PageModules" Heading=@Localizer["PageModules.Heading"]>
 | 
			
		||||
        <TabPanel Name="PageModules" Heading="Modules" ResourceKey="PageModules">
 | 
			
		||||
            @if(_pageModules != null)
 | 
			
		||||
            {
 | 
			
		||||
                <Pager Items="_pageModules">
 | 
			
		||||
@ -169,10 +167,10 @@
 | 
			
		||||
                        <th>@Localizer["ModuleDefinition"]</th>
 | 
			
		||||
                    </Header>
 | 
			
		||||
                    <Row>
 | 
			
		||||
                        <td><button type="button" class="btn btn-info" @onclick="() => LoadModuleSettings(context)">@SharedLocalizer["Settings"]</button></td>
 | 
			
		||||
                        <td><button type="button" class="btn btn-danger" @onclick="@(async() => await DeleteModule(context))">@SharedLocalizer["Delete"]</button></td>
 | 
			
		||||
                        <td><ActionLink Action="Settings" Text="Edit" ModuleId="@context.ModuleId" Security="SecurityAccessLevel.Edit" Permissions="@context.Permissions" ResourceKey="ModuleSettings" /></td>
 | 
			
		||||
                        <td><ActionDialog Header="Delete Module" Message="Are You Sure You Wish To Delete This Module?" Action="Delete" Security="SecurityAccessLevel.Edit" Permissions="@context.Permissions" Class="btn btn-danger" OnClick="@(async () => await DeleteModule(context))" ResourceKey="DeleteModule" /></td>
 | 
			
		||||
                        <td>@context.Title</td>
 | 
			
		||||
                        <td>@(context.ModuleDefinition.Name.Length > 0 ? context.ModuleDefinition.Name : context.ModuleDefinitionName)</td>
 | 
			
		||||
                        <td>@context.ModuleDefinition.Name</td>
 | 
			
		||||
                    </Row>
 | 
			
		||||
                </Pager>
 | 
			
		||||
            }
 | 
			
		||||
@ -190,135 +188,131 @@
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
@code {
 | 
			
		||||
    public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
 | 
			
		||||
	public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin;
 | 
			
		||||
 | 
			
		||||
    private ElementReference form;
 | 
			
		||||
    private bool validated = false;
 | 
			
		||||
    private List<Theme> _themeList;
 | 
			
		||||
    private List<ThemeControl> _themes = new List<ThemeControl>();
 | 
			
		||||
    private List<ThemeControl> _containers = new List<ThemeControl>();
 | 
			
		||||
    private List<Page> _pageList;
 | 
			
		||||
    private List<Module> _pageModules;
 | 
			
		||||
    private int _pageId;
 | 
			
		||||
    private string _name;
 | 
			
		||||
    private string _title;
 | 
			
		||||
    private string _path;
 | 
			
		||||
    private string _currentparentid;
 | 
			
		||||
    private string _parentid = "-1";
 | 
			
		||||
    private string _insert = "=";
 | 
			
		||||
    private List<Page> _children;
 | 
			
		||||
    private int _childid = -1;
 | 
			
		||||
    private string _isnavigation;
 | 
			
		||||
    private string _isclickable;
 | 
			
		||||
    private string _url;
 | 
			
		||||
    private string _ispersonalizable;
 | 
			
		||||
    private string _themetype;
 | 
			
		||||
    private string _containertype = "-";
 | 
			
		||||
    private string _icon;
 | 
			
		||||
    private string _permissions = null;
 | 
			
		||||
    private string _createdby;
 | 
			
		||||
    private DateTime _createdon;
 | 
			
		||||
    private string _modifiedby;
 | 
			
		||||
    private DateTime _modifiedon;
 | 
			
		||||
    private string _deletedby;
 | 
			
		||||
    private DateTime? _deletedon;
 | 
			
		||||
    private PermissionGrid _permissionGrid;
 | 
			
		||||
    private Type _themeSettingsType;
 | 
			
		||||
    private object _themeSettings;
 | 
			
		||||
    private RenderFragment ThemeSettingsComponent { get; set; }
 | 
			
		||||
    private bool _refresh = false;
 | 
			
		||||
    protected Page page;
 | 
			
		||||
	private ElementReference form;
 | 
			
		||||
	private bool validated = false;
 | 
			
		||||
	private List<Theme> _themeList;
 | 
			
		||||
	private List<ThemeControl> _themes = new List<ThemeControl>();
 | 
			
		||||
	private List<ThemeControl> _containers = new List<ThemeControl>();
 | 
			
		||||
	private List<Page> _pageList;
 | 
			
		||||
	private List<Module> _pageModules;
 | 
			
		||||
	private int _pageId;
 | 
			
		||||
	private string _name;
 | 
			
		||||
	private string _title;
 | 
			
		||||
	private string _path;
 | 
			
		||||
	private string _currentparentid;
 | 
			
		||||
	private string _parentid = "-1";
 | 
			
		||||
	private string _insert = "=";
 | 
			
		||||
	private List<Page> _children;
 | 
			
		||||
	private int _childid = -1;
 | 
			
		||||
	private string _isnavigation;
 | 
			
		||||
	private string _isclickable;
 | 
			
		||||
	private string _url;
 | 
			
		||||
	private string _ispersonalizable;
 | 
			
		||||
	private string _themetype;
 | 
			
		||||
	private string _containertype = "-";
 | 
			
		||||
	private string _icon;
 | 
			
		||||
	private string _permissions = null;
 | 
			
		||||
	private string _createdby;
 | 
			
		||||
	private DateTime _createdon;
 | 
			
		||||
	private string _modifiedby;
 | 
			
		||||
	private DateTime _modifiedon;
 | 
			
		||||
	private string _deletedby;
 | 
			
		||||
	private DateTime? _deletedon;
 | 
			
		||||
	private PermissionGrid _permissionGrid;
 | 
			
		||||
	private Type _themeSettingsType;
 | 
			
		||||
	private object _themeSettings;
 | 
			
		||||
	private RenderFragment ThemeSettingsComponent { get; set; }
 | 
			
		||||
	private bool _refresh = false;
 | 
			
		||||
	protected Page page;
 | 
			
		||||
 | 
			
		||||
    protected override async Task OnInitializedAsync()
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            _pageList = PageState.Pages;
 | 
			
		||||
            _children = PageState.Pages.Where(item => item.ParentId == null).ToList();
 | 
			
		||||
            _themeList = await ThemeService.GetThemesAsync();
 | 
			
		||||
            _themes = ThemeService.GetThemeControls(_themeList);
 | 
			
		||||
	protected override async Task OnInitializedAsync()
 | 
			
		||||
	{
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			_pageList = PageState.Pages;
 | 
			
		||||
			_children = PageState.Pages.Where(item => item.ParentId == null).ToList();
 | 
			
		||||
			_themeList = await ThemeService.GetThemesAsync();
 | 
			
		||||
			_themes = ThemeService.GetThemeControls(_themeList);
 | 
			
		||||
 | 
			
		||||
            _pageId = Int32.Parse(PageState.QueryString["id"]);
 | 
			
		||||
            page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
 | 
			
		||||
			_pageId = Int32.Parse(PageState.QueryString["id"]);
 | 
			
		||||
			page = PageState.Pages.FirstOrDefault(item => item.PageId == _pageId);
 | 
			
		||||
 | 
			
		||||
            if (page != null)
 | 
			
		||||
            {
 | 
			
		||||
                _name = page.Name;
 | 
			
		||||
                _title = page.Title;
 | 
			
		||||
                _path = page.Path;
 | 
			
		||||
                _pageModules = PageState.Modules.Where(m => m.PageId == page.PageId && m.IsDeleted == false).ToList();
 | 
			
		||||
			if (page != null)
 | 
			
		||||
			{
 | 
			
		||||
				_name = page.Name;
 | 
			
		||||
				_title = page.Title;
 | 
			
		||||
				_path = page.Path;
 | 
			
		||||
				_pageModules = PageState.Modules.Where(m => m.PageId == page.PageId && m.IsDeleted == false).ToList();
 | 
			
		||||
 | 
			
		||||
                if (string.IsNullOrEmpty(_path))
 | 
			
		||||
                {
 | 
			
		||||
                    _path = "/";
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    if (_path.Contains("/"))
 | 
			
		||||
                    {
 | 
			
		||||
                        _path = _path.Substring(_path.LastIndexOf("/") + 1);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
				if (string.IsNullOrEmpty(_path))
 | 
			
		||||
				{
 | 
			
		||||
					_path = "/";
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					if (_path.Contains("/"))
 | 
			
		||||
					{
 | 
			
		||||
						_path = _path.Substring(_path.LastIndexOf("/") + 1);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
                if (page.ParentId == null)
 | 
			
		||||
                {
 | 
			
		||||
                    _parentid = "-1";
 | 
			
		||||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    _parentid = page.ParentId.ToString();
 | 
			
		||||
                }
 | 
			
		||||
				if (page.ParentId == null)
 | 
			
		||||
				{
 | 
			
		||||
					_parentid = "-1";
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					_parentid = page.ParentId.ToString();
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
                _currentparentid = _parentid;
 | 
			
		||||
                _isnavigation = page.IsNavigation.ToString();
 | 
			
		||||
                _isclickable = page.IsClickable.ToString();
 | 
			
		||||
                _url = page.Url;
 | 
			
		||||
                _ispersonalizable = page.IsPersonalizable.ToString();
 | 
			
		||||
                _themetype = page.ThemeType;
 | 
			
		||||
                if (string.IsNullOrEmpty(_themetype))
 | 
			
		||||
                {
 | 
			
		||||
                    _themetype = PageState.Site.DefaultThemeType;
 | 
			
		||||
                }
 | 
			
		||||
                _containers = ThemeService.GetContainerControls(_themeList, _themetype);
 | 
			
		||||
                _containertype = page.DefaultContainerType;
 | 
			
		||||
                if (string.IsNullOrEmpty(_containertype))
 | 
			
		||||
                {
 | 
			
		||||
                    _containertype = PageState.Site.DefaultContainerType;
 | 
			
		||||
                }
 | 
			
		||||
                _icon = page.Icon;
 | 
			
		||||
                _permissions = page.Permissions;
 | 
			
		||||
                _createdby = page.CreatedBy;
 | 
			
		||||
                _createdon = page.CreatedOn;
 | 
			
		||||
                _modifiedby = page.ModifiedBy;
 | 
			
		||||
                _modifiedon = page.ModifiedOn;
 | 
			
		||||
                _deletedby = page.DeletedBy;
 | 
			
		||||
                _deletedon = page.DeletedOn;
 | 
			
		||||
				_currentparentid = _parentid;
 | 
			
		||||
				_isnavigation = page.IsNavigation.ToString();
 | 
			
		||||
				_isclickable = page.IsClickable.ToString();
 | 
			
		||||
				_url = page.Url;
 | 
			
		||||
				_ispersonalizable = page.IsPersonalizable.ToString();
 | 
			
		||||
				_themetype = page.ThemeType;
 | 
			
		||||
				if (string.IsNullOrEmpty(_themetype))
 | 
			
		||||
				{
 | 
			
		||||
					_themetype = PageState.Site.DefaultThemeType;
 | 
			
		||||
				}
 | 
			
		||||
				_containers = ThemeService.GetContainerControls(_themeList, _themetype);
 | 
			
		||||
				_containertype = page.DefaultContainerType;
 | 
			
		||||
				if (string.IsNullOrEmpty(_containertype))
 | 
			
		||||
				{
 | 
			
		||||
					_containertype = PageState.Site.DefaultContainerType;
 | 
			
		||||
				}
 | 
			
		||||
				_icon = page.Icon;
 | 
			
		||||
				_permissions = page.Permissions;
 | 
			
		||||
				_createdby = page.CreatedBy;
 | 
			
		||||
				_createdon = page.CreatedOn;
 | 
			
		||||
				_modifiedby = page.ModifiedBy;
 | 
			
		||||
				_modifiedon = page.ModifiedOn;
 | 
			
		||||
				_deletedby = page.DeletedBy;
 | 
			
		||||
				_deletedon = page.DeletedOn;
 | 
			
		||||
 | 
			
		||||
                ThemeSettings();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
            await logger.LogError(ex, "Error Loading Page {PageId} {Error}", _pageId, ex.Message);
 | 
			
		||||
            AddModuleMessage(Localizer["Error.Page.Load"], MessageType.Error);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
				ThemeSettings();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception ex)
 | 
			
		||||
		{
 | 
			
		||||
			await logger.LogError(ex, "Error Loading Page {PageId} {Error}", _pageId, ex.Message);
 | 
			
		||||
			AddModuleMessage(Localizer["Error.Page.Load"], MessageType.Error);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    protected void LoadModuleSettings(Module module)
 | 
			
		||||
    {
 | 
			
		||||
        NavigationManager.NavigateTo(EditUrl(module.ModuleId, "Settings"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private async Task DeleteModule(Module module)
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            PageModule pagemodule = await PageModuleService.GetPageModuleAsync(page.PageId,module.ModuleId);
 | 
			
		||||
            pagemodule.IsDeleted = true;
 | 
			
		||||
 | 
			
		||||
            await PageModuleService.UpdatePageModuleAsync(pagemodule);
 | 
			
		||||
            await logger.LogInformation(LogFunction.Update,"Module Deleted {Title}", module.Title);
 | 
			
		||||
            NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path, true));
 | 
			
		||||
	private async Task DeleteModule(Module module)
 | 
			
		||||
	{
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			PageModule pagemodule = await PageModuleService.GetPageModuleAsync(page.PageId, module.ModuleId);
 | 
			
		||||
			pagemodule.IsDeleted = true;
 | 
			
		||||
			await PageModuleService.UpdatePageModuleAsync(pagemodule);
 | 
			
		||||
			await logger.LogInformation(LogFunction.Update,"Module Deleted {Title}", module.Title);
 | 
			
		||||
			_pageModules.RemoveAll(item => item.PageModuleId == pagemodule.PageModuleId);
 | 
			
		||||
			StateHasChanged();
 | 
			
		||||
			NavigationManager.NavigateTo(NavigationManager.Uri + "&tab=PageModules");
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,7 @@
 | 
			
		||||
                    <th>@Localizer["DeletedOn"]</th>
 | 
			
		||||
                </Header>
 | 
			
		||||
                <Row>
 | 
			
		||||
                    <td><button @onclick="@(() => RestorePage(context))" class="btn btn-info" title="Restore">Restore</button></td>
 | 
			
		||||
                    <td><button type="button" @onclick="@(() => RestorePage(context))" class="btn btn-info" title="Restore">Restore</button></td>
 | 
			
		||||
                    <td><ActionDialog Header="Delete Page" Message="@string.Format(Localizer["Confirm.Page.Delete"], context.Name)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeletePage(context))" ResourceKey="DeletePage" /></td>
 | 
			
		||||
                    <td>@context.Name</td>
 | 
			
		||||
                    <td>@context.DeletedBy</td>
 | 
			
		||||
@ -34,9 +34,7 @@
 | 
			
		||||
            </Pager>
 | 
			
		||||
            @if (_pages.Any())
 | 
			
		||||
            {
 | 
			
		||||
                <div style="text-align:right;">
 | 
			
		||||
                    <ActionDialog Header="Delete All Pages" Message="Are You Sure You Wish To Permanently Delete All Pages?" Action="Delete All Pages" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllPages())" ResourceKey="DeleteAllPages" />
 | 
			
		||||
                </div>
 | 
			
		||||
                <br /><ActionDialog Header="Delete All Pages" Message="Are You Sure You Wish To Permanently Delete All Pages?" Action="Delete All Pages" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllPages())" ResourceKey="DeleteAllPages" />
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    </TabPanel>
 | 
			
		||||
@ -58,7 +56,7 @@
 | 
			
		||||
                    <th>@Localizer["DeletedOn"]</th>
 | 
			
		||||
                </Header>
 | 
			
		||||
                <Row>
 | 
			
		||||
                    <td><button @onclick="@(() => RestoreModule(context))" class="btn btn-info" title="Restore">@Localizer["Restore"]</button></td>
 | 
			
		||||
                    <td><button type="button" @onclick="@(() => RestoreModule(context))" class="btn btn-info" title="Restore">@Localizer["Restore"]</button></td>
 | 
			
		||||
                    <td><ActionDialog Header="Delete Module" Message="@string.Format(Localizer["Confirm.Module.Delete"], context.Title)" Action="Delete" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteModule(context))" ResourceKey="DeleteModule" /></td>
 | 
			
		||||
                    <td>@PageState.Pages.Find(item => item.PageId == context.PageId).Name</td>
 | 
			
		||||
                    <td>@context.Title</td>
 | 
			
		||||
@ -68,9 +66,7 @@
 | 
			
		||||
            </Pager>
 | 
			
		||||
            @if (_modules.Any())
 | 
			
		||||
            {
 | 
			
		||||
                <div style="text-align:right;">
 | 
			
		||||
                    <ActionDialog Header="Delete All Modules" Message="Are You Sure You Wish To Permanently Delete All Modules?" Action="Delete All Modules" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllModules())" ResourceKey="DeleteAllModules" />
 | 
			
		||||
                </div>
 | 
			
		||||
                <br /><ActionDialog Header="Delete All Modules" Message="Are You Sure You Wish To Permanently Delete All Modules?" Action="Delete All Modules" Security="SecurityAccessLevel.Admin" Class="btn btn-danger" OnClick="@(async () => await DeleteAllModules())" ResourceKey="DeleteAllModules" />
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -23,7 +23,7 @@ else
 | 
			
		||||
                <input class="form-control" @bind="@_search" />
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="col-sm-4">
 | 
			
		||||
                <button class="btn btn-secondary" @onclick="OnSearch">@SharedLocalizer["Search"]</button>
 | 
			
		||||
                <button type="button" class="btn btn-secondary" @onclick="OnSearch">@SharedLocalizer["Search"]</button>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
@ -17,7 +17,7 @@
 | 
			
		||||
                    <div class="modal-footer">
 | 
			
		||||
                        @if (!string.IsNullOrEmpty(Action))
 | 
			
		||||
                        {
 | 
			
		||||
                            <button type="button" class="@Class" @onclick="Confirm">@((MarkupString)_iconSpan) @Localize(Action)</button>
 | 
			
		||||
                            <button type="button" class="@Class" @onclick="Confirm">@((MarkupString)_iconSpan) @Text</button>
 | 
			
		||||
                        }
 | 
			
		||||
                        <button type="button" class="btn btn-secondary" @onclick="DisplayModal">@Localize("Cancel")</button>
 | 
			
		||||
                    </div>
 | 
			
		||||
@ -30,16 +30,17 @@
 | 
			
		||||
{
 | 
			
		||||
    if (Disabled)
 | 
			
		||||
    {
 | 
			
		||||
        <button class="@Class" disabled>@((MarkupString)_iconSpan) @Text</button>
 | 
			
		||||
        <button type="button" class="@Class" disabled>@((MarkupString)_iconSpan) @Text</button>
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        <button class="@Class" @onclick="DisplayModal">@((MarkupString)_iconSpan) @Text</button>
 | 
			
		||||
        <button type="button" class="@Class" @onclick="DisplayModal">@((MarkupString)_iconSpan) @Text</button>
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@code {
 | 
			
		||||
    private bool _visible = false;
 | 
			
		||||
	private string _permissions = string.Empty;
 | 
			
		||||
    private bool _editmode = false;
 | 
			
		||||
    private bool _authorized = false;
 | 
			
		||||
    private string _iconSpan = string.Empty;
 | 
			
		||||
@ -59,6 +60,9 @@
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public SecurityAccessLevel? Security { get; set; } // optional - can be used to explicitly specify SecurityAccessLevel
 | 
			
		||||
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public string Permissions { get; set; } // optional - can be used to specify a permission string
 | 
			
		||||
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public string Class { get; set; } // optional
 | 
			
		||||
 | 
			
		||||
@ -105,6 +109,7 @@
 | 
			
		||||
        Header = Localize(nameof(Header), Header);
 | 
			
		||||
        Message = Localize(nameof(Message), Message);
 | 
			
		||||
 | 
			
		||||
		_permissions = (string.IsNullOrEmpty(Permissions)) ? ModuleState.Permissions : Permissions;
 | 
			
		||||
        _authorized = IsAuthorized();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -138,10 +143,10 @@
 | 
			
		||||
                    authorized = true;
 | 
			
		||||
                    break;
 | 
			
		||||
                case SecurityAccessLevel.View:
 | 
			
		||||
                    authorized = UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, ModuleState.Permissions);
 | 
			
		||||
                    authorized = UserSecurity.IsAuthorized(PageState.User,PermissionNames.View, _permissions);
 | 
			
		||||
                    break;
 | 
			
		||||
                case SecurityAccessLevel.Edit:
 | 
			
		||||
                    authorized = UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, ModuleState.Permissions);
 | 
			
		||||
                    authorized = UserSecurity.IsAuthorized(PageState.User,PermissionNames.Edit, _permissions);
 | 
			
		||||
                    break;
 | 
			
		||||
                case SecurityAccessLevel.Admin:
 | 
			
		||||
                    authorized = UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin);
 | 
			
		||||
 | 
			
		||||
@ -6,101 +6,118 @@
 | 
			
		||||
{
 | 
			
		||||
    if (Disabled)
 | 
			
		||||
    {
 | 
			
		||||
        <button class="@_classname" style="@_style" disabled>@((MarkupString)_iconSpan) @_text</button>
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        <NavLink class="@_classname" href="@_url" style="@_style">@((MarkupString)_iconSpan) @_text</NavLink>
 | 
			
		||||
    }
 | 
			
		||||
		<button type="button" class="@_classname" style="@_style" disabled>@((MarkupString)_iconSpan) @_text</button>
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		if (OnClick == null)
 | 
			
		||||
		{
 | 
			
		||||
			<NavLink class="@_classname" href="@_url" style="@_style">@((MarkupString)_iconSpan) @_text</NavLink>
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			<button type="button" class="@_classname" style="@_style" onclick="@OnClick">@((MarkupString)_iconSpan) @_text</button>
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@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 = false;
 | 
			
		||||
    private bool _authorized = false;
 | 
			
		||||
    private string _iconSpan = string.Empty;
 | 
			
		||||
	private string _text = string.Empty;
 | 
			
		||||
	private string _parameters = string.Empty;
 | 
			
		||||
	private string _url = string.Empty;
 | 
			
		||||
	private string _permissions = string.Empty;
 | 
			
		||||
	private bool _editmode = false;
 | 
			
		||||
	private bool _authorized = false;
 | 
			
		||||
	private string _classname = "btn btn-primary";
 | 
			
		||||
	private string _style = string.Empty;
 | 
			
		||||
	private string _iconSpan = string.Empty;
 | 
			
		||||
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public string Action { get; set; } // required
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public string Action { get; set; } // required
 | 
			
		||||
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public SecurityAccessLevel? Security { get; set; } // optional - can be used to explicitly specify SecurityAccessLevel
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public string Text { get; set; } // optional - defaults to Action if not specified
 | 
			
		||||
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public string Text { get; set; } // optional - defaults to Action if not specified
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public string Parameters { get; set; } // optional - querystring parameters should be in the form of "id=x&name=y"
 | 
			
		||||
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public string Parameters { get; set; } // optional - querystring parameter should be in the form of "id=x&name=y"
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public int ModuleId { get; set; } = -1; // optional - allows the link to target a specific moduleid
 | 
			
		||||
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public string Class { get; set; } // optional - defaults to primary if not specified
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public Action OnClick { get; set; } = null; // optional - executes a method in the calling component
 | 
			
		||||
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public string Style { get; set; } // optional
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public SecurityAccessLevel? Security { get; set; } // optional - can be used to explicitly specify SecurityAccessLevel
 | 
			
		||||
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public bool Disabled { get; set; } // optional
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public string Permissions { get; set; } // optional - can be used to specify a permission string
 | 
			
		||||
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public string EditMode { get; set; } // optional - specifies if an authorized user must be in edit mode to see the action - default is false.
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public bool Disabled { get; set; } // optional
 | 
			
		||||
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public string EditMode { get; set; } // optional - specifies if an authorized user must be in edit mode to see the action - default is false.
 | 
			
		||||
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public bool IconOnly { get; set; } // optional - specifies only icon in link
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public string Class { get; set; } // optional - defaults to primary if not specified
 | 
			
		||||
 | 
			
		||||
    protected override void OnParametersSet()
 | 
			
		||||
    {
 | 
			
		||||
        base.OnParametersSet();
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public string Style { get; set; } // optional
 | 
			
		||||
 | 
			
		||||
        _text = Action;
 | 
			
		||||
        if (!string.IsNullOrEmpty(Text))
 | 
			
		||||
        {
 | 
			
		||||
            _text = Text;
 | 
			
		||||
        }
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public string IconName { get; set; } // optional - specifies an icon for the link - default is no icon
 | 
			
		||||
 | 
			
		||||
        if (IconOnly && !string.IsNullOrEmpty(IconName))
 | 
			
		||||
        {
 | 
			
		||||
            _text = string.Empty;
 | 
			
		||||
        }
 | 
			
		||||
	[Parameter]
 | 
			
		||||
	public bool IconOnly { get; set; } // optional - specifies only icon in link
 | 
			
		||||
 | 
			
		||||
        if (!string.IsNullOrEmpty(Parameters))
 | 
			
		||||
        {
 | 
			
		||||
            _parameters = Parameters;
 | 
			
		||||
        }
 | 
			
		||||
	protected override void OnParametersSet()
 | 
			
		||||
	{
 | 
			
		||||
		base.OnParametersSet();
 | 
			
		||||
 | 
			
		||||
        if (!string.IsNullOrEmpty(Class))
 | 
			
		||||
        {
 | 
			
		||||
            _classname = Class;
 | 
			
		||||
        }
 | 
			
		||||
		_text = Action;
 | 
			
		||||
		if (!string.IsNullOrEmpty(Text))
 | 
			
		||||
		{
 | 
			
		||||
			_text = Text;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        if (!string.IsNullOrEmpty(Style))
 | 
			
		||||
        {
 | 
			
		||||
            _style = Style;
 | 
			
		||||
        }
 | 
			
		||||
		if (IconOnly && !string.IsNullOrEmpty(IconName))
 | 
			
		||||
		{
 | 
			
		||||
			_text = string.Empty;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        if (!string.IsNullOrEmpty(EditMode))
 | 
			
		||||
        {
 | 
			
		||||
            _editmode = bool.Parse(EditMode);
 | 
			
		||||
        }
 | 
			
		||||
		if (!string.IsNullOrEmpty(Parameters))
 | 
			
		||||
		{
 | 
			
		||||
			_parameters = Parameters;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        if (!string.IsNullOrEmpty(IconName))
 | 
			
		||||
        {
 | 
			
		||||
            if (!IconName.Contains(" "))
 | 
			
		||||
            {
 | 
			
		||||
                IconName = "oi oi-" + IconName;
 | 
			
		||||
            }
 | 
			
		||||
            _iconSpan = $"<span class=\"{IconName}\"></span>{(IconOnly ? "" : " ")}";
 | 
			
		||||
		if (!string.IsNullOrEmpty(Class))
 | 
			
		||||
		{
 | 
			
		||||
			_classname = Class;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
		if (!string.IsNullOrEmpty(Style))
 | 
			
		||||
		{
 | 
			
		||||
			_style = Style;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        _text = Localize(nameof(Text), _text);
 | 
			
		||||
        _url = EditUrl(Action, _parameters);
 | 
			
		||||
		if (!string.IsNullOrEmpty(EditMode))
 | 
			
		||||
		{
 | 
			
		||||
			_editmode = bool.Parse(EditMode);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!string.IsNullOrEmpty(IconName))
 | 
			
		||||
		{
 | 
			
		||||
			if (!IconName.Contains(" "))
 | 
			
		||||
			{
 | 
			
		||||
				IconName = "oi oi-" + IconName;
 | 
			
		||||
			}
 | 
			
		||||
			_iconSpan = $"<span class=\"{IconName}\"></span>{(IconOnly ? "" : " ")}";
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		_permissions = (string.IsNullOrEmpty(Permissions)) ? ModuleState.Permissions : Permissions;
 | 
			
		||||
		_text = Localize(nameof(Text), _text);		
 | 
			
		||||
        _url = (ModuleId == -1) ? EditUrl(Action, _parameters) : EditUrl(ModuleId, Action, _parameters);
 | 
			
		||||
        _authorized = IsAuthorized();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -136,10 +153,10 @@
 | 
			
		||||
                    authorized = true;
 | 
			
		||||
                    break;
 | 
			
		||||
                case SecurityAccessLevel.View:
 | 
			
		||||
                    authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, ModuleState.Permissions);
 | 
			
		||||
                    authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, _permissions);
 | 
			
		||||
                    break;
 | 
			
		||||
                case SecurityAccessLevel.Edit:
 | 
			
		||||
                    authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, ModuleState.Permissions);
 | 
			
		||||
                    authorized = UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, _permissions);
 | 
			
		||||
                    break;
 | 
			
		||||
                case SecurityAccessLevel.Admin:
 | 
			
		||||
                    authorized = UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin);
 | 
			
		||||
 | 
			
		||||
@ -43,16 +43,12 @@
 | 
			
		||||
    [Parameter]
 | 
			
		||||
    public bool Refresh { get; set; } // optional - used in scenarios where TabPanels are added/removed dynamically within a parent form. ActiveTab may need to be reset as well when this property is used.
 | 
			
		||||
 | 
			
		||||
    protected override void OnInitialized()
 | 
			
		||||
    protected override void OnParametersSet()
 | 
			
		||||
    {
 | 
			
		||||
        if (PageState.QueryString.ContainsKey("tab"))
 | 
			
		||||
        {
 | 
			
		||||
            ActiveTab = PageState.QueryString["tab"];
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected override void OnParametersSet()
 | 
			
		||||
    {
 | 
			
		||||
        if (_tabPanels == null || Refresh)
 | 
			
		||||
        {
 | 
			
		||||
            _tabPanels = new List<TabPanel>();
 | 
			
		||||
 | 
			
		||||
@ -136,7 +136,12 @@ namespace Oqtane.Modules
 | 
			
		||||
 | 
			
		||||
        public string ImageUrl(int fileid, int width, int height, string mode)
 | 
			
		||||
        {
 | 
			
		||||
            return Utilities.ImageUrl(PageState.Alias, fileid, width, height, mode);
 | 
			
		||||
            return ImageUrl(fileid, width, height, mode, 0);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public string ImageUrl(int fileid, int width, int height, string mode, int rotate)
 | 
			
		||||
        {
 | 
			
		||||
            return Utilities.ImageUrl(PageState.Alias, fileid, width, height, mode, rotate);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public virtual Dictionary<string, string> GetUrlParameters(string parametersTemplate = "")
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user