Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions MW-GC.EventManager.API/Services/EventGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ public static string GenerateName()

private static List<Activity> FilterActivities(IReadOnlyList<Activity> activities, GenerateEventRequest req)
{
if (!req.ThemedOnly && req.SelectedThemeIds.Count == 0 && req.SelectedHolidayIds.Count == 0)
if (!req.ThemedOnly && req.SelectedGameIds.Count == 0 && req.SelectedThemeIds.Count == 0 && req.SelectedHolidayIds.Count == 0)
return activities.ToList();

return activities.Where(a =>
{
var isSelectedGame = req.SelectedGameIds.Count == 0 || req.SelectedGameIds.Contains(a.GameId);
var hasThemes = req.SelectedThemeIds.Count == 0 || a.ThemeIds.Intersect(req.SelectedThemeIds).Any();
var hasHolidays = req.SelectedHolidayIds.Count == 0 || a.HolidayIds.Intersect(req.SelectedHolidayIds).Any();
var isThemed = !req.ThemedOnly || a.ThemeIds.Count > 0 || a.HolidayIds.Count > 0;
return hasThemes && hasHolidays && isThemed;
return isSelectedGame && hasThemes && hasHolidays && isThemed;
}).ToList();
}

Expand Down
1 change: 1 addition & 0 deletions MW-GC.EventManager.Shared/Requests/GenerateEventRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public record GenerateEventRequest
{
public int Count { get; init; } = 3;
public bool ThemedOnly { get; init; }
public List<Guid> SelectedGameIds { get; init; } = [];
public List<Guid> SelectedThemeIds { get; init; } = [];
public List<Guid> SelectedHolidayIds { get; init; } = [];
public bool UniqueGamesOnly { get; init; } = true;
Expand Down
9 changes: 2 additions & 7 deletions MW-GC.EventManager.Web/MW-GC.EventManager.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.9" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.10" PrivateAssets="all" />
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components" Version="4.14.3" />
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components.Icons" Version="4.14.3" />
</ItemGroup>
Expand All @@ -18,8 +17,4 @@
<ProjectReference Include="..\MW-GC.EventManager.Shared\MW-GC.EventManager.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>

</Project>
30 changes: 26 additions & 4 deletions MW-GC.EventManager.Web/Pages/Events.razor
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,26 @@
<FluentSwitch @bind-Value="_custThemedOnly" Label="Themed Activities Only" />
</FluentCard>

@* Theme / Holiday filters *@
@* Game / Theme / Holiday filters *@
<FluentGrid Spacing="3">
<FluentGridItem xs="12" sm="6">
<FluentGridItem xs="12" sm="4">
<FluentCard Style="padding: 12px;" AreaRestricted="false">
<FluentLabel Weight="FontWeight.Bold" Style="margin-bottom: 4px;">Filter by Games</FluentLabel>
<FluentLabel Typo="Typography.Body" Style="color: var(--neutral-foreground-hint); margin-bottom: 8px; font-size: 0.8rem;">Only randomize from specific games</FluentLabel>
@if (_games is not null)
{
<FluentStack Orientation="Orientation.Vertical" VerticalGap="4" Style="max-height: 160px; overflow-y: auto;">
@foreach (var game in _games.OrderBy(g => g.Name))
{
<FluentCheckbox Label="@game.Name"
Value="@_custGameIds.Contains(game.Id)"
ValueChanged="@(v => ToggleId(_custGameIds, game.Id, v))" />
}
</FluentStack>
}
</FluentCard>
</FluentGridItem>
<FluentGridItem xs="12" sm="4">
<FluentCard Style="padding: 12px;" AreaRestricted="false">
<FluentLabel Weight="FontWeight.Bold" Style="margin-bottom: 4px;">Filter by Themes</FluentLabel>
<FluentLabel Typo="Typography.Body" Style="color: var(--neutral-foreground-hint); margin-bottom: 8px; font-size: 0.8rem;">Select specific themes</FluentLabel>
Expand All @@ -127,7 +144,7 @@
}
</FluentCard>
</FluentGridItem>
<FluentGridItem xs="12" sm="6">
<FluentGridItem xs="12" sm="4">
<FluentCard Style="padding: 12px;" AreaRestricted="false">
<FluentLabel Weight="FontWeight.Bold" Style="margin-bottom: 4px;">Filter by Holidays</FluentLabel>
<FluentLabel Typo="Typography.Body" Style="color: var(--neutral-foreground-hint); margin-bottom: 8px; font-size: 0.8rem;">Select specific holidays</FluentLabel>
Expand All @@ -151,7 +168,7 @@
Wrap="true">
<div>
<FluentLabel Weight="FontWeight.Bold">Game & Activity Selections (@_custSelections.Count)</FluentLabel>
@if (_custThemedOnly || _custThemeIds.Count > 0 || _custHolidayIds.Count > 0)
@if (_custThemedOnly || _custGameIds.Count > 0 || _custThemeIds.Count > 0 || _custHolidayIds.Count > 0)
{
<FluentLabel Typo="Typography.Body" Style="color: var(--neutral-foreground-hint); font-size: 0.75rem;">Click "Randomize All" to apply filters</FluentLabel>
}
Expand Down Expand Up @@ -377,6 +394,7 @@
private DateTime? _custDate = DateTime.Today;
private DateTime? _custTime = DateTime.Today.AddHours(19);
private bool _custThemedOnly;
private List<Guid> _custGameIds = [];
private List<Guid> _custThemeIds = [];
private List<Guid> _custHolidayIds = [];
private bool _custUniqueGames = true;
Expand Down Expand Up @@ -434,6 +452,7 @@
_custDate = DateTime.Today;
_custTime = DateTime.Today.AddHours(19);
_custThemedOnly = false;
_custGameIds = [];
_custThemeIds = [];
_custHolidayIds = [];
_custUniqueGames = true;
Expand All @@ -451,6 +470,7 @@
_custTime = localStart;
_custUniqueGames = e.UniqueGamesOnly;
_custThemedOnly = false;
_custGameIds = [];
_custThemeIds = [];
_custHolidayIds = [];
_custSelections = e.Selections.Select(s => new SlotSelection { GameId = s.Game.Id, ActivityId = s.Activity.Id }).ToList();
Expand Down Expand Up @@ -488,6 +508,8 @@
{
if (_activities is null) return [];
IEnumerable<ActivityEntity> q = _activities;
if (_custGameIds.Count > 0)
q = q.Where(a => _custGameIds.Contains(a.GameId));
if (_custThemedOnly)
q = q.Where(a => a.ThemeIds.Count > 0 || a.HolidayIds.Count > 0);
if (_custThemeIds.Count > 0)
Expand Down
Loading