fixing spacing
This commit is contained in:
		| @ -19,25 +19,25 @@ | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink> | ||||
| </form> | ||||
|  | ||||
|     @code { | ||||
|         private ElementReference form; | ||||
|         private bool validated = false; | ||||
|         private string _content = string.Empty; | ||||
|         public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; | ||||
|         public override string Title => "Export Content"; | ||||
| @code { | ||||
|     private ElementReference form; | ||||
|     private bool validated = false; | ||||
|     private string _content = string.Empty; | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; | ||||
|     public override string Title => "Export Content"; | ||||
|  | ||||
|  | ||||
|         private async Task ExportModule() | ||||
|     private async Task ExportModule() | ||||
|     { | ||||
|         validated = true; | ||||
|         var interop = new Interop(JSRuntime); | ||||
|         if (await interop.FormValid(form)) | ||||
|         { | ||||
|             validated = true; | ||||
|             var interop = new Interop(JSRuntime); | ||||
|             if (await interop.FormValid(form)) | ||||
|             { | ||||
|                 _content = await ModuleService.ExportModuleAsync(ModuleState.ModuleId); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); | ||||
|             } | ||||
|             _content = await ModuleService.ExportModuleAsync(ModuleState.ModuleId); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -20,48 +20,48 @@ | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink> | ||||
| </form> | ||||
|  | ||||
|     @code { | ||||
|         private string _content = string.Empty; | ||||
|         private ElementReference form; | ||||
|         private bool validated = false; | ||||
| @code { | ||||
|     private string _content = string.Empty; | ||||
|     private ElementReference form; | ||||
|     private bool validated = false; | ||||
|  | ||||
|         public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; | ||||
|         public override string Title => "Import Content"; | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Admin; | ||||
|     public override string Title => "Import Content"; | ||||
|  | ||||
|         private async Task ImportModule() | ||||
|     private async Task ImportModule() | ||||
|     { | ||||
|         validated = true; | ||||
|         var interop = new Interop(JSRuntime); | ||||
|         if (await interop.FormValid(form)) | ||||
|         { | ||||
|             validated = true; | ||||
|             var interop = new Interop(JSRuntime); | ||||
|             if (await interop.FormValid(form)) | ||||
|             if (_content != string.Empty) | ||||
|             { | ||||
|                 if (_content != string.Empty) | ||||
|                 try | ||||
|                 { | ||||
|                     try | ||||
|                     bool success = await ModuleService.ImportModuleAsync(ModuleState.ModuleId, _content); | ||||
|                     if (success) | ||||
|                     { | ||||
|                         bool success = await ModuleService.ImportModuleAsync(ModuleState.ModuleId, _content); | ||||
|                         if (success) | ||||
|                         { | ||||
|                             AddModuleMessage(Localizer["Success.Content.Import"], MessageType.Success); | ||||
|                         } | ||||
|                         else | ||||
|                         { | ||||
|                             AddModuleMessage(Localizer["Message.Content.ImportProblem"], MessageType.Warning); | ||||
|                         } | ||||
|                         AddModuleMessage(Localizer["Success.Content.Import"], MessageType.Success); | ||||
|                     } | ||||
|                     catch (Exception ex) | ||||
|                     else | ||||
|                     { | ||||
|                         await logger.LogError(ex, "Error Importing Module {ModuleId} {Error}", ModuleState.ModuleId, ex.Message); | ||||
|                         AddModuleMessage(Localizer["Error.Module.Import"], MessageType.Error); | ||||
|                         AddModuleMessage(Localizer["Message.Content.ImportProblem"], MessageType.Warning); | ||||
|                     } | ||||
|                 } | ||||
|                 else | ||||
|                 catch (Exception ex) | ||||
|                 { | ||||
|                     AddModuleMessage(Localizer["Message.Required.ImportContent"], MessageType.Warning); | ||||
|                     await logger.LogError(ex, "Error Importing Module {ModuleId} {Error}", ModuleState.ModuleId, ex.Message); | ||||
|                     AddModuleMessage(Localizer["Error.Module.Import"], MessageType.Error); | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); | ||||
|                 AddModuleMessage(Localizer["Message.Required.ImportContent"], MessageType.Warning); | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -17,7 +17,7 @@ | ||||
|                     <div class="row mb-1 align-items-center"> | ||||
|                         <Label Class="col-sm-3" For="title" HelpText="Enter the title of the module" ResourceKey="Title">Title: </Label> | ||||
|                         <div class="col-sm-9"> | ||||
|                             <input id="title" type="text" name="Title" class="form-control" @bind="@_title" required/> | ||||
|                             <input id="title" type="text" name="Title" class="form-control" @bind="@_title" required /> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                     <div class="row mb-1 align-items-center"> | ||||
| @ -88,148 +88,148 @@ | ||||
|     <AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo> | ||||
| </form> | ||||
|  | ||||
|     @code { | ||||
|         public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit; | ||||
|         public override string Title => "Module Settings"; | ||||
| @code { | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit; | ||||
|     public override string Title => "Module Settings"; | ||||
|  | ||||
|         private ElementReference form; | ||||
|         private bool validated = false; | ||||
|         private List<Theme> _themes; | ||||
|         private List<ThemeControl> _containers = new List<ThemeControl>(); | ||||
|         private string _title; | ||||
|         private string _containerType; | ||||
|         private string _allPages = "false"; | ||||
|         private string _permissionNames = ""; | ||||
|         private string _permissions = null; | ||||
|         private string _pageId; | ||||
|         private PermissionGrid _permissionGrid; | ||||
|         private Type _moduleSettingsType; | ||||
|         private object _moduleSettings; | ||||
|         private string _moduleSettingsTitle = "Module Settings"; | ||||
|         private RenderFragment ModuleSettingsComponent { get; set; } | ||||
|         private Type _containerSettingsType; | ||||
|         private object _containerSettings; | ||||
|         private RenderFragment ContainerSettingsComponent { get; set; } | ||||
|         private string createdby; | ||||
|         private DateTime createdon; | ||||
|         private string modifiedby; | ||||
|         private DateTime modifiedon; | ||||
|     private ElementReference form; | ||||
|     private bool validated = false; | ||||
|     private List<Theme> _themes; | ||||
|     private List<ThemeControl> _containers = new List<ThemeControl>(); | ||||
|     private string _title; | ||||
|     private string _containerType; | ||||
|     private string _allPages = "false"; | ||||
|     private string _permissionNames = ""; | ||||
|     private string _permissions = null; | ||||
|     private string _pageId; | ||||
|     private PermissionGrid _permissionGrid; | ||||
|     private Type _moduleSettingsType; | ||||
|     private object _moduleSettings; | ||||
|     private string _moduleSettingsTitle = "Module Settings"; | ||||
|     private RenderFragment ModuleSettingsComponent { get; set; } | ||||
|     private Type _containerSettingsType; | ||||
|     private object _containerSettings; | ||||
|     private RenderFragment ContainerSettingsComponent { get; set; } | ||||
|     private string createdby; | ||||
|     private DateTime createdon; | ||||
|     private string modifiedby; | ||||
|     private DateTime modifiedon; | ||||
|  | ||||
|         protected override async Task OnInitializedAsync() | ||||
|     protected override async Task OnInitializedAsync() | ||||
|     { | ||||
|         _title = ModuleState.Title; | ||||
|         _themes = await ThemeService.GetThemesAsync(); | ||||
|         _containers = ThemeService.GetContainerControls(_themes, PageState.Page.ThemeType); | ||||
|         _containerType = ModuleState.ContainerType; | ||||
|         _allPages = ModuleState.AllPages.ToString(); | ||||
|         _permissions = ModuleState.Permissions; | ||||
|         _permissionNames = ModuleState.ModuleDefinition.PermissionNames; | ||||
|         _pageId = ModuleState.PageId.ToString(); | ||||
|         createdby = ModuleState.CreatedBy; | ||||
|         createdon = ModuleState.CreatedOn; | ||||
|         modifiedby = ModuleState.ModifiedBy; | ||||
|         modifiedon = ModuleState.ModifiedOn; | ||||
|  | ||||
|         if (!string.IsNullOrEmpty(ModuleState.ModuleDefinition.SettingsType)) | ||||
|         { | ||||
|             _title = ModuleState.Title; | ||||
|             _themes = await ThemeService.GetThemesAsync(); | ||||
|             _containers = ThemeService.GetContainerControls(_themes, PageState.Page.ThemeType); | ||||
|             _containerType = ModuleState.ContainerType; | ||||
|             _allPages = ModuleState.AllPages.ToString(); | ||||
|             _permissions = ModuleState.Permissions; | ||||
|             _permissionNames = ModuleState.ModuleDefinition.PermissionNames; | ||||
|             _pageId = ModuleState.PageId.ToString(); | ||||
|             createdby = ModuleState.CreatedBy; | ||||
|             createdon = ModuleState.CreatedOn; | ||||
|             modifiedby = ModuleState.ModifiedBy; | ||||
|             modifiedon = ModuleState.ModifiedOn; | ||||
|  | ||||
|             if (!string.IsNullOrEmpty(ModuleState.ModuleDefinition.SettingsType)) | ||||
|             // module settings type explicitly declared in IModule interface | ||||
|             _moduleSettingsType = Type.GetType(ModuleState.ModuleDefinition.SettingsType); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             // legacy support - module settings type determined by convention ( ie. existence of a "Settings.razor" component in module ) | ||||
|             _moduleSettingsType = Type.GetType(ModuleState.ModuleDefinition.ControlTypeTemplate.Replace(Constants.ActionToken, PageState.Action), false, true); | ||||
|         } | ||||
|         if (_moduleSettingsType != null) | ||||
|         { | ||||
|             var moduleobject = Activator.CreateInstance(_moduleSettingsType) as IModuleControl; | ||||
|             if (!string.IsNullOrEmpty(moduleobject.Title)) | ||||
|             { | ||||
|                 // module settings type explicitly declared in IModule interface | ||||
|                 _moduleSettingsType = Type.GetType(ModuleState.ModuleDefinition.SettingsType); | ||||
|                 _moduleSettingsTitle = moduleobject.Title; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 // legacy support - module settings type determined by convention ( ie. existence of a "Settings.razor" component in module ) | ||||
|                 _moduleSettingsType = Type.GetType(ModuleState.ModuleDefinition.ControlTypeTemplate.Replace(Constants.ActionToken, PageState.Action), false, true); | ||||
|             } | ||||
|             if (_moduleSettingsType != null) | ||||
|             { | ||||
|                 var moduleobject = Activator.CreateInstance(_moduleSettingsType) as IModuleControl; | ||||
|                 if (!string.IsNullOrEmpty(moduleobject.Title)) | ||||
|                 { | ||||
|                     _moduleSettingsTitle = moduleobject.Title; | ||||
|                 } | ||||
|  | ||||
|                 ModuleSettingsComponent = builder => | ||||
|             ModuleSettingsComponent = builder => | ||||
|             { | ||||
|                 builder.OpenComponent(0, _moduleSettingsType); | ||||
|                 builder.AddComponentReferenceCapture(1, inst => { _moduleSettings = Convert.ChangeType(inst, _moduleSettingsType); }); | ||||
|                 builder.CloseComponent(); | ||||
|             }; | ||||
|         } | ||||
|  | ||||
|         var theme = _themes.FirstOrDefault(item => item.Containers.Any(themecontrol => themecontrol.TypeName.Equals(_containerType))); | ||||
|         if (theme != null && !string.IsNullOrEmpty(theme.ContainerSettingsType)) | ||||
|         { | ||||
|             _containerSettingsType = Type.GetType(theme.ContainerSettingsType); | ||||
|             if (_containerSettingsType != null) | ||||
|             { | ||||
|                 ContainerSettingsComponent = builder => | ||||
|                 { | ||||
|                     builder.OpenComponent(0, _moduleSettingsType); | ||||
|                     builder.AddComponentReferenceCapture(1, inst => { _moduleSettings = Convert.ChangeType(inst, _moduleSettingsType); }); | ||||
|                     builder.OpenComponent(0, _containerSettingsType); | ||||
|                     builder.AddComponentReferenceCapture(1, inst => { _containerSettings = Convert.ChangeType(inst, _containerSettingsType); }); | ||||
|                     builder.CloseComponent(); | ||||
|                 }; | ||||
|             } | ||||
|  | ||||
|             var theme = _themes.FirstOrDefault(item => item.Containers.Any(themecontrol => themecontrol.TypeName.Equals(_containerType))); | ||||
|             if (theme != null && !string.IsNullOrEmpty(theme.ContainerSettingsType)) | ||||
|             { | ||||
|                 _containerSettingsType = Type.GetType(theme.ContainerSettingsType); | ||||
|                 if (_containerSettingsType != null) | ||||
|                 { | ||||
|                     ContainerSettingsComponent = builder => | ||||
|                     { | ||||
|                         builder.OpenComponent(0, _containerSettingsType); | ||||
|                         builder.AddComponentReferenceCapture(1, inst => { _containerSettings = Convert.ChangeType(inst, _containerSettingsType); }); | ||||
|                         builder.CloseComponent(); | ||||
|                     }; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|         private async Task SaveModule() | ||||
|     private async Task SaveModule() | ||||
|     { | ||||
|         validated = true; | ||||
|         var interop = new Interop(JSRuntime); | ||||
|         if (await interop.FormValid(form)) | ||||
|         { | ||||
|             validated = true; | ||||
|             var interop = new Interop(JSRuntime); | ||||
|             if (await interop.FormValid(form)) | ||||
|             if (!string.IsNullOrEmpty(_title)) | ||||
|             { | ||||
|                 if (!string.IsNullOrEmpty(_title)) | ||||
|                 var pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId); | ||||
|                 pagemodule.PageId = int.Parse(_pageId); | ||||
|                 pagemodule.Title = _title; | ||||
|                 pagemodule.ContainerType = (_containerType != "-") ? _containerType : string.Empty; | ||||
|                 if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Page.DefaultContainerType) | ||||
|                 { | ||||
|                     var pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId); | ||||
|                     pagemodule.PageId = int.Parse(_pageId); | ||||
|                     pagemodule.Title = _title; | ||||
|                     pagemodule.ContainerType = (_containerType != "-") ? _containerType : string.Empty; | ||||
|                     if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Page.DefaultContainerType) | ||||
|                     { | ||||
|                         pagemodule.ContainerType = string.Empty; | ||||
|                     } | ||||
|                     if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Site.DefaultContainerType) | ||||
|                     { | ||||
|                         pagemodule.ContainerType = string.Empty; | ||||
|                     } | ||||
|                     await PageModuleService.UpdatePageModuleAsync(pagemodule); | ||||
|                     await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane); | ||||
|  | ||||
|                     var module = ModuleState; | ||||
|                     module.AllPages = bool.Parse(_allPages); | ||||
|                     module.Permissions = _permissionGrid.GetPermissions(); | ||||
|                     await ModuleService.UpdateModuleAsync(module); | ||||
|  | ||||
|                     if (_moduleSettingsType != null) | ||||
|                     { | ||||
|                         if (_moduleSettings is ISettingsControl moduleSettingsControl) | ||||
|                         { | ||||
|                             // module settings updated using explicit interface | ||||
|                             await moduleSettingsControl.UpdateSettings(); | ||||
|                         } | ||||
|                         else | ||||
|                         { | ||||
|                             // legacy support - module settings updated by convention ( ie. by calling a public method named "UpdateSettings" in settings component ) | ||||
|                             _moduleSettings?.GetType().GetMethod("UpdateSettings")?.Invoke(_moduleSettings, null); | ||||
|                         } | ||||
|                     } | ||||
|  | ||||
|                     if (_containerSettingsType != null && _containerSettings is ISettingsControl containerSettingsControl) | ||||
|                     { | ||||
|                         await containerSettingsControl.UpdateSettings(); | ||||
|                     } | ||||
|  | ||||
|                     NavigationManager.NavigateTo(NavigateUrl()); | ||||
|                     pagemodule.ContainerType = string.Empty; | ||||
|                 } | ||||
|                 else | ||||
|                 if (!string.IsNullOrEmpty(pagemodule.ContainerType) && pagemodule.ContainerType == PageState.Site.DefaultContainerType) | ||||
|                 { | ||||
|                     AddModuleMessage(Localizer["Message.Required.Title"], MessageType.Warning); | ||||
|                     pagemodule.ContainerType = string.Empty; | ||||
|                 } | ||||
|                 await PageModuleService.UpdatePageModuleAsync(pagemodule); | ||||
|                 await PageModuleService.UpdatePageModuleOrderAsync(pagemodule.PageId, pagemodule.Pane); | ||||
|  | ||||
|                 var module = ModuleState; | ||||
|                 module.AllPages = bool.Parse(_allPages); | ||||
|                 module.Permissions = _permissionGrid.GetPermissions(); | ||||
|                 await ModuleService.UpdateModuleAsync(module); | ||||
|  | ||||
|                 if (_moduleSettingsType != null) | ||||
|                 { | ||||
|                     if (_moduleSettings is ISettingsControl moduleSettingsControl) | ||||
|                     { | ||||
|                         // module settings updated using explicit interface | ||||
|                         await moduleSettingsControl.UpdateSettings(); | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         // legacy support - module settings updated by convention ( ie. by calling a public method named "UpdateSettings" in settings component ) | ||||
|                         _moduleSettings?.GetType().GetMethod("UpdateSettings")?.Invoke(_moduleSettings, null); | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|                 if (_containerSettingsType != null && _containerSettings is ISettingsControl containerSettingsControl) | ||||
|                 { | ||||
|                     await containerSettingsControl.UpdateSettings(); | ||||
|                 } | ||||
|  | ||||
|                 NavigationManager.NavigateTo(NavigateUrl()); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); | ||||
|                 AddModuleMessage(Localizer["Message.Required.Title"], MessageType.Warning); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         else | ||||
|         { | ||||
|             AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Grayson Walker
					Grayson Walker