change participants when creating a new day
This commit is contained in:
parent
e75ea84e66
commit
965ec24d33
|
|
@ -46,7 +46,8 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
<MudChipSet T="Guid" SelectionMode="SelectionMode.MultiSelection" @bind-SelectedValues="_selectedPersonIds" Class="mb-4">
|
||||
<MudChipSet T="Guid" SelectionMode="SelectionMode.MultiSelection" CheckMark="true" @bind-SelectedValues="_selectedPersonIds"
|
||||
Class="mb-4">
|
||||
@foreach (var person in PersonState.Value.Persons.OrderByDescending(p => p.PersonStatus == PersonStatus.Member).ThenBy(p => p.Name))
|
||||
{
|
||||
<MudChip T="Guid"
|
||||
|
|
@ -64,11 +65,16 @@
|
|||
</MudChipSet>
|
||||
}
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrEmpty(_error))
|
||||
{
|
||||
<MudAlert Severity="Severity.Error">@_error</MudAlert>
|
||||
}
|
||||
</MudForm>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Abbrechen</MudButton>
|
||||
<MudButton Color="Color.Primary" Variant="Variant.Filled" Disabled="!_isValid" OnClick="Submit">
|
||||
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="Submit">
|
||||
@(IsEditMode ? "Speichern" : "Erstellen")
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
|
|
@ -82,7 +88,8 @@
|
|||
public DaySummaryDto? Day { get; set; }
|
||||
|
||||
private MudForm? _form;
|
||||
private bool _isValid;
|
||||
private string _error = string.Empty;
|
||||
private bool _isValid = true;
|
||||
private DateTime? _postDate = DateTime.Today;
|
||||
private DayStatus _status = DayStatus.New;
|
||||
private IReadOnlyCollection<Guid> _selectedPersonIds = [];
|
||||
|
|
@ -122,7 +129,10 @@
|
|||
|
||||
private void Submit()
|
||||
{
|
||||
if (!_isValid || _postDate is null) return;
|
||||
Validate();
|
||||
|
||||
if (!_isValid || _postDate is null)
|
||||
return;
|
||||
|
||||
if (IsEditMode)
|
||||
{
|
||||
|
|
@ -144,4 +154,18 @@
|
|||
MudDialog?.Close(DialogResult.Ok(dto));
|
||||
}
|
||||
}
|
||||
|
||||
private void Validate()
|
||||
{
|
||||
_error = "";
|
||||
if (_selectedPersonIds.Count < 2)
|
||||
{
|
||||
_isValid = false;
|
||||
_error = "Es müssen mindestens zwei Teilnehmer ausgewählt werden.";
|
||||
return;
|
||||
}
|
||||
|
||||
_isValid = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue