Skip to content

Commit 013f10b

Browse files
committed
Add select box for Modifier categories
1 parent 2c61d0b commit 013f10b

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

BlazorDiffusion.ServiceModel/AppData.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,33 @@
33
using System.Collections.Generic;
44
using System.Linq;
55
using System.Text;
6-
using System.Threading.Tasks;
76

87
namespace BlazorDiffusion.ServiceModel;
98

10-
public static class AppData
9+
public class AppData
1110
{
1211
public const string Title = "Blazor Diffusion";
1312

1413
public const int MaxArtiactSize = 10 * 1024 * 1024;
1514
public const int MaxAvatarSize = 1024 * 1024;
1615

17-
static List<NavItem> DefaultLinks { get; set; } = new() { };
18-
static List<NavItem> AdminLinks { get; set; } = new() {
16+
public static AppData Instance { get; private set; } = new();
17+
18+
List<NavItem> DefaultLinks { get; set; } = new() { };
19+
List<NavItem> AdminLinks { get; set; } = new() {
1920
new NavItem { Label = "Admin", Href = "/admin" },
2021
};
21-
public static List<NavItem> GetNavItems(bool isAdmin) => isAdmin ? AdminLinks : DefaultLinks;
22+
public static List<NavItem> GetNavItems(bool isAdmin) => isAdmin ? Instance.AdminLinks : Instance.DefaultLinks;
2223

2324
public static List<Group> CategoryGroups = new Group[] {
2425
new() { Name = "Scene", Items = new[] { "Quality", "Style", "Aesthetic", "Features", "Medium", "Setting", "Theme" } },
2526
new() { Name = "Effects", Items = new[] { "Effects", "CGI", "Filters", "Lenses", "Photography", "Lighting", "Color" } },
2627
new() { Name = "Art Style", Items = new[] { "Art Movement", "Art Style", "18 Century", "19 Century", "20 Century", "21 Century" } },
2728
new() { Name = "Mood", Items = new[] { "Positive Mood", "Negative Mood" } },
2829
}.ToList();
30+
31+
string[]? categories;
32+
public string[] Categories => categories ??= CategoryGroups.SelectMany(x => x.Items).OrderBy(x => x).ToArray();
2933
}
3034

3135
public class AppSource

BlazorDiffusion.ServiceModel/Creative.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ public class CreateModifier : ICreateDb<Modifier>, IReturn<Modifier>
170170
[ValidateNotEmpty, Required]
171171
public string Name { get; set; }
172172
[ValidateNotEmpty, Required]
173+
[Input(Type="select", EvalAllowableValues = "AppData.Categories")]
173174
public string Category { get; set; }
174175
public string? Description { get; set; }
175176
}
@@ -180,6 +181,7 @@ public class UpdateModifier : IPatchDb<Modifier>, IReturn<Modifier>
180181
{
181182
public int Id { get; set; }
182183
public string? Name { get; set; }
184+
[Input(Type = "select", EvalAllowableValues = "AppData.Categories")]
183185
public string? Category { get; set; }
184186
public string? Description { get; set; }
185187
}

BlazorDiffusion/Configure.AppHost.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ public override void Configure(Container container)
8585
PublicPrefix = appConfig.AssetsBasePath,
8686
VirtualFiles = appFs
8787
});
88+
89+
ScriptContext.Args[nameof(AppData)] = AppData.Instance;
8890
}
8991

9092
public void Configure(IWebHostBuilder builder) => builder

0 commit comments

Comments
 (0)