Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/improve filtering on allocations page (#900)

Thomas Kauldfa67b275c69
diff --git a/CHANGELOG.md b/CHANGELOG.md
index be70a9d5fa..ebe293e866 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## Unreleased
+
+### Changed
+
+- Improved the allocations page with no filtering (include cash positions)
+
## 1.146.3 - 08.05.2022
### Added
diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts
index 6ffdc94e1a..314cedf601 100644
--- a/apps/api/src/app/portfolio/portfolio.service.ts
+++ b/apps/api/src/app/portfolio/portfolio.service.ts
@@ -318,8 +318,8 @@ export class PortfolioService {
(user.Settings?.settings as UserSettings)?.emergencyFund ?? 0
);
const userCurrency =
- this.request.user?.Settings?.currency ??
user.Settings?.currency ??
+ this.request.user?.Settings?.currency ??
baseCurrency;
const { orders, portfolioOrders, transactionPoints } =
@@ -448,7 +448,7 @@ export class PortfolioService {
value: totalValue
});
- if (aFilters === undefined) {
+ if (aFilters?.length === 0) {
for (const symbol of Object.keys(cashPositions)) {
holdings[symbol] = cashPositions[symbol];
}
diff --git a/apps/client/src/app/components/positions-table/positions-table.component.ts b/apps/client/src/app/components/positions-table/positions-table.component.ts
index 6c5224db2e..390ba5e02e 100644
--- a/apps/client/src/app/components/positions-table/positions-table.component.ts
+++ b/apps/client/src/app/components/positions-table/positions-table.component.ts
@@ -73,11 +73,6 @@ export class PositionsTableComponent implements OnChanges, OnDestroy, OnInit {
}
}
- /*public applyFilter(event: Event) {
- const filterValue = (event.target as HTMLInputElement).value;
- this.dataSource.filter = filterValue.trim().toLowerCase();
- }*/
-
public onOpenPositionDialog({ dataSource, symbol }: UniqueAsset): void {
this.router.navigate([], {
queryParams: { dataSource, symbol, positionDetailDialog: true }
diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts
index 1c20dc518c..01e9a7cefc 100644
--- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts
+++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts
@@ -33,6 +33,7 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
value: number;
};
};
+ public activeFilters: Filter[] = [];
public allFilters: Filter[];
public continents: {
[code: string]: { name: string; value: number };
@@ -130,8 +131,11 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
distinctUntilChanged(),
switchMap((filters) => {
this.isLoading = true;
+ this.activeFilters = filters;
- return this.dataService.fetchPortfolioDetails({ filters });
+ return this.dataService.fetchPortfolioDetails({
+ filters: this.activeFilters
+ });
}),
takeUntil(this.unsubscribeSubject)
)
@@ -343,7 +347,10 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
}
}
- if (position.dataSource) {
+ if (
+ this.activeFilters?.length === 0 ||
+ position.assetSubClass !== AssetClass.CASH
+ ) {
this.symbols[prettifySymbol(symbol)] = {
dataSource: position.dataSource,
name: position.name,
diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.html b/apps/client/src/app/pages/portfolio/allocations/allocations-page.html
index 07418a4af4..9a71dbe276 100644
--- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.html
+++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.html
@@ -95,7 +95,7 @@
<mat-card class="mb-3">
<mat-card-header class="overflow-hidden w-100">
<mat-card-title class="align-items-center d-flex text-truncate"
- ><span i18n>By Symbol</span
+ ><span i18n>By Position</span
><ion-icon
*ngIf="user?.subscription?.type === 'Basic'"
class="ml-1 text-muted"
diff --git a/apps/client/src/app/pages/public/public-page.html b/apps/client/src/app/pages/public/public-page.html
index b4f7e72950..896ec705f5 100644
--- a/apps/client/src/app/pages/public/public-page.html
+++ b/apps/client/src/app/pages/public/public-page.html
@@ -10,7 +10,7 @@
<div class="col-md-12 allocations-by-symbol">
<mat-card class="mb-3">
<mat-card-header class="overflow-hidden w-100">
- <mat-card-title class="text-truncate" i18n>Symbols</mat-card-title>
+ <mat-card-title class="text-truncate" i18n>Positions</mat-card-title>
</mat-card-header>
<mat-card-content>
<gf-portfolio-proportion-chart