fix colorpicker:
1. Neues Feld _colorValue für direkten String-Wert 2. OnInitialized: _colorValue direkt aus Category.Color geladen 3. MudColorPicker: ValueChanged="OnColorChanged" statt @bind-Value 4. Neue OnColorChanged Methode aktualisiert beide Felder 5. DTOs verwenden jetzt _colorValue statt _color?.Value
This commit is contained in:
parent
7afc242be4
commit
fbfdb74cad
|
|
@ -54,14 +54,15 @@
|
|||
<MudText Typo="Typo.subtitle2" Class="mb-2">Darstellung</MudText>
|
||||
|
||||
<MudStack Row="true" Spacing="4" Class="mb-4">
|
||||
<MudColorPicker @bind-Value="_color"
|
||||
<MudColorPicker Value="_color"
|
||||
ValueChanged="OnColorChanged"
|
||||
Label="Farbe"
|
||||
DisableAlpha="true"
|
||||
ColorPickerMode="ColorPickerMode.HEX"
|
||||
Style="width: 150px;" />
|
||||
@if (!string.IsNullOrWhiteSpace(_color?.Value))
|
||||
@if (!string.IsNullOrWhiteSpace(_colorValue))
|
||||
{
|
||||
<MudIcon Icon="@Icons.Material.Filled.Circle" Style="@($"color: {_color.Value}; align-self: center;")" />
|
||||
<MudIcon Icon="@Icons.Material.Filled.Circle" Style="@($"color: {_colorValue}; align-self: center;")" />
|
||||
}
|
||||
</MudStack>
|
||||
|
||||
|
|
@ -109,6 +110,7 @@
|
|||
private string? _description;
|
||||
private BookingCategoryType _categoryType = BookingCategoryType.Income;
|
||||
private MudColor? _color;
|
||||
private string? _colorValue;
|
||||
private string? _icon;
|
||||
private bool _isActive = true;
|
||||
|
||||
|
|
@ -139,6 +141,7 @@
|
|||
_name = Category.Name;
|
||||
_description = Category.Description;
|
||||
_categoryType = Category.CategoryType;
|
||||
_colorValue = Category.Color;
|
||||
_color = string.IsNullOrWhiteSpace(Category.Color) ? null : new MudColor(Category.Color);
|
||||
_icon = Category.Icon;
|
||||
_isActive = Category.IsActive;
|
||||
|
|
@ -152,6 +155,12 @@
|
|||
_ => type.ToString()
|
||||
};
|
||||
|
||||
private void OnColorChanged(MudColor? color)
|
||||
{
|
||||
_color = color;
|
||||
_colorValue = color?.Value;
|
||||
}
|
||||
|
||||
private void Cancel() => MudDialog?.Cancel();
|
||||
|
||||
private void Submit()
|
||||
|
|
@ -165,7 +174,7 @@
|
|||
Id = Category!.Id,
|
||||
Name = _name,
|
||||
Description = _description,
|
||||
Color = _color?.Value,
|
||||
Color = _colorValue,
|
||||
Icon = _icon,
|
||||
IsActive = Category.IsSystemCategory ? true : _isActive
|
||||
};
|
||||
|
|
@ -178,7 +187,7 @@
|
|||
Name = _name,
|
||||
Description = _description,
|
||||
CategoryType = _categoryType,
|
||||
Color = _color?.Value,
|
||||
Color = _colorValue,
|
||||
Icon = _icon
|
||||
};
|
||||
MudDialog?.Close(DialogResult.Ok(dto));
|
||||
|
|
|
|||
Loading…
Reference in New Issue