From 565e920f1b089eaa65cd5b41ff46e424b89f3541 Mon Sep 17 00:00:00 2001 From: Mantovani Gabriele Date: Tue, 11 May 2021 18:01:46 +0200 Subject: [PATCH] Add link to retrieve manually the current market price (#74) * feat: add link to retrieve manually the current market price from data source * Add icon * Update changelog Co-authored-by: Thomas <4159106+dtslvr@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ ...-or-update-transaction-dialog.component.ts | 17 ++++++++++++++++- .../create-or-update-transaction-dialog.html | 19 +++++++++++++++++-- ...ate-or-update-transaction-dialog.module.ts | 5 +++-- .../create-or-update-transaction-dialog.scss | 12 ++++++++++++ 5 files changed, 52 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cbf8bd10..b7b9505a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added a button to fetch the current market price in the create or edit transaction dialog + ### Changed - Improved the transaction filtering with multi filter support diff --git a/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.component.ts b/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.component.ts index e1b30a8ef..798eab8e5 100644 --- a/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.component.ts +++ b/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.component.ts @@ -30,6 +30,7 @@ import { CreateOrUpdateTransactionDialogParams } from './interfaces/interfaces'; }) export class CreateOrUpdateTransactionDialog { public currencies: Currency[] = []; + public currentMarketPrice = null; public filteredLookupItems: Observable; public isLoading = false; public platforms: { id: string; name: string }[]; @@ -65,6 +66,20 @@ export class CreateOrUpdateTransactionDialog { return []; }) ); + + if (this.data.transaction.symbol) { + this.dataService + .fetchSymbolItem(this.data.transaction.symbol) + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe(({ marketPrice }) => { + this.currentMarketPrice = marketPrice; + this.cd.markForCheck(); + }); + } + } + + public applyCurrentMarketPrice() { + this.data.transaction.unitPrice = this.currentMarketPrice; } public onCancel(): void { @@ -81,7 +96,7 @@ export class CreateOrUpdateTransactionDialog { .subscribe(({ currency, dataSource, marketPrice }) => { this.data.transaction.currency = currency; this.data.transaction.dataSource = dataSource; - this.data.transaction.unitPrice = marketPrice; + this.currentMarketPrice = marketPrice; this.isLoading = false; diff --git a/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.html b/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.html index 3476ca15e..738fc68f5 100644 --- a/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.html +++ b/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.html @@ -81,7 +81,13 @@ [matDatepicker]="date" [(ngModel)]="data.transaction.date" /> - + + + @@ -110,7 +116,7 @@
- + Unit Price +
diff --git a/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.module.ts b/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.module.ts index 01cb51875..b9a3c08ee 100644 --- a/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.module.ts +++ b/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.module.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; +import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatAutocompleteModule } from '@angular/material/autocomplete'; import { MatButtonModule } from '@angular/material/button'; @@ -30,6 +30,7 @@ import { CreateOrUpdateTransactionDialog } from './create-or-update-transaction- MatSelectModule, ReactiveFormsModule ], - providers: [] + providers: [], + schemas: [CUSTOM_ELEMENTS_SCHEMA] }) export class CreateOrUpdateTransactionDialogModule {} diff --git a/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.scss b/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.scss index 0ce226588..fb2501ff3 100644 --- a/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.scss +++ b/apps/client/src/app/pages/transactions/create-or-update-transaction-dialog/create-or-update-transaction-dialog.scss @@ -14,6 +14,18 @@ } } + .mat-form-field-appearance-outline { + ::ng-deep { + .mat-form-field-suffix { + top: -0.3rem; + } + } + + ion-icon { + font-size: 130%; + } + } + .mat-select { &.no-arrow { ::ng-deep {