Skip to content

Commit

Permalink
fix: dashboard widget shows correct number excluding inactive records (
Browse files Browse the repository at this point in the history
  • Loading branch information
sadaf895 authored Nov 12, 2024
1 parent a3e369f commit 1b20cea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ const Template: StoryFn<EntityCountDashboardComponent> = (
export const Primary = {
args: {
entityType: "TestEntity",
groupBy: ["other"],
groupBy: ["category", "other"],
},
};

0 comments on commit 1b20cea

Please sign in to comment.