allow users to modify default module names, descriptions, and categories and improve control panel behavior
This commit is contained in:
parent
f56d1fe543
commit
62987ca72f
|
@ -16,10 +16,10 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="version" HelpText="The version of the module">Version: </Label>
|
<Label For="description" HelpText="The description of the module">Description: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="version" class="form-control" @bind="@_version" disabled />
|
<textarea id="description" class="form-control" @bind="@_description" rows="2"></textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -43,10 +43,10 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="description" HelpText="The description of the module">Description: </Label>
|
<Label For="version" HelpText="The version of the module">Version: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea id="description" class="form-control" @bind="@_description" rows="2" disabled></textarea>
|
<input id="version" class="form-control" @bind="@_version" disabled />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -158,6 +158,18 @@
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId);
|
var moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId);
|
||||||
|
if (moduledefinition.Name != _name)
|
||||||
|
{
|
||||||
|
moduledefinition.Name = _name;
|
||||||
|
}
|
||||||
|
if (moduledefinition.Description != _description)
|
||||||
|
{
|
||||||
|
moduledefinition.Description = _description;
|
||||||
|
}
|
||||||
|
if (moduledefinition.Categories != _categories)
|
||||||
|
{
|
||||||
|
moduledefinition.Categories = _categories;
|
||||||
|
}
|
||||||
moduledefinition.Permissions = _permissionGrid.GetPermissions();
|
moduledefinition.Permissions = _permissionGrid.GetPermissions();
|
||||||
await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition);
|
await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition);
|
||||||
await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition);
|
await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition);
|
||||||
|
|
|
@ -87,14 +87,27 @@
|
||||||
@if (_moduleDefinitions != null)
|
@if (_moduleDefinitions != null)
|
||||||
{
|
{
|
||||||
<select class="form-control" @onchange="(e => CategoryChanged(e))">
|
<select class="form-control" @onchange="(e => CategoryChanged(e))">
|
||||||
<option value="-"><Common Modules></option>
|
|
||||||
@foreach (var category in _categories)
|
@foreach (var category in _categories)
|
||||||
{
|
{
|
||||||
<option value="@category">@category</option>
|
if (category == _category)
|
||||||
|
{
|
||||||
|
<option value="@category" selected>@category Modules</option>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<option value="@category">@category Modules</option>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
<select class="form-control" @bind="@_moduleDefinitionName">
|
<select class="form-control" @onchange="(e => ModuleChanged(e))">
|
||||||
|
@if (_moduleDefinitionName == "-")
|
||||||
|
{
|
||||||
|
<option value="-" selected><Select Module></option>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
<option value="-"><Select Module></option>
|
<option value="-"><Select Module></option>
|
||||||
|
}
|
||||||
@foreach (var moduledefinition in _moduleDefinitions)
|
@foreach (var moduledefinition in _moduleDefinitions)
|
||||||
{
|
{
|
||||||
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Utilize, moduledefinition.Permissions))
|
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.Utilize, moduledefinition.Permissions))
|
||||||
|
@ -103,6 +116,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
|
@((MarkupString)@_description)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -207,6 +221,8 @@
|
||||||
private List<Module> _modules = new List<Module>();
|
private List<Module> _modules = new List<Module>();
|
||||||
private Dictionary<string, string> _containers = new Dictionary<string, string>();
|
private Dictionary<string, string> _containers = new Dictionary<string, string>();
|
||||||
private string _moduleDefinitionName = "-";
|
private string _moduleDefinitionName = "-";
|
||||||
|
private string _category = "Common";
|
||||||
|
private string _description = "";
|
||||||
private string _pane = "";
|
private string _pane = "";
|
||||||
private string _title = "";
|
private string _title = "";
|
||||||
private string _containerType = "";
|
private string _containerType = "";
|
||||||
|
@ -267,6 +283,7 @@
|
||||||
|
|
||||||
_allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
_allModuleDefinitions = await ModuleDefinitionService.GetModuleDefinitionsAsync(PageState.Site.SiteId);
|
||||||
|
|
||||||
|
_categories = new List<string>();
|
||||||
foreach (ModuleDefinition moduledefinition in _allModuleDefinitions)
|
foreach (ModuleDefinition moduledefinition in _allModuleDefinitions)
|
||||||
{
|
{
|
||||||
if (moduledefinition.Categories != "")
|
if (moduledefinition.Categories != "")
|
||||||
|
@ -281,23 +298,34 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories == "").ToList();
|
_category = "Common";
|
||||||
|
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(_category)).ToList();
|
||||||
|
_moduleDefinitionName = "-";
|
||||||
|
_description = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CategoryChanged(ChangeEventArgs e)
|
private void CategoryChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
var category = (string) e.Value;
|
_category = (string) e.Value;
|
||||||
if (category == "-")
|
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(_category)).ToList();
|
||||||
|
_moduleDefinitionName = "-";
|
||||||
|
_description = "";
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ModuleChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories == "").ToList();
|
_moduleDefinitionName = (string)e.Value;
|
||||||
|
if (_moduleDefinitionName != "-")
|
||||||
|
{
|
||||||
|
var moduleDefinition = _moduleDefinitions.FirstOrDefault(item => item.ModuleDefinitionName == _moduleDefinitionName);
|
||||||
|
_description = "<br /><div class=\"alert alert-info\" role=\"alert\">" + moduleDefinition.Description + "</div>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_moduleDefinitions = _allModuleDefinitions.Where(item => item.Categories.Contains(category)).ToList();
|
_description = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
_moduleDefinitionName = "-";
|
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,6 +399,7 @@
|
||||||
_message = "<br /><div class=\"alert alert-success\" role=\"alert\">Module Added To Page</div>";
|
_message = "<br /><div class=\"alert alert-success\" role=\"alert\">Module Added To Page</div>";
|
||||||
|
|
||||||
_moduleDefinitionName = "-";
|
_moduleDefinitionName = "-";
|
||||||
|
_description = "";
|
||||||
_pane = "";
|
_pane = "";
|
||||||
_title = "";
|
_title = "";
|
||||||
_containerType = "";
|
_containerType = "";
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
using Oqtane.Models;
|
||||||
|
using Oqtane.Infrastructure;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
namespace Oqtane.SiteTemplates
|
||||||
|
{
|
||||||
|
public class EmptySiteTemplate : ISiteTemplate
|
||||||
|
{
|
||||||
|
private readonly IPermissionRepository _permissionRepository;
|
||||||
|
|
||||||
|
public EmptySiteTemplate(IPermissionRepository permissionRepository)
|
||||||
|
{
|
||||||
|
_permissionRepository = permissionRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return "Empty Site Template"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PageTemplate> CreateSite(Site site)
|
||||||
|
{
|
||||||
|
List<PageTemplate> _pageTemplates = new List<PageTemplate>();
|
||||||
|
|
||||||
|
_pageTemplates.Add(new PageTemplate
|
||||||
|
{
|
||||||
|
Name = "Home",
|
||||||
|
Parent = "",
|
||||||
|
Path = "",
|
||||||
|
Icon = "home",
|
||||||
|
IsNavigation = true,
|
||||||
|
IsPersonalizable = false,
|
||||||
|
EditMode = false,
|
||||||
|
PagePermissions = _permissionRepository.EncodePermissions( new List<Permission> {
|
||||||
|
new Permission(PermissionNames.View, Constants.AllUsersRole, true),
|
||||||
|
new Permission(PermissionNames.View, Constants.AdminRole, true),
|
||||||
|
new Permission(PermissionNames.Edit, Constants.AdminRole, true)
|
||||||
|
}),
|
||||||
|
PageTemplateModules = new List<PageTemplateModule>()
|
||||||
|
});
|
||||||
|
|
||||||
|
return _pageTemplates;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Oqtane.Extensions;
|
using Oqtane.Extensions;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
@ -37,6 +38,8 @@ namespace Oqtane.Repository
|
||||||
|
|
||||||
public void UpdateModuleDefinition(ModuleDefinition moduleDefinition)
|
public void UpdateModuleDefinition(ModuleDefinition moduleDefinition)
|
||||||
{
|
{
|
||||||
|
_db.Entry(moduleDefinition).State = EntityState.Modified;
|
||||||
|
_db.SaveChanges();
|
||||||
_permissions.UpdatePermissions(moduleDefinition.SiteId, EntityNames.ModuleDefinition, moduleDefinition.ModuleDefinitionId, moduleDefinition.Permissions);
|
_permissions.UpdatePermissions(moduleDefinition.SiteId, EntityNames.ModuleDefinition, moduleDefinition.ModuleDefinitionId, moduleDefinition.Permissions);
|
||||||
_cache.Remove("moduledefinitions:" + moduleDefinition.SiteId.ToString());
|
_cache.Remove("moduledefinitions:" + moduleDefinition.SiteId.ToString());
|
||||||
}
|
}
|
||||||
|
@ -90,6 +93,18 @@ namespace Oqtane.Repository
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// existing module definition
|
// existing module definition
|
||||||
|
if (!string.IsNullOrEmpty(moduledef.Name))
|
||||||
|
{
|
||||||
|
moduledefinition.Name = moduledef.Name;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(moduledef.Description))
|
||||||
|
{
|
||||||
|
moduledefinition.Description = moduledef.Description;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(moduledef.Categories))
|
||||||
|
{
|
||||||
|
moduledefinition.Categories = moduledef.Categories;
|
||||||
|
}
|
||||||
if (permissions.Count == 0)
|
if (permissions.Count == 0)
|
||||||
{
|
{
|
||||||
_permissions.UpdatePermissions(siteId, EntityNames.ModuleDefinition, moduledef.ModuleDefinitionId, moduledefinition.Permissions);
|
_permissions.UpdatePermissions(siteId, EntityNames.ModuleDefinition, moduledef.ModuleDefinitionId, moduledefinition.Permissions);
|
||||||
|
@ -166,7 +181,7 @@ namespace Oqtane.Repository
|
||||||
moduledefinition = new ModuleDefinition
|
moduledefinition = new ModuleDefinition
|
||||||
{
|
{
|
||||||
Name = moduleType.Substring(moduleType.LastIndexOf(".") + 1),
|
Name = moduleType.Substring(moduleType.LastIndexOf(".") + 1),
|
||||||
Description = moduleType.Substring(moduleType.LastIndexOf(".") + 1),
|
Description = "Manage " + moduleType.Substring(moduleType.LastIndexOf(".") + 1),
|
||||||
Categories = ((qualifiedModuleType.StartsWith("Oqtane.Modules.Admin.")) ? "Admin" : ""),
|
Categories = ((qualifiedModuleType.StartsWith("Oqtane.Modules.Admin.")) ? "Admin" : ""),
|
||||||
Version = new Version(1, 0, 0).ToString()
|
Version = new Version(1, 0, 0).ToString()
|
||||||
};
|
};
|
||||||
|
@ -175,6 +190,10 @@ namespace Oqtane.Repository
|
||||||
moduledefinition.ModuleDefinitionName = qualifiedModuleType;
|
moduledefinition.ModuleDefinitionName = qualifiedModuleType;
|
||||||
moduledefinition.ControlTypeTemplate = moduleType + "." + Constants.ActionToken + ", " + typename[1];
|
moduledefinition.ControlTypeTemplate = moduleType + "." + Constants.ActionToken + ", " + typename[1];
|
||||||
moduledefinition.AssemblyName = assembly.FullName.Split(",")[0];
|
moduledefinition.AssemblyName = assembly.FullName.Split(",")[0];
|
||||||
|
if (string.IsNullOrEmpty(moduledefinition.Categories))
|
||||||
|
{
|
||||||
|
moduledefinition.Categories = "Common";
|
||||||
|
}
|
||||||
if (moduledefinition.Categories == "Admin")
|
if (moduledefinition.Categories == "Admin")
|
||||||
{
|
{
|
||||||
moduledefinition.Permissions = new List<Permission>
|
moduledefinition.Permissions = new List<Permission>
|
||||||
|
|
|
@ -40,6 +40,9 @@ GO
|
||||||
CREATE TABLE [dbo].[ModuleDefinition](
|
CREATE TABLE [dbo].[ModuleDefinition](
|
||||||
[ModuleDefinitionId] [int] IDENTITY(1,1) NOT NULL,
|
[ModuleDefinitionId] [int] IDENTITY(1,1) NOT NULL,
|
||||||
[ModuleDefinitionName] [nvarchar](200) NOT NULL,
|
[ModuleDefinitionName] [nvarchar](200) NOT NULL,
|
||||||
|
[Name] [nvarchar](200) NULL,
|
||||||
|
[Description] [nvarchar](2000) NULL,
|
||||||
|
[Categories] [nvarchar](200) NULL,
|
||||||
[CreatedBy] [nvarchar](256) NOT NULL,
|
[CreatedBy] [nvarchar](256) NOT NULL,
|
||||||
[CreatedOn] [datetime] NOT NULL,
|
[CreatedOn] [datetime] NOT NULL,
|
||||||
[ModifiedBy] [nvarchar](256) NOT NULL,
|
[ModifiedBy] [nvarchar](256) NOT NULL,
|
||||||
|
|
|
@ -24,6 +24,9 @@ namespace Oqtane.Models
|
||||||
|
|
||||||
public int ModuleDefinitionId { get; set; }
|
public int ModuleDefinitionId { get; set; }
|
||||||
public string ModuleDefinitionName { get; set; }
|
public string ModuleDefinitionName { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
public string Categories { get; set; }
|
||||||
|
|
||||||
public string CreatedBy { get; set; }
|
public string CreatedBy { get; set; }
|
||||||
public DateTime CreatedOn { get; set; }
|
public DateTime CreatedOn { get; set; }
|
||||||
|
@ -33,12 +36,6 @@ namespace Oqtane.Models
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int SiteId { get; set; }
|
public int SiteId { get; set; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string Name { get; set; }
|
|
||||||
[NotMapped]
|
|
||||||
public string Description { get; set; }
|
|
||||||
[NotMapped]
|
|
||||||
public string Categories { get; set; }
|
|
||||||
[NotMapped]
|
|
||||||
public string Version { get; set; }
|
public string Version { get; set; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string Owner { get; set; }
|
public string Owner { get; set; }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user