Skip to content

Commit 4eb785f

Browse files
PhantomDaveCopilot
andauthored
feat: Implement GraphQL mutations and service for dashboard and widget management (#162)
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent 4a032f7 commit 4eb785f

24 files changed

+1394
-335
lines changed

PhantomDave.BankTracking.Api/Types/Inputs/AddWidgetInput.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,4 @@ public sealed class AddWidgetInput
1010
public int Y { get; init; }
1111
public int Rows { get; init; }
1212
public int Cols { get; init; }
13-
public string? Title { get; init; }
14-
public string? Subtitle { get; init; }
15-
public string? Config { get; init; }
1613
}

PhantomDave.BankTracking.Api/Types/Inputs/UpdateWidgetInput.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,4 @@ public sealed class UpdateWidgetInput
1010
public int? Y { get; init; }
1111
public int? Rows { get; init; }
1212
public int? Cols { get; init; }
13-
public string? Title { get; init; }
14-
public string? Subtitle { get; init; }
15-
public string? Config { get; init; }
1613
}

PhantomDave.BankTracking.Api/Types/Mutations/DashboardWidgetMutations.cs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,14 @@ public async Task<DashboardWidgetType> AddWidget(
3838
.Build());
3939
}
4040

41-
var title = ValidateAndTrimString(input.Title, "title");
42-
var subtitle = ValidateAndTrimString(input.Subtitle, "subtitle");
43-
4441
var widget = new DashboardWidget
4542
{
4643
DashboardId = input.DashboardId,
4744
Type = input.Type,
4845
X = Math.Max(0, input.X),
4946
Y = Math.Max(0, input.Y),
5047
Rows = input.Rows,
51-
Cols = input.Cols,
52-
Title = title,
53-
Subtitle = subtitle,
54-
Config = input.Config
48+
Cols = input.Cols
5549
};
5650

5751
await unitOfWork.DashboardWidgets.AddAsync(widget);
@@ -131,21 +125,6 @@ public async Task<DashboardWidgetType> UpdateWidget(
131125
widget.Cols = input.Cols.Value;
132126
}
133127

134-
if (input.Title is not null)
135-
{
136-
widget.Title = ValidateAndTrimString(input.Title, "title");
137-
}
138-
139-
if (input.Subtitle is not null)
140-
{
141-
widget.Subtitle = ValidateAndTrimString(input.Subtitle, "subtitle");
142-
}
143-
144-
if (input.Config is not null)
145-
{
146-
widget.Config = input.Config;
147-
}
148-
149128
await unitOfWork.DashboardWidgets.UpdateAsync(widget);
150129
await unitOfWork.SaveChangesAsync();
151130

@@ -185,20 +164,4 @@ public async Task<bool> RemoveWidget(
185164

186165
return true;
187166
}
188-
189-
private static string? ValidateAndTrimString(string? value, string fieldName)
190-
{
191-
if (value is null) return null;
192-
193-
var trimmed = value.Trim();
194-
if (string.IsNullOrEmpty(trimmed))
195-
{
196-
throw new GraphQLException(
197-
ErrorBuilder.New()
198-
.SetMessage($"Widget {fieldName} cannot be empty or whitespace.")
199-
.SetCode("BAD_USER_INPUT")
200-
.Build());
201-
}
202-
return trimmed;
203-
}
204167
}

PhantomDave.BankTracking.Api/Types/ObjectTypes/DashboardWidgetType.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ public class DashboardWidgetType
66
{
77
public int Id { get; set; }
88
public WidgetType WidgetType { get; set; }
9-
public string? Title { get; set; }
10-
public string? Subtitle { get; set; }
11-
public string? Config { get; set; }
129
public int Cols { get; set; }
1310
public int Rows { get; set; }
1411
public int X { get; set; }
@@ -20,9 +17,6 @@ public static DashboardWidgetType FromDashboardWidget(DashboardWidget widget)
2017
{
2118
Id = widget.Id,
2219
WidgetType = widget.Type,
23-
Title = widget.Title,
24-
Subtitle = widget.Subtitle,
25-
Config = widget.Config,
2620
Cols = widget.Cols,
2721
Rows = widget.Rows,
2822
X = widget.X,

PhantomDave.BankTracking.Data/Migrations/20251209095546_RemoveWidgetMetadataFields.Designer.cs

Lines changed: 268 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)