fix module template issues
This commit is contained in:
parent
f330c4fcb6
commit
32c49f74d3
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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<List<Models.[Module]>> Get[Module]sAsync(int ModuleId)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
@using Oqtane.Enums
|
||||
@using Oqtane.Interfaces
|
|
@ -27,9 +27,9 @@ namespace [Owner].[Module].Controllers
|
|||
public IEnumerable<Models.[Module]> 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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user