From 1b20cea5fb2aca30c8bc79b354cafd596828d70a Mon Sep 17 00:00:00 2001 From: Abu Sadaf <116058905+sadaf895@users.noreply.github.com> Date: Tue, 12 Nov 2024 14:00:06 +0530 Subject: [PATCH] fix: dashboard widget shows correct number excluding inactive records (#2649) fixes #2647 --- .../entity-count-dashboard.component.ts | 9 +++++++-- .../entity-count-dashboard.stories.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/features/dashboard-widgets/entity-count-dashboard-widget/entity-count-dashboard/entity-count-dashboard.component.ts b/src/app/features/dashboard-widgets/entity-count-dashboard-widget/entity-count-dashboard/entity-count-dashboard.component.ts index 4e7bf4f6bc..0b10131ed6 100644 --- a/src/app/features/dashboard-widgets/entity-count-dashboard-widget/entity-count-dashboard/entity-count-dashboard.component.ts +++ b/src/app/features/dashboard-widgets/entity-count-dashboard-widget/entity-count-dashboard/entity-count-dashboard.component.ts @@ -136,11 +136,16 @@ export class EntityCountDashboardComponent this.label = this._entity.labelPlural; this.entityIcon = this._entity.icon; + // Load all entities of the specified type const entities = await this.entityMapper.loadType(this._entity); - this.totalEntities = entities.length; + + // Filter entities to only include active ones for the total count + const activeEntities = entities.filter((e) => e.isActive); + + this.totalEntities = activeEntities.length; for (const groupByField of this.groupBy) { this.entityGroupCounts[groupByField] = this.calculateGroupCounts( - entities.filter((e) => e.isActive), + activeEntities, groupByField, ); } diff --git a/src/app/features/dashboard-widgets/entity-count-dashboard-widget/entity-count-dashboard/entity-count-dashboard.stories.ts b/src/app/features/dashboard-widgets/entity-count-dashboard-widget/entity-count-dashboard/entity-count-dashboard.stories.ts index 92ec77b99b..94679a5642 100644 --- a/src/app/features/dashboard-widgets/entity-count-dashboard-widget/entity-count-dashboard/entity-count-dashboard.stories.ts +++ b/src/app/features/dashboard-widgets/entity-count-dashboard-widget/entity-count-dashboard/entity-count-dashboard.stories.ts @@ -39,6 +39,6 @@ const Template: StoryFn = ( export const Primary = { args: { entityType: "TestEntity", - groupBy: ["other"], + groupBy: ["category", "other"], }, };