From dfa67b275c691a67fe8000d428ad50c00107faaf Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Tue, 10 May 2022 19:22:57 +0200 Subject: [PATCH] Feature/improve filtering on allocations page (#900) * Include cash positions on allocations page (with no filtering) * Update changelog --- CHANGELOG.md | 6 ++++++ apps/api/src/app/portfolio/portfolio.service.ts | 4 ++-- .../positions-table/positions-table.component.ts | 5 ----- .../allocations/allocations-page.component.ts | 11 +++++++++-- .../pages/portfolio/allocations/allocations-page.html | 2 +- apps/client/src/app/pages/public/public-page.html | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be70a9d5f..ebe293e86 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 6ffdc94e1..314cedf60 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 6c5224db2..390ba5e02 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 1c20dc518..01e9a7cef 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 07418a4af..9a71dbe27 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 @@ By SymbolBy Position - Symbols + Positions