| @ -10,67 +10,71 @@ | ||||
|  | ||||
| @if (_templates != null) | ||||
| { | ||||
|     <div class="container"> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="owner" HelpText="Enter the name of the organization who is developing this module. It should not contain spaces or punctuation." ResourceKey="OwnerName">Owner Name: </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <input id="owner" class="form-control" @bind="@_owner" /> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="module" HelpText="Enter a name for this module. It should not contain spaces or punctuation." ResourceKey="ModuleName">Module Name: </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <input id="module" class="form-control" @bind="@_module" /> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="description" HelpText="Enter a short description for the module" ResourceKey="Description">Description: </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <textarea id="description" class="form-control" @bind="@_description" rows="3"></textarea> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="template" HelpText="Select a module template. Templates are located in the wwwroot/Modules/Templates folder on the server." ResourceKey="Template">Template: </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <select id="template" class="form-select" @onchange="(e => TemplateChanged(e))"> | ||||
|                     <option value="-"><@Localizer["Template.Select"]></option> | ||||
|                     @foreach (Template template in _templates) | ||||
|                     { | ||||
|                         <option value="@template.Name">@template.Title</option> | ||||
|                     } | ||||
|                 </select> | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="row mb-1 align-items-center"> | ||||
|             <Label Class="col-sm-3" For="reference" HelpText="Select a framework reference version" ResourceKey="FrameworkReference">Framework Reference: </Label> | ||||
|             <div class="col-sm-9"> | ||||
|                 <select id="reference" class="form-select" @bind="@_reference"> | ||||
|                     @foreach (string version in _versions) | ||||
|                     { | ||||
|                         if (Version.Parse(version).CompareTo(Version.Parse(_minversion)) >= 0) | ||||
|                         { | ||||
|                             <option value="@(version)">@(version)</option> | ||||
|                         } | ||||
|                     } | ||||
|                     <option value="local">@SharedLocalizer["LocalVersion"]</option> | ||||
|                 </select> | ||||
|             </div> | ||||
|         </div> | ||||
|         @if (!string.IsNullOrEmpty(_location)) | ||||
|         { | ||||
|     <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="location" HelpText="Location where the module will be created" ResourceKey="Location">Location: </Label> | ||||
|                 <Label Class="col-sm-3" For="owner" HelpText="Enter the name of the organization who is developing this module. It should not contain spaces or punctuation." ResourceKey="OwnerName">Owner Name: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <input id="module" class="form-control" @bind="@_location" readonly /> | ||||
|                     <input id="owner" class="form-control" @bind="@_owner" required /> | ||||
|                 </div> | ||||
|             </div> | ||||
|         } | ||||
|     </div> | ||||
|     <button type="button" class="btn btn-success" @onclick="CreateModule">@Localizer["CreateModule"]</button> | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="module" HelpText="Enter a name for this module. It should not contain spaces or punctuation." ResourceKey="ModuleName">Module Name: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <input id="module" class="form-control" @bind="@_module" required /> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="description" HelpText="Enter a short description for the module" ResourceKey="Description">Description: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <textarea id="description" class="form-control" @bind="@_description" rows="3" maxlength="2000" required></textarea> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="template" HelpText="Select a module template. Templates are located in the wwwroot/Modules/Templates folder on the server." ResourceKey="Template">Template: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <select id="template" class="form-select" @onchange="(e => TemplateChanged(e))" required> | ||||
|                         <option value="-"><@Localizer["Template.Select"]></option> | ||||
|                         @foreach (Template template in _templates) | ||||
|                         { | ||||
|                             <option value="@template.Name">@template.Title</option> | ||||
|                         } | ||||
|                     </select> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="reference" HelpText="Select a framework reference version" ResourceKey="FrameworkReference">Framework Reference: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <select id="reference" class="form-select" @bind="@_reference" required> | ||||
|                         @foreach (string version in _versions) | ||||
|                         { | ||||
|                             if (Version.Parse(version).CompareTo(Version.Parse(_minversion)) >= 0) | ||||
|                             { | ||||
|                                 <option value="@(version)">@(version)</option> | ||||
|                             } | ||||
|                         } | ||||
|                         <option value="local">@SharedLocalizer["LocalVersion"]</option> | ||||
|                     </select> | ||||
|                 </div> | ||||
|             </div> | ||||
|             @if (!string.IsNullOrEmpty(_location)) | ||||
|             { | ||||
|                 <div class="row mb-1 align-items-center"> | ||||
|                     <Label Class="col-sm-3" For="location" HelpText="Location where the module will be created" ResourceKey="Location">Location: </Label> | ||||
|                     <div class="col-sm-9"> | ||||
|                         <input id="module" class="form-control" @bind="@_location" readonly /> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             } | ||||
|         </div> | ||||
|         <button type="button" class="btn btn-success" @onclick="CreateModule">@Localizer["CreateModule"]</button> | ||||
|         <NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink> | ||||
|     </form> | ||||
| } | ||||
|  | ||||
| @code { | ||||
|     private ElementReference form; | ||||
|     private bool validated = false; | ||||
|     private string _owner = string.Empty; | ||||
|     private string _module = string.Empty; | ||||
|     private string _description = string.Empty; | ||||
| @ -99,23 +103,32 @@ | ||||
|  | ||||
|     private async Task CreateModule() | ||||
|     { | ||||
|         try | ||||
|         validated = true; | ||||
|         var interop = new Interop(JSRuntime); | ||||
|         if (await interop.FormValid(form)) | ||||
|         { | ||||
|             if (IsValid(_owner) && IsValid(_module) && _owner != _module && _template != "-") | ||||
|             try | ||||
|             { | ||||
|                 var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference }; | ||||
|                 moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition); | ||||
|                 GetLocation(); | ||||
|                 AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success); | ||||
|                 if (IsValid(_owner) && IsValid(_module) && _owner != _module && _template != "-") | ||||
|                 { | ||||
|                     var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference }; | ||||
|                     moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition); | ||||
|                     GetLocation(); | ||||
|                     AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     AddModuleMessage(Localizer["Message.Require.ValidName"], MessageType.Warning); | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 AddModuleMessage(Localizer["Message.Require.ValidName"], MessageType.Warning); | ||||
|                 await logger.LogError(ex, "Error Creating Module"); | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         else | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Creating Module"); | ||||
|             AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|  | ||||
| @ -7,26 +7,28 @@ | ||||
|  | ||||
| <TabStrip> | ||||
|     <TabPanel Name="Definition" ResourceKey="Definition"> | ||||
|         <div class="container"> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="name" HelpText="The name of the module" ResourceKey="Name">Name: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <input id="name" class="form-control" @bind="@_name" /> | ||||
|         <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="name" HelpText="The name of the module" ResourceKey="Name">Name: </Label> | ||||
|                     <div class="col-sm-9"> | ||||
|                         <input id="name" class="form-control" @bind="@_name" maxlength="200" required /> | ||||
|                     </div> | ||||
|                 </div> | ||||
|                 <div class="row mb-1 align-items-center"> | ||||
|                     <Label Class="col-sm-3" For="description" HelpText="The description of the module" ResourceKey="Description">Description: </Label> | ||||
|                     <div class="col-sm-9"> | ||||
|                         <textarea id="description" class="form-control" @bind="@_description" rows="2" maxlength="2000" required></textarea> | ||||
|                     </div> | ||||
|                 </div> | ||||
|                 <div class="row mb-1 align-items-center"> | ||||
|                     <Label Class="col-sm-3" For="categories" HelpText="Comma delimited list of module categories" ResourceKey="Categories">Categories: </Label> | ||||
|                     <div class="col-sm-9"> | ||||
|                         <input id="categories" class="form-control" @bind="@_categories" maxlength="200" required /> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="description" HelpText="The description of the module" ResourceKey="Description">Description: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <textarea id="description" class="form-control" @bind="@_description" rows="2"></textarea> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="categories" HelpText="Comma delimited list of module categories" ResourceKey="Categories">Categories: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <input id="categories" class="form-control" @bind="@_categories" /> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|         </form> | ||||
|         <Section Name="Information" ResourceKey="Information"> | ||||
|             <div class="container"> | ||||
|                 <div class="row mb-1 align-items-center"> | ||||
| @ -89,6 +91,8 @@ | ||||
| <AuditInfo CreatedBy="@_createdby" CreatedOn="@_createdon" ModifiedBy="@_modifiedby" ModifiedOn="@_modifiedon"></AuditInfo> | ||||
|  | ||||
| @code { | ||||
|     private ElementReference form; | ||||
|     private bool validated = false; | ||||
|     private int _moduleDefinitionId; | ||||
|     private string _name; | ||||
|     private string _version; | ||||
| @ -146,30 +150,39 @@ | ||||
|  | ||||
|     private async Task SaveModuleDefinition() | ||||
|     { | ||||
|         try | ||||
|         validated = true; | ||||
|         var interop = new Interop(JSRuntime); | ||||
|         if (await interop.FormValid(form)) | ||||
|         { | ||||
|             var moduledefinition = await ModuleDefinitionService.GetModuleDefinitionAsync(_moduleDefinitionId, ModuleState.SiteId); | ||||
|             if (moduledefinition.Name != _name) | ||||
|             try | ||||
|             { | ||||
|                 moduledefinition.Name = _name; | ||||
|                 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(); | ||||
|                 await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition); | ||||
|                 await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition); | ||||
|                 NavigationManager.NavigateTo(NavigateUrl()); | ||||
|             } | ||||
|             if (moduledefinition.Description != _description) | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 moduledefinition.Description = _description; | ||||
|                 await logger.LogError(ex, "Error Saving ModuleDefinition {ModuleDefinitionId} {Error}", _moduleDefinitionId, ex.Message); | ||||
|                 AddModuleMessage(Localizer["Error.Module.Save"], MessageType.Error); | ||||
|             } | ||||
|             if (moduledefinition.Categories != _categories) | ||||
|             { | ||||
|                 moduledefinition.Categories = _categories; | ||||
|             } | ||||
|             moduledefinition.Permissions = _permissionGrid.GetPermissions(); | ||||
|             await ModuleDefinitionService.UpdateModuleDefinitionAsync(moduledefinition); | ||||
|             await logger.LogInformation("ModuleDefinition Saved {ModuleDefinition}", moduledefinition); | ||||
|             NavigationManager.NavigateTo(NavigateUrl()); | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|         else | ||||
|         { | ||||
|             await logger.LogError(ex, "Error Saving ModuleDefinition {ModuleDefinitionId} {Error}", _moduleDefinitionId, ex.Message); | ||||
|             AddModuleMessage(Localizer["Error.Module.Save"], MessageType.Error); | ||||
|             AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Shaun Walker
					Shaun Walker