-
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 #28 from SSchulze1989/develop
v0.4.1
- Loading branch information
Showing
106 changed files
with
4,026 additions
and
2,419 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
namespace iRLeagueManager.Web.Components | ||
namespace iRLeagueManager.Web.Components; | ||
|
||
public enum ButtonTypes | ||
{ | ||
public enum ButtonTypes | ||
{ | ||
Ok, | ||
OkCancel, | ||
YesNo, | ||
} | ||
Ok, | ||
OkCancel, | ||
YesNo, | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
namespace iRLeagueManager.Web.Components | ||
namespace iRLeagueManager.Web.Components; | ||
|
||
public enum ConfirmResult | ||
{ | ||
public enum ConfirmResult | ||
{ | ||
Ok, | ||
Yes, | ||
No, | ||
Cancel | ||
} | ||
Ok, | ||
Yes, | ||
No, | ||
Cancel | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using Blazored.Modal; | ||
using Blazored.Modal.Services; | ||
using iRLeagueManager.Web.Data; | ||
using iRLeagueManager.Web.Exceptions; | ||
using iRLeagueManager.Web.Shared; | ||
using iRLeagueManager.Web.ViewModels; | ||
using Microsoft.AspNetCore.Components; | ||
using MvvmBlazor.Components; | ||
|
||
namespace iRLeagueManager.Web.Components; | ||
|
||
public class EditModalBase<TViewModel, TModel> : MvvmComponentBase where TViewModel : LeagueViewModelBase<TViewModel, TModel> | ||
{ | ||
[Inject] | ||
protected TViewModel Vm { get; set; } = default!; | ||
|
||
[CascadingParameter] | ||
public BlazoredModalInstance ModalInstance { get; set; } = default!; | ||
[CascadingParameter] | ||
public IModalService ModalService { get; set; } = default!; | ||
|
||
private TModel model = default!; | ||
[Parameter, EditorRequired] | ||
public TModel Model | ||
{ | ||
get => model; | ||
set | ||
{ | ||
if (EqualityComparer<TModel>.Default.Equals(model, value) == false) | ||
{ | ||
model = value; | ||
Vm.SetModel(model); | ||
} | ||
} | ||
} | ||
|
||
[Parameter] | ||
public Func<TViewModel, CancellationToken, Task<StatusResult>>? OnSubmit { get; set; } | ||
[Parameter] | ||
public Func<TViewModel, CancellationToken, Task>? OnCancel { get; set; } | ||
|
||
private CancellationTokenSource cts = new(); | ||
protected StatusResultValidator? ResultValidator { get; set; } | ||
|
||
protected override void OnParametersSet() | ||
{ | ||
_ = ModalInstance ?? throw BlazorParameterNullException.New(this, ModalInstance); | ||
_ = ModalService ?? throw BlazorParameterNullException.New(this, ModalService); | ||
_ = Model ?? throw BlazorParameterNullException.New(this, Model); | ||
} | ||
|
||
protected virtual 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); | ||
} | ||
} | ||
|
||
protected virtual async Task Cancel() | ||
{ | ||
if (OnCancel is not null) | ||
{ | ||
await OnCancel(Vm, cts.Token); | ||
} | ||
await ModalInstance.CancelAsync(); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
if (disposing == false) | ||
{ | ||
cts.Cancel(); | ||
cts.Dispose(); | ||
} | ||
base.Dispose(disposing); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.Forms; | ||
using Microsoft.AspNetCore.Components.Rendering; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace iRLeagueManager.Web.Components; | ||
|
||
public class InputTimeSpan : InputBase<TimeSpan> | ||
{ | ||
/// <summary> | ||
/// Gets or sets the associated <see cref="ElementReference"/>. | ||
/// <para> | ||
/// May be <see langword="null"/> if accessed before the component is rendered. | ||
/// </para> | ||
/// </summary> | ||
[DisallowNull] public ElementReference? Element { get; protected set; } | ||
|
||
protected override bool TryParseValueFromString(string? value, [MaybeNullWhen(false)] out TimeSpan result, [NotNullWhen(false)] out string? validationErrorMessage) | ||
{ | ||
if (TimeSpan.TryParse(value, out result) == false) | ||
{ | ||
validationErrorMessage = "Input is not a valid time span format"; | ||
result = TimeSpan.Zero; | ||
return false; | ||
} | ||
validationErrorMessage = null; | ||
return true; | ||
} | ||
|
||
protected override void BuildRenderTree(RenderTreeBuilder builder) | ||
{ | ||
builder.OpenElement(0, "input"); | ||
builder.AddMultipleAttributes(1, AdditionalAttributes); | ||
builder.AddAttribute(2, "type", "time"); | ||
builder.AddAttribute(3, "class", CssClass); | ||
builder.AddAttribute(4, "value", BindConverter.FormatValue(CurrentValueAsString)); | ||
builder.AddAttribute(5, "onchange", EventCallback.Factory.CreateBinder<string?>(this, __value => CurrentValueAsString = __value, CurrentValueAsString)); | ||
builder.AddElementReferenceCapture(6, __inputReference => Element = __inputReference); | ||
builder.CloseElement(); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
src/iRLeagueManager.Web/Components/Reviews/EditReviewResultModal.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
Oops, something went wrong.