allow users to modify default module names, descriptions, and categories and improve control panel behavior
This commit is contained in:
@ -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.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Oqtane.Extensions;
|
||||
using Oqtane.Models;
|
||||
@ -37,6 +38,8 @@ namespace Oqtane.Repository
|
||||
|
||||
public void UpdateModuleDefinition(ModuleDefinition moduleDefinition)
|
||||
{
|
||||
_db.Entry(moduleDefinition).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
_permissions.UpdatePermissions(moduleDefinition.SiteId, EntityNames.ModuleDefinition, moduleDefinition.ModuleDefinitionId, moduleDefinition.Permissions);
|
||||
_cache.Remove("moduledefinitions:" + moduleDefinition.SiteId.ToString());
|
||||
}
|
||||
@ -90,6 +93,18 @@ namespace Oqtane.Repository
|
||||
else
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
_permissions.UpdatePermissions(siteId, EntityNames.ModuleDefinition, moduledef.ModuleDefinitionId, moduledefinition.Permissions);
|
||||
@ -166,7 +181,7 @@ namespace Oqtane.Repository
|
||||
moduledefinition = new ModuleDefinition
|
||||
{
|
||||
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" : ""),
|
||||
Version = new Version(1, 0, 0).ToString()
|
||||
};
|
||||
@ -175,6 +190,10 @@ namespace Oqtane.Repository
|
||||
moduledefinition.ModuleDefinitionName = qualifiedModuleType;
|
||||
moduledefinition.ControlTypeTemplate = moduleType + "." + Constants.ActionToken + ", " + typename[1];
|
||||
moduledefinition.AssemblyName = assembly.FullName.Split(",")[0];
|
||||
if (string.IsNullOrEmpty(moduledefinition.Categories))
|
||||
{
|
||||
moduledefinition.Categories = "Common";
|
||||
}
|
||||
if (moduledefinition.Categories == "Admin")
|
||||
{
|
||||
moduledefinition.Permissions = new List<Permission>
|
||||
|
@ -40,6 +40,9 @@ GO
|
||||
CREATE TABLE [dbo].[ModuleDefinition](
|
||||
[ModuleDefinitionId] [int] IDENTITY(1,1) NOT NULL,
|
||||
[ModuleDefinitionName] [nvarchar](200) NOT NULL,
|
||||
[Name] [nvarchar](200) NULL,
|
||||
[Description] [nvarchar](2000) NULL,
|
||||
[Categories] [nvarchar](200) NULL,
|
||||
[CreatedBy] [nvarchar](256) NOT NULL,
|
||||
[CreatedOn] [datetime] NOT NULL,
|
||||
[ModifiedBy] [nvarchar](256) NOT NULL,
|
||||
|
Reference in New Issue
Block a user