button add is OK

teams
samuel 10 months ago committed by sam
parent 0a9f7db736
commit 98e6386d36

@ -12,7 +12,7 @@
<MudTextField T="string" Label="MainColor" Required="true" @bind-Value="FormMainColor" RequiredError="Main color is required!"/> <MudTextField T="string" Label="MainColor" Required="true" @bind-Value="FormMainColor" RequiredError="Main color is required!"/>
<MudTextField T="string" Label="SecondaryColor" Required="true" @bind-Value="FormSecondaryColor" RequiredError="Secondary color is required!"/> <MudTextField T="string" Label="SecondaryColor" Required="true" @bind-Value="FormSecondaryColor" RequiredError="Secondary color is required!"/>
<div class="d-flex justify-center"> <div class="d-flex justify-center">
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@AddTeam" Class="ml-auto">Apply</MudButton> <MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@AddTeamConfirmed" Class="ml-auto">Apply</MudButton>
</div> </div>
</MudForm> </MudForm>
<MudButton OnClick="@ToggleOpen" Class="ml-auto mr-n3 mb-1" Color="Color.Error">Close</MudButton> <MudButton OnClick="@ToggleOpen" Class="ml-auto mr-n3 mb-1" Color="Color.Error">Close</MudButton>

@ -11,16 +11,16 @@ public partial class TeamListPanel
[Inject] [Inject]
private ITeamService TeamService { get; init; } private ITeamService TeamService { get; init; }
private bool _isOpen; private bool _isOpen;
private MudForm form;
bool success;
string[] errors = { };
private string? FormName { get; set; } private string? FormName { get; set; }
private string? FormPicture { get; set; } private string? FormPicture { get; set; }
private string? FormMainColor { get; set; } private string? FormMainColor { get; set; }
private string? FormSecondaryColor { get; set; } private string? FormSecondaryColor { get; set; }
private MudForm form;
bool success;
string[] errors = { };
MudTextField<string> pwField1;
private async Task<GridData<Team>> GetTeamsFromServer(GridState<Team> state) private async Task<GridData<Team>> GetTeamsFromServer(GridState<Team> state)
@ -33,17 +33,20 @@ public partial class TeamListPanel
}; };
} }
private void ToggleOpen() private void ToggleOpen()
{ {
if (_isOpen) _isOpen = !(_isOpen);
_isOpen = false;
else
_isOpen = true;
} }
private async void AddTeam() private async void AddTeam()
{ {
await TeamService.AddTeam(FormName!,FormPicture!,FormMainColor!,FormSecondaryColor!); await TeamService.AddTeam(FormName!,FormPicture!,FormMainColor!,FormSecondaryColor!);
} }
private void AddTeamConfirmed()
{
AddTeam();
ToggleOpen();
}
} }

Loading…
Cancel
Save