-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from SSchulze1989/feature/championships
Feature/championships
- Loading branch information
Showing
31 changed files
with
1,107 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/iRLeagueManager.Web/Components/Settings/ChampSeasonPreview.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
@using iRLeagueManager.Web.ViewModels | ||
|
||
<div @attributes=AdditionalAttributes> | ||
<div class="mb-1"> | ||
<h5>@ChampSeason.ChampionshipName</h5> | ||
</div> | ||
<div class="d-flex mb-2 gap-3"> | ||
<h6>ResultConfigs</h6> | ||
<div class="d-flex"> | ||
@foreach(var config in ChampSeason.ResultConfigs) | ||
{ | ||
<div class="badge bg-secondary p-2"> | ||
@config.Name | ||
</div> | ||
} | ||
</div> | ||
</div> | ||
<div class="d-flex gap-3"> | ||
<h6>Standing Config</h6> | ||
<div> | ||
@ChampSeason.StandingConfig?.Name | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
@code { | ||
[Parameter(CaptureUnmatchedValues=true)] | ||
public IDictionary<string, object>? AdditionalAttributes { get; set; } | ||
|
||
[Parameter, EditorRequired] | ||
public ChampSeasonViewModel ChampSeason { get; set; } = default!; | ||
|
||
protected override void OnParametersSet() | ||
{ | ||
_ = ChampSeason ?? throw BlazorParameterNullException.New(this, ChampSeason); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/iRLeagueManager.Web/Components/Settings/ChampionshipPreview.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
@using iRLeagueManager.Web.ViewModels | ||
|
||
<div @attributes=AdditionalAttributes> | ||
@{ | ||
var name = ChampSeason?.ChampionshipName ?? Championship.Name; | ||
var displayName = ChampSeason?.ChampionshipDisplayName ?? Championship.DisplayName; | ||
} | ||
<div class="d-flex"> | ||
<h5>@name</h5> | ||
@if (string.IsNullOrEmpty(displayName) == false && displayName != name) | ||
{ | ||
<i> => "@displayName"</i> | ||
} | ||
</div> | ||
@if (ChampSeason is not null) | ||
{ | ||
<div class="row"> | ||
<div class="col-5"> | ||
<h6>Result Configurations</h6> | ||
<ul> | ||
@foreach(var config in ChampSeason.ResultConfigs) | ||
{ | ||
<li>@config.Name</li> | ||
} | ||
</ul> | ||
</div> | ||
<div class="col-5"> | ||
<h6>Standings</h6> | ||
<ul> | ||
<li>Count @ChampSeason.StandingConfig?.WeeksCounted weeks</li> | ||
</ul> | ||
</div> | ||
</div> | ||
} | ||
</div> | ||
|
||
|
||
@code { | ||
[Parameter(CaptureUnmatchedValues=true)] | ||
public IDictionary<string, object>? AdditionalAttributes { get; set; } | ||
|
||
[Parameter, EditorRequired] | ||
public ChampionshipViewModel Championship { get; set; } = default!; | ||
|
||
[Parameter, EditorRequired] | ||
public ChampSeasonViewModel? ChampSeason { get; set; } | ||
|
||
protected override void OnParametersSet() | ||
{ | ||
_ = Championship ?? throw BlazorParameterNullException.New(this, Championship); | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
src/iRLeagueManager.Web/Components/Settings/EditChampSeasonModal.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
@using iRLeagueApiCore.Common.Models; | ||
@inherits EditModalBase<ChampSeasonViewModel, ChampSeasonModel> | ||
|
||
<EditForm Model="Vm" OnValidSubmit=Submit> | ||
<StatusResultValidator @ref=ResultValidator /> | ||
<div class="accordion mb-3"> | ||
<div class="accordion-item"> | ||
<h2 class="accordion-header"> | ||
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseChampionship" aria-expanded="true" aria-controls="collapseChampionship"> | ||
Championship | ||
</button> | ||
</h2> | ||
<div class="accordion-collapse collapse show input-group-list input-group-list-flush" id="collapseChampionship"> | ||
<InputGroup Label="Name"> | ||
<InputText class="form-control" @bind-Value=Vm.ChampionshipName placeholder="Enter championship name ..." data-bs-toggle="tooltip" title="Name to identify the championship" /> | ||
</InputGroup> | ||
<InputGroup Label="Display Name"> | ||
<InputText class="form-control" @bind-Value=Vm.ChampionshipDisplayName placeholder="@Vm.ChampionshipName" data-bs-toggle="tooltip" title="Name of the championship to be shown displayed on results and standings" /> | ||
</InputGroup> | ||
</div> | ||
</div> | ||
<div class="accordion-item"> | ||
<h2 class="accordion-header"> | ||
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseResults" aria-expanded="true" aria-controls="collapseResults"> | ||
Race Results | ||
</button> | ||
</h2> | ||
<div class="accordion-collapse collapse show list-group list-group-flush" id="collapseResults"> | ||
@foreach(var resultConfig in Vm.ResultConfigViewModels) | ||
{ | ||
<div class="list-group-item list-group-item-action d-flex justify-content-between" type="button" @onclick=@(() => OnResultConfigClick(resultConfig))> | ||
<ResultConfigPreview ResultConfig="resultConfig" class="overflow-auto"/> | ||
<div class="d-flex align-self-start"> | ||
<button class="btn btn-toggle" type="button" data-bs-toggle="collapse" data-bs-target="#config_@(resultConfig.ResultConfigId)_details" | ||
aria-expanded="false" @onclick:stopPropagation> | ||
<span class="oi oi-chevron-bottom btn-toggle-off" /> | ||
<span class="oi oi-chevron-top btn-toggle-on" /> | ||
</button> | ||
<button class="btn btn-outline-danger" type="button" @onclick=@(() =>OnDeleteResultConfigClick(resultConfig)) @onclick:stopPropagation> | ||
<span class="oi oi-trash" /> | ||
</button> | ||
</div> | ||
</div> | ||
} | ||
<div class="list-group-item"> | ||
<button class="btn btn-outline-secondary" type="button" @onclick=OnAddResultConfigClick> | ||
Add Result Configuration | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="accordion-item"> | ||
<h2 class="accordion-header"> | ||
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseStandings" aria-expanded="true" aria-controls="collapseStandings"> | ||
Standings | ||
</button> | ||
</h2> | ||
<div class="accordion-collapse collapse show input-group-list input-group-list-flush" id="collapseStandings"> | ||
@if (Vm.StandingConfig is not null) | ||
{ | ||
<div class="input-group"> | ||
<div class="input-group-text"> | ||
<InputCheckbox class="form-check-input mt-0" @bind-Value=Vm.StandingConfig.UseCombinedResult /> | ||
</div> | ||
<label class="form-control" data-bs-toggle="tooltip" title="Treat events with multiple race sessions as single events (if they have a combined result). This will affect the statistics for race-nr, wins, fastest laps etc.">Treat as single event</label> | ||
</div> | ||
<InputGroup Label="Count Weeks"> | ||
<InputNumber class="form-control" @bind-Value=Vm.StandingConfig.WeeksCounted data-bs-toggle="tooltip" title="Number of races counted per season. (used for Dropweeks)" /> | ||
</InputGroup> | ||
} | ||
</div> | ||
</div> | ||
</div> | ||
<FormValidationMessage TValue=string Message=@ResultValidator?.ErrorMessage /> | ||
<CancelSubmitButtons ModelState=Vm SubmitText="Save" OnCancel=Cancel /> | ||
</EditForm> | ||
|
||
@code { | ||
private IEnumerable<ResultConfigViewModel> ResultConfigs { get; set; } = Array.Empty<ResultConfigViewModel>(); | ||
|
||
protected override async Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
await base.OnAfterRenderAsync(firstRender); | ||
if (firstRender == false) return; | ||
|
||
await Vm.LoadResultConfigs(Cts.Token); | ||
await InvokeAsync(StateHasChanged); | ||
} | ||
|
||
private async Task OnResultConfigClick(ResultConfigViewModel config) | ||
{ | ||
var parameters = new ModalParameters<EditResultConfigModal>() | ||
.Add(x => x.Model, config.CopyModel()) | ||
.Add(x => x.OnSubmit, (configVm, cancellationToken) => configVm.SaveChangesAsync(cancellationToken)); | ||
var result = await ModalService.Show<EditResultConfigModal>("Edit result config", parameters).Result; | ||
if (result.Confirmed && result.Data is ResultConfigModel model) | ||
{ | ||
config.SetModel(model); | ||
} | ||
} | ||
|
||
private async Task OnAddResultConfigClick() | ||
{ | ||
var parameters = new ModalParameters<EditResultConfigModal>() | ||
.Add(x => x.Model, CreateResultConfig()) | ||
.Add(x => x.OnSubmit, (x, c) => Vm.AddResultConfig(x.GetModel(), c)); | ||
await ModalService.Show<EditResultConfigModal>("Add result config", parameters).Result; | ||
} | ||
|
||
private async Task OnDeleteResultConfigClick(ResultConfigViewModel config) | ||
{ | ||
var parameters = new ModalParameters<ConfirmModal>() | ||
.Add(x => x.Text, $"Really delete result config \"{config.Name}\"?") | ||
.Add(x => x.ButtonTypes, ButtonTypes.YesNo); | ||
var result = await ModalService.Show<ConfirmModal>("Delete Result Config", parameters).Result; | ||
if (result.Confirmed) | ||
{ | ||
await Vm.DeleteResultConfig(config.GetModel()); | ||
} | ||
} | ||
|
||
private ResultConfigModel CreateResultConfig() | ||
{ | ||
return new ResultConfigModel(); | ||
} | ||
} |
Oops, something went wrong.