Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Feature/clone or edit activity from account detail dialog (#3647)

Thomas Kaule85cc0fcfca5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f5902f217f..3b4a5c1e7b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
+- Added support to clone an activity from the account detail dialog (experimental)
+- Added support to edit an activity from the account detail dialog (experimental)
- Added support to clone an activity from the holding detail dialog (experimental)
- Added support to edit an activity from the holding detail dialog (experimental)
diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts
index 919b9549da..1cec23aba9 100644
--- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts
+++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts
@@ -23,6 +23,7 @@ import {
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { Sort, SortDirection } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
+import { Router } from '@angular/router';
import { Big } from 'big.js';
import { format, parseISO } from 'date-fns';
import { isNumber } from 'lodash';
@@ -66,6 +67,7 @@ export class AccountDetailDialog implements OnDestroy, OnInit {
@Inject(MAT_DIALOG_DATA) public data: AccountDetailDialogParams,
private dataService: DataService,
public dialogRef: MatDialogRef<AccountDetailDialog>,
+ private router: Router,
private userService: UserService
) {
this.userService.stateChanged
@@ -92,6 +94,14 @@ export class AccountDetailDialog implements OnDestroy, OnInit {
this.fetchPortfolioPerformance();
}
+ public onCloneActivity(aActivity: Activity) {
+ this.router.navigate(['/portfolio', 'activities'], {
+ queryParams: { activityId: aActivity.id, createDialog: true }
+ });
+
+ this.dialogRef.close();
+ }
+
public onClose() {
this.dialogRef.close();
}
@@ -147,6 +157,14 @@ export class AccountDetailDialog implements OnDestroy, OnInit {
this.fetchActivities();
}
+ public onUpdateActivity(aActivity: Activity) {
+ this.router.navigate(['/portfolio', 'activities'], {
+ queryParams: { activityId: aActivity.id, editDialog: true }
+ });
+
+ this.dialogRef.close();
+ }
+
private fetchAccount() {
this.dataService
.fetchAccount(this.data.accountId)
diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html
index 0f0091ce57..a814a19a8b 100644
--- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html
+++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html
@@ -101,10 +101,17 @@
[hasPermissionToFilter]="false"
[hasPermissionToOpenDetails]="false"
[locale]="user?.settings?.locale"
- [showActions]="false"
+ [showActions]="
+ !data.hasImpersonationId &&
+ data.hasPermissionToCreateOrder &&
+ user?.settings?.isExperimentalFeatures &&
+ !user?.settings?.isRestrictedView
+ "
[sortColumn]="sortColumn"
[sortDirection]="sortDirection"
[totalItems]="totalItems"
+ (activityToClone)="onCloneActivity($event)"
+ (activityToUpdate)="onUpdateActivity($event)"
(export)="onExport()"
(sortChanged)="onSortChanged($event)"
/>
diff --git a/apps/client/src/app/components/account-detail-dialog/interfaces/interfaces.ts b/apps/client/src/app/components/account-detail-dialog/interfaces/interfaces.ts
index 016fc3b7d4..9ad6a5ba4f 100644
--- a/apps/client/src/app/components/account-detail-dialog/interfaces/interfaces.ts
+++ b/apps/client/src/app/components/account-detail-dialog/interfaces/interfaces.ts
@@ -2,4 +2,5 @@ export interface AccountDetailDialogParams {
accountId: string;
deviceType: string;
hasImpersonationId: boolean;
+ hasPermissionToCreateOrder: boolean;
}
diff --git a/apps/client/src/app/pages/accounts/accounts-page.component.ts b/apps/client/src/app/pages/accounts/accounts-page.component.ts
index 244333243e..9f86bf587f 100644
--- a/apps/client/src/app/pages/accounts/accounts-page.component.ts
+++ b/apps/client/src/app/pages/accounts/accounts-page.component.ts
@@ -221,7 +221,11 @@ export class AccountsPageComponent implements OnDestroy, OnInit {
data: <AccountDetailDialogParams>{
accountId: aAccountId,
deviceType: this.deviceType,
- hasImpersonationId: this.hasImpersonationId
+ hasImpersonationId: this.hasImpersonationId,
+ hasPermissionToCreateOrder:
+ !this.hasImpersonationId &&
+ hasPermission(this.user?.permissions, permissions.createOrder) &&
+ !this.user?.settings?.isRestrictedView
},
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',
width: this.deviceType === 'mobile' ? '100vw' : '50rem'
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 5af3a30993..89b08ad95a 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
@@ -12,6 +12,7 @@ import {
PortfolioPosition,
User
} from '@ghostfolio/common/interfaces';
+import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import { Market, MarketAdvanced } from '@ghostfolio/common/types';
import { translate } from '@ghostfolio/ui/i18n';
@@ -584,7 +585,11 @@ export class AllocationsPageComponent implements OnDestroy, OnInit {
data: <AccountDetailDialogParams>{
accountId: aAccountId,
deviceType: this.deviceType,
- hasImpersonationId: this.hasImpersonationId
+ hasImpersonationId: this.hasImpersonationId,
+ hasPermissionToCreateOrder:
+ !this.hasImpersonationId &&
+ hasPermission(this.user?.permissions, permissions.createOrder) &&
+ !this.user?.settings?.isRestrictedView
},
height: this.deviceType === 'mobile' ? '97.5vh' : '80vh',
width: this.deviceType === 'mobile' ? '100vw' : '50rem'