updated modules for input requirements
This commit is contained in:
		| @ -5,28 +5,39 @@ | ||||
| @inject IStringLocalizer<Export> Localizer | ||||
| @inject IStringLocalizer<SharedResources> SharedLocalizer | ||||
|  | ||||
| <form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate> | ||||
|     <div class="container"> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="content" HelpText="Enter the module content" ResourceKey="Content">Content: </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <textarea id="content" class="form-control" @bind="@_content" rows="5"></textarea> | ||||
|                 <textarea id="content" class="form-control" @bind="@_content" rows="5" required></textarea> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
|  | ||||
|     <button type="button" class="btn btn-success" @onclick="ExportModule">@Localizer["Export"]</button> | ||||
|     <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"; | ||||
|  | ||||
|  | ||||
|         private async Task ExportModule() | ||||
|         { | ||||
|             _content = await ModuleService.ExportModuleAsync(ModuleState.ModuleId); | ||||
|             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); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -5,6 +5,7 @@ | ||||
| @inject IStringLocalizer<Import> Localizer | ||||
| @inject IStringLocalizer<SharedResources> SharedLocalizer | ||||
|  | ||||
| <form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate> | ||||
|     <div class="container"> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="content" HelpText="Enter the module content" ResourceKey="Content">Content: </Label> | ||||
| @ -17,39 +18,50 @@ | ||||
|  | ||||
|     <button type="button" class="btn btn-success" @onclick="ImportModule">@Localizer["Import"]</button> | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink> | ||||
|  | ||||
| </form> | ||||
|  | ||||
|     @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"; | ||||
|  | ||||
|         private async Task ImportModule() | ||||
|         { | ||||
|             if (_content != string.Empty) | ||||
|             validated = true; | ||||
|             var interop = new Interop(JSRuntime); | ||||
|             if (await interop.FormValid(form)) | ||||
|             { | ||||
|                 try | ||||
|                 if (_content != string.Empty) | ||||
|                 { | ||||
|                     bool success = await ModuleService.ImportModuleAsync(ModuleState.ModuleId, _content); | ||||
|                     if (success) | ||||
|                     try | ||||
|                     { | ||||
|                         AddModuleMessage(Localizer["Success.Content.Import"], MessageType.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); | ||||
|                         } | ||||
|                     } | ||||
|                     else | ||||
|                     catch (Exception ex) | ||||
|                     { | ||||
|                         AddModuleMessage(Localizer["Message.Content.ImportProblem"], MessageType.Warning); | ||||
|                         await logger.LogError(ex, "Error Importing Module {ModuleId} {Error}", ModuleState.ModuleId, ex.Message); | ||||
|                         AddModuleMessage(Localizer["Error.Module.Import"], MessageType.Error); | ||||
|                     } | ||||
|                 } | ||||
|                 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.Required.ImportContent"], MessageType.Warning); | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 AddModuleMessage(Localizer["Message.Required.ImportContent"], MessageType.Warning); | ||||
|                 AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -8,215 +8,228 @@ | ||||
| @inject IStringLocalizer<Settings> Localizer | ||||
| @inject IStringLocalizer<SharedResources> SharedLocalizer | ||||
|  | ||||
| <TabStrip> | ||||
|     <TabPanel Name="Settings" Heading="Settings" ResourceKey="Settings"> | ||||
|         @if (_containers != null) | ||||
|         { | ||||
|         <div class="container"> | ||||
|             <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" /> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="container" HelpText="Select the module's container" ResourceKey="Container">Container: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <select id="container" class="form-select" @bind="@_containerType"> | ||||
|                         @foreach (var container in _containers) | ||||
|                         { | ||||
|                             <option value="@container.TypeName">@container.Name</option> | ||||
|                         } | ||||
|                     </select> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="allpages" HelpText="Indicate if this module should be displayed on all pages" ResourceKey="DisplayOnAllPages">Display On All Pages? </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <select id="allpages" class="form-select" @bind="@_allPages"> | ||||
|                         <option value="True">@SharedLocalizer["Yes"]</option> | ||||
|                         <option value="False">@SharedLocalizer["No"]</option> | ||||
|                     </select> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="page" HelpText="The page that the module is located on" ResourceKey="Page">Page: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <select id="page" class="form-select" @bind="@_pageId"> | ||||
|                         @foreach (Page p in PageState.Pages) | ||||
|                         { | ||||
|                             if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.Permissions)) | ||||
|                             { | ||||
|                                 <option value="@p.PageId">@(new string('-', p.Level * 2))@(p.Name)</option> | ||||
|                             } | ||||
|                         } | ||||
|                     </select> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|         } | ||||
|     </TabPanel> | ||||
|     <TabPanel Name="Permissions" ResourceKey="Permissions"> | ||||
|         @if (_permissions != null) | ||||
|         { | ||||
|             <div class="container"> | ||||
|                 <div class="row mb-1 align-items-center"> | ||||
|                     <PermissionGrid EntityName="@EntityNames.Module" PermissionNames="@_permissionNames" Permissions="@_permissions" @ref="_permissionGrid" /> | ||||
|                 </div> | ||||
|             </div> | ||||
|  | ||||
|         } | ||||
|     </TabPanel> | ||||
|     @if (_moduleSettingsType != null) | ||||
|     { | ||||
|         <TabPanel Name="ModuleSettings" Heading="@_moduleSettingsTitle" ResourceKey="ModuleSettings"> | ||||
|             @ModuleSettingsComponent | ||||
|         </TabPanel> | ||||
|     } | ||||
|     @if (_containerSettingsType != null) | ||||
|     { | ||||
|         <TabPanel Name="ContainerSettings" Heading="Container Settings" ResourceKey="ContainerSettings"> | ||||
|             @ContainerSettingsComponent | ||||
|         </TabPanel> | ||||
|     } | ||||
| </TabStrip> | ||||
| <button type="button" class="btn btn-success" @onclick="SaveModule">@SharedLocalizer["Save"]</button> | ||||
| <NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink> | ||||
| <br /> | ||||
| <br /> | ||||
| <AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo> | ||||
|  | ||||
| @code { | ||||
|     public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit; | ||||
|     public override string Title => "Module Settings"; | ||||
|  | ||||
|     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() | ||||
|     { | ||||
|         _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)) | ||||
| <form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate> | ||||
|     <TabStrip> | ||||
|         <TabPanel Name="Settings" Heading="Settings" ResourceKey="Settings"> | ||||
|             @if (_containers != null) | ||||
|             { | ||||
|                 _moduleSettingsTitle = moduleobject.Title; | ||||
|                 <div class="container"> | ||||
|                     <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/> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                     <div class="row mb-1 align-items-center"> | ||||
|                         <Label Class="col-sm-3" For="container" HelpText="Select the module's container" ResourceKey="Container">Container: </Label> | ||||
|                         <div class="col-sm-9"> | ||||
|                             <select id="container" class="form-select" @bind="@_containerType" required> | ||||
|                                 @foreach (var container in _containers) | ||||
|                                 { | ||||
|                                     <option value="@container.TypeName">@container.Name</option> | ||||
|                                 } | ||||
|                             </select> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                     <div class="row mb-1 align-items-center"> | ||||
|                         <Label Class="col-sm-3" For="allpages" HelpText="Indicate if this module should be displayed on all pages" ResourceKey="DisplayOnAllPages">Display On All Pages? </Label> | ||||
|                         <div class="col-sm-9"> | ||||
|                             <select id="allpages" class="form-select" @bind="@_allPages" required> | ||||
|                                 <option value="True">@SharedLocalizer["Yes"]</option> | ||||
|                                 <option value="False">@SharedLocalizer["No"]</option> | ||||
|                             </select> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                     <div class="row mb-1 align-items-center"> | ||||
|                         <Label Class="col-sm-3" For="page" HelpText="The page that the module is located on" ResourceKey="Page">Page: </Label> | ||||
|                         <div class="col-sm-9"> | ||||
|                             <select id="page" class="form-select" @bind="@_pageId" required> | ||||
|                                 @foreach (Page p in PageState.Pages) | ||||
|                                 { | ||||
|                                     if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.Permissions)) | ||||
|                                     { | ||||
|                                         <option value="@p.PageId">@(new string('-', p.Level * 2))@(p.Name)</option> | ||||
|                                     } | ||||
|                                 } | ||||
|                             </select> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             } | ||||
|  | ||||
|             ModuleSettingsComponent = builder => | ||||
|         </TabPanel> | ||||
|         <TabPanel Name="Permissions" ResourceKey="Permissions"> | ||||
|             @if (_permissions != null) | ||||
|             { | ||||
|                 builder.OpenComponent(0, _moduleSettingsType); | ||||
|                 builder.AddComponentReferenceCapture(1, inst => { _moduleSettings = Convert.ChangeType(inst, _moduleSettingsType); }); | ||||
|                 builder.CloseComponent(); | ||||
|             }; | ||||
|         } | ||||
|                 <div class="container"> | ||||
|                     <div class="row mb-1 align-items-center"> | ||||
|                         <PermissionGrid EntityName="@EntityNames.Module" PermissionNames="@_permissionNames" Permissions="@_permissions" @ref="_permissionGrid" /> | ||||
|                     </div> | ||||
|                 </div> | ||||
|  | ||||
|         var theme = _themes.FirstOrDefault(item => item.Containers.Any(themecontrol => themecontrol.TypeName.Equals(_containerType))); | ||||
|         if (theme != null && !string.IsNullOrEmpty(theme.ContainerSettingsType)) | ||||
|             } | ||||
|         </TabPanel> | ||||
|         @if (_moduleSettingsType != null) | ||||
|         { | ||||
|             _containerSettingsType = Type.GetType(theme.ContainerSettingsType); | ||||
|             if (_containerSettingsType != null) | ||||
|             <TabPanel Name="ModuleSettings" Heading="@_moduleSettingsTitle" ResourceKey="ModuleSettings"> | ||||
|                 @ModuleSettingsComponent | ||||
|             </TabPanel> | ||||
|         } | ||||
|         @if (_containerSettingsType != null) | ||||
|         { | ||||
|             <TabPanel Name="ContainerSettings" Heading="Container Settings" ResourceKey="ContainerSettings"> | ||||
|                 @ContainerSettingsComponent | ||||
|             </TabPanel> | ||||
|         } | ||||
|     </TabStrip> | ||||
|     <button type="button" class="btn btn-success" @onclick="SaveModule">@SharedLocalizer["Save"]</button> | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink> | ||||
|     <br /> | ||||
|     <br /> | ||||
|     <AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo> | ||||
| </form> | ||||
|  | ||||
|     @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; | ||||
|  | ||||
|         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)) | ||||
|             { | ||||
|                 ContainerSettingsComponent = builder => | ||||
|                 // 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)) | ||||
|                 { | ||||
|                     builder.OpenComponent(0, _containerSettingsType); | ||||
|                     builder.AddComponentReferenceCapture(1, inst => { _containerSettings = Convert.ChangeType(inst, _containerSettingsType); }); | ||||
|                     _moduleSettingsTitle = moduleobject.Title; | ||||
|                 } | ||||
|  | ||||
|                 ModuleSettingsComponent = builder => | ||||
|                 { | ||||
|                     builder.OpenComponent(0, _moduleSettingsType); | ||||
|                     builder.AddComponentReferenceCapture(1, inst => { _moduleSettings = Convert.ChangeType(inst, _moduleSettingsType); }); | ||||
|                     builder.CloseComponent(); | ||||
|                 }; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private async Task SaveModule() | ||||
|     { | ||||
|         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 theme = _themes.FirstOrDefault(item => item.Containers.Any(themecontrol => themecontrol.TypeName.Equals(_containerType))); | ||||
|             if (theme != null && !string.IsNullOrEmpty(theme.ContainerSettingsType)) | ||||
|             { | ||||
|                 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) | ||||
|                 _containerSettingsType = Type.GetType(theme.ContainerSettingsType); | ||||
|                 if (_containerSettingsType != null) | ||||
|                 { | ||||
|                     // module settings updated using explicit interface | ||||
|                     await moduleSettingsControl.UpdateSettings(); | ||||
|                     ContainerSettingsComponent = builder => | ||||
|                     { | ||||
|                         builder.OpenComponent(0, _containerSettingsType); | ||||
|                         builder.AddComponentReferenceCapture(1, inst => { _containerSettings = Convert.ChangeType(inst, _containerSettingsType); }); | ||||
|                         builder.CloseComponent(); | ||||
|                     }; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         private async Task SaveModule() | ||||
|         { | ||||
|             validated = true; | ||||
|             var interop = new Interop(JSRuntime); | ||||
|             if (await interop.FormValid(form)) | ||||
|             { | ||||
|                 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) | ||||
|                     { | ||||
|                         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()); | ||||
|                 } | ||||
|                 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); | ||||
|                     AddModuleMessage(Localizer["Message.Required.Title"], MessageType.Warning); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             if (_containerSettingsType != null && _containerSettings is ISettingsControl containerSettingsControl) | ||||
|             else | ||||
|             { | ||||
|                 await containerSettingsControl.UpdateSettings(); | ||||
|                 AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|             NavigationManager.NavigateTo(NavigateUrl()); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             AddModuleMessage(Localizer["Message.Required.Title"], MessageType.Warning); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Grayson Walker
					Grayson Walker