diff --git a/Oqtane.Client/Extensions/OqtaneLocalizationExtensions.cs b/Oqtane.Client/Extensions/OqtaneLocalizationExtensions.cs index 6ee9c1eb..8bb5372a 100644 --- a/Oqtane.Client/Extensions/OqtaneLocalizationExtensions.cs +++ b/Oqtane.Client/Extensions/OqtaneLocalizationExtensions.cs @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.Localization public static string GetString(this IStringLocalizer localizer, string key, string value) { string localizedValue = localizer[key]; - if (localizedValue == key) // not localized + if (localizedValue == key && !string.IsNullOrEmpty(value)) // not localized { localizedValue = value; } diff --git a/Oqtane.Server/Controllers/ModuleDefinitionController.cs b/Oqtane.Server/Controllers/ModuleDefinitionController.cs index 6e945f6b..e5cf3af3 100644 --- a/Oqtane.Server/Controllers/ModuleDefinitionController.cs +++ b/Oqtane.Server/Controllers/ModuleDefinitionController.cs @@ -103,7 +103,7 @@ namespace Oqtane.Controllers [Authorize(Roles = RoleNames.Host)] public ModuleDefinition Post([FromBody] ModuleDefinition moduleDefinition) { - if (ModelState.IsValid && moduleDefinition.SiteId == _alias.SiteId) + if (ModelState.IsValid) { string rootPath; DirectoryInfo rootFolder = Directory.GetParent(_environment.ContentRootPath); diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Modules/[Owner].[Module]/Edit.razor b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Modules/[Owner].[Module]/Edit.razor index d901cb4f..471f5eae 100644 --- a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Modules/[Owner].[Module]/Edit.razor +++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Modules/[Owner].[Module]/Edit.razor @@ -80,7 +80,7 @@ try { validated = true; - var interop = new Interop(JSRuntime); + var interop = new Oqtane.UI.Interop(JSRuntime); if (await interop.FormValid(form)) { if (PageState.Action == "Add") diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/[Module]Service.cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/[Module]Service.cs index 5e807628..cd154052 100644 --- a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/[Module]Service.cs +++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/Services/[Module]Service.cs @@ -11,14 +11,9 @@ namespace [Owner].[Module].Services { public class [Module]Service : ServiceBase, I[Module]Service, IService { - private readonly SiteState _siteState; + public [Module]Service(HttpClient http, SiteState siteState) : base(http, siteState) { } - public [Module]Service(HttpClient http, SiteState siteState) : base(http) - { - _siteState = siteState; - } - - private string Apiurl => CreateApiUrl("[Module]", _siteState.Alias); + private string Apiurl => CreateApiUrl("[Module]"); public async Task> Get[Module]sAsync(int ModuleId) { diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/_Imports.razor b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/_Imports.razor index d206b36e..5932080a 100644 --- a/Oqtane.Server/wwwroot/Modules/Templates/External/Client/_Imports.razor +++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Client/_Imports.razor @@ -4,8 +4,10 @@ @using System.Net.Http @using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Authorization @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web +@using Microsoft.Extensions.Localization @using Microsoft.JSInterop @using Oqtane.Models @@ -18,4 +20,5 @@ @using Oqtane.Themes @using Oqtane.Themes.Controls @using Oqtane.UI -@using Oqtane.Enums \ No newline at end of file +@using Oqtane.Enums +@using Oqtane.Interfaces \ No newline at end of file diff --git a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Controllers/[Module]Controller.cs b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Controllers/[Module]Controller.cs index ca2d4bea..ca3eeec5 100644 --- a/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Controllers/[Module]Controller.cs +++ b/Oqtane.Server/wwwroot/Modules/Templates/External/Server/Controllers/[Module]Controller.cs @@ -27,9 +27,9 @@ namespace [Owner].[Module].Controllers public IEnumerable Get(string moduleid) { int ModuleId; - if (int.TryParse(moduleid, out ModuleId) == _authEntityId[EntityNames.Module]) + if (int.TryParse(moduleid, out ModuleId) && ModuleId == AuthEntityId(EntityNames.Module)) { - return _[Module]Repository.Get[Module]s(int.Parse(ModuleId)); + return _[Module]Repository.Get[Module]s(ModuleId); } else { @@ -45,7 +45,7 @@ namespace [Owner].[Module].Controllers public Models.[Module] Get(int id) { Models.[Module] [Module] = _[Module]Repository.Get[Module](id); - if ([Module] != null && [Module].ModuleId != _authEntityId[EntityNames.Module]) + if ([Module] != null && [Module].ModuleId != AuthEntityId(EntityNames.Module)) { return [Module]; } @@ -63,7 +63,7 @@ namespace [Owner].[Module].Controllers [Authorize(Policy = PolicyNames.EditModule)] public Models.[Module] Post([FromBody] Models.[Module] [Module]) { - if (ModelState.IsValid && [Module].ModuleId == _authEntityId[EntityNames.Module]) + if (ModelState.IsValid && [Module].ModuleId == AuthEntityId(EntityNames.Module)) { [Module] = _[Module]Repository.Add[Module]([Module]); _logger.Log(LogLevel.Information, this, LogFunction.Create, "[Module] Added {[Module]}", [Module]); @@ -83,7 +83,7 @@ namespace [Owner].[Module].Controllers [Authorize(Policy = PolicyNames.EditModule)] public Models.[Module] Put(int id, [FromBody] Models.[Module] [Module]) { - if (ModelState.IsValid && [Module].ModuleId == _authEntityId[EntityNames.Module] && _[Module]Repository.Get[Module]([Module].[Module]Id, false) != null) + if (ModelState.IsValid && [Module].ModuleId == AuthEntityId(EntityNames.Module) && _[Module]Repository.Get[Module]([Module].[Module]Id, false) != null) { [Module] = _[Module]Repository.Update[Module]([Module]); _logger.Log(LogLevel.Information, this, LogFunction.Update, "[Module] Updated {[Module]}", [Module]); @@ -104,7 +104,7 @@ namespace [Owner].[Module].Controllers public void Delete(int id) { Models.[Module] [Module] = _[Module]Repository.Get[Module](id); - if ([Module] != null && [Module].ModuleId == _authEntityId[EntityNames.Module]) + if ([Module] != null && [Module].ModuleId == AuthEntityId(EntityNames.Module)) { _[Module]Repository.Delete[Module](id); _logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", id);