Merge pull request #2839 from sbwalker/dev

add ability to modify Theme Name
This commit is contained in:
Shaun Walker 2023-05-25 12:57:02 -04:00 committed by GitHub
commit b360944742
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 59 additions and 21 deletions

View File

@ -13,7 +13,7 @@
<div class="row mb-1 align-items-center"> <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> <Label Class="col-sm-3" For="name" HelpText="The name of the module" ResourceKey="Name">Name: </Label>
<div class="col-sm-9"> <div class="col-sm-9">
<input id="name" class="form-control" @bind="@_name" disabled /> <input id="name" class="form-control" @bind="@_name" />
</div> </div>
</div> </div>
<div class="row mb-1 align-items-center"> <div class="row mb-1 align-items-center">
@ -142,6 +142,7 @@
try try
{ {
var theme = await ThemeService.GetThemeAsync(_themeId, ModuleState.SiteId); var theme = await ThemeService.GetThemeAsync(_themeId, ModuleState.SiteId);
theme.Name = _name;
theme.IsEnabled = (_isenabled == null ? true : bool.Parse(_isenabled)); theme.IsEnabled = (_isenabled == null ? true : bool.Parse(_isenabled));
await ThemeService.UpdateThemeAsync(theme); await ThemeService.UpdateThemeAsync(theme);
await logger.LogInformation("Theme Saved {Theme}", theme); await logger.LogInformation("Theme Saved {Theme}", theme);

View File

@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Oqtane.Databases.Interfaces;
using Oqtane.Migrations.EntityBuilders;
using Oqtane.Repository;
namespace Oqtane.Migrations.Master
{
[DbContext(typeof(MasterDBContext))]
[Migration("Master.04.00.00.02")]
public class AddThemeName : MultiDatabaseMigration
{
public AddThemeName(IDatabase database) : base(database)
{
}
protected override void Up(MigrationBuilder migrationBuilder)
{
var themeEntityBuilder = new ThemeEntityBuilder(migrationBuilder, ActiveDatabase);
themeEntityBuilder.AddStringColumn("Name", 200, true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
// not implemented
}
}
}

View File

@ -12,6 +12,7 @@ using Oqtane.Models;
using Oqtane.Shared; using Oqtane.Shared;
using Oqtane.Themes; using Oqtane.Themes;
using System.Reflection.Metadata; using System.Reflection.Metadata;
using Oqtane.Migrations.Master;
namespace Oqtane.Repository namespace Oqtane.Repository
{ {
@ -125,6 +126,12 @@ namespace Oqtane.Repository
} }
else else
{ {
// override user customizable property values
Theme.Name = (!string.IsNullOrEmpty(theme.Name)) ? theme.Name : Theme.Name;
foreach (var themecontrol in Theme.Themes)
{
themecontrol.Name = Theme.Name + " - " + themecontrol.Name;
}
// remove theme from list as it is already synced // remove theme from list as it is already synced
themes.Remove(theme); themes.Remove(theme);
} }
@ -286,7 +293,7 @@ namespace Oqtane.Repository
new ThemeControl new ThemeControl
{ {
TypeName = themeControlType.FullName + ", " + themeControlType.Assembly.GetName().Name, TypeName = themeControlType.FullName + ", " + themeControlType.Assembly.GetName().Name,
Name = theme.Name + " - " + ((string.IsNullOrEmpty(themecontrolobject.Name)) ? Utilities.GetTypeNameLastSegment(themeControlType.FullName, 0) : themecontrolobject.Name), Name = ((string.IsNullOrEmpty(themecontrolobject.Name)) ? Utilities.GetTypeNameLastSegment(themeControlType.FullName, 0) : themecontrolobject.Name),
Thumbnail = themecontrolobject.Thumbnail, Thumbnail = themecontrolobject.Thumbnail,
Panes = themecontrolobject.Panes Panes = themecontrolobject.Panes
} }

View File

@ -48,7 +48,7 @@ namespace Oqtane.Models
public string ModuleDefinitionName { get; set; } public string ModuleDefinitionName { get; set; }
/// <summary> /// <summary>
/// Nice name to show in admin / edit dialogs. /// Friendly name to show in UI
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }

View File

@ -35,10 +35,12 @@ namespace Oqtane.Models
/// </summary> /// </summary>
public string ThemeName { get; set; } public string ThemeName { get; set; }
// additional ITheme properties /// <summary>
[NotMapped] /// Friendly name to show in UI
/// </summary>
public string Name { get; set; } public string Name { get; set; }
// additional ITheme properties
[NotMapped] [NotMapped]
public string Version { get; set; } public string Version { get; set; }