From b57301ef5000a20f7810f86ce1cd6601f181146d Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 16 Oct 2021 21:23:15 +0200 Subject: [PATCH] Feature/extend import validation message (#421) * Extend import validation message * Update changelog --- CHANGELOG.md | 6 + apps/api/src/app/import/import.service.ts | 4 +- .../import-transaction-dialog.component.ts | 16 ++- .../import-transaction-dialog.html | 29 +++-- .../import-transaction-dialog.module.ts | 4 +- .../import-transaction-dialog.scss | 9 ++ .../interfaces/interfaces.ts | 1 + .../transactions-page.component.ts | 17 ++- .../services/import-transactions.service.ts | 117 +++++++++++++----- .../src/lib/interfaces/info-item.interface.ts | 1 + 10 files changed, 159 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f3ea41d6..b0c305d66 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 + +### Added + +- Extended the validation message of the import functionality for transactions + ## 1.61.0 - 15.10.2021 ### Added diff --git a/apps/api/src/app/import/import.service.ts b/apps/api/src/app/import/import.service.ts index 4c7a99d33..59df401bd 100644 --- a/apps/api/src/app/import/import.service.ts +++ b/apps/api/src/app/import/import.service.ts @@ -94,7 +94,9 @@ export class ImportService { ]); if (result[symbol] === undefined) { - throw new Error(`${symbol} is not a valid symbol for ${dataSource}`); + throw new Error( + `orders.${index}.symbol ("${symbol}") is not valid for the specified data source ("${dataSource}")` + ); } } } diff --git a/apps/client/src/app/pages/portfolio/transactions/import-transaction-dialog/import-transaction-dialog.component.ts b/apps/client/src/app/pages/portfolio/transactions/import-transaction-dialog/import-transaction-dialog.component.ts index f5ccf8f26..ac7832ff5 100644 --- a/apps/client/src/app/pages/portfolio/transactions/import-transaction-dialog/import-transaction-dialog.component.ts +++ b/apps/client/src/app/pages/portfolio/transactions/import-transaction-dialog/import-transaction-dialog.component.ts @@ -16,6 +16,8 @@ import { ImportTransactionDialogParams } from './interfaces/interfaces'; templateUrl: 'import-transaction-dialog.html' }) export class ImportTransactionDialog implements OnDestroy { + public details: any[] = []; + private unsubscribeSubject = new Subject(); public constructor( @@ -23,7 +25,19 @@ export class ImportTransactionDialog implements OnDestroy { public dialogRef: MatDialogRef ) {} - public ngOnInit() {} + public ngOnInit() { + for (const message of this.data.messages) { + if (message.includes('orders.')) { + let [index] = message.split(' '); + index = index.replace('orders.', ''); + [index] = index.split('.'); + + this.details.push(this.data.orders[index]); + } else { + this.details.push(''); + } + } + } public onCancel(): void { this.dialogRef.close(); diff --git a/apps/client/src/app/pages/portfolio/transactions/import-transaction-dialog/import-transaction-dialog.html b/apps/client/src/app/pages/portfolio/transactions/import-transaction-dialog/import-transaction-dialog.html index 28e2a7f50..604eb7c06 100644 --- a/apps/client/src/app/pages/portfolio/transactions/import-transaction-dialog/import-transaction-dialog.html +++ b/apps/client/src/app/pages/portfolio/transactions/import-transaction-dialog/import-transaction-dialog.html @@ -6,14 +6,27 @@ >
-
    -
  • -
    - -
    -
    {{ message }}
    -
  • -
+ + + + +
+
+ +
+
{{ message }}
+
+
+
+
{{ details[i] | json }}
+
+