From 6e544361a3ca899aef239d92429035ed8ec7580b Mon Sep 17 00:00:00 2001 From: korecko Date: Wed, 1 Jul 2026 18:25:57 +0200 Subject: [PATCH 1/2] improvements --- Ticky.Base/Models/LabelModel.cs | 8 ++++---- Ticky.Web/Components/Dialogs/AddLabelModal.razor | 14 +++++++------- Ticky.Web/Components/Dialogs/EditLabelModal.razor | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Ticky.Base/Models/LabelModel.cs b/Ticky.Base/Models/LabelModel.cs index ad83bc3..7a4498b 100644 --- a/Ticky.Base/Models/LabelModel.cs +++ b/Ticky.Base/Models/LabelModel.cs @@ -6,11 +6,11 @@ public class LabelModel [Display(Name = "Label text")] public string Text { get; set; } = string.Empty; - [Required(AllowEmptyStrings = false)] + [Required] [Display(Name = "Text color")] - public Color? TextColor { get; set; } + public Color TextColor { get; set; } = Color.White; - [Required(AllowEmptyStrings = false)] + [Required] [Display(Name = "Background color")] - public Color? BackgroundColor { get; set; } + public Color BackgroundColor { get; set; } = Color.Red; } diff --git a/Ticky.Web/Components/Dialogs/AddLabelModal.razor b/Ticky.Web/Components/Dialogs/AddLabelModal.razor index 907fe81..b25d095 100644 --- a/Ticky.Web/Components/Dialogs/AddLabelModal.razor +++ b/Ticky.Web/Components/Dialogs/AddLabelModal.razor @@ -16,13 +16,13 @@
- +
- +
@@ -53,8 +53,8 @@ { BoardId = board.Id, Name = "Example", - BackgroundColor = Color.AliceBlue, - TextColor = Color.Black + BackgroundColor = _labelModel.BackgroundColor, + TextColor = _labelModel.TextColor }; _editContext = new EditContext(_labelModel); @@ -111,8 +111,8 @@ { BoardId = board.Id, Name = _labelModel.Text, - TextColor = _labelModel.TextColor!.Value, - BackgroundColor = _labelModel.BackgroundColor!.Value + TextColor = _labelModel.TextColor, + BackgroundColor = _labelModel.BackgroundColor }); await db.SaveChangesAsync(); @@ -122,4 +122,4 @@ await OnSubmit.InvokeAsync(); Modal?.Close(); } -} \ No newline at end of file +} diff --git a/Ticky.Web/Components/Dialogs/EditLabelModal.razor b/Ticky.Web/Components/Dialogs/EditLabelModal.razor index db4c0f2..6172968 100644 --- a/Ticky.Web/Components/Dialogs/EditLabelModal.razor +++ b/Ticky.Web/Components/Dialogs/EditLabelModal.razor @@ -16,13 +16,13 @@
- +
- +
@@ -63,7 +63,7 @@ BackgroundColor = label.BackgroundColor, TextColor = label.TextColor }; - _editContext = new EditContext(_board); + _editContext = new EditContext(_labelModel); base.Open(); } @@ -121,8 +121,8 @@ targetLabel.BoardId = board.Id; targetLabel.Name = _labelModel.Text; - targetLabel.TextColor = _labelModel.TextColor!.Value; - targetLabel.BackgroundColor = _labelModel.BackgroundColor!.Value; + targetLabel.TextColor = _labelModel.TextColor; + targetLabel.BackgroundColor = _labelModel.BackgroundColor; await db.SaveChangesAsync(); @@ -131,4 +131,4 @@ await OnSubmit.InvokeAsync(); Modal?.Close(); } -} \ No newline at end of file +} From 5199bd2a2b0c9a357da608b713eaeb186d0a7716 Mon Sep 17 00:00:00 2001 From: korecko <22599403+dkorecko@users.noreply.github.com> Date: Wed, 1 Jul 2026 19:15:04 +0200 Subject: [PATCH 2/2] improvements --- Ticky.Base/Models/LabelModel.cs | 4 ++-- Ticky.Internal/Helpers/ColorHelper.cs | 8 ++++++++ Ticky.Web/Components/Dialogs/AddLabelModal.razor | 4 ++-- Ticky.Web/Components/Dialogs/EditLabelModal.razor | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 Ticky.Internal/Helpers/ColorHelper.cs diff --git a/Ticky.Base/Models/LabelModel.cs b/Ticky.Base/Models/LabelModel.cs index 7a4498b..79e425a 100644 --- a/Ticky.Base/Models/LabelModel.cs +++ b/Ticky.Base/Models/LabelModel.cs @@ -6,11 +6,11 @@ public class LabelModel [Display(Name = "Label text")] public string Text { get; set; } = string.Empty; - [Required] + [Required(AllowEmptyStrings = false)] [Display(Name = "Text color")] public Color TextColor { get; set; } = Color.White; - [Required] + [Required(AllowEmptyStrings = false)] [Display(Name = "Background color")] public Color BackgroundColor { get; set; } = Color.Red; } diff --git a/Ticky.Internal/Helpers/ColorHelper.cs b/Ticky.Internal/Helpers/ColorHelper.cs new file mode 100644 index 0000000..7a7e349 --- /dev/null +++ b/Ticky.Internal/Helpers/ColorHelper.cs @@ -0,0 +1,8 @@ +using System.Drawing; + +namespace Ticky.Internal.Helpers; + +public static class ColorHelper +{ + public static string ToColorInputValue(this Color color) => $"#{color.R:X2}{color.G:X2}{color.B:X2}"; +} diff --git a/Ticky.Web/Components/Dialogs/AddLabelModal.razor b/Ticky.Web/Components/Dialogs/AddLabelModal.razor index b25d095..a7f0d3a 100644 --- a/Ticky.Web/Components/Dialogs/AddLabelModal.razor +++ b/Ticky.Web/Components/Dialogs/AddLabelModal.razor @@ -16,13 +16,13 @@
- +
- +
diff --git a/Ticky.Web/Components/Dialogs/EditLabelModal.razor b/Ticky.Web/Components/Dialogs/EditLabelModal.razor index 6172968..16ca968 100644 --- a/Ticky.Web/Components/Dialogs/EditLabelModal.razor +++ b/Ticky.Web/Components/Dialogs/EditLabelModal.razor @@ -16,13 +16,13 @@
- +
- +