Skip to content

Commit

Permalink
Merge pull request #154 from SSchulze1989/develop
Browse files Browse the repository at this point in the history
v 0.12.0
  • Loading branch information
SSchulze1989 authored Jul 12, 2024
2 parents 28ee77a + 010b621 commit 3e300bb
Show file tree
Hide file tree
Showing 28 changed files with 737 additions and 185 deletions.
2 changes: 1 addition & 1 deletion src/iRLeagueManager.Web/Components/EventSelect.razor
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
return null;
}
index ??= EventList.EventList.IndexOf(@event);
return $"{(index + 1).Value.ToString("00")}. {@event.Date.GetValueOrDefault().ToString("dd.MM.yy")}: {@event.TrackName}" + (@event.ConfigName != "-" ? $" - {@event.ConfigName}" : "");
return $"{(index + 1).Value.ToString("00")}. {@event.Date.GetValueOrDefault().ToShortDateFormatted()}: {@event.TrackName}" + (@event.ConfigName != "-" ? $" - {@event.ConfigName}" : "");
}

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
@using iRLeagueApiCore.Common.Models.Tracks
@using iRLeagueManager.Web.ViewModels
@inherits EditDialogBase<EventViewModel, EventModel>
@inject JsonSerializerOptions jsonOptions
@inject TrackListService trackListService

<EditForm Model=Vm OnValidSubmit=Submit>
<EditForm Model=Vm>
<StatusResultValidator @ref=ResultValidator TrimPrefix="Event." />
<MudDialog>
<DialogContent>
Expand Down Expand Up @@ -106,7 +105,7 @@
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel" Color="Color.Secondary">Cancel</MudButton>
<ProgressButton ButtonType="ButtonType.Submit" Color="Color.Primary" Loading="Loading">Save</ProgressButton>
<ProgressButton OnClick="Submit" Color="Color.Primary" Loading="Loading">Save</ProgressButton>
</DialogActions>
</MudDialog>
</EditForm>
Expand Down
2 changes: 0 additions & 2 deletions src/iRLeagueManager.Web/Components/InputMarkdown.razor
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
</div>

@code {
private string uuid = "1";

protected override bool TryParseValueFromString(string? value, [MaybeNullWhen(false)] out string result, [NotNullWhen(false)] out string? validationErrorMessage)
{
validationErrorMessage = null;
Expand Down
30 changes: 29 additions & 1 deletion src/iRLeagueManager.Web/Components/Results/DisplayResult.razor
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<MudMenu Icon="@Icons.Material.Filled.MoreVert" Dense="true" Size="Size.Small">
<MudMenuItem OnClick="() => AddBonusPentalyClick(Row)">Add Bonus/Penalty</MudMenuItem>
<MudMenuItem OnClick="() => ShowBonusesPenaltiesClick(Row)">Show Bonuses/Penalties</MudMenuItem>
<MudMenuItem OnClick="() => ChangeTeamClick(Row)">Change Team</MudMenuItem>
</MudMenu>
</td>
}
Expand All @@ -127,6 +128,8 @@
@code {
[CascadingParameter]
private EventListViewModel EventList { get; set; } = default!;
[CascadingParameter]
private ResultsPageViewModel? ResultsPageVm { get; set; }
[Parameter, EditorRequired]
public SessionResultViewModel Result { get; set; } = default!;
[Parameter]
Expand All @@ -143,7 +146,7 @@
protected override void OnParametersSet()
{
base.OnParametersSet();
BlazorParameterNullException.ThrowIfNull(this, EventList);
BlazorParameterNullException.ThrowIfNull(this, EventList, cascading: true);
BlazorParameterNullException.ThrowIfNull(this, Result);
isTeamResult = Result.ResultRows.Any(x => x.MemberId == null);
showDisqualification = Result.ResultRows.Any(x => x.Status == RaceStatus.Disqualified);
Expand Down Expand Up @@ -220,4 +223,29 @@
};
await DialogService.Show<ShowPenaltiesDialog>("Bonuses/Penalties", parameters, options).Result;
}

private async Task ChangeTeamClick(ResultRowModel? row)
{
if (row is null)
{
return;
}

var parameters = new DialogParameters<ChangeTeamsDialog>()
{
{ x => x.Member, new() { FirstName = row.Firstname, LastName = row.Lastname, MemberId = row.MemberId.GetValueOrDefault() }},
};

await DialogService.Show<ChangeTeamsDialog>("Change Team", parameters).Result;
await Refresh();
}

private async Task Refresh()
{
if (ResultsPageVm?.SelectedEvent is null)
{
return;
}
await ResultsPageVm.LoadFromEventAsync(ResultsPageVm.SelectedEvent.EventId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@inherits EditDialogBase<ReviewCommentViewModel, ReviewCommentModel>
@inject LeagueApiService ApiService

<EditForm Model=Vm OnValidSubmit=Submit>
<EditForm Model=Vm>
<MudDialog>
<DialogContent>
<MudStack Spacing="2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@using iRLeagueManager.Web.ViewModels
@inherits EditDialogBase<ReviewViewModel, ReviewModel>

<EditForm Model=Vm OnValidSubmit=Submit>
<EditForm Model=Vm>
<StatusResultValidator @ref=ResultValidator />
<MudDialog>
<DialogContent>
Expand Down Expand Up @@ -53,7 +53,7 @@
</DialogContent>
<DialogActions>
<MudButton Color="Color.Secondary" OnClick="Cancel">Cancel</MudButton>
<ProgressButton Color="Color.Primary" ButtonType="ButtonType.Submit" Loading="Loading">Save</ProgressButton>
<ProgressButton Color="Color.Primary" OnClick="Submit" Loading="Loading">Save</ProgressButton>
</DialogActions>
</MudDialog>
</EditForm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@inherits EditDialogBase<ReviewViewModel, ReviewModel>
@inject LeagueApiService ApiService

<EditForm Model=Vm OnValidSubmit=Submit>
<EditForm Model=Vm>
<MudDialog>
<DialogContent>
<MudStack Spacing="2">
Expand Down Expand Up @@ -84,7 +84,7 @@
</DialogContent>
<DialogActions>
<MudButton Color="Color.Secondary" OnClick="Cancel">Cancel</MudButton>
<ProgressButton Color="Color.Primary" ButtonType="ButtonType.Submit" Loading="Vm.Loading">Save</ProgressButton>
<ProgressButton Color="Color.Primary" OnClick="Submit" Loading="Vm.Loading">Save</ProgressButton>
</DialogActions>
</MudDialog>
</EditForm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@
}
}

private bool formulaHelpOpen = false;

protected override void OnParametersSet()
{
base.OnParametersSet();
Expand Down
104 changes: 60 additions & 44 deletions src/iRLeagueManager.Web/Components/Standings/DisplayStanding.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,64 @@
var showDriver = HasDriver(Standing.StandingRows) && Standing.IsTeamStanding == false;
var hasTeam = HasTeam(Standing.StandingRows);
}
<ResultTable Data="@Standing.StandingRows">
<HeaderTemplate>
<ResultTableHeader Text="Pos" Sort="@(x => x.Position)" Default=true />
@if (showDriver)
{
<ResultTableHeader Text="Driver" Sort="@(x => x.Firstname)"/>
}
@if (hasTeam)
{
<ResultTableHeader Text="Team" Sort="@(x => x.TeamName)" />
}
<ResultTableHeader Text="RacePoints" Sort="@(x => x.RacePoints)" Direction="SortDirection.Descending" />
<ResultTableHeader Text="Penalties" Sort="@(x => x.PenaltyPoints)" />
<ResultTableHeader Text="Total Points" Sort="@(x => x.TotalPoints)" Direction="SortDirection.Descending" />
<ResultTableHeader Text="Races" Sort="@(x => x.Races)" Direction="SortDirection.Descending" />
<ResultTableHeader Text="Poles" Sort="@(x => x.PolePositions)" Direction="SortDirection.Descending" />
<ResultTableHeader Text="Wins" Sort="@(x => x.Wins)" Direction="SortDirection.Descending" />
<ResultTableHeader Text="Podiums" Sort="@(x => x.Top3)" Direction="SortDirection.Descending" />
<ResultTableHeader Text="Incidents" Sort="@(x => x.Incidents)" />
</HeaderTemplate>
<RowTemplate Context=Row>
<td class="px-1 py-1"><ValueChange Value=Row.Position Change=Row.PositionChange /></td>
@if (showDriver)
{
<td class="px-1 py-1">@Row.Firstname @Row.Lastname</td>
}
@if (hasTeam)
{
<td class="px-1 py-1" style="color:@Row.TeamColor">@Row.TeamName</td>
}
<td class="px-1 py-1"><ValueChange Value=Row.RacePoints Change=Row.RacePointsChange /></td>
<td class="px-1 py-1" style="@(@Row.PenaltyPoints != 0 ? "color:red" : "")">
@(Row.PenaltyPoints != 0 ? "-" : "")@Row.PenaltyPoints
</td>
<td class="px-1 py-1"><ValueChange Value=Row.TotalPoints Change=Row.TotalPointsChange /></td>
<td class="px-1 py-1">
@Row.RacesCounted@(Row.RacesCounted != Row.Races ? $" ({Row.Races})" : "")
</td>
<td class="px-1 py-1"><ValueChange Value=Row.PolePositions Change=Row.PolePositionsChange /></td>
<td class="px-1 py-1"><ValueChange Value=Row.Wins Change=Row.WinsChange /></td>
<td class="px-1 py-1">@Row.Top3</td>
<td class="px-1 py-1">@Row.Incidents</td>
</RowTemplate>
</ResultTable>

<MudElement HtmlTag="div" Class="d-flex justify-end">
<MudSwitch @bind-Value="showRaceByRace" Class="px-2" Color="Color.Primary">
Show race-by-race
</MudSwitch>
</MudElement>

@if (showRaceByRace)
{
<RaceByRacePoints StandingRows="Standing.StandingRows" />
}
else
{
<ResultTable Data="@Standing.StandingRows">
<HeaderTemplate>
<ResultTableHeader Text="Pos" Sort="@(x => x.Position)" Default=true />
@if (showDriver)
{
<ResultTableHeader Text="Driver" Sort="@(x => x.Firstname)" />
}
@if (hasTeam)
{
<ResultTableHeader Text="Team" Sort="@(x => x.TeamName)" />
}
<ResultTableHeader Text="RacePoints" Sort="@(x => x.RacePoints)" Direction="SortDirection.Descending" />
<ResultTableHeader Text="Penalties" Sort="@(x => x.PenaltyPoints)" />
<ResultTableHeader Text="Total Points" Sort="@(x => x.TotalPoints)" Direction="SortDirection.Descending" />
<ResultTableHeader Text="Races" Sort="@(x => x.Races)" Direction="SortDirection.Descending" />
<ResultTableHeader Text="Poles" Sort="@(x => x.PolePositions)" Direction="SortDirection.Descending" />
<ResultTableHeader Text="Wins" Sort="@(x => x.Wins)" Direction="SortDirection.Descending" />
<ResultTableHeader Text="Podiums" Sort="@(x => x.Top3)" Direction="SortDirection.Descending" />
<ResultTableHeader Text="Incidents" Sort="@(x => x.Incidents)" />
</HeaderTemplate>
<RowTemplate Context=Row>
<td class="px-1 py-1"><ValueChange Value=Row.Position Change=Row.PositionChange /></td>
@if (showDriver)
{
<td class="px-1 py-1">@Row.Firstname @Row.Lastname</td>
}
@if (hasTeam)
{
<td class="px-1 py-1" style="color:@Row.TeamColor">@Row.TeamName</td>
}
<td class="px-1 py-1"><ValueChange Value=Row.RacePoints Change=Row.RacePointsChange /></td>
<td class="px-1 py-1" style="@(@Row.PenaltyPoints != 0 ? "color:red" : "")">
@(Row.PenaltyPoints != 0 ? "-" : "")@Row.PenaltyPoints
</td>
<td class="px-1 py-1"><ValueChange Value=Row.TotalPoints Change=Row.TotalPointsChange /></td>
<td class="px-1 py-1">
@Row.RacesCounted@(Row.RacesCounted != Row.Races ? $" ({Row.Races})" : "")
</td>
<td class="px-1 py-1"><ValueChange Value=Row.PolePositions Change=Row.PolePositionsChange /></td>
<td class="px-1 py-1"><ValueChange Value=Row.Wins Change=Row.WinsChange /></td>
<td class="px-1 py-1">@Row.Top3</td>
<td class="px-1 py-1">@Row.Incidents</td>
</RowTemplate>
</ResultTable>
}
</div>

@code {
Expand All @@ -58,6 +72,8 @@
[Parameter, EditorRequired]
public StandingsModel Standing { get; set; } = default!;

private bool showRaceByRace = false;

private bool HasDriver(IEnumerable<StandingRowModel> rows)
{
return rows.Any(x => x.MemberId != null);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@namespace iRLeagueManager.Web.Components
@using iRLeagueApiCore.Common.Models
@using iRLeagueApiCore.Common.Models.Standings

<MudSimpleTable Elevation=5 Dense="true" Bordered="true">
@{
var columnsCount = RaceColumns ?? StandingRows.Select(x => x.ResultRows.Count()).Max();
}
<thead>
<tr>
<td rowspan="2" class="py-2">
Pos.
</td>
<td rowspan="2" class="py-2">
Name
</td>
@for (int i = 1; i <= columnsCount; i++)
{
<th colspan="3" style="text-align: center">
R@(i.ToString())
</th>
}
</tr>
</thead>
@foreach (var row in StandingRows)
{
var columns = row.ResultRows.ToList();
if (columnsCount > columns.Count)
{
columns.AddRange(Enumerable.Repeat<StandingResultRowModel?>(null, columns.Count - columnsCount));
};
<tbody>
<tr>
<td rowspan="2" class="py-0">
@(row.Position).
</td>
<td rowspan="2" class="py-0">
@row.Firstname @row.Lastname
</td>
@foreach (var race in columns)
{
<td class="@($"col-3 py-0 {(race?.IsScored == false ? "dropped" : "")}")" colspan="3" style="text-align: center">
@race?.TotalPoints
</td>
}
</tr>
<tr>
@foreach (var race in columns)
{
<td class="@($"col-1 py-0 {(race?.IsScored == false ? "dropped" : "")}")">
@race?.RacePoints
</td>
<td class="@($"col-1 py-0 {(race?.IsScored == false ? "dropped" : "")}")">
@race?.BonusPoints
</td>
<td class="@($"col-1 py-0 {(race?.IsScored == false ? "dropped" : "")}")" style="@(race?.PenaltyPoints != 0 ? "color:red" : "")">
@(race?.PenaltyPoints is < 0 or > 0 ? "-" : "")@race?.PenaltyPoints
</td>
}
</tr>
</tbody>
}
</MudSimpleTable>

@code {
[Parameter] public IEnumerable<StandingRowModel> StandingRows { get; set; } = default!;
[Parameter] public int? RaceColumns { get; set; }

protected override void OnParametersSet()
{
base.OnParametersSet();
BlazorParameterNullException.ThrowIfNull(this, StandingRows);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.mud-simple-table .mud-table-container table tbody tr:last-child {
border-bottom: 1px solid var(--mud-palette-table-lines);
}

.mud-simple-table .mud-table-container table tbody:hover {
background-color: var(--mud-palette-table-hover) !important;
}

.mud-simple-table .mud-table-container table tbody:nth-of-type(2n+1):not(:hover) {
background-color: var(--mud-palette-table-striped);
}

.mud-simple-table .mud-table-container table tbody:nth-child(2n+1):not(:hover) tr:nth-child(2n+1) td:nth-child(2n+3),
.mud-simple-table .mud-table-container table tbody:nth-child(2n+1):not(:hover) tr:nth-child(2n) td:nth-child(6n+3),
.mud-simple-table .mud-table-container table tbody:nth-child(2n+1):not(:hover) tr:nth-child(2n) td:nth-child(6n+2),
.mud-simple-table .mud-table-container table tbody:nth-child(2n+1):not(:hover) tr:nth-child(2n) td:nth-child(6n+1) {
background-color: var(--mud-palette-table-striped);
filter: brightness(85%);
}

.mud-simple-table .mud-table-container table tbody tr td.dropped {
color: var(--mud-palette-text-disabled);
}
Loading

0 comments on commit 3e300bb

Please sign in to comment.