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)
|
public static string GetString(this IStringLocalizer localizer, string key, string value)
|
||||||
{
|
{
|
||||||
string localizedValue = localizer[key];
|
string localizedValue = localizer[key];
|
||||||
if (localizedValue == key) // not localized
|
if (localizedValue == key && !string.IsNullOrEmpty(value)) // not localized
|
||||||
{
|
{
|
||||||
localizedValue = value;
|
localizedValue = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ namespace Oqtane.Controllers
|
||||||
[Authorize(Roles = RoleNames.Host)]
|
[Authorize(Roles = RoleNames.Host)]
|
||||||
public ModuleDefinition Post([FromBody] ModuleDefinition moduleDefinition)
|
public ModuleDefinition Post([FromBody] ModuleDefinition moduleDefinition)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid && moduleDefinition.SiteId == _alias.SiteId)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
string rootPath;
|
string rootPath;
|
||||||
DirectoryInfo rootFolder = Directory.GetParent(_environment.ContentRootPath);
|
DirectoryInfo rootFolder = Directory.GetParent(_environment.ContentRootPath);
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
validated = true;
|
validated = true;
|
||||||
var interop = new Interop(JSRuntime);
|
var interop = new Oqtane.UI.Interop(JSRuntime);
|
||||||
if (await interop.FormValid(form))
|
if (await interop.FormValid(form))
|
||||||
{
|
{
|
||||||
if (PageState.Action == "Add")
|
if (PageState.Action == "Add")
|
||||||
|
|
|
@ -11,14 +11,9 @@ namespace [Owner].[Module].Services
|
||||||
{
|
{
|
||||||
public class [Module]Service : ServiceBase, I[Module]Service, IService
|
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)
|
private string Apiurl => CreateApiUrl("[Module]");
|
||||||
{
|
|
||||||
_siteState = siteState;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string Apiurl => CreateApiUrl("[Module]", _siteState.Alias);
|
|
||||||
|
|
||||||
public async Task<List<Models.[Module]>> Get[Module]sAsync(int ModuleId)
|
public async Task<List<Models.[Module]>> Get[Module]sAsync(int ModuleId)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
@using System.Net.Http
|
@using System.Net.Http
|
||||||
@using System.Net.Http.Json
|
@using System.Net.Http.Json
|
||||||
|
|
||||||
|
@using Microsoft.AspNetCore.Components.Authorization
|
||||||
@using Microsoft.AspNetCore.Components.Routing
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
@using Microsoft.AspNetCore.Components.Web
|
@using Microsoft.AspNetCore.Components.Web
|
||||||
|
@using Microsoft.Extensions.Localization
|
||||||
@using Microsoft.JSInterop
|
@using Microsoft.JSInterop
|
||||||
|
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
|
@ -19,3 +21,4 @@
|
||||||
@using Oqtane.Themes.Controls
|
@using Oqtane.Themes.Controls
|
||||||
@using Oqtane.UI
|
@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)
|
public IEnumerable<Models.[Module]> Get(string moduleid)
|
||||||
{
|
{
|
||||||
int 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
|
else
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ namespace [Owner].[Module].Controllers
|
||||||
public Models.[Module] Get(int id)
|
public Models.[Module] Get(int id)
|
||||||
{
|
{
|
||||||
Models.[Module] [Module] = _[Module]Repository.Get[Module](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];
|
return [Module];
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ namespace [Owner].[Module].Controllers
|
||||||
[Authorize(Policy = PolicyNames.EditModule)]
|
[Authorize(Policy = PolicyNames.EditModule)]
|
||||||
public Models.[Module] Post([FromBody] Models.[Module] [Module])
|
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]);
|
[Module] = _[Module]Repository.Add[Module]([Module]);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Create, "[Module] Added {[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)]
|
[Authorize(Policy = PolicyNames.EditModule)]
|
||||||
public Models.[Module] Put(int id, [FromBody] Models.[Module] [Module])
|
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]);
|
[Module] = _[Module]Repository.Update[Module]([Module]);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Update, "[Module] Updated {[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)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
Models.[Module] [Module] = _[Module]Repository.Get[Module](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);
|
_[Module]Repository.Delete[Module](id);
|
||||||
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", id);
|
_logger.Log(LogLevel.Information, this, LogFunction.Delete, "[Module] Deleted {[Module]Id}", id);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user