Browse Source

code review fixes

pull/5555/head
Attila Cseh 1 month ago
parent
commit
6c8e82a57b
  1. 5
      CHANGELOG.md
  2. 25
      apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts
  3. 8
      apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/types/activity-type.type.ts
  4. 2
      libs/ui/src/lib/i18n.ts

5
CHANGELOG.md

@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `settings` to the `Access` model - Added `settings` to the `Access` model
### Changed
- Changed the deprecated `ITEM` activity type to `VALUABLE` in the create or update activity dialog
## 2.201.0 - 2025-09-24 ## 2.201.0 - 2025-09-24
### Added ### Added
@ -27,7 +31,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Refreshed the cryptocurrencies list - Refreshed the cryptocurrencies list
- Improved the language localization for German (`de`) - Improved the language localization for German (`de`)
- Upgraded `countup.js` from version `2.8.2` to `2.9.0` - Upgraded `countup.js` from version `2.8.2` to `2.9.0`
- Deprecated _ITEM_ activity type removed from the create or update activity dialog
### Fixed ### Fixed

25
apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts

@ -51,18 +51,7 @@ import { catchError, delay, takeUntil } from 'rxjs/operators';
import { DataService } from '../../../../services/data.service'; import { DataService } from '../../../../services/data.service';
import { validateObjectForForm } from '../../../../util/form.util'; import { validateObjectForForm } from '../../../../util/form.util';
import { CreateOrUpdateActivityDialogParams } from './interfaces/interfaces'; import { CreateOrUpdateActivityDialogParams } from './interfaces/interfaces';
import { ActivityType } from './types/activity-type.type';
const DisplayedActivityType = {
BUY: Type.BUY,
DIVIDEND: Type.DIVIDEND,
FEE: Type.FEE,
INTEREST: Type.INTEREST,
LIABILITY: Type.LIABILITY,
SELL: Type.SELL,
VALUABLE: 'VALUABLE' as const
};
type DisplayedActivityType =
(typeof DisplayedActivityType)[keyof typeof DisplayedActivityType];
@Component({ @Component({
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
@ -190,9 +179,9 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy {
}; };
}) ?? []; }) ?? [];
Object.keys(DisplayedActivityType).forEach((type) => { Object.keys(ActivityType).forEach((type) => {
this.typesTranslationMap[DisplayedActivityType[type]] = translate( this.typesTranslationMap[ActivityType[type]] = translate(
DisplayedActivityType[type] ActivityType[type]
); );
}); });
@ -277,7 +266,7 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy {
this.activityForm.get('accountId').valueChanges.subscribe((accountId) => { this.activityForm.get('accountId').valueChanges.subscribe((accountId) => {
const type = this.activityForm.get('type').value; const type = this.activityForm.get('type').value;
if (['FEE', 'INTEREST', 'VALUABLE', 'LIABILITY'].includes(type)) { if (['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes(type)) {
const currency = const currency =
this.data.accounts.find(({ id }) => { this.data.accounts.find(({ id }) => {
return id === accountId; return id === accountId;
@ -373,7 +362,7 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy {
this.activityForm this.activityForm
.get('type') .get('type')
.valueChanges.pipe(takeUntil(this.unsubscribeSubject)) .valueChanges.pipe(takeUntil(this.unsubscribeSubject))
.subscribe((type: DisplayedActivityType) => { .subscribe((type: ActivityType) => {
if ( if (
type === 'VALUABLE' || type === 'VALUABLE' ||
(this.activityForm.get('dataSource').value === 'MANUAL' && (this.activityForm.get('dataSource').value === 'MANUAL' &&
@ -536,7 +525,7 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy {
fee: this.activityForm.get('fee').value, fee: this.activityForm.get('fee').value,
quantity: this.activityForm.get('quantity').value, quantity: this.activityForm.get('quantity').value,
symbol: symbol:
(['FEE', 'INTEREST', 'VALUABLE', 'LIABILITY'].includes( (['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes(
this.activityForm.get('type').value this.activityForm.get('type').value
) )
? undefined ? undefined

8
apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/types/activity-type.type.ts

@ -0,0 +1,8 @@
import { Type } from '@prisma/client';
export const ActivityType = {
...Type,
VALUABLE: 'VALUABLE'
} as const;
export type ActivityType = (typeof ActivityType)[keyof typeof ActivityType];

2
libs/ui/src/lib/i18n.ts

@ -38,9 +38,9 @@ const locales = {
DIVIDEND: $localize`Dividend`, DIVIDEND: $localize`Dividend`,
FEE: $localize`Fee`, FEE: $localize`Fee`,
INTEREST: $localize`Interest`, INTEREST: $localize`Interest`,
VALUABLE: $localize`Valuable`,
LIABILITY: $localize`Liability`, LIABILITY: $localize`Liability`,
SELL: $localize`Sell`, SELL: $localize`Sell`,
VALUABLE: $localize`Valuable`,
// AssetClass (enum) // AssetClass (enum)
ALTERNATIVE_INVESTMENT: $localize`Alternative Investment`, ALTERNATIVE_INVESTMENT: $localize`Alternative Investment`,

Loading…
Cancel
Save