From 1f9124dfa7d9d0d8d61b094e71bf1a69b456bc00 Mon Sep 17 00:00:00 2001 From: tschumpr Date: Wed, 7 Aug 2024 15:45:13 +0200 Subject: [PATCH] Only return borehole count --- src/api/Controllers/WorkgroupController.cs | 8 -------- src/api/Models/Workgroup.cs | 2 ++ src/client/src/api/apiInterfaces.ts | 2 +- src/client/src/pages/settings/admin/adminSettings.jsx | 6 +++--- tests/Controllers/WorkgroupControllerTest.cs | 4 ++-- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/api/Controllers/WorkgroupController.cs b/src/api/Controllers/WorkgroupController.cs index 85f52db19..6349e34c3 100644 --- a/src/api/Controllers/WorkgroupController.cs +++ b/src/api/Controllers/WorkgroupController.cs @@ -36,14 +36,6 @@ public async Task> GetAll() .ToListAsync() .ConfigureAwait(false); - foreach (var workgroup in workgroups) - { - if (workgroup.Boreholes != null) - { - workgroup.Boreholes = workgroup.Boreholes.Select(b => new Borehole() { Id = b.Id }).ToList(); - } - } - return workgroups; } diff --git a/src/api/Models/Workgroup.cs b/src/api/Models/Workgroup.cs index 1765914d9..edbdde12f 100644 --- a/src/api/Models/Workgroup.cs +++ b/src/api/Models/Workgroup.cs @@ -1,5 +1,6 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using System.Text.Json.Serialization; namespace BDMS.Models; @@ -52,6 +53,7 @@ public class Workgroup : IIdentifyable /// /// Gets the boreholes for the workgroup. /// + [JsonIgnore] public ICollection? Boreholes { get; set; } /// diff --git a/src/client/src/api/apiInterfaces.ts b/src/client/src/api/apiInterfaces.ts index 08697eff5..f0796550b 100644 --- a/src/client/src/api/apiInterfaces.ts +++ b/src/client/src/api/apiInterfaces.ts @@ -14,7 +14,7 @@ export interface Workgroup { createdAt?: Date | string; settings?: string; isSupplier?: boolean; - boreholesCount: number; + boreholeCount: number; } export interface WorkgroupRole { diff --git a/src/client/src/pages/settings/admin/adminSettings.jsx b/src/client/src/pages/settings/admin/adminSettings.jsx index 6d3bd289d..c619ab834 100644 --- a/src/client/src/pages/settings/admin/adminSettings.jsx +++ b/src/client/src/pages/settings/admin/adminSettings.jsx @@ -779,7 +779,7 @@ class AdminSettings extends React.Component { />

- ) : this.state.deleteWorkgroup.boreholesCount === 0 ? ( + ) : this.state.deleteWorkgroup.boreholeCount === 0 ? (

@@ -906,7 +906,7 @@ class AdminSettings extends React.Component { )} {this.state.deleteWorkgroup !== null && this.state.deleteWorkgroup.disabled === null && - this.state.deleteWorkgroup.boreholesCount === 0 ? ( + this.state.deleteWorkgroup.boreholeCount === 0 ? (