Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v 0.4.0 #19

Merged
merged 6 commits into from
Dec 13, 2022
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
2 changes: 1 addition & 1 deletion src/iRLeagueManager.Web/Components/DisplaySchedule.razor
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
return;
}
var parameters = new ModalParameters()
.Add(nameof(EditEventModal.EventModel), new EventModel())
.Add(nameof(EditEventModal.EventModel), new EventModel() { Date = DateTime.Now.Date })
.Add(nameof(EditEventModal.OnSubmit),
new Func<EventViewModel, CancellationToken,
Task<StatusResult>>(async (@event, cancellationToken) => await Schedule.AddEvent(@event)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
var displayStartPos = resultRows.Any(x => x.StartPosition != 0);
var displayQualyLap = resultRows.Any(x => x.QualifyingTime > TimeSpan.FromSeconds(1));
}
<div class="card-body overflow-scroll m-0 p-1">
<div class="card-body overflow-scroll p-1">
<table class="table table-sm table-striped table-hover" style="font-size: 0.9rem; line-height: 1rem">
<thead>
<tr>
Expand Down
215 changes: 138 additions & 77 deletions src/iRLeagueManager.Web/Components/Settings/EditResultConfigModal.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,95 +6,156 @@

<EditForm Model=vm OnValidSubmit=Submit>
<StatusResultValidator @ref=ResultValidator />
<div class="input-group-list mb-2">
<InputGroup Label="Name">
<InputText class="form-control" id="input-name" placeholder="Name..." aria-label="input-name" @bind-Value=vm.Name/>
</InputGroup>
<InputGroup Label="Show as">
<InputText class="form-control" id="input-display-name" placeholder="Show as ..." aria-label="input-display-name" @bind-Value=vm.DisplayName/>
</InputGroup>
<InputGroup Label="Type">
<InputSelect class="form-select" id="input-type" placeholder="Type..." aria-label="input-type" @bind-Value=vm.ResultKind>
<option [email protected]>Member</option>
<option [email protected]>Team</option>
</InputSelect>
</InputGroup>
<InputGroup Label="Source">
<InputSelect class="form-select" id="input-source" placeholder="Source..." aria-label="input-source" @bind-Value=vm.SourceResultConfigId>
<option value="0">Raw</option>
@foreach(var config in @Bind(vm, x => x.AvailableResultConfigs).Where(CanSelectAsSourceConfig))
<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="#collapseGeneralSettings" aria-expanded="true" aria-controls="collapseGeneralSettings">
General Settings
</button>
</h2>
<div class="accordion-collapse collapse show input-group-list input-group-list-flush" id="collapseGeneralSettings">
<InputGroup Label="Name">
<InputText class="form-control" id="input-name" placeholder="Name..." aria-label="input-name" @bind-Value=vm.Name/>
</InputGroup>
<InputGroup Label="Show as">
<InputText class="form-control" id="input-display-name" placeholder="Show as ..." aria-label="input-display-name" @bind-Value=vm.DisplayName/>
</InputGroup>
<InputGroup Label="Type">
<InputSelect class="form-select" id="input-type" placeholder="Type..." aria-label="input-type" @bind-Value=vm.ResultKind>
<option [email protected]>Member</option>
<option [email protected]>Team</option>
</InputSelect>
</InputGroup>
<InputGroup Label="Source">
<InputSelect class="form-select" id="input-source" placeholder="Source..." aria-label="input-source" @bind-Value=vm.SourceResultConfigId>
<option value="0">Raw</option>
@foreach(var config in @Bind(vm, x => x.AvailableResultConfigs).Where(CanSelectAsSourceConfig))
{
<option [email protected]>@config.Name</option>
}
</InputSelect>
</InputGroup>
@if (vm.ResultKind == ResultKind.Team)
{
<option [email protected]>@config.Name</option>
<InputGroup Label="Results per Team">
<InputNumber class="form-control" id="input-results-per-team" aria-label="input-results-per-team" @bind-Value=vm.ResultsPerTeam/>
</InputGroup>
}
</InputSelect>
</InputGroup>
@if (vm.ResultKind == ResultKind.Team)
{
<InputGroup Label="Take">
<InputNumber class="form-control" id="input-results-per-team" aria-label="input-results-per-team" @bind-Value=vm.ResultsPerTeam/>
</InputGroup>
}
</div>
</div>
</div>

<div class="input-group-list mb-2">
<InputGroup Label="Points Filter">
<button class="form-control" type="button" @onclick=PointsFilterClick>
@if (vm.FiltersForPoints.Count == 0)
{
<span class="text-secondary"><em>Configure</em></span>
}
else
{
<span class="text-secondary">@vm.FiltersForPoints.Count filters applied</span>
}
</button>
</InputGroup>
<InputGroup Label="Result Filter">
<button class="form-control" type="button" @onclick=ResultFilterClick>
@if (vm.FiltersForResult.Count == 0)
{
<span class="text-secondary"><em>Configure</em></span>
}
else
{
<span class="text-secondary">@vm.FiltersForResult.Count filters applied</span>
}
</button>
</InputGroup>
</div>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseFilters" aria-expanded="false" aria-controls="collapseFilters">
Filters
</button>
</h2>
<div class="accordion-collapse collapse input-group-list input-group-list-flush" id="collapseFilters">
<InputGroup Label="Points Filter">
<button class="form-control" type="button" @onclick=PointsFilterClick>
@if (vm.FiltersForPoints.Count == 0)
{
<span class="text-secondary"><em>Configure</em></span>
}
else
{
<span class="text-secondary">@vm.FiltersForPoints.Count filters applied</span>
}
</button>
</InputGroup>
<InputGroup Label="Result Filter">
<button class="form-control" type="button" @onclick=ResultFilterClick>
@if (vm.FiltersForResult.Count == 0)
{
<span class="text-secondary"><em>Configure</em></span>
}
else
{
<span class="text-secondary">@vm.FiltersForResult.Count filters applied</span>
}
</button>
</InputGroup>
</div>
</div>

<div class="card mb-2">
<div class="card-body">
<div class="card-title">
Session Scorings
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseSessionScorings" aria-expanded="false" aria-controls="collapseSessionScorings">
Session Scorings
</button>
</h2>
<div class="accordion-collapse collapse card" id="collapseSessionScorings">
<div class="card-body">
<div class="card-title">
Session Scorings
</div>
@foreach(var scoring in @Bind(vm, x => x.Scorings).Where(x => x.IsCombinedResult == false))
{
<div class="input-group-list mb-3">
<div class="input-group">
<InputText class="form-control" id="scoring-name" aria-label="scoring-name" placeholder="Name..." @bind-Value=scoring.Name/>
<button class="btn btn-outline-danger" type="button" @onclick="@(() => vm.RemoveScoring(scoring))"><span class="oi oi-trash"/></button>
</div>
<EditScoring Scoring=scoring />
</div>
}
<div class="mt-3">
<button class="btn btn-outline-secondary" type="button" @onclick="@(() => vm.AddScoring())">Add Scoring</button>
</div>
</div>
</div>
@foreach(var scoring in @Bind(vm, x => x.Scorings).Where(x => x.IsCombinedResult == false))
{
<div class="input-group-list mb-3">
<div class="input-group">
<InputText class="form-control" id="scoring-name" aria-label="scoring-name" placeholder="Name..." @bind-Value=scoring.Name/>
<button class="btn btn-outline-danger" type="button" @onclick="@(() => vm.RemoveScoring(scoring))"><span class="oi oi-trash"/></button>
</div>

<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseCombined" aria-expanded="false" aria-controls="collapseCombined">
Combined Result
</button>
</h2>
<div class="accordion-collapse collapse input-group-list input-group-list-flush" id="collapseCombined">
<div class="input-group" disabled>
<div class="input-group-text">
<InputCheckbox class="form-check-input mt-0" @bind-Value=vm.CalculateCombinedResult/>
</div>
<EditScoring Scoring=scoring />
<label class="form-control">Get Combined Result</label>
</div>
}
<div class="mt-3">
<button class="btn btn-outline-secondary" type="button" @onclick="@(() => vm.AddScoring())">Add Scoring</button>
@if (vm.CalculateCombinedResult)
{
<EditScoring Scoring=@(vm.Scorings.First(x => x.IsCombinedResult)) />
}
</div>
</div>
</div>

<div class="input-group-list mb-3">
<div class="input-group" disabled>
<div class="input-group-text">
<InputCheckbox class="form-form-check-input mt-0" @bind-Value=vm.CalculateCombinedResult/>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseStandings" aria-expanded="false" aria-controls="collapseStandings">
Standings
</button>
</h2>
<div class="accordion-collapse collapse input-group-list input-group-list-flush" id="collapseStandings">
<div class="input-group" disabled>
<div class="input-group-text">
<InputCheckbox class="form-check-input mt-0" @bind-Value=vm.CalculateStandings />
</div>
<label class="form-control">Calculate Standings</label>
</div>
@if (vm.CalculateStandings && vm.StandingConfig is not null)
{
@if (vm.CalculateCombinedResult)
{
<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">Use combined Result</label>
</div>
}
<InputGroup Label="Count Weeks">
<InputNumber class="form-control" @bind-Value=vm.StandingConfig.WeeksCounted />
</InputGroup>
}
</div>
<label class="form-control">Get Combined Result</label>
</div>
@if (vm.CalculateCombinedResult)
{
<EditScoring Scoring=@(vm.Scorings.First(x => x.IsCombinedResult)) />
}
</div>
<FormValidationMessage TValue=string Message=@ResultValidator?.ErrorMessage />
<CancelSubmitButtons ModelState=vm SubmitText="Save" OnCancel=Cancel/>
Expand Down
76 changes: 76 additions & 0 deletions src/iRLeagueManager.Web/Components/Settings/EditSeasonModal.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
@inherits MvvmComponentBase
@using iRLeagueApiCore.Common.Enums
@using iRLeagueApiCore.Common.Models
@using iRLeagueManager.Web.ViewModels
@inject SeasonViewModel vm

<EditForm Model=vm OnValidSubmit=Submit>
<StatusResultValidator @ref=ResultValidator />
<div class="input-group-list">
<InputGroup Label="Name">
<InputText class="form-control" @bind-Value=vm.Name />
</InputGroup>
<div class="input-group disabled">
<div class="input-group-text">
<InputCheckbox class="form-check" @bind-Value=vm.Finished />
</div>
<label class="form-control">Finished</label>
</div>
</div>
<FormValidationMessage TValue=string Message=@ResultValidator?.ErrorMessage />
<CancelSubmitButtons ModelState=vm SubmitText="Save" OnCancel=Cancel/>
</EditForm>

@code {
[CascadingParameter]
public BlazoredModalInstance ModalInstance { get; set; } = default!;
[Parameter]
public SeasonModel Model { get; set; } = default!;
[Parameter]
public Func<SeasonViewModel, CancellationToken, Task<StatusResult>>? OnSubmit { get; set; }

private CancellationTokenSource cts = new();

private StatusResultValidator? ResultValidator { get; set; }

protected override void OnParametersSet()
{
_ = ModalInstance ?? throw BlazorParameterNullException.New(this, ModalInstance);
_ = Model ?? throw BlazorParameterNullException.New(this, Model);
vm.SetModel(Model);
}

private async Task Submit()
{
var success = true;
if (OnSubmit is not null)
{
var status = await OnSubmit(vm, cts.Token);
success &= status.IsSuccess;
ResultValidator?.ValidateResult(status);
}
if (success)
{
var result = ModalResult.Ok(vm.GetModel());
await ModalInstance.CloseAsync(result);
}
}

private async Task Cancel()
{
if (ModalInstance != null)
{
await ModalInstance.CancelAsync();
}
}

protected override void Dispose(bool disposing)
{
if (disposing == false)
{
cts.Cancel();
cts.Dispose();
}
base.Dispose(disposing);
}
}
Loading