Browse Source

Bugfix/fix values in position detail dialog (#351)

* Nullify netPerformance

* Introduce precision

* Update changelog
pull/352/head^2
Thomas Kaul 3 years ago
committed by GitHub
parent
commit
9cbf789c22
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      CHANGELOG.md
  2. 1
      apps/api/src/app/portfolio/portfolio.controller.ts
  3. 5
      apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html
  4. 4
      libs/ui/.eslintrc.json
  5. 17
      libs/ui/src/lib/value/value.component.stories.ts
  6. 10
      libs/ui/src/lib/value/value.component.ts

10
CHANGELOG.md

@ -5,6 +5,16 @@ 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
- Added the attribute `precision` in the value component
### Fixed
- Hid the performance in the _Presenter View_
## 1.47.1 - 06.09.2021
### Fixed

1
apps/api/src/app/portfolio/portfolio.controller.ts

@ -276,6 +276,7 @@ export class PortfolioController {
position = nullifyValuesInObject(position, [
'grossPerformance',
'investment',
'netPerformance',
'quantity'
]);
}

5
apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html

@ -80,7 +80,8 @@
<gf-value
label="Quantity"
size="medium"
[isCurrency]="true"
[locale]="data.locale"
[precision]="2"
[value]="quantity"
></gf-value>
</div>
@ -103,8 +104,6 @@
<div class="col-6 mb-3">
<gf-value
size="medium"
[isCurrency]="false"
[isInteger]="true"
[label]="transactionCount === 1 ? 'Transaction' : 'Transactions'"
[locale]="data.locale"
[value]="transactionCount"

4
libs/ui/.eslintrc.json

@ -13,7 +13,7 @@
"error",
{
"type": "attribute",
"prefix": "ghostfolio",
"prefix": "gf",
"style": "camelCase"
}
],
@ -21,7 +21,7 @@
"error",
{
"type": "element",
"prefix": "ghostfolio",
"prefix": "gf",
"style": "kebab-case"
}
]

17
libs/ui/src/lib/value/value.component.stories.ts

@ -29,17 +29,16 @@ Currency.args = {
value: 7
};
export const Integer = Template.bind({});
Integer.args = {
isInteger: true,
locale: 'en-US',
value: 7
};
export const Label = Template.bind({});
Label.args = {
isInteger: true,
label: 'Label',
locale: 'en-US',
value: 7
value: 7.25
};
export const Precision = Template.bind({});
Precision.args = {
locale: 'en-US',
precision: 3,
value: 7.2534802394809285309
};

10
libs/ui/src/lib/value/value.component.ts

@ -18,11 +18,11 @@ export class ValueComponent implements OnChanges {
@Input() colorizeSign = false;
@Input() currency = '';
@Input() isCurrency = false;
@Input() isInteger = false;
@Input() isPercent = false;
@Input() label = '';
@Input() locale = '';
@Input() position = '';
@Input() precision: number | undefined;
@Input() size = '';
@Input() value: number | string = '';
@ -82,13 +82,15 @@ export class ValueComponent implements OnChanges {
minimumFractionDigits: 2
});
} catch {}
} else if (this.isInteger) {
} else if (this.precision || this.precision === 0) {
try {
this.formattedValue = this.value?.toLocaleString(this.locale, {
maximumFractionDigits: 0,
minimumFractionDigits: 0
maximumFractionDigits: this.precision,
minimumFractionDigits: this.precision
});
} catch {}
} else {
this.formattedValue = this.value?.toString();
}
} else {
try {

Loading…
Cancel
Save