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:
beo3000 2026-01-04 13:09:23 +01:00
parent 7afc242be4
commit fbfdb74cad
1 changed files with 14 additions and 5 deletions

View File

@ -54,14 +54,15 @@
<MudText Typo="Typo.subtitle2" Class="mb-2">Darstellung</MudText> <MudText Typo="Typo.subtitle2" Class="mb-2">Darstellung</MudText>
<MudStack Row="true" Spacing="4" Class="mb-4"> <MudStack Row="true" Spacing="4" Class="mb-4">
<MudColorPicker @bind-Value="_color" <MudColorPicker Value="_color"
ValueChanged="OnColorChanged"
Label="Farbe" Label="Farbe"
DisableAlpha="true" DisableAlpha="true"
ColorPickerMode="ColorPickerMode.HEX" ColorPickerMode="ColorPickerMode.HEX"
Style="width: 150px;" /> 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> </MudStack>
@ -109,6 +110,7 @@
private string? _description; private string? _description;
private BookingCategoryType _categoryType = BookingCategoryType.Income; private BookingCategoryType _categoryType = BookingCategoryType.Income;
private MudColor? _color; private MudColor? _color;
private string? _colorValue;
private string? _icon; private string? _icon;
private bool _isActive = true; private bool _isActive = true;
@ -139,6 +141,7 @@
_name = Category.Name; _name = Category.Name;
_description = Category.Description; _description = Category.Description;
_categoryType = Category.CategoryType; _categoryType = Category.CategoryType;
_colorValue = Category.Color;
_color = string.IsNullOrWhiteSpace(Category.Color) ? null : new MudColor(Category.Color); _color = string.IsNullOrWhiteSpace(Category.Color) ? null : new MudColor(Category.Color);
_icon = Category.Icon; _icon = Category.Icon;
_isActive = Category.IsActive; _isActive = Category.IsActive;
@ -152,6 +155,12 @@
_ => type.ToString() _ => type.ToString()
}; };
private void OnColorChanged(MudColor? color)
{
_color = color;
_colorValue = color?.Value;
}
private void Cancel() => MudDialog?.Cancel(); private void Cancel() => MudDialog?.Cancel();
private void Submit() private void Submit()
@ -165,7 +174,7 @@
Id = Category!.Id, Id = Category!.Id,
Name = _name, Name = _name,
Description = _description, Description = _description,
Color = _color?.Value, Color = _colorValue,
Icon = _icon, Icon = _icon,
IsActive = Category.IsSystemCategory ? true : _isActive IsActive = Category.IsSystemCategory ? true : _isActive
}; };
@ -178,7 +187,7 @@
Name = _name, Name = _name,
Description = _description, Description = _description,
CategoryType = _categoryType, CategoryType = _categoryType,
Color = _color?.Value, Color = _colorValue,
Icon = _icon Icon = _icon
}; };
MudDialog?.Close(DialogResult.Ok(dto)); MudDialog?.Close(DialogResult.Ok(dto));